Repository navigation
fix(fp8): refuse every inverse-scale FP8 layout instead of publishing fp8 (#5202) - #5214
Merged
Merged
Conversation
FineGrainedFP8 reads `weight_scale_inv` as a multiplier and allocates e4m3 weights. GPT-QModel always quantizes with `weight_scale_semantics="inverse"`, so every layout it writes — row, tensor and block — is misread: the block path silently produces NaN, and the row/tensor path burns minutes on a broadcast before a shape error. Require block + multiplier + e4m3 (including every `dynamic` override) in `_fp8_layout_is_hf_readable`. No GPT-QModel save satisfies that, so every FP8 export now publishes `gptqmodel_fp8` and is refused by the import-time guard. Update the save-time warning, docs and the tests that asserted the block layout kept `fp8`.
Qubitium
marked this pull request as ready for review
November 18, 2026 11:19
3 tasks done
Qubitium
added a commit
that referenced
this pull request
Nov 18, 2026
…xport (#5242) FP8 checkpoints are now consumed from production producers only: transformers FineGrainedFP8 / DeepSeek / Qwen block scales, NVIDIA ModelOpt per-tensor scales, and MXFP8/NVFP8 decode. GPT-QModel no longer writes an FP8 checkpoint of its own. - Remove the FP8_EXPORT_QUANT_METHOD alias and its refusal-table entries, the hf_compat_warnings FP8 branch, and the METHOD.FP8 export serialization split. - FP8Config is load-only (is_load_only() -> True); BaseQModel.quantize() raises before calibration, and _resolve_quantize_config_class rejects weight-only FP8. - Delete the calibrated GSQ-FP8 path (FP8GSQProcessor, gsq_fp8, gsq_fp8_task, gsq_calibration), the MLX FP8 encoder, and the MLX FP8 benchmarks. - TorchFP8Linear.pack* now raise; quantize_fp8_weight and the MLX encode helpers are removed. Production decode and legacy inverse-scale loading are unchanged. - Rewrite the FP8 docs as load-only, add docs/fp8-load-only.md with the old/new flow, and move test fixtures to tests/fp8_test_utils.py. Refs #5202, #5214.
Qubitium
added a commit
that referenced
this pull request
Nov 18, 2026
#5242 removed the invented FP8 exporter and its refusing transformers quantizer. Legacy checkpoints written between #5181 and #5242 still carry `quant_method: "gptqmodel_fp8"`; without the refusal transformers silently loads the fp8 weights into plain Linear and drops the inverse scales. Restore the refusal, accept the alias as a read-only load name, and refuse the pre-#5214 `fp8` + inverse layout before FineGrainedFP8 can misread it. FP8 stays load-only: exports still write `fp8` and quantize/pack still fail.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5202
Summary
Net diff: 7 files, +190/−70. No runtime kernel changes: this changes which
quant_methodthe FP8 export publishes, the readability predicate that decidesit, the save-time warning, the docs, and the tests that asserted the old
premise.
Problem
FineGrainedFP8(transformers/integrations/finegrained_fp8.py:72) reads a2-D block
weight_scale_invas a multiplier and allocatesfloat8_e4m3fnweights:GPT-QModel always quantizes with
weight_scale_semantics="inverse"(
weight = fp8 / scale), and_normalize_fp8_scale_semanticsaccepts onlyinverse, soFP8Config(weight_scale_semantics="multiplier")raises. #5181nonetheless kept
quant_method: "fp8"for the block layout, so plaintransformers multiplies where it must divide: every weight overflows and the
model is NaN, with no warning and no refusal.
flowchart TD A["FP8Config.to_dict"] --> B["_serialize_export_quant_method"] B --> C{"_fp8_layout_is_hf_readable<br/>block + block_size?"} C -- yes --> D["quant_method: fp8<br/>inverse weight_scale_inv"] C -- no --> E["quant_method: gptqmodel_fp8"] D --> F["FineGrainedFP8: weight = fp8 * scale"] F --> G["~1e6-1e7 too large<br/>fp16 overflow -> NaN"] style G fill:#f8d7da,stroke:#b02a37New flow
_fp8_layout_is_hf_readablenow requires block +weight_scale_semanticsmultiplier+float8_e4m3fn, including everydynamicoverride. NoGPT-QModel save can satisfy it (
_normalize_fp8_scale_semanticsrejectsmultiplier), so every FP8 export publishesgptqmodel_fp8and is refused bythe import-time guard.
fp8is reserved for third-party block/multipliercheckpoints.
flowchart TD A["FP8Config.to_dict"] --> B["_serialize_export_quant_method"] B --> C{"block + multiplier + e4m3?"} C -- "third-party only" --> D["quant_method: fp8"] C -- "any GPT-QModel save" --> E["quant_method: gptqmodel_fp8"] E --> F["REFUSED_HF_QUANT_METHODS"] F --> G["ValueError naming gptqmodel_fp8<br/>and GPTQModel.load"] style G fill:#d9f2d9,stroke:#2e7d32block+[128,128])quant_method: fp8, NaN in plain transformersgptqmodel_fp8+ save-time warning; refused withimport gptqmodelgptqmodel_fp8quant_method: fp8gptqmodel_fp8fp8fp8)Tests
fp8tests/test_fp8.py::test_block_fp8_layout_publishes_gptqmodel_only_quant_methodfp8dynamictests/test_fp8.py::test_fp8_layout_is_hf_readable_requires_block_multiplier_and_e4m3tests/test_fp8.py::test_block_fp8_save_publishes_gptqmodel_quant_method_and_round_tripsquant_method == fp8tests/test_fp8.py::test_hf_compat_warning_for_gptqmodel_only_fp8tests/test_fp8.py::test_fp8_quantize_config_round_trip[5 formats]tests/test_fp8.py::test_fp8_config_rejects_multiplier_scale_semanticsRed evidence: copied only the new
tests/test_fp8.pyinto a detachedorigin/mainworktree and ran the six nodes above: 9 failed, 1 passed(the control), each at its intended assertion.
Green:
GPTQ_BYPASS_SAFETY_CHECKS=1is only for this box's torch 2.11 (below thedocumented gate); CI does not need it.
Pre-existing, reproduced on unmodified
origin/main:tests/test_docs_contract_refs.pycites
generateatgptqmodel/models/base.py:3939but it is at3948; andtest_model_dequant_fp8.py::test_ignored_layers_are_honored_by_non_fp8_convertersneeds the uninstalled
bitsandbytes. Neither touches this change.Skips
All skips need a CUDA/ROCm device,
peft, or an external model fixture. Nonative GPU path was exercised here.
Docs
Updated in the same PR:
docs/checkpoint-interop.md§10,docs/hf-interop.md§5,
docs/support-matrix.md, and thegptqmodel/_quant_methods.pycomment.Unverified / scope
FineGrainedFP8loading of a block checkpoint is not exercised: thefix is that it now refuses such checkpoints.
covers the save/reload/name path.
PR only stops shipping the faux FP8 under a name that implies a standard
layout.