Skip to content

Load ModelOpt and compressed-tensors exports on the fine-grained formats - #49823

Draft
IlyasMoutawwakil wants to merge 6 commits into
fg-split/8-mxfp8from
fg-split/9-producers
Draft

IlyasMoutawwakil wants to merge 6 commits into
fg-split/8-mxfp8from
fg-split/9-producers

Conversation

@IlyasMoutawwakil

@IlyasMoutawwakil IlyasMoutawwakil commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

🤗 Transformers CI

What. The checkpoints that NVIDIA ModelOpt and compressed-tensors export load on the fine-grained formats of
#49777 to #49780. A reader turns the producer's quantization_config into the configs that load it, so there is no
producer quantizer.

  • read_modelopt: one format per quant_algo (FP8, NVFP4, W4A16_NVFP4, MXFP8, MXFP4, W4A16_MXFP4).
    An export that mixes formats, through config_groups or MIXED_PRECISION's quantized_layers, reads as a
    FineGrainedConfig. exclude_modules and ignore become None entries in a plan, or the skip-list of one format.
  • read_compressed_tensors: per-tensor and block FP8, NVFP4 and MX float-quantized groups, e.g.
    RedHatAI/Llama-3.2-1B-Instruct-FP8 and RedHatAI/Qwen3-8B-FP8-block. Integer, per-channel, sparse, transformed and
    KV-cache checkpoints return None, so CompressedTensorsConfig loads them as on main.
  • Unsupported producer metadata raises instead of guessing, e.g. a zero point or a pre-quant scale.
  • Each format reads its producers' tensor layouts:
    • both tools name the block scale weight_scale, the same multiplier as weight_scale_inv, so loading renames it;
    • FP8 gives ModelOpt's 0-d per-expert scales a 1x1 grid, so the gate/up concat can join them
      (FineGrainedScalarScales);
    • NVFP4 inverts compressed-tensors' reciprocal globals and reads its weight_packed and input_global_scale;
    • MXFP4 reads ModelOpt's uint8 bytes as the int8 the modules hold.
  • A passed CompressedTensorsConfig reads the checkpoint as its own class, so it keeps compressed-tensors as the
    backend.
  • A ModelOpt export names one module per expert, such as experts.3.gate_proj. The host's plan resolution (Fine-grained quantization: a host quantizer that mixes methods per module #49818)
    maps them to the fused experts module. All of its pieces must have the same format.
  • A MIXED_PRECISION export lists every module, tens of thousands for a big MoE. The reader turns the names of one
    format into one regex that matches exactly those modules. Names that differ only in a layer or expert index share
    an alternation. So the plan has one entry per format, and resolution takes well under a second at 60 layers x 256
    experts. One pattern per module took hours there.

Behaviour change. Compressed-tensors FP8, NVFP4 and MX checkpoints that the fine-grained kernels serve now load
through them. Pass a CompressedTensorsConfig to keep compressed-tensors for any checkpoint. KV-cache checkpoints stay
with compressed-tensors. ModelOpt exports had no loader in transformers before.

Depends on. #49780.

How tested. tests/quantization/finegrained/test_config_readers.py, the ModelOpt and compressed-tensors loading
tests in tests/integrations/finegrained/test_loading_regressions.py and each format's suite. The tiny ModelOpt and
compressed-tensors checkpoints in the tests load and save back as shipped. nvidia/GLM-5.2-NVFP4 loads and answers.

The comments and docstrings that say why each change exists are there for readability. Feel free to ask for any of them to go if it's self-evident.

🤖 Generated with Claude Code

@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.

@IlyasMoutawwakil
IlyasMoutawwakil force-pushed the fg-split/9-producers branch 3 times, most recently from 0fa8fdb to ed28d48 Compare October 22, 2026 07:18
IlyasMoutawwakil and others added 5 commits October 23, 2026 13:35
- read_modelopt and read_compressed_tensors turn a producer's config into the format configs, or a FineGrainedConfig
  for an export that mixes formats.
- Each format reads its producers' tensor layouts. FP8 gives ModelOpt's 0-d per-expert scales a 1x1 grid. NVFP4
  inverts compressed-tensors' reciprocal globals.
- A passed CompressedTensorsConfig keeps compressed-tensors as the backend.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A ModelOpt export names one module per expert, such as experts.3.gate_proj. The model fuses them into one experts
module. Each piece's name comes from the param's reversed converter. A fused module takes one format, so its entries
must cover all of its pieces in the same format. Any other entry that matches no module raises.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A big MoE lists tens of thousands of modules. One pattern per module made plan resolution scale with names times patterns, hours at that size. The names of one format now share one trie-shaped regex, which matches exactly the listed modules.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

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

run-slow: finegrained, finegrained_fp8, fp8, mxfp4, mxfp8, nvfp4

This branch has not been deployed

No deployments
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.

2 participants