Repository navigation
[inductor][test] Cover nested-cat view bounds and chunk values (#205202) - #205202
Z-Ghostshell wants to merge 1 commit into
Conversation
PR Status: Approved 🚀Please fix all CI failures and trigger merge by commenting "@pytorchbot merge". ✅ AUTOMATED REVIEW - OUTDATED (earlier commit) - Ready for human review:
Findings (7): Reviewed commit: 🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/205202
Note: Links to docs will display an error until the docs builds have been completed. ✅ You can merge normally! (1 Unrelated Failure)As of commit 27ee416 with merge base 76745a9 ( BROKEN TRUNK - The following job failed but were present on the merge base:👉 Rebase onto the `viable/strict` branch to avoid these failures
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
@Z-Ghostshell has exported this pull request. If you are a Meta employee, you can view the originating Diff in D131637630. |
There was a problem hiding this comment.
Automated review of 50a734b: nothing blocking; ready for human review.
This PR adds NestedCatPaddingTest to test/inductor/test_padding.py as regression coverage for # 204346, with storage-bounds and value checks on nested cat/chunk graphs compiled with comprehensive padding. The review recommends Approve and labels every point non-blocking. The most useful follow-ups: say in the code that the chunk test is not a fail-before guard, make the dynamic=True cases actually test padding or drop them, and let the tests run on XPU.
⚪ 7 non-blocking findings
pytorch/test/inductor/test_padding.py
Line 1031 in 50a734b
Non-blocking: test_nested_cat_chunk_values doesn't catch the regression it is named for. The PR body says that with the old View.create restored, "the two chunk cases pass in the unittest environment" and are "not independent fail-before oracles", so both parametrizations pass with or without the # 192575 fix. Either find out why the standalone repro fails but this TestCase version passes and make the test fail before the fix, or add a comment saying it is forward/smoke coverage, so readers don't take it as a guard for # 204346.
pytorch/test/inductor/test_padding.py
Line 1072 in 50a734b
Non-blocking: the dynamic=True variants never test padding of dynamic shapes. pad_dynamic_shapes defaults to False (config.py:1806), and Layout._pad_strides returns strides unchanged whenever a size or stride is symbolic (ir.py:4809-4814), only bumping num_comprehensive_padding after it actually pads. In the chunk test the if not dynamic: guard hides this, so the dynamic run is a plain dynamic-shape correctness check. That contradicts the description's claim that both static and dynamic compilation use comprehensive padding. In the expand test, assertGreater(metrics.num_comprehensive_padding, 0) (:1028) can only pass under dynamic=True because the literal expand(1, 48, 49, 27) (:1008) turns the symbols into constants, so the dynamic case repeats the static check. Either patch pad_dynamic_shapes=True and avoid literal sizes, or drop the dynamic parametrization. Either way, add a comment explaining the asymmetric guard.
pytorch/test/inductor/test_padding.py
Line 1069 in 50a734b
Non-blocking: use assertEqual instead of self.assertTrue(same(..., fp64_ref=reference)). On failure the assertion only says "False is not true", and the details go to log.error. same() compares with broadcasting torch.allclose/RMSE (torch/_dynamo/utils.py:3876, 3901), so a wrongly shaped but broadcastable output still passes. CLAUDE.md:81 asks for assertEqual on tensors, which the expand test already uses (:1027). self.assertEqual(fn(x, other), actual), with explicit atol/rtol if needed, would check shapes and give a useful diff. Nit: the generator variable in tuple(x.cpu() for x in actual) shadows the input x from :1053.
pytorch/test/inductor/test_padding.py
Line 1076 in 50a734b
Non-blocking: only_for="cuda" silently drops XPU. The rest of the file runs on any GPU through GPU_TYPE/@ requires_gpu(), and run_tests() runs whenever HAS_GPU is true (:1080), XPU included. Nothing in these tests is CUDA-specific, since every tensor is created on the device parameter. instantiate_device_type_tests defaults to allow_xpu=False. Use the existing idiom only_for=GPU_TYPE, allow_xpu=True (test/inductor/test_triton_helpers.py:608-611), or say why the tests are CUDA-only.
pytorch/test/inductor/test_padding.py
Line 984 in 50a734b
Non-blocking: say in the code what the tests guard (:984, :1000, :1031). Neither test mentions # 204346 or the View.create freeze fix; only the PR body does. Without that context, the fuzzer-style body (v1\[..., 0:1:60\], v20/v24/v35_0, unused chunk halves) is hard to follow. Add a short docstring like the one on test_reduction_comprehensive_padding_stride (:964-969) that names the issue and says the storage-bounds check is the assertion that fails before the fix.
pytorch/test/inductor/test_padding.py
Line 985 in 50a734b
Non-blocking: _assert_valid_storage_bounds re-implements an existing utility. torch._prims_common.compute_required_storage_length(shape, strides, storage_offset) (torch/_prims_common/init.py:1916) computes the same quantity and returns 0 for empty tensors. The hand-rolled (size - 1) * stride goes wrong for zero-size dims, though that can't happen with these shapes today. Keep the separate stride >= 0 check, and add a msg= with the size, stride, offset and nbytes so a bounds failure says which output broke.
pytorch/test/inductor/test_padding.py
Line 1015 in 50a734b
Non-blocking: the setup block is duplicated (:1015-1022 and :1057-1064). The metrics.reset() + config.patch(...) + no_grad() + compile + bounds-loop sequence could be a small helper. The patch could use the dict form the file uses elsewhere (:905, :978) instead of mixing keyword arguments with **{"triton.cudagraphs": False}.
This review is AI-generated and advisory. Each new automated review replaces the previous one. Report a bad review
50a734b to
8d01d32
Compare
…ch#205202) Summary: Add regression coverage for pytorch#204346. PR pytorch#192575 already fixes the implementation by freezing the backing layout before a noncontiguous reshape records its index map. This diff changes tests only. Both tests compile the issue's graphs with comprehensive padding. `test_nested_cat_returned_expand` checks that every returned tensor fits inside its storage before any output is read; `test_nested_cat_chunk_values` compares the chunk outputs with eager using `assertEqual`. Both turn off Dynamo's `canonicalize_output_graph_node_order`, which the Dynamo test harness enables: the bug depends on the traced output order, and with canonicalization the chunk case passes even without the fix. The earlier `dynamic=True` variants are removed because dynamic shapes are not padded by default, so they did not exercise the bug. ### Agent details Prepared with an AI assistant. The author must inspect the exact code before GitHub export. No landing or review-gate bypass is authorized. Test Plan: Ran on an NVIDIA PG509-210 (A100, sm80, driver 580.126.09) with the published torch 2.15.0+cu132 / Triton 3.9.0 wheels in an isolated venv, loading this test file directly rather than a source build. The runner instantiates the CUDA tests from the file; `--old-view` restores the pre-pytorch#192575 `View.create` in-process (backing layout looked up with `freeze=False`). ```sh python run_nested_cat.py test_padding.py # x3 python run_nested_cat.py test_padding.py --old-view # x3 arc lint fbcode/caffe2/test/inductor/test_padding.py ``` With the fix, both tests pass in 3/3 runs. With the old `View.create`, both fail in 3/3 runs: the expand test at the storage-bounds check (`257964 not less than or equal to 254016`, stride `(0, 1344, 27, 1)`), and the chunk test with 16198/16320 mismatched elements and a max absolute difference of 4.16, matching the issue. In the previous revision the chunk test passed without the fix because of the harness's output canonicalization; turning it off makes both tests real fail-before guards. Not run: a clean current-master native build, XPU, or the rest of `test_padding.py`. `arc lint` passes. Differential Revision: D131637630
8d01d32 to
27ee416
Compare
|
@pytorchbot merge (Initiating merge automatically since Phabricator Diff has merged) |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Summary:
Add regression coverage for #204346. PR #192575 already fixes the implementation by freezing the backing layout before a noncontiguous reshape records its index map. This diff changes tests only.
Both tests compile the issue's graphs with comprehensive padding.
test_nested_cat_returned_expandchecks that every returned tensor fits inside its storage before any output is read;test_nested_cat_chunk_valuescompares the chunk outputs with eager usingassertEqual. Both turn off Dynamo'scanonicalize_output_graph_node_order, which the Dynamo test harness enables: the bug depends on the traced output order, and with canonicalization the chunk case passes even without the fix. The earlierdynamic=Truevariants are removed because dynamic shapes are not padded by default, so they did not exercise the bug.Agent details
Prepared with an AI assistant. The author must inspect the exact code before GitHub export. No landing or review-gate bypass is authorized.
Test Plan:
Ran on an NVIDIA PG509-210 (A100, sm80, driver 580.126.09) with the published torch 2.15.0+cu132 / Triton 3.9.0 wheels in an isolated venv, loading this test file directly rather than a source build. The runner instantiates the CUDA tests from the file;
--old-viewrestores the pre-#192575View.createin-process (backing layout looked up withfreeze=False).With the fix, both tests pass in 3/3 runs. With the old
View.create, both fail in 3/3 runs: the expand test at the storage-bounds check (257964 not less than or equal to 254016, stride(0, 1344, 27, 1)), and the chunk test with 16198/16320 mismatched elements and a max absolute difference of 4.16, matching the issue. In the previous revision the chunk test passed without the fix because of the harness's output canonicalization; turning it off makes both tests real fail-before guards.Not run: a clean current-master native build, XPU, or the rest of
test_padding.py.arc lintpasses.Differential Revision: D131637630