Repository navigation
Restore the MegaBlocksMoeMLP hub kernel mapping for MXFP4 GPT-OSS - #50150
Conversation
huggingface#49548 replaces GptOssMLP with Mxfp4GptOssMLP, which dropped the MegaBlocksMoeMLP hub mapping, so use_kernels=True no longer kernelizes the MoE MLP of MXFP4 GPT-OSS on CPU/XPU.
Replaces the decorator-only check with a slow test that loads openai/gpt-oss-20b with use_kernels=True, checks every MLP keeps MXFP4 experts and runs the MegaBlocksMoeMLP kernel, and checks generation. Limited to CPU/XPU: other devices dequantize to bf16 with use_kernels=True and keep GptOssMLP.
is_fa2_or_kernel_available() pinned kernels-community/flash-attn2 to version=1, which has no XPU build, so flash_attention_2 benchmarks silently fell back to SDPA on XPU. Use FLASH_ATTN_KERNEL_VERSIONS, the same version the model loads.
|
Also bumped the outdated flash-attn2 kernel version in
|
|
Thank you for your contribution 🤗! CI Security Gate — automatic approval blockedThis PR was not automatically approved for CI because the security gate failed. Possible reasons:
See the workflow run for the exact violations. A maintainer can review and manually approve CI if a finding is a false positive. |
|
[For maintainers] Suggested jobs to run (before merge) run-slow: mxfp4 |
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
955b6d3
What
Fixes a regression from #49548 (Quantization cleanpup). That PR replaced
GptOssMLPwithMxfp4GptOssMLP. The new class dropped@use_kernel_forward_from_hub("MegaBlocksMoeMLP"), souse_kernels=Truestopped swapping in the megablocks MoE kernel for MXFP4 GPT-OSS:This PR adds the decorator back to
Mxfp4GptOssMLP. It also adds a slow test that loadsopenai/gpt-oss-20bwithuse_kernels=True, checks that every MLP runs the megablocks kernel, and checks the generated text. The test is skipped on devices other than CPU and XPU.use_kernels=Falseis unchanged, sincekernelizeonly runs whenuse_kernels=True. CUDA is also unchanged:use_kernels=Truedequantizes there, soMxfp4GptOssMLPis never created.Perf
openai/gpt-oss-20bon one Intel Arc Pro B60 (BMG), bf16, greedy decoding:Tests
RUN_SLOW=1 pytest tests/quantization/mxfp4/test_mxfp4.py::Mxfp4KernelsModelTestThe new test fails on main and passes with this PR, on both XPU and CPU.
@ArthurZucker could you please review? Thanks!