Repository navigation
Conversation
Signed-off-by: Jan Bielak <[email protected]>
6 of 13 tasks
siddhant-rajhans
pushed a commit
to siddhant-rajhans/TransformerEngine
that referenced
this pull request
Nov 5, 2026
Calling .to() on a QuantizedTensor from inside __torch_dispatch__ reaches the dispatcher as an aten.to.* overload rather than aten._to_copy, because the CompositeImplicitAutograd decomposition is skipped there. Those overloads fell through to the dequantizing fallback, so an op such as `x_cpu + 0` on a CPU-resident MXFP8 or NVFP4 tensor recursed: the fallback dequantizes, dequantization moves the tensor to the GPU with .to(), and .to() dispatches back into the fallback. Handle the aten.to.* overloads like aten._to_copy in the base class, as proposed in NVIDIA#3279. This replaces the MXFP8- and NVFP4-specific buffer copies from the earlier commits of this PR, and the test moves into test_quantized_tensor.py, parametrized over all quantization formats. Co-authored-by: Jan Bielak <[email protected]> Signed-off-by: Siddhant Rajhans <[email protected]>
siddhant-rajhans
added a commit
to siddhant-rajhans/TransformerEngine
that referenced
this pull request
Nov 6, 2026
Calling .to() on a QuantizedTensor from inside __torch_dispatch__ reaches the dispatcher as an aten.to.* overload rather than aten._to_copy, because the CompositeImplicitAutograd decomposition is skipped there. Those overloads fell through to the dequantizing fallback, so an op such as `x_cpu + 0` on a CPU-resident MXFP8 or NVFP4 tensor recursed: the fallback dequantizes, dequantization moves the tensor to the GPU with .to(), and .to() dispatches back into the fallback. Handle the aten.to.* overloads like aten._to_copy in the base class, as proposed in NVIDIA#3279. This replaces the MXFP8- and NVFP4-specific buffer copies from the earlier commits of this PR, and the test moves into test_quantized_tensor.py, parametrized over all quantization formats. Co-authored-by: Jan Bielak <[email protected]> Signed-off-by: Siddhant Rajhans <[email protected]>
vthumbe1503
added a commit
that referenced
this pull request
Nov 7, 2026
…#3812) * Fix CPU QuantizedTensor dequantize RecursionError _FromNVFP4Func.forward() and _FromMXFP8Func.forward() call tensor.to(device=cuda) on the full QuantizedTensor when dequantizing a CPU-resident quantized tensor. This triggers __torch_dispatch__, which calls maybe_unwrap -> dequantize() -> forward() -> tensor.to() -> __torch_dispatch__ in an infinite loop. Move the raw inner data tensors to CUDA individually via get_metadata() and construct a plain TensorStorage for the tex.dequantize call. Plain torch.Tensor.to() on the inner buffers does not enter __torch_dispatch__, breaking the cycle. Fixes #3294 Signed-off-by: Siddhant Rajhans <[email protected]> * fix: add GPU capability checks and MXFP8 fp8_dtype to tests - MXFP8Quantizer requires fp8_dtype argument; pass kFloat8E4M3 - Skip NVFP4/MXFP8 tests on GPUs that lack support via is_nvfp4_available() / is_mxfp8_available() Signed-off-by: Siddhant Rajhans <[email protected]> * Fix CPU dequantize recursion in the QuantizedTensor base class Calling .to() on a QuantizedTensor from inside __torch_dispatch__ reaches the dispatcher as an aten.to.* overload rather than aten._to_copy, because the CompositeImplicitAutograd decomposition is skipped there. Those overloads fell through to the dequantizing fallback, so an op such as `x_cpu + 0` on a CPU-resident MXFP8 or NVFP4 tensor recursed: the fallback dequantizes, dequantization moves the tensor to the GPU with .to(), and .to() dispatches back into the fallback. Handle the aten.to.* overloads like aten._to_copy in the base class, as proposed in #3279. This replaces the MXFP8- and NVFP4-specific buffer copies from the earlier commits of this PR, and the test moves into test_quantized_tensor.py, parametrized over all quantization formats. Co-authored-by: Jan Bielak <[email protected]> Signed-off-by: Siddhant Rajhans <[email protected]> * Update tests/pytorch/test_quantized_tensor.py Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> Signed-off-by: vthumbe1503 <[email protected]> --------- Signed-off-by: Siddhant Rajhans <[email protected]> Signed-off-by: vthumbe1503 <[email protected]> Co-authored-by: Jan Bielak <[email protected]> Co-authored-by: vthumbe1503 <[email protected]> Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Collaborator
|
Closing as fixed by #3812. |
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.
Description
Trying to use a
QuantizedTensorin certain ways causes aRecursionErrorif it has been moved to the CPU. For instance,will cause:
I noticed this when trying to use
torch.testing.assert_closeon a tensor quantized withNVFP4Quantizerand a custom Pytorch implementation on the CPU.Type of change
Changes
Please list the changes introduced in this PR:
Checklist: