Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
6d3eece
Add TensorProto mechanism for data-free quantized tensor allocation
pggPL Jun 16, 2026
4bdaa60
[PyTorch] torch.compile: dedup cached FP8 weight from saved-for-backward
pggPL Jun 22, 2026
3be6fc7
[PyTorch] nvfp4: emit _describe_buffers in canonical flatten order
pggPL Jun 22, 2026
8a9d90c
Address review: error on undescribed buffers, gate nvfp4 test on HW s…
pggPL Jun 29, 2026
e36cf6d
[PyTorch] Workaround torch.compile staticmethod guard bug in NVFP4 _d…
pggPL Jun 29, 2026
90fc494
[PyTorch] Document TensorOrQuantized union (review feedback)
pggPL Jul 13, 2026
a3bf5c1
[PyTorch] Add shape property to QuantizedTensorStorage
pggPL Jul 13, 2026
37b0d17
[PyTorch] Test parity of Python alloc vs C++ make_empty
pggPL Jul 13, 2026
4feacdc
[PyTorch] Simplify comment on captured requires_grad flags
pggPL Jul 13, 2026
5adb6e4
[PyTorch] Drop redundant None guards in wt_save alias dedup
pggPL Jul 13, 2026
40d2d7b
[PyTorch] Use torch._prims_common.make_contiguous_strides_for
pggPL Jul 13, 2026
78e95a6
[PyTorch] Raise on update_usage of a non-quantized TensorProto
pggPL Jul 13, 2026
b3229cc
[PyTorch] Collapse to_tensor_proto branches
pggPL Jul 13, 2026
2b19368
[PyTorch] Drop dead weight_fp8 fallback in fake backward
pggPL Jul 13, 2026
c3dec83
[PyTorch] Drop redundant comment on saved_weight
pggPL Jul 13, 2026
cb53cc3
Merge branch 'main' of https://github.com/NVIDIA/TransformerEngine in…
pggPL Jul 13, 2026
dd99206
[PyTorch] Add TensorProto.assemble for rebuilding from ready-made buf…
pggPL Jul 15, 2026
2c28aa1
Merge remote-tracking branch 'upstream/main' into tensor_proto_mechanism
pggPL Jul 27, 2026
a30ea45
Merge remote-tracking branch 'upstream/main' into tensor_proto_mechanism
pggPL Jul 28, 2026
7e72013
Fix blockwise alloc parity test and drop dead CUDA skips
pggPL Jul 28, 2026
65cc334
Mirror quantize_weight's cache semantics in the Linear fake forward
pggPL Jul 28, 2026
3d10222
Honor the dequantized backward override in the Linear fake forward
pggPL Jul 28, 2026
a257fa3
Include the bias in the Linear fake output's differentiability
pggPL Jul 28, 2026
0414586
Move the Linear fake impls out to the custom-op branch
pggPL Jul 28, 2026
d5e1f20
Keep attributes attached to quantized parameters across _apply
pggPL Jul 29, 2026
6e61d36
Fail loudly if a buffer vanishes from a parameter during _apply
pggPL Jul 29, 2026
0228c9c
Merge remote-tracking branch 'upstream/main' into tensor_proto_mechanism
pggPL Jul 31, 2026
a24e4e0
Raise when a parameter vanishes during _apply instead of skipping it
pggPL Jul 31, 2026
a8b8873
Drop the vanished-buffer check from _apply
pggPL Jul 31, 2026
6bb030f
Declare flat buffers on the field instead of in a parallel tuple
pggPL Jul 31, 2026
e0bbb18
Name the flat buffers after PyTorch's own term for them
pggPL Jul 31, 2026
9a4fa8a
Carry the storage class itself through the flatten context
pggPL Jul 31, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions tests/pytorch/test_sanity.py
Original file line number Diff line number Diff line change
Expand Up @@ -1154,6 +1154,41 @@ def test_quantized_model_init_high_precision_init_val():
), "clear_high_precision_init_val() not work"


@pytest.mark.skipif(not fp8_available, reason=reason_for_no_fp8)
@pytest.mark.parametrize("move", ["cuda", "cpu", "half"])
def test_quantized_param_attrs_survive_apply(move):
"""Attributes attached to a quantized parameter survive nn.Module._apply.

Quantized parameters implement the flatten protocol, so ``_apply`` moves them
with ``swap_tensors``, which exchanges the parameter's whole ``__dict__``.
Anything attached from the outside rides out on the discarded tensor unless
the module re-attaches it.
"""
with quantized_model_init(preserve_high_precision_init_val=True):
model = Linear(64, 64)

weight = model.weight
expected = weight.get_high_precision_init_val()
weight.probe_attr = "attached-from-outside"

if move == "cuda":
model = model.cuda()
elif move == "cpu":
model = model.cpu()
else:
model = model.half()

weight = model.weight
assert hasattr(weight, "get_high_precision_init_val"), f"accessor lost by .{move}()"
assert hasattr(weight, "clear_high_precision_init_val"), f"accessor lost by .{move}()"
torch.testing.assert_close(weight.get_high_precision_init_val(), expected, rtol=0, atol=0)
assert weight.probe_attr == "attached-from-outside", f"custom attr lost by .{move}()"

# The accessor must read the surviving parameter, not the discarded one.
weight.clear_high_precision_init_val()
assert weight.get_high_precision_init_val() is None


@pytest.mark.skipif(not mxfp8_available, reason=reason_for_no_mxfp8)
def test_grouped_linear_single_param_preserves_high_precision_init(monkeypatch):
"""Grouped MXFP8 and discrete weights produce identical FP32 master initialization."""
Expand Down
Loading
Loading