Skip to content

fix(fp8): measure the native cast contract instead of gating every ROCm device (#5429) - #5550

Merged
Qubitium merged 1 commit into
mainfrom
fix/fp8-native-cast-5429
Nov 19, 2026
Merged

Qubitium merged 1 commit into
mainfrom
fix/fp8-native-cast-5429

Conversation

@Qubitium

@Qubitium Qubitium commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

What

TorchFP8Linear._lean_epilogue_eligible rejected every ROCm device with a bare if IS_ROCM, so row/tensor-scaled FP8 checkpoints took the pre-#5146 dequantize-then-matmul path there. On gfx1201 that costs about 3x latency and rounds ~41% of outputs to a different value (measured in #5429), even though all 256 codes of all four FP8 formats cast to fp16/bfloat16/fp32 bit-equal to the CPU cast.

The blanket rejection is replaced by a measurement:

Tests

tests/test_fp8_native_cast_probe_5429.py (8 nodes): the prober accepts every code of all four formats × fp16/bfloat16/fp32 on the reference device, returns a device-side verdict, skips the measurement on CUDA, measures once and caches, caches a failed cast, does not cache while capturing, and the lean gate follows the verdict. All 8 fail on origin/main with the source change stashed and pass with it.

Neighbours: tests/test_rocm_fp8_gating.py, test_fp8_bias_range.py, test_fp8_bias_native_gemm_4681.py, test_fp8_dequant_inplace.py, test_fp8_packed_weight_lifecycle.py, test_fp8_bf16_scale_reload.py, test_fp8_bias_dtype_4575.py, test_fp8.py, plus the new file → 120 passed. tests/kernels/test_fp8_{probe_5195,kernel,lean_decode_5146,block_decode_5318}.py → 159 passed, 6 skipped. bash format/check.sh clean.

Limits

  • No ROCm host in this environment; the gfx1201 numbers come from the issue. The prober is verified on CPU (the reference cast) and the ROCm branch through monkey-patched verdicts; the CUDA branch is unchanged and runs in the GPU suite above (GB10, sm_121).
  • The prober covers the torch cast the lean epilogue uses. The Triton block-decode paths already cast in-kernel and are unchanged.

Closes #5429.

@Qubitium
Qubitium merged commit 681a417 into main Nov 19, 2026
6 checks passed
@Qubitium
Qubitium deleted the fix/fp8-native-cast-5429 branch November 19, 2026 11:27
Qubitium added a commit that referenced this pull request Nov 20, 2026
…5649)

The ROCm FP8 cast probe compared the raw bit pattern of every code
against the CPU reference. ROCm preserves the source NaN payload/sign
while the CPU cast canonicalises it, so all four FP8 formats were judged
not bit-exact on gfx1201 and the lean bf16 path was never taken (#5550
left this half-fixed: only the non-NaN codes agree).

A NaN cannot change a matmul result and the conversion contract does not
pin its payload, so compare NaN-ness and the remaining codes' bits
separately. A code that becomes (or stops being) NaN is still rejected.

Adds tests/test_fp8_native_cast_probe_nan_5570.py: NaN-payload-only
differences pass, a single non-NaN bit flip / NaN<->number transition
fails, and the probe is wired to the new comparison.
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