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

Ouverte
#15,132 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

  • #15064 par @YaoleWu — fermée sans fusion

Évaluation

Difficulté
4/5
Temps estimé
3-5 jours
Accessibilité débutants
42/100
Type d'issue
Fonctionnalité
Clarté
Clairement spécifiée
Activité
Active
Stack technique
python, pytorch

Piste de recherche

Read src/diffusers/models/attention_dispatch.py around the Q/K/V and output helpers, then trace the H3 block stack in src/diffusers/models/transformers/transformer_minimax_h3.py. Use the proposed attention_kwargs opt-in and the named CPU/Gloo test as starting points; verify per-call plan rebuilding, collective ordering, and unchanged default and token-refiner paths. The issue reports prior results for packed lengths 18 → 20 → 18, while CUDA/NCCL, compile, latency, and generation checks remain unvalidated; maintainer coordination on scope is pending.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

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.

Langage dominant
Python
Étoiles
35k
Forks
7.5k
Merge moyen
2 j 22 h
PR mergées (30 j)
58

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de huggingface/diffusers

Toutes les issues de huggingface/diffusers

Issues similaires

Plus d'issues Python

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.