[PyTorch][torch.compile] Add value object support for quantizers#2792
Draft
pggPL wants to merge 3 commits intoNVIDIA:mainfrom
Draft
[PyTorch][torch.compile] Add value object support for quantizers#2792pggPL wants to merge 3 commits intoNVIDIA:mainfrom
pggPL wants to merge 3 commits intoNVIDIA:mainfrom
Conversation
Declare Float8CurrentScalingQuantizer, MXFP8Quantizer, Float8BlockQuantizer and NVFP4Quantizer as torch.compile value-typed opaque objects by adding __eq__, __hash__ and __fx_repr__ methods. This lets Dynamo bake them as constants and guard on equality instead of treating them as graph inputs. Key changes: - Add _TEQuantizerMeta combining OpaqueBaseMeta + ABCMeta (graceful fallback on PyTorch < 2.14) - Float8CurrentScalingQuantizer: lazy workspace allocation for scale/amax via __getattr__ so __fx_repr__ produces a tensor-free reconstruction - NVFP4Quantizer: store with_random_sign_mask for __fx_repr__ - New dynamo.py with register_opaque_type calls (no-op on older PyTorch) - Test: test_torch_compile.py with roundtrip value object test Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com> Made-with: Cursor
…_objects Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com> Made-with: Cursor # Conflicts: # transformer_engine/pytorch/quantized_tensor.py # transformer_engine/pytorch/tensor/float8_tensor.py # transformer_engine/pytorch/tensor/nvfp4_tensor.py
for more information, see https://pre-commit.ci
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.
Declare Float8CurrentScalingQuantizer, MXFP8Quantizer, Float8BlockQuantizer and NVFP4Quantizer as torch.compile value-typed opaque objects by adding eq, hash and fx_repr methods.
Type of change
Changes
Please list the changes introduced in this PR:
Checklist: