[急切的 MOE] 选择的专家 ID 最好不要被视为 0-d GPU 张量
作者: fxmarty-amd创建于 2026年9月29日更新于 2026年10月2日
标签bug
- https://GitHub.com/huggingface/transformers/blob/e159fcef58f43aec5ce588a891c726572451974a/src/transformers/models/qwen3_moe/modeling_qwen3_moe.py#L236 creates
aten::eqandaten::is_nonzeroonce per expert. - Repeated tensor-scalar indexing produces extra
selectandas_stridedview operations (expert_mask[expert_idx],self.gate_up_proj[expert_idx],self.down_proj[expert_idx]) - Each scalar materialization then creates both
aten::itemandaten::_local_scalar_dense.
It appears that using instead:
内容来源: huggingface/transformers