You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[PyTorch] fp8_cs_quantize fake implementation returns a vector inverse scale instead of a scalar #3636
At current main 9d4bd38678f29a29dc0989e3a679dc14f3538e6a, onnx_cs_quantize_fp8_op computes amax = tensor.abs().max() without a dimension, then scale_inv = 1 / scale. This produces a zero-dimensional float32 tensor. Its register_fake implementation instead returns torch.ones(1, ...) for that output, describing a one-dimensional tensor.
This violates the custom operator's eager/FakeTensor metadata contract. PyTorch's torch.library.opcheck(..., test_utils=("test_faketensor",)) reports:
found mismatched tensor metadata for output[1]:
Shapes torch.Size([]) and torch.Size([1]) are not equal!
Narrow reproduction and limitation
I isolated the exact upstream current-scaling function and its fake registration on Linux with PyTorch 2.11.0+cu130, CUDA hidden. I replaced only the lower tex::fp8_quantize operation with a CPU uint8 shape producer. The separately computed inverse scale does not depend on that producer's output. Across FP32/FP16/BF16 inputs with shapes (4,), (2, 3), and (2, 3, 4), all nine original metadata checks fail with the mismatch above.
Changing only the fake inverse-scale allocation to torch.ones((), dtype=torch.float32, device=tensor.device) makes all nine isolated metadata checks pass. This is a shape-contract reproduction, not a test of native TE FP8 kernels, numerical quantization, ONNX Runtime, or TensorRT export.
Suggested fix and native follow-up
Return a scalar inverse scale in the fake implementation:
Hi, I'd like to work on this issue. I can investigate the FakeTensor shape mismatch, implement the proposed fix, and add a regression test. Would it be okay for me to take this up?
Thanks, please go ahead! A native torch.library.opcheck(..., test_utils=("test_faketensor",)) regression would be useful; my report only validated the isolated metadata path, not the TE CUDA kernel.
Activity
sanjana658 commentedon Oct 8, 2026
Hi, I'd like to work on this issue. I can investigate the FakeTensor shape mismatch, implement the proposed fix, and add a regression test. Would it be okay for me to take this up?
adenzhou1350 commentedon Oct 8, 2026
Thanks, please go ahead! A native
torch.library.opcheck(..., test_utils=("test_faketensor",))regression would be useful; my report only validated the isolated metadata path, not the TE CUDA kernel.