Repository navigation
Quantize the tiny DeepSeek-V3 and GPT-OSS models like their references (FP8, MXFP4) - #8058
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 902f2f1149
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
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. |
# Conflicts: # tests/test_utils.py
| 6. Runs `print_config_diff` — prints every flat-key difference between the reference Hub config and the tiny model's config (for debugging scale-downs). | ||
| 7. Pushes the model, tokenizer/processor, generation config, and model card to the Hub in a single commit. | ||
|
|
||
| When the reference checkpoint is quantized (DeepSeek-R1 in FP8, gpt-oss in MXFP4), the script quantizes the random weights the same way, writes the checkpoint itself in the reference's layout, loads it back for the smoke test, and pushes the directory with `push_dir_to_hub`. Loading these tiny models needs a GPU with FP8 support, or the `kernels` package for MXFP4 (transformers dequantizes to bf16 without it). |
There was a problem hiding this comment.
needs a GPU with FP8 support,
Is this always true ? we dont do software quantization in transformers 🤔 ?
There was a problem hiding this comment.
Right, without a GPU with FP8 support, transformers dequantizes the checkpoint to bf16 on load, like MXFP4 without kernels. Let's be precise
# Conflicts: # scripts/generate_tiny_models/_common.py
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 82f6631. Configure here.
|
merging this one, it's been waiting for a while, it's only tests changes |

Three tiny models have quantized references but were not quantized: DeepSeek-R1 and R1-0528 ship FP8 weights, gpt-oss-20b ships MXFP4 experts. The scripts now quantize the random weights the same way and write the checkpoint in the reference layout (transformers' FP8 quantizer rejects the 576-row
kv_a_proj_with_mqa, and its MXFP4 save path hardcodes gpt-oss-20b's shapes), so the tiny models load like the real ones, dequantized by TRL since #8070. DeepSeek widens to 128 (the FP8 activation block), gpt-oss to 32 (the MXFP4 block).dequantize: weights with a partial 128-block fail to load (DeepSeek-V3/R1) or dequantize silently wrong transformers#49873; the gpt-oss tests that need float32 experts run from transformers 5.23.0.conftest.py. To merge: drop the pins, merge the Hub PRs, then this PR.Note
Medium Risk
Changes quantized tiny Hub artifacts and broad test matrix behavior (xfail/skip/revisions); DeepSeek tests stay red until upstream FP8 dequant is fixed, but runtime trainer code is mostly test and script tooling.
Overview
Tiny-model generators for DeepSeek-V3 (R1 and 0528) and GPT-OSS now write Hub checkpoints in the same FP8 / MXFP4 layouts as the real models—manual block quantization and
safetensorssave, reload for smoke tests, thenpush_dir_to_hub. DeepSeek configs widen to 128-wide blocks; gpt-oss uses 32-wide expert blocks.scripts/generate_tiny_models/_common.pygains dtype checking from a raw state dict,push_dir_to_hub, and a--revisionflag to append commits to an existing Hub PR (documented in the README).Tests point at unpinned Hub PR refs for the three tiny quant models; MoE LoRA/PEFT coverage moves from gpt-oss to
tiny-Qwen3MoeForCausalLM(fused experts need transformers ≥5). DeepSeek cases arexfailuntil transformers#49873; gpt-oss is gated at 5.23.0 for float32 expert dequant; fused-head and aux-loss tests load viacreate_model_from_pathso MXFP4 weights dequantize like trainers do.Reviewed by Cursor Bugbot for commit 82f6631. Bugbot is set up for automated code reviews on this repo. Configure here.