Skip to content

test(fp8): build the FP8 fixtures without the removed quantize path (#5271) - #5290

Closed
Qubitium wants to merge 1 commit into
mainfrom
fix/5271-fp8-test-fixtures
Closed

Qubitium wants to merge 1 commit into
mainfrom
fix/5271-fp8-test-fixtures

Conversation

@Qubitium

Copy link
Copy Markdown
Collaborator

Fixes #5271.

Problem

#5242 made FP8 load-only (BaseQModel.quantize() raises ValueError: FP8 is load-only), but two tests still built their FP8 fixture through FP8Config + quantize(), so both have been red on main since:

  • tests/test_checkpoint_quantization.py::test_dynamic_weight_only_quantized_tensors_equal_after_resume
  • tests/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"]
    end
Loading

Fix

tests/fp8_test_utils.py gains write_fp8_checkpoint(base, destination, *, config=None, dynamic=None): it replaces every dense projection of a model directory with a TorchFP8Linear carrying the reference-encoded payload (honouring an FP8Config.dynamic override per module), writes the safetensors shard plus the quantization_config, de-duplicates tied weights, and carries the tokenizer over.

  • test_fail_closed_checkpoint_5218.py: the parametrization now takes a build_checkpoint(source, checkpoint) callable; FP8 uses the new writer, NF12 keeps quantize().
  • test_checkpoint_quantization.py: the old quantize+resume test becomes test_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

test main this PR
test_truncated_weight_only_checkpoint_fails_closed[fp8-…] ValueError: FP8 is load-only passed
dynamic FP8 settings test ValueError: FP8 is load-only passed (rewritten)
  • tests/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).

…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.
# reference encoder instead of a quantize() run (#5271).
(
"fp8",
lambda source, checkpoint: write_fp8_checkpoint(source, checkpoint),
@Qubitium

Copy link
Copy Markdown
Collaborator Author

Closing as superseded: #5288 landed the same fix (rebuild the load-only FP8 fixtures without quantize()) for #5271 and is merged. Nothing here is needed on top of main.

@Qubitium Qubitium closed this Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant