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

未关闭
#15,132 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

  • #15064 来自 @YaoleWu —— 已关闭,未合并

评估

难度
4/5
预计耗时
3-5 天
新手友好度
42/100
Issue 类型
功能
描述清晰度
描述清楚
活跃度
活跃
技术栈
python, pytorch

调研方向

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.

由索引模型根据 Issue 内容生成。

描述

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.

主要语言
Python
星标
35k
派生
7.5k
平均合并
2 天 22 小时
30 天内合并 PR
58

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

huggingface/diffusers 的其他 Issue

查看 huggingface/diffusers 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。