Skip to content

Quantization cleanpup - #49548

Merged
ArthurZucker merged 32 commits into
mainfrom
clean-fp8
Oct 16, 2026
Merged

ArthurZucker merged 32 commits into
mainfrom
clean-fp8

Conversation

@ArthurZucker

@ArthurZucker ArthurZucker commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator

🤗 Transformers CI

What does this PR do?

Too much shit got past the reviews. Fixes #48757.

I think AI just does not understand it when it's spread across many files. We probably don't have the greatest doc either.

Anyways, there are 3 case:

  1. Deserialize needed: you need to cast the ckpt weight because it was "wrongly" saved
  2. Dequantize: you want the full weight
  3. Quantize: you do it on the fly from a bf16 ckpt.

Those 3 cases each have a different injection point in core model loading:

  1. We update all ConversionOps to start with deserialization.
  2. We do it after all conversion ops using get_quantize_ops
  3. We should probably do it before all conversion ops to reduce loading imbalance. But today it goes through the get quantize ops?

The various agent PRs most probably did not understand the core logic /
idea behind the weight converter, this left a lot of method patching
here and ther.
1. Deserialize: some method just need a cast, other need more work. The
ConversionOps added as the "first" operation, updating the weights
conversion (each one of them) are here for that.
2. TP: bloated code to just update a plan.
3. Patch: I have no idea how, but we accepted plans that had explicit
overwrite. This is legacy
Saw another PR recently: #48759, had the same bug. this adresses it
@HuggingFaceDocBuilderDev

Copy link
Copy Markdown

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.

Comment thread src/transformers/quantizers/base.py Resolved
Comment thread src/transformers/quantizers/base.py Resolved
Comment thread src/transformers/core_model_loading.py Resolved
Comment thread src/transformers/integrations/mxfp4.py Resolved
@ArthurZucker

Copy link
Copy Markdown
Collaborator Author

run-slow: fbgemm_fp8, finegrained_fp8, higgs, hqq, metal, mxfp4, nvfp4, sinq

Comment thread src/transformers/quantizers/base.py Resolved

@IlyasMoutawwakil IlyasMoutawwakil left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall very nice and clean !
left two nits on the class vs instance attrs changing nature and the two deepgemm/megamoe comments

@ArthurZucker

Copy link
Copy Markdown
Collaborator Author

run-slow: fbgemm_fp8, finegrained_fp8, higgs, hqq, metal, mxfp4, nvfp4, sinq

@github-actions

Copy link
Copy Markdown
Contributor

[For maintainers] Suggested jobs to run (before merge)

run-slow: fbgemm_fp8, finegrained_fp8, higgs, hqq, metal, mxfp4, nvfp4, sinq

@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

CI (Nvidia + AMD)

Nvidia CI

Workflow Run ⚙️

Commit Info

Context Commit Description
RUN a4ff0711 workflow commit (merge commit)
PR 602fd8ba branch commit (from PR)
main 9fb4b5a9 base commit (on main)

✅ No failing test specific to this PR 🎉 👏 !


AMD CI

⏳ Starting...

@ArthurZucker
ArthurZucker disabled auto-merge October 16, 2026 09:38
@ArthurZucker
ArthurZucker merged commit b7c4168 into main Oct 16, 2026
111 of 113 checks passed
@ArthurZucker
ArthurZucker deleted the clean-fp8 branch October 16, 2026 09:39
@github-actions

Copy link
Copy Markdown
Contributor

CI recap

Dashboard: View test results in Grafana
Latest run: 38880291632:1
Result: failure | Jobs: 15 | Tests: 202,516 | Failures: 2 | Duration: 14h 51m

Stanley00 pushed a commit to stanley-fork/hf-transformers that referenced this pull request Oct 30, 2026
…uggingface#50150)

* Restore MegaBlocksMoeMLP hub kernel mapping for MXFP4 GPT-OSS MLP

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.

* Test the megablocks kernel on a real MXFP4 GPT-OSS model 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.

* Use the modeling flash-attn2 kernel version in benchmark_v2's FA2 check

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.

---------

Co-authored-by: Marc Sun <57196510+SunMarc@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FP8 quantizer: update_tp_plan misses composite configs, expert scales stay replicated under EP

5 participants