Repository navigation
Conversation
kshitij12345
approved these changes
Jun 9, 2026
pggPL
force-pushed
the
remove_process_group_from_quantizers
branch
from
June 16, 2026 12:23
e9097d6 to
948cd6d
Compare
pggPL
force-pushed
the
remove_process_group_from_quantizers
branch
from
June 16, 2026 14:56
b8c1bec to
6c9b986
Compare
pggPL
force-pushed
the
make_qunatizers_opaque
branch
from
June 16, 2026 15:21
33e9d73 to
d341eeb
Compare
pggPL
force-pushed
the
make_qunatizers_opaque
branch
2 times, most recently
from
June 29, 2026 07:33
adc65f6 to
c7bbc83
Compare
…ompile Give tensorless quantizers (MXFP8, FP8 blockwise, FP8 current-scaling, NVFP4) value-object semantics so torch.compile can treat them as baked-in constants: - Add opt-in value identity to the base Quantizer (_value_fields / _value_key / __eq__ / __hash__). Quantizers holding live tensors (delayed-scaling Float8Quantizer) and custom quantizers keep identity semantics. - New transformer_engine/pytorch/dynamo.py houses the torch.compile glue: __fx_repr__, value-key reconstruction and register_value_opaque_quantizer (gracefully a no-op on PyTorch builds without the opaque-object API). - Register the four tensorless quantizers as value opaque types. Also fix CustomRecipe state caching in TransformerEngineBaseModule: set_meta_tensor now rebuilds quantizers when the CustomRecipe instance changes (e.g. nested te.autocast regions) instead of reusing the first recipe's state, since every CustomRecipe shares the CustomRecipeState type but carries its own qfactory. Move the quantizer value-object tests into tests/pytorch/test_torch_compile.py and add that file to the L0 pytorch unittest QA suite. Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
…globals Follow-up to the value-opaque quantizer support: - Remove the module-level _QUANTIZER_VALUE_REGISTRY (qualname -> class) and _quantizer_from_value_key. __fx_repr__ now captures the quantizer class directly in the FX globals and reconstructs via _rebuild_quantizer(cls, items), matching how PyTorch's own value opaque types (e.g. DTensor placements) reconstruct themselves. This removes global mutable state and the qualname collision risk. - Consolidate the quantizer value-object tests in test_torch_compile.py down to two functions and exercise reconstruction through the public __fx_repr__ path instead of internal helpers. Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
Replace the single dynamo.py module with a dynamo/ package so the
torch.compile glue can grow with a clear responsibility split across the
stacked branches. This branch owns the value-opaque quantizer layer.
* dynamo/quantizer_opaque.py -- register_value_opaque_quantizer and helpers
* dynamo/__init__.py -- re-exports the public API so callers keep importing
from transformer_engine.pytorch.dynamo unchanged
Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
A value-opaque quantizer must not carry live distributed state. Scan the quantizer attributes in __fx_repr__ and raise TypeError if any holds a torch.distributed.ProcessGroup (e.g. a non-None deprecated amax_reduction_group), so it cannot be silently baked into a torch.compile FX graph. Clarify the related comments accordingly. Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
NVFP4Quantizer is registered as a value-opaque quantizer but was missing from the value-semantics / __fx_repr__ round-trip test. Add it to _VALUE_QUANTIZERS (skipped without CUDA, which it needs to construct). Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
…__/__hash__ The amax reduction group is excluded from the value key, so a value quantizer that stored one would compare/hash equal to a groupless one and let torch.compile reuse a graph that skips the reduction. __eq__/__hash__ now raise (mirroring __fx_repr__, which already rejects any process-group-bearing quantizer). The group should be passed per quantize call, not stored on the quantizer. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
Add is_value_opaque_quantizer() + the _te_compile_value_opaque flag stamped at registration, so dynamo-traced code can detect registered quantizers (and fall back to eager for unregistered ones). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
pggPL
force-pushed
the
make_qunatizers_opaque
branch
from
June 29, 2026 09:26
c7bbc83 to
f592cbb
Compare
…fp4 value key - Narrow register_opaque_type except to (RuntimeError, TypeError): the API is already imported above, so ImportError/AttributeError there only mask real errors. - Add test_quantizer_value_object_fullgraph exercising torch.compile(fullgraph=True) end-to-end to verify opaque-type registration took effect. - Restore missing NVFP4Quantizer._with_random_sign_mask assignment required by _value_fields()/_value_key(). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
pggPL
force-pushed
the
make_qunatizers_opaque
branch
from
June 29, 2026 09:34
f592cbb to
945f62d
Compare
…trip _rebuild_quantizer only restores value-key fields, so a reconstructed NVFP4Quantizer was missing the derived rht_matrix tensor (not hashable, so not in the value key) and failed at copy()/quantize time. Add a _rebuild_derived_state hook (called by _rebuild_quantizer) that NVFP4Quantizer uses to rebuild rht_matrix from _with_random_sign_mask (lru_cache -> cheap). Extend test_quantizer_value_object to also quantize with the original and the rebuilt quantizer and require bit-exact results (gated on HW support), so a field the kernel needs but the value key omits can no longer slip through. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
Move the ProcessGroup guard out of the (overridable) __fx_repr__ into Quantizer._value_key -- the single point every value-materialization path (__eq__/__hash__/__fx_repr__) goes through -- so a custom __fx_repr__ can no longer bypass it. Generalizes the old amax-only check to any field holding a ProcessGroup. Add a test that a value quantizer carrying a live group raises. Addresses review on NVIDIA#3152. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
…assthrough Replace the trivial pass-through fullgraph test with one that drives each production quantizer through a minimal custom op (quantize + dequantize) under torch.compile(fullgraph=True) and compares to eager -- so the opaque-type registration is actually exercised inside the graph (a graph break would make fullgraph=True raise). Op registration sits right before the test. Also drop stale comments referencing the old __fx_repr__-side process-group guard. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
…paque flag - rht_matrix_random_sign_mask_t is a device-independent int derived from _with_random_sign_mask (the device only places a throwaway tensor); fix the misleading comment. - Explain why registration uses a class attribute, not a registry set: is_value_opaque_quantizer is traced inside the compile graph and dynamo can bake a getattr constant but cannot do 'type(q) in set' on the opaque class. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
is_opaque_value_type(cls) sat between the import guard and the register_opaque_type guard, so on a partial/experimental opaque-object build it could raise RuntimeError/TypeError and crash TE import. Move it inside the same except so the 'registration never crashes import' promise holds for both calls. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
…m-mem zero-copy (NVIDIA#3035) * Expert Parallelism: PyTorch wrapper + autograd ops with symm-mem zero-copy Signed-off-by: Phuong Nguyen <phuonguyen@nvidia.com> --------- Signed-off-by: Phuong Nguyen <phuonguyen@nvidia.com>
…NS_PER_RANK (NVIDIA#3150) * nccl with relax num_dispatch_tokens%64!=0 Signed-off-by: Phuong Nguyen <phuonguyen@nvidia.com> * Skip EP tests/examples on nodes without NVLink Signed-off-by: Phuong Nguyen <phuonguyen@nvidia.com> --------- Signed-off-by: Phuong Nguyen <phuonguyen@nvidia.com>
…VIDIA#3141) * Preserve fprop operands for dequantized backward override Signed-off-by: Evgeny <etsykunov@nvidia.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Add test_grouped_linear_backward_override_high_precision_forces_save_original_input test Signed-off-by: root <root@prenyx0017.a51.clusters.nvidia.com> --------- Signed-off-by: Evgeny <etsykunov@nvidia.com> Signed-off-by: root <root@prenyx0017.a51.clusters.nvidia.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: root <root@prenyx0017.a51.clusters.nvidia.com>
* Make quantized-tensor __repr__ fake-safe under torch.compile
Under torch.compile, TE quantized-tensor __repr__ methods are invoked on
FakeTensors during AOT autograd's structured logging. The repr bodies call
self._scale_inv.item() and/or self.dequantize() (which dispatches to the raw
C++ op tex.dequantize), both of which access a FakeTensor's data pointer and
raise:
RuntimeError: Cannot access data pointer of Tensor (e.g. FakeTensor,
FunctionalTensor) ...
This was the sole cause of six fp8 failures in tests/pytorch/test_torch_compile.py.
Fix: add one shared helper, safe_quantized_repr, in tensor/_quantization_helpers.py
(a safe leaf module importing only torch) that builds a metadata-only repr
string. Each data-touching __repr__ now wraps its existing body in a try/except
and falls back to the helper when the data cannot be materialized. The eager
(non-fake) repr output is unchanged; only a fallback path is added.
Wrapped reprs: Float8Tensor, Float8BlockwiseQTensor, MXFP8Tensor, NVFP4Tensor
and their *Storage counterparts.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Make quantized __repr__ fallback universal, drop FakeTensor-specific logic
Remove the FakeTensor-specific heuristic (_is_fake_data_access_error) and the
warning path from safe_quantized_repr. The fallback is now a plain metadata-only
repr triggered by any exception while materializing data, with each attribute
access individually guarded so __repr__ never raises.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
---------
Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
…` with `total_recv_tokens_per_rank` placeholder (NVIDIA#3154) * versioning EP C configs Signed-off-by: Phuong Nguyen <phuonguyen@nvidia.com> * Rename EP prepare token_counts to recv_tokens_per_expert Signed-off-by: Phuong Nguyen <phuonguyen@nvidia.com> * Add total_recv_tokens_per_rank placeholder to nvte_ep_prepare Signed-off-by: Phuong Nguyen <phuonguyen@nvidia.com> * Adapt PyTorch EP binding to versioned nvte_ep C config API Signed-off-by: Phuong Nguyen <phuonguyen@nvidia.com> * Rename EP group config max_num_sms to num_comm_sms Signed-off-by: Phuong Nguyen <phuonguyen@nvidia.com> --------- Signed-off-by: Phuong Nguyen <phuonguyen@nvidia.com>
Move the _VALUE_OPAQUE_FLAG setattr to the end of register_value_opaque_quantizer, after register_opaque_type succeeds (or the type is already opaque). Previously the flag was set up front, so is_value_opaque_quantizer reported True even when the opaque-object API was missing or registration raised, since both paths are swallowed. Eager value semantics (__eq__/__hash__/__fx_repr__) are independent of the flag, so this only tightens the predicate to mean torch actually knows the type as opaque. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
_check_value_has_no_process_group ran on every guard eval (via __eq__/__hash__) and scanned all of vars(self) recursively. The only attribute that can hold a ProcessGroup is the deprecated amax_reduction_group, so check it directly (O(1)) and drop the _contains_process_group helper. Same guarantee, off the hot path. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
# Conflicts: # transformer_engine/pytorch/tensor/float8_blockwise_tensor.py # transformer_engine/pytorch/tensor/float8_tensor.py # transformer_engine/pytorch/tensor/mxfp8_tensor.py # transformer_engine/pytorch/tensor/nvfp4_tensor.py
Remove the a==b / hash / dict-key block that just exercised Python's own dict semantics; equality and hashing are still covered by the __fx_repr__ round-trip (rebuilt == a, hash match) and the bit-exact kernel check. other_kwargs is now unused, so drop it from the parametrization and both test signatures. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
… CUBLAS GGEMM heuristics (NVIDIA#3143) * support in grouped linear and relevant tests Signed-off-by: Varun Thumbe <vthumbe@nvidia.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Unecessary details remove Removed details about FP8 current scaling methods. Signed-off-by: vthumbe1503 <vthumbe@nvidia.com> * fix grouped linear module's grouped tensor path Signed-off-by: Varun Thumbe <vthumbe@nvidia.com> * allow more current scaling use-cases.. block nvfp4+rht+single grouped weight being cuda graphable Signed-off-by: Varun Thumbe <vthumbe@nvidia.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * some minor comment fixing Signed-off-by: Varun Thumbe <vthumbe@nvidia.com> * fix heuristics Signed-off-by: Varun Thumbe <vthumbe@nvidia.com> * only dealyed scaling skip in failure comment Signed-off-by: vthumbe1503 <vthumbe@nvidia.com> * address review comment Signed-off-by: Varun Thumbe <vthumbe@nvidia.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix for other 2 nvte APIs Signed-off-by: Varun Thumbe <vthumbe@nvidia.com> * fix m and n Signed-off-by: Varun Thumbe <vthumbe@nvidia.com> --------- Signed-off-by: Varun Thumbe <vthumbe@nvidia.com> Signed-off-by: vthumbe1503 <vthumbe@nvidia.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
…n megatron. (NVIDIA#2898) * add support for THD CUDA graph Signed-off-by: HaochenYuan <haocheny@nvidia.com> * modify comment Signed-off-by: HaochenYuan <haocheny@nvidia.com> * address @timmoon10: drop FAv2-bwd alloc gate, rely on THD tail zero-fill Signed-off-by: HaochenYuan <haocheny@nvidia.com> * Support graph-safe MoE aux loss token count Signed-off-by: HaochenYuan <haocheny@nvidia.com> * add graph guard for one zero fill Signed-off-by: HaochenYuan <haocheny@nvidia.com> * remove redundant zero-fill Signed-off-by: HaochenYuan <haocheny@nvidia.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * rename & remove prelude kernel Signed-off-by: HaochenYuan <haocheny@nvidia.com> * Update warp reduction function Co-authored-by: Tim Moon <4406448+timmoon10@users.noreply.github.com> Signed-off-by: Tim Moon <4406448+timmoon10@users.noreply.github.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Signed-off-by: HaochenYuan <haocheny@nvidia.com> Signed-off-by: Tim Moon <4406448+timmoon10@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Tim Moon <4406448+timmoon10@users.noreply.github.com>
…ling (NVIDIA#3135) Implements grouped-tensor quantize for the FP8 1D (1x128) and 2D (128x128) block-scaling recipes in row-wise (RW), column-wise (CW) and BOTH quantization directions. A single CUDA kernel launch walks 128x128 tiles across every tensor in the group, with each CTA decoding its owning tensor from the device-side GroupedTensor metadata with (N, R, K) shapes. Supports SAME_BOTH_DIMS (all tensors identical) and VARYING_FIRST_DIM (constant K, varying R) shape representations. Three kernels share the dispatcher in group_quantize_blockwise_{1d,2d}: - group_block_scaled_1d_rw_kernel: RW-only dispatch; 8 threads/row, reads global memory directly into vec-16 registers; bypasses TMA since the shared-memory roundtrip and ptx::mbarrier do not buy anything without re-use in the CW path. - group_block_scaled_1d_tma_kernel: CW-only and BOTH dispatch. TMA bulk-load fills shared memory input cache. BOTH runs an RW pass (8 threads/row, vec-16 read from shared memory) then a CW pass; CW-only skips the RW pass. The CW pass uses 4 t/col with 32-row reg_data and two column passes in the BOTH instantiation (keeps the per-thread register footprint under the sm_90 3-CTAs/SM threshold) and 2 t/col with 64-row reg_data in the CW-only instantiation (avoids doubling the smem-load bank-conflict footprint that 4 t/col would introduce). - group_block_scaled_2d_tma_kernel: RW-only, CW-only and BOTH dispatch. TMA bulk-load fills shared memory input cache. Pass 1 stages 8 IVecs/thread in registers while computing the per-tile scalar amax. Pass 2 quantizes from registers, emits row-wise output, stages column-wise output to the shared memory transpose staging buffer, then drains smem_T to global memory. Per-expert scale offsets: - 1D RW: closed-form O(1) for both SAME_BOTH_DIMS and VARYING_FIRST_DIM (each M_i is a multiple of kTileDim=128, hence of kScaleColAlign=4, so DIVUP_TO_MULTIPLE collapses and the prefix sum reduces to a single tensor_offsets_ptr[tensor_id]/K load). - 2D CW: closed-form O(1) for SAME_BOTH_DIMS; CTA-cooperative warp-shuffle prefix sum for VARYING_FIRST_DIM (non-linear DIVUP_TO_MULTIPLE on blocks_y_t prevents a closed form). The cooperative reduction uses the existing warp_allreduce_sum helper from common/utils.cuh. Dequantize and bias-gradient (bgrad): - group_dequantize_fp8_blockwise.cuh: kernels for all four modes (1D/2D x rowwise/columnwise), inverting the per-expert layouts the quantize kernels write. - bgrad_group_quantize accepts Float8Block quantizers and computes dbias per-tile column-partial in-kernel (mirroring MXFP8); reduced per expert via the existing common::grouped_reduce_dbias. Scale constraints: the fused grouped FP8BS path supports only unconstrained FP32 scales (Float8BlockQuantizer::create_grouped_tensor rejects force_pow_2_scales=True). Power-of-2 scales remain available on the non-grouped/unfused split-quantize path used for Blackwell MXFP8 emulation. Tests: existing parametrized grouped quantize / dequantize / bgrad tests in test_grouped_tensor.py cover MXFP8, NVFP4, FP8 current scaling and the newly-added FP8 block scaling recipe. tests/cpp/operator/ test_cast_float8blockwise_grouped.cu adds 72 C++ unit-test cases over uniform/jagged shapes, all four (BD x direction) modes, K in {128, 256, 512}, and CUDA-graph capture coverage. Kernels are gated to Hopper (sm_90) at the host dispatcher (cuBlasLt grouped GEMM supports FP8 block-scaling only on Hopper). JAX integration is intentionally left out of scope and deferred to a follow-up PR. Resolves NVIDIA#2525 Signed-off-by: Alp Dener <adener@nvidia.com>
…L2 Jax dist (NVIDIA#3159) * Keep the routing map format alive Signed-off-by: Kshitij Lakhani <klakhani@nvidia.com> * Fix incorrectly launched multi process EP tests in L2 Jax instead of L2 jax dist Signed-off-by: Kshitij Lakhani <klakhani@nvidia.com> --------- Signed-off-by: Kshitij Lakhani <klakhani@nvidia.com>
Signed-off-by: Santosh Bhavani <santosh.bhavani@live.com>
* skip tests on hopper Signed-off-by: Varun Thumbe <vthumbe@nvidia.com> * Update qa/L1_pytorch_mcore_fsdp_integration/test.sh Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> Signed-off-by: vthumbe1503 <vthumbe@nvidia.com> --------- Signed-off-by: Varun Thumbe <vthumbe@nvidia.com> Signed-off-by: vthumbe1503 <vthumbe@nvidia.com> Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
…ests (NVIDIA#3174) fixing Blackwell skip condition for grouped FP8 block-scaling tests in C++ Signed-off-by: Alp Dener <adener@nvidia.com>
- Replace the class-attribute value-opaque flag with a module-level set of class qualnames: a set of class objects is untraceable under fullgraph=True (opaque classes have no equality rule in Dynamo), but the qualname constant-folds to a plain string; also avoids falsely reporting unregistered subclasses. - Register MXFP8Quantizer right after the class like the other quantizers. - Clarify the amax_reduction_group exclusion comment in Float8CurrentScalingQuantizer._value_fields. - Restore import order in test_torch_compile.py, import NVFP4Quantizer from transformer_engine.pytorch, drop unused Float8Quantizer import. Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
Make the class annotations the single source of truth for what defines a quantizer's value, instead of hand-written per-class _value_fields lists: - Quantizer._value_fields is now derived from the annotations across the MRO (subsuming _BASE_VALUE_FIELDS); register_value_opaque_quantizer is the explicit opt-in and validates at import time that no annotated field is a tensor or process group. - Drop the four per-class _value_fields overrides. - Remove the deprecated amax_reduction_group annotation from Float8CurrentScalingQuantizer and NVFP4Quantizer (the attribute is still set for backward compatibility). - NVFP4: rename _with_random_sign_mask to with_random_sign_mask (annotated, matching the constructor argument), stop storing the derived rht_matrix_random_sign_mask_t in the value key and rebuild it together with rht_matrix in _rebuild_derived_state (lru-cached getters), which __init__ now also uses. copy() now propagates with_random_sign_mask. Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
- NVFP4: stop storing with_random_sign_mask; the annotated value field is the derived (deterministic, device-independent) rht_matrix_random_sign_mask_t and rht_matrix is rebuilt from it in _rebuild_derived_state. Quantizers pickled before this PR already carry the mask in __dict__, so old checkpoints keep working (a boolean back-fill default could lie for quantizers created with with_random_sign_mask=False). - Value semantics no longer leak into unregistered subclasses: register_value_opaque_quantizer stores the field tuple on the class and _value_fields looks it up in the class's own __dict__, so a subclass must register explicitly (it previously inherited value eq/hash that ignored its unannotated fields and skipped the annotation check). - The value-field tuple is computed once at registration instead of an MRO walk per __eq__/__hash__ call (these run per compiled-function invocation via the EQUALS_MATCH guard); registration validation and field derivation now share one annotation walk (Quantizer._annotated_fields). Drop the unreachable other._value_fields() branch and do the cheap type check first in __eq__. Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
Replace the substring blocklist with get_type_hints + an allowlist of value types (int/bool/float/str/enum): aliased tensor types no longer slip through and benign types whose name merely contains "Tensor" are no longer rejected. Runs once per class at import time, not in any hot path. Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
_rebuild_quantizer no longer back-fills the deprecated amax_reduction_group (and loses the field_names set that existed only for that check): a rebuilt quantizer deliberately lacks the attribute, so anything that genuinely needs it fails loudly instead of silently getting None. The only unconditional readers were the two copy() methods, which now tolerate the absent field; _canonicalized_amax_reduction_group (used by the kernel only when with_amax_reduction is set) still raises AttributeError on a rebuilt quantizer, which is the intended behavior. Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
The quantize kernel rejects with_rht=True without with_post_rht_amax=True (pre-RHT amax unsupported); mirror the recipe, which always sets both together. Unnoticed locally because the NVFP4 round-trip is skipped on non-NVFP4 hardware. Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
pggPL
pushed a commit
that referenced
this pull request
Sep 29, 2026
…IA#3137) * start draft Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * remove benchmark scripts Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * add license Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * fix Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * make cutlass dsl required Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * fix linting errors Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * warn failed compilation Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * make tvm-ffi common dependency Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * use a higher version for cutlass-dsl Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * less comment Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * skip zeroing buffer if noop flag set Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * refactor activations Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * fix Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * lint Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * fix Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * nit Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * maybe it's better to prepare tvm-ffi & cutedsl kernels in common/__init__.py Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * nit Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * fix Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * fix Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * fix Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * fix Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * also flush colwise scale in SMEM Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * use explicit fp8 types Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * nit Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * add checks Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * refactor Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * nit Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * nit Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * nit Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * fi Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * nit Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * nit Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * skip comparision test if cutedsl disabled Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * fix Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * Merge pull request #3 from janekb04/cutedsl_mxfp8_common Perform noop tensor check on device Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * add test to the qa script Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * warn only once if dlopen fails Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * fix Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * let tests cover swizzling Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * warn not chosen cutedsl kernel during testing Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * improve lazyload so now the cache is uint32 Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * let tests be verbose about warnings so we know if cutedsl kernel is not dispatched Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * support swizzled scale for specialized kernel but disable it Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * fix Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * nit Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * fix inline ptx Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * more fix Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * revert to mul Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * nit Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * add jax tests Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * also ignore noop when dbias Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * relax dim check for the kernels Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * reject 2D quant Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * run more tests with CuTeDSL path Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * make rowwise only handle divisible cases Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * fallback to CUDA if not TMA aligned Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * specialize skip masking version Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * nit Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * add type annotations Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * optimize masking Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * skip masking for some acts Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * allow user to opt out from building with CuTeDSL Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * better warning Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * doc Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * add jax test coverage for cutedsl Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * fix device sm query Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * catch more python error Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * nit Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * nit Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * nit Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * fix Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * make tvm-ffi required for python users Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * optimize dbias Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * skip scale bound check whenever possible Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * allow colwise to fuse relu too Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * dispatch to rowwise specialized with swizzled scale Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * don't link tvmffi if building a standalong C++ lib without framework Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * change some logging Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * use the right fast math flag Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * also let test script use NVTE_DEBUG Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * also let mutex cover the loading of tvm-ffi func Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * locate tvm-ffi include dir from setup_common_extension Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * fix how tests run with cutedsl enabled Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * nit Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * reduce framework scope tests run with cutedsl backend Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * allow C++ tests to run with cutdsl Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * remove tvmffi and cutlass dependencies from setup.py due to being optional Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * encode sm numbers in tvm_ffi function name & cache key Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * make C++ tests run in sequential Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * make CuTeDSL default and cover C++ in L1 Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * Improvements and fix to CuTe DSL kernel launches (#7) * [Common] Bypass Python wrapper overhead with __tvm_ffi_object__ Signed-off-by: Jan Bielak <jbielak@nvidia.com> * [Common] Avoid heap allocations in DLTensorWrapper Signed-off-by: Jan Bielak <jbielak@nvidia.com> * [Common] Avoid querying device in DLTensorWrapper Signed-off-by: Jan Bielak <jbielak@nvidia.com> * [Common] Fix packed dtype handling in DLTensorWrapper Signed-off-by: Jan Bielak <jbielak@nvidia.com> * Apply review suggestions Signed-off-by: Jan Bielak <jbielak@nvidia.com> --------- Signed-off-by: Jan Bielak <jbielak@nvidia.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix dispatching so it never uses specialized if grid won't fit Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * also add tests Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * Minor fixes to CuTe DSL infrastructure (#8) * Improvements and fix to CuTe DSL kernel launches (#7) * [Common] Bypass Python wrapper overhead with __tvm_ffi_object__ Signed-off-by: Jan Bielak <jbielak@nvidia.com> * [Common] Avoid heap allocations in DLTensorWrapper Signed-off-by: Jan Bielak <jbielak@nvidia.com> * [Common] Avoid querying device in DLTensorWrapper Signed-off-by: Jan Bielak <jbielak@nvidia.com> * [Common] Fix packed dtype handling in DLTensorWrapper Signed-off-by: Jan Bielak <jbielak@nvidia.com> * Apply review suggestions Signed-off-by: Jan Bielak <jbielak@nvidia.com> --------- Signed-off-by: Jan Bielak <jbielak@nvidia.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * [Common] Add missing dtypes to CuTe DSL dispatch Signed-off-by: Jan Bielak <jbielak@nvidia.com> * [Common] Add line information to CuTe DSL inline PTX helpers Signed-off-by: Jan Bielak <jbielak@nvidia.com> --------- Signed-off-by: Jan Bielak <jbielak@nvidia.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * add missing ip & loc Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * refactor so we don't need #pragma to avoid collision in tests Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * whoops Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * whoops again Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * rename NVTE_ENABLE_CUTEDSL_QUANT_BACKEND to NVTE_ENABLE_CUTEDSL_BACKEND Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * switch back to NVTE_WARN_IF_CUTEDSL_BACKEND_NOT_CHOSEN Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * use TE's to_string to convert dtype to str Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * remove MXFP8QuantFused Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * move python init from tests to TE lib Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * software path for e8m0 conversion Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * nit Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * remove unreachable branch Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * fold quantize_mxfp8_cutedsl_config.h back to quantize_mxfp8_cutedsl.h Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * nit Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * nit for some C++ Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * rewrite dsl_user_op to cute.jit if possible and let compiler optimize Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * fix python init Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * prefere inline_ptx instead of llvm.inline_asm Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * nit Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * fix activation encoding Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * remove unused device_is_blackwell function Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * link C++ test executable to libtvm_ffi.so Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * move cutedsl utils from math.h to a separate file Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * recover test_cast_mxfp8.cu Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * no need to init extension now Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * hoist importorskip in cutedsl python tests Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * fix activation_func_to_enum so it works with CUDA 12.8 Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * make NVTE_WITH_CUTEDSL both a env var and a cmake option Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * fix TE path searching for python bootstrap Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * when enabling cutedsl manually, also initialize python if it's not done before Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * use dlsym Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * fix Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * nit Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * let main TE lib link to Python::Module Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * add a test to cover untested manually enable cutedsl path Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * fix Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * nit Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * update min ver workflow Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * rename L1 CUDA C++ UT Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * fix build issues for CuTeDSL backend (#10) * disable CuTeDSL support and other fix Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * remove docs that mention CuTeDSL since they are off by default now Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * fix Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * remove test_cutedsl_backend.cpp Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * make envvar.rst more human Signed-off-by: Kaining Zhong <kainingz@nvidia.com> --------- Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * fix Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * fix python tests Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * skip L1 C++ UT with CUDA when CuTeDSL is not enabled globally Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * fix Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * fix C++ UT python discovery Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * fix deadlock for multigpu Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * fix python init Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * fix python init again thanks to codex Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * refactor the serialized initial launch Signed-off-by: Kaining Zhong <kainingz@nvidia.com> * nit Signed-off-by: Kaining Zhong <kainingz@nvidia.com> --------- Signed-off-by: Kaining Zhong <kainingz@nvidia.com> Signed-off-by: Jan Bielak <jbielak@nvidia.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Jan Bielak <janekb04@icloud.com> Co-authored-by: Jan Bielak <jbielak@nvidia.com>
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
Tensorless quantizers in TE (MXFP8, FP8 blockwise, FP8 current-scaling, NVFP4)
are fully described by a handful of plain, reproducible scalars — they hold no
live tensors and no process groups. This PR turns them into opaque value
objects so
torch.compilecan treat them as baked-in constants: twoquantizers with the same configuration become interchangeable, hashable, and
reconstructible inside an FX graph.
Quantizers that hold live state (delayed-scaling
Float8Quantizer, which keepsscale/amaxtensors) and any user-defined quantizer keep the defaultidentity semantics, so the change is opt-in and backward compatible. On older
PyTorch builds without the opaque-object API the registration is a graceful
no-op.
Along the way this also un-breaks the existing
test_torch_compile.pysuite:that file lived on
mainbut was never wired into CI, and itstest_autocast_nested_customcase (nestedte.autocastwith multipleCustomRecipeinstances) was failing because of theCustomRecipestate-cachingbug fixed here. The file is now run in CI and passes.
Type of change
Changes
Quantizer(
_value_fields/_value_key/__eq__/__hash__). ReturningNonefrom
_value_fields()(the default) keeps identity semantics.transformer_engine/pytorch/dynamo.pyholding thetorch.compileglue:__fx_repr__, value-key reconstruction andregister_value_opaque_quantizer(gracefully no-op without PyTorch'sopaque-object API).
MXFP8Quantizer,Float8BlockQuantizer,Float8CurrentScalingQuantizerandNVFP4Quantizeras value opaque types(the deprecated
amax_reduction_groupis never part of the value).CustomRecipestate caching inTransformerEngineBaseModule.set_meta_tensor:rebuild quantizers when the
CustomRecipeinstance changes (e.g. nestedte.autocastregions) instead of reusing the first recipe's state, sinceevery
CustomRecipeshares theCustomRecipeStatetype but carries its ownqfactory. This fixes the previously-failingtest_autocast_nested_custom.tests/pytorch/test_torch_compile.pyin theL0_pytorch_unittestQAsuite (it existed on
mainbut was never run in CI), and add the quantizervalue-object tests to it. Bringing it into CI required fixing the existing
CustomRecipetorch.compile path: theqfactorynow dispatches onQuantizerRole.tensor_typesupplied byToyLinear.get_quantizer_roles.__fx_repr__already rejects any quantizer holding a process group, and
__eq__/__hash__now raise too. The group is excluded from the value key, so a stored group would
otherwise compare/hash equal to a groupless quantizer and let
torch.compilereuse a graph that skips the reduction. Pass the group per quantize call instead.
Checklist: