Skip to content

[Feature] Reuse Ulysses shard lengths across MiniMax-H3 blocks #15132

Open

Description

@LeslieWylie

MiniMax-H3 keeps the same packed text/video/audio sequence throughout its transformer blocks. With Ulysses Anything, each attention call still gathers shard lengths separately for Q, K, V and the output exchange. This repeats metadata communication even though the layout is unchanged within that forward.

On main at aaf57d03, the Q/K/V helper calls gather_size_by_comm, as does the output helper. H3 then repeats attention across its block stack.

Could H3 share an immutable shard-length plan within one inference forward? The plan should be rebuilt on every call, preserve collective ordering on all ranks, and leave the default and token-refiner paths unchanged. It should not become a cache shared between requests.

The proposed opt-in in #15064 is:

with torch.inference_mode():
    output = model(**inputs, attention_kwargs={"reuse_ulysses_metadata": True})

The existing two-process CPU/Gloo checks for that implementation, recorded on base d42ebf9c, matched the default tiny-H3 outputs for packed lengths 18 → 20 → 18 while using fewer all-gathers. Uneven attention checks covered 9 → 10 → 9; inconsistent full layouts raised on both ranks, and the original parallel configuration stayed unchanged.

DIFFUSERS_TEST_DEVICE=cpu PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 OMP_NUM_THREADS=1 \
  python -m pytest tests/models/transformers/test_models_transformer_minimax_h3.py::TestMiniMaxH3SequencePlan -q

These are prior CPU/Gloo results for the proposed implementation, not a new run on current main. CUDA/NCCL, compile, isolated latency, full-checkpoint generation and output quality remain unvalidated; no speedup is claimed.

#14871/#14834 cover Ulysses Anything backward and metadata within an attention call. This request concerns reuse across H3 blocks. Would you prefer this scope in #15064 or an extension of that lower-level work? Maintainer coordination is pending. AI assistance was used to prepare the implementation and this proposal.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions