Repository navigation
Conversation
…5271) #5242 made FP8 load-only, so the two tests that built their fixture through `FP8Config` + `quantize()` have been red on main since. Their coverage is still wanted: the FP8 case of the #5218 fail-closed matrix is the only end-to-end check of `TorchFP8Linear`'s `("weight", "weight_scale_inv")` requirement, and the dynamic per-module settings test covered config routing into the loader. Add `write_fp8_checkpoint()` to tests/fp8_test_utils.py: it replaces every dense projection of a model directory with a `TorchFP8Linear` holding the reference-encoded payload (honouring an `FP8Config.dynamic` override per module), writes the safetensors shard and the `quantization_config`, and carries the tokenizer over. Both tests now build their checkpoint with it. The dynamic test becomes a load-only test: the override must reach the module, its siblings must keep the base encoding, and loading the same checkpoint twice must produce identical tensors.
Qubitium
marked this pull request as ready for review
November 18, 2026 17:02
| # reference encoder instead of a quantize() run (#5271). | ||
| ( | ||
| "fp8", | ||
| lambda source, checkpoint: write_fp8_checkpoint(source, checkpoint), |
Collaborator
Author
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 #5271.
Problem
#5242 made FP8 load-only (
BaseQModel.quantize()raisesValueError: FP8 is load-only), but two tests still built their FP8 fixture throughFP8Config+quantize(), so both have been red onmainsince:tests/test_checkpoint_quantization.py::test_dynamic_weight_only_quantized_tensors_equal_after_resumetests/test_fail_closed_checkpoint_5218.py::test_truncated_weight_only_checkpoint_fails_closed[fp8-…]The second is the FP8 case of #5239's own fail-closed matrix (#5218) — with it red,
TorchFP8Linear's("weight", "weight_scale_inv")requirement had no working end-to-end test.flowchart TD subgraph before["Before: fixture needs quantize()"] A1["test"] --> B1["FP8Config + GPTQModel.quantize()"] B1 --> C1["ValueError: FP8 is load-only"] C1 --> D1["test red on main<br/>(#5218 guard unexercised)"] end subgraph after["After: fixture written directly"] A2["test"] --> B2["write_fp8_checkpoint()"] B2 --> C2["dense linears -> TorchFP8Linear payloads<br/>+ quantization_config"] C2 --> D2["GPTQModel.load()"] D2 --> E2["test green, guard exercised"] endFix
tests/fp8_test_utils.pygainswrite_fp8_checkpoint(base, destination, *, config=None, dynamic=None): it replaces every dense projection of a model directory with aTorchFP8Linearcarrying the reference-encoded payload (honouring anFP8Config.dynamicoverride per module), writes the safetensors shard plus thequantization_config, de-duplicates tied weights, and carries the tokenizer over.test_fail_closed_checkpoint_5218.py: the parametrization now takes abuild_checkpoint(source, checkpoint)callable; FP8 uses the new writer, NF12 keepsquantize().test_checkpoint_quantization.py: the old quantize+resume test becomestest_dynamic_weight_only_fp8_settings_survive_load— the override must reach the module, its siblings must keep the base encoding, and loading the same checkpoint twice must produce identical tensors.Evidence
maintest_truncated_weight_only_checkpoint_fails_closed[fp8-…]ValueError: FP8 is load-onlyValueError: FP8 is load-onlytests/test_fail_closed_checkpoint_5218.py: 21 passed, 2 skipped.tests/test_checkpoint_quantization.py: 41 passed (9m32s).uvx [email protected] check gptqmodel docs/eora tests setup.py: clean.Not verified: GPU/ROCm paths (these are CPU fixtures by design).