Repository navigation
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/186032
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit be2c047 with merge base bbcda55 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
@claude review these changes |
|
Claude finished @jansel's task in 2m 42s —— View job Code Review: PR #186032 — Avoid reshape metadata guards on symbolic size-one checks
SummaryThis PR correctly addresses the problem: metadata-only decisions (view strides, contiguity, channels-last, broadcast) were using The approach is sound and well-scoped. A few observations below: Issues1. Stale comments in
|
Root cause: export was recording runtime guards from metadata-only layout and view decisions that used example-shape truth for symbolic size-one checks. In the issue repro, temporal slicing feeds GroupNormSpatial through flatten/reshape and group_norm; guard-producing checks such as channels-last contiguity and view stride collapse excluded valid values from the declared Dim range. Fix the reshape metadata path by preserving the original requested shape across symbol-unification retries, allowing statically-known equal chunk sizes to advance view stride inference, and refusing to fold undecidable size-one dimensions into collapse-view strides. For group_norm with symbolic sizes/strides, choose a channels-last copy only when that contiguity is statically proven; otherwise make an unconditional contiguous clone so export does not emit a data-dependent contiguous guard. Exact global TensorImpl symbolic metadata behavior is unchanged. Fixes #143463 Generated by my agent Benchmark Results: - Not run. The change affects compile/export metadata fast paths rather than eager tensor runtime kernels; validation focused on the dynamic export regression and lint. Test Plan: - ninja -C build torch_cpu - python test/export/test_export.py -k test_group_norm_spatial_dynamic_temporal_dim - python test/export/test_export.py TestDynamismExpression.test_view_unify_cross_symbols - python - <<'PY' collapse-view symbolic possibly-size-one stride regression check - git diff --check - lintrunner -a (fails only on unrelated existing torch/nn/modules/loss.py pyrefly unexpected-keyword linear_bias) - python test/inductor/test_cpu_repro.py CPUReproTests.test_inductor_dynamic_shapes_broadcasting (blocked by local PyTorch CUDA 12.8 / torchvision CUDA 13.0 mismatch) - Fresh agent review: no findings after narrowing the diff ghstack-source-id: f4e84e9 Pull-Request: #186032
|
My agent says @claude review these changes Updated the PR to address the dynamic-shape CI regressions without the earlier broad symbolic metadata changes. The new diff keeps TensorImpl symbolic layout predicates unchanged, narrows group_norm to make an unconditional contiguous clone only when symbolic layout contiguity is not statically proven, and fixes reshape/collapse metadata to avoid guard-producing size-one decisions while preserving correct strides. Validation:
Known local blockers:
|
|
Claude finished @jansel's task in 1m 59s —— View job Code Review: PR #186032 (Updated) — Avoid reshape metadata guards on symbolic size-one checks
SummaryThe updated PR is well-scoped and correctly addresses the core issue: metadata-only decisions (view strides, contiguity, channels-last, broadcast) were guarding on symbolic dimensions being 0/1 via The new approach to Issues1. Stale comments in
|
Root cause: export was recording runtime guards from metadata-only layout, broadcast, and view decisions that used example-shape truth for symbolic size-one checks. In the issue repro, temporal slicing feeds GroupNormSpatial through flatten/reshape and group_norm; guard-producing checks such as channels-last contiguity, broadcast shape checks, and reshape viewability excluded valid values from the declared Dim range. Fix the reshape metadata path by preserving the original requested shape across symbol-unification retries, making native flatten handle ranges with only one non-size-one dimension as direct views, and using static proofs for optional Python metadata fast paths that otherwise can fall back. For group_norm with symbolic sizes/strides, choose a channels-last copy only when that contiguity is statically proven; otherwise make an unconditional contiguous clone so export does not emit a data-dependent contiguous guard. The Python broadcast changes are intentionally narrow: they avoid guards for statically equal/no-broadcast cases and otherwise keep existing runtime assertion or slow-path behavior. A new reshape regression covers symbolic divisibility so the refs reshape helper keeps accumulating available source dims instead of guarding on the example value or walking past rank. Fixes #143463 Generated by my agent Test Plan: - ninja -C build torch_cpu - cp build/lib/libtorch_cpu.so build/lib/libc10.so torch/lib/ - python test/export/test_export.py TestDynamismExpression.test_group_norm_spatial_dynamic_temporal_dim - python test/export/test_export.py TestDynamismExpression.test_reshape_symbolic_divisibility_no_guard - python test/export/test_export.py TestExport.test_derived_dim_1_2 - python test/test_dynamic_shapes.py TestUbackedOps.test_inductor_view_issue_172693 - python test/export/test_export.py TestDynamismExpression.test_view_unify_cross_symbols - git diff --check - lintrunner -a - python test/inductor/test_cpu_repro.py CPUReproTests.test_inductor_dynamic_shapes_broadcasting (blocked locally by PyTorch CUDA 12.8 / torchvision CUDA 13.0 mismatch) - Fresh review subagent: first found the generic symbolic reshape divisibility issue; after the fix and added regression, no findings ghstack-source-id: f5ddfdb Pull-Request: #186032
|
@claude review these changes |
|
My agent says I updated the PR to address the failing dynamic-shape CI regressions. The fix keeps the GroupNorm symbolic-size guard removal, narrows Python metadata changes to static-proof fast paths, adds a generic symbolic reshape divisibility regression, and validates the earlier derived-dim and ubacked reshape failures locally. |
|
Claude finished @jansel's task in 3m 17s —— View job Code Review: PR #186032 (Latest) — Avoid reshape metadata guards on symbolic size-one checks
SummaryThe changes correctly convert metadata-only decisions (view strides, contiguity, channels-last, broadcast) from Issues1. Stale comments in
|
Root cause: export was recording runtime guards from metadata-only layout, broadcast, and view decisions that used example-shape truth for symbolic size-one checks. In the issue repro, temporal slicing feeds GroupNormSpatial through flatten/reshape and group_norm; those metadata checks excluded valid values from the declared Dim range. Use static proofs for optional symbolic metadata branches that can safely fall back instead of guarding, preserve the original requested fake view shape across retry, and make symbolic CPU group_norm clone using a memory format that is statically known safe. Native flatten now handles a range with at most one provably non-size-one dimension as a direct view, avoiding reshape viewability guards for that case. Fixes #143463 Generated by my agent Test Plan: - ninja -C build torch_cpu - cp build/lib/libtorch_cpu.so build/lib/libc10.so torch/lib/ - python test/export/test_export.py TestDynamismExpression.test_group_norm_spatial_dynamic_temporal_dim -q - python test/export/test_export.py TestExport.test_dim_dynamic -q - python test/test_dynamic_shapes.py TestUbackedOps.test_unbacked_reshape1 -q - git diff --check main - python -m py_compile torch/_refs/__init__.py - lintrunner -a - Review subagent found and I removed a transient torch.nn.functional.py regression from the diff ghstack-source-id: 35fcc9e Pull-Request: #186032
|
My agent says I updated the PR to avoid symbolic size-one metadata guards in the GroupNormSpatial export repro. Targeted tests now pass locally: TestDynamismExpression.test_group_norm_spatial_dynamic_temporal_dim, TestExport.test_dim_dynamic, TestUbackedOps.test_unbacked_reshape1, plus lintrunner -a. |
|
@claude review these changes |
|
Claude finished @jansel's task in 5m 24s —— View job Code Review: PR #186032 — Avoid reshape metadata guards on symbolic size-one checks
SummaryThe diff has tightened since prior reviews. The core idea is unchanged and correct: metadata-only fast paths (view strides, contiguity, channels-last, broadcast) used Two notable improvements relative to the earlier rounds:
Issues / Questions1. Asymmetric
|
Root cause: export was recording runtime guards from metadata-only layout, broadcast, and view decisions that used example-shape truth for symbolic size-one checks. In the issue repro, temporal slicing feeds GroupNormSpatial through flatten/reshape and group_norm; those metadata checks excluded valid values from the declared Dim range. Use static proofs for optional symbolic metadata branches that can safely fall back instead of guarding, preserve the original requested fake view shape across retry, and make symbolic CPU group_norm clone using a memory format that is statically known safe. Native flatten now only bypasses reshape for the specific statically size-one leading-dimension case needed by the repro, avoiding the broader one-non-size-one fast path that broke channels-last cat. Fixes #143463 Generated by my agent Test Plan: - ninja -C build torch_cpu - cp build/lib/libtorch_cpu.so build/lib/libc10.so torch/lib/ - python test/export/test_export.py TestDynamismExpression.test_group_norm_spatial_dynamic_temporal_dim -q - python test/export/test_export.py TestExport.test_export_max_onnx_reported -q - python test/export/test_export.py TestExport.test_dim_dynamic -q (review subagent) - python test/export/test_export.py TestDynamismExpression.test_view_unify_cross_symbols -q (review subagent) - python test/test_dynamic_shapes.py TestUbackedOps.test_unbacked_reshape1 -q - python - <<'PY' ... run test/inductor/test_torchinductor.py CpuTests.test_cat_cpu with torchvision shim ... PY - python - <<'PY' ... run test/inductor/test_compiled_autograd.py TestCompiledAutograd.test_compiled_autograd_does_not_specialize_on_bw_symints with torchvision shim ... PY - git diff --check main - lintrunner aten/src/ATen/native/TensorShape.cpp test/export/test_export.py - lintrunner -a (fails only on unrelated existing pyrefly errors in effects.py, functional_tensor.py, and proxy_tensor.py) ghstack-source-id: 2218ea7 Pull-Request: #186032
|
@claude review these changes |
|
My agent says I updated the PR to fix the CI regression from the prior broad flatten fast path. The flatten special case is now limited to the statically size-one leading-dimension pattern needed by the GroupNormSpatial export repro, and the reproduced CpuTests.test_cat_cpu failure passes locally with the torchvision import shim. |
|
Claude finished @jansel's task in 6m 36s —— View job Code Review: PR #186032 — Avoid reshape metadata guards on symbolic size-one checks
SummaryThe diff is unchanged in intent from prior rounds: metadata-only fast paths (view strides, contiguity, channels-last, broadcast) that used One new concern is worth verifying before merge, plus the carried-over asymmetry note. Concern worth verifying
|
Root cause: export was recording runtime guards from metadata-only layout, broadcast, and view decisions that used example-shape truth for symbolic size-one checks. In the issue repro, temporal slicing feeds GroupNormSpatial through flatten/reshape and group_norm; those metadata checks excluded valid values from the declared Dim range. Use static proofs for optional symbolic metadata branches that can safely fall back instead of guarding, preserve the original requested fake view shape across retry, and make symbolic CPU group_norm clone using a memory format that is statically known safe. Native flatten only bypasses reshape for symbolic tensors in the specific statically size-one leading-dimension case needed by the repro, preserving concrete and subclass flatten behavior. After CI exposed normal-compile broadcast regressions, keep the static-proof `_broadcast_shapes` behavior limited to export and preserve the original `guard_or_false` behavior for normal torch.compile so hinted size-one broadcasting still works. Fixes #143463 Generated by my agent Test Plan: - ninja -C build torch_cpu - cp build/lib/libtorch_cpu.so torch/lib/libtorch_cpu.so && cp build/lib/libc10.so torch/lib/libc10.so - python test/export/test_export.py TestDynamismExpression.test_group_norm_spatial_dynamic_temporal_dim -q - python test/export/test_export.py TestExport.test_export_max_onnx_reported -q - python test/test_dynamic_shapes.py TestUbackedOps.test_unbacked_reshape1 -q - python test/test_dynamic_shapes.py TestUbackedOps.test_backed_size_oblivious_broadcast -q - python test/test_torch.py TestTorchDeviceTypeCPU.test_memory_format_operators_cpu -q - python - <<'PY' ... run test/test_linalg.py TestLinalgCPU.test_cholesky_solve_batched_broadcasting_cpu_complex128 with torchvision shim ... PY - python test/distributed/tensor/test_dtensor_ops.py TestMultiThreadedDTensorOpsCPU.test_dtensor_op_db_cartesian_prod_cpu_float32 -q - python test/export/test_export.py -k test_dim_dynamic (review subagent) - python test/export/test_export.py -k test_view_unify_cross_symbols (review subagent) - python test/test_dynamic_shapes.py -k test_backed_size_oblivious_expand (review subagent) - git diff --check - lintrunner -a Attempted but locally timed out after 120s: - python - <<'PY' ... run test/functorch/test_aotdispatch.py TestEagerFusionOpInfoCPU.test_aot_autograd_symbolic_exhaustive_linalg_tensorinv_cpu_float32 with torchvision shim ... PY - python - <<'PY' ... run test/test_proxy_tensor.py TestProxyTensorOpInfoCPU.test_make_fx_symbolic_exhaustive_nn_functional_conv_transpose3d_cpu_float32 with torchvision shim ... PY ghstack-source-id: b82dfa9 Pull-Request: #186032
|
@claude review these changes |
|
My agent says I updated the PR to address the latest CI fallout. The broadcast metadata change is now export-only so normal torch.compile keeps hinted guard_or_false broadcasting behavior, and the flatten as_strided fast path is limited to symbolic-size tensors so concrete/subclass paths such as DTensor cartesian_prod keep the old reshape behavior. Local targeted checks now pass for the original GroupNormSpatial export repro, export max, unbacked reshape, backed-size-oblivious broadcast, memory_format_operators, cholesky_solve_batched_broadcasting, and DTensor cartesian_prod. |
|
My agent says the TorchBench CSV changes are from reapplying the existing determinism setup after model construction, not from the symbolic-shape metadata fix. The affected torchvision constructors reset cuDNN determinism flags, so reapplying determinism makes the eager-vs-eager accuracy check exercise the intended deterministic compiled path; the higher graph-break counts for mnasnet1_0 and mobilenet_v2 are the real compiled baselines once that masking is removed. I added this context to the PR description, and the latest Dr. CI classifies remaining inductor failures as flaky or broken trunk rather than new regressions. |
Root cause: export was recording runtime guards from metadata-only layout, broadcast, and view decisions that used example-shape truth for symbolic size-one checks. In the issue repro, temporal slicing feeds GroupNormSpatial through flatten/reshape and group_norm; those metadata checks excluded valid values from the declared Dim range. Use static proofs for optional symbolic metadata branches that can safely fall back instead of guarding, preserve the original requested fake view shape across retry, and make symbolic group_norm clone using a memory format that is statically known safe instead of calling guard-producing contiguous checks. Native flatten only bypasses reshape for symbolic tensors in the specific statically size-one leading-dimension case needed by the repro, preserving concrete and subclass flatten behavior. After CI exposed normal-compile broadcast regressions, keep the static-proof broadcast behavior limited to export while preserving guard_or_false behavior for normal torch.compile. Restore the hinted SymbolicShapeMeta layout fast path as well, because sending backed symbolic layouts through the full symbolic expression path caused proxy tensor and AOT OpInfo tests to time out on complex SymPy expressions. The previous CI failure was an inductor TorchBench eager determinism check, not a compiled accuracy failure: TorchBench torchvision model constructors reset cuDNN determinism flags after the harness configures accuracy-run determinism, so eager-vs-eager could return eager_two_runs_differ before Inductor ran. Reapply the existing determinism setup after model construction for accuracy runs, and restore the real compiled graph-break baselines for mnasnet1_0 and mobilenet_v2 that were incorrectly moved to zero by an early-return run. Reviewer feedback found one overly broad reshape split: producing a target dimension of 1 by unconditionally splitting the current source dimension misaligned reshapes with a leading concrete size-one source dimension followed by a dynamic dimension. Keep symbolic unknown source dimensions on the split path to avoid size-one guards, but skip the split when the source dimension is statically known to be 1. This uses static proof rather than guard_or_false so it does not reinstall the same symbolic size-one guard this PR removes. Fixes #143463 Generated by my agent Test Plan: - ninja -C build torch_cpu - ninja -C build torch_python - cp build/lib/*.so torch/lib/ - python test/export/test_export.py TestDynamismExpression.test_reshape_view_static_size_one_before_dynamic_dim TestDynamismExpression.test_group_norm_spatial_dynamic_temporal_dim TestDynamismExpression.test_reshape_view_backed_size_oblivious TestDynamismExpression.test_view_unify_cross_symbols -q - python test/export/test_export.py TestDynamismExpression.test_group_norm_spatial_dynamic_temporal_dim_cuda -q - python -m py_compile torch/_refs/__init__.py test/export/test_export.py - git diff --check - git diff --cached --check - lintrunner -a - fresh review subagent found no blocking issues - Prior validation for the benchmark determinism update: TorchBench training AMP mobilenet_v2 and mnasnet1_0 accuracy plus graph-break checks with local torchvision extension shim ghstack-source-id: 4604b46 Pull-Request: #186032
[ghstack-poisoned]
|
My agent says I rebased this PR onto current main and adapted the GroupNorm path to #186414: concrete inputs and affine contiguity remain owned by native_group_norm, while the high-level path keeps only the symbolic input clone required to avoid size-one guards. The supported editable CPU/CUDA build, focused CPU/CUDA export regressions, adjacent dynamic-shape tests, py_compile, and lintrunner -a all pass. CI has restarted on be2c047. |
|
@claude review these changes |
|
Claude finished @jansel's task in 43m 4s —— View job Reviewed the rebased diff — the export-gated broadcast work looks right, but three changes (the Full review: PR #186032 — Avoid symbolic size-one metadata guardsPR Review: #186032SummaryConverts metadata-only fast paths (view strides, contiguity, channels-last, broadcast) from guard-emitting Code Quality1.
2.
guard_or_false_maybe = (
statically_known_true if torch.compiler.is_exporting() else guard_or_false
)3.
4.
5. Infrastructure6. Three different gating strategies, and one of them is effectively dead. The PR now uses three distinct policies for the same "don't guard on size-one during export" intent:
The PR description says "preserving guard-based behavior for normal 7.
The identical-symbol case is fine: the new 8.
9. Eager vs. compile output memory-format divergence in CPU channels-last input, contiguity not statically provable symbolically → Testing10. New tests don't use the repo's device-generic pattern. 11. No test for the 12. No coverage for findings #8/#9. No test asserts 13. rf"Guard failed: (?:x\.size\(\)\[0\] == 1 or )?{expected_guard}"The optional group means the test passes with or without the new API Design14. Re-invoking The graph-break CSV bumps that motivated it are no longer in this diff — Backward Compatibility15.
RecommendationRequest Changes Blocking: finding #1 (the |
Root cause: export recorded guards from metadata-only layout, broadcast, and view decisions that used example-shape truth for symbolic size-one checks. In the issue repro, temporal slicing feeds GroupNormSpatial through flatten, reshape, and group_norm; those checks excluded valid values from the declared Dim range. Use static proofs for optional metadata fast paths that can safely fall back, while preserving guard-based behavior for normal torch.compile broadcasting. Preserve the original requested fake-view shape across retries, avoid specializing unknown source dimensions when reshaping to a size-one target, and directly flatten the statically size-one leading-dimension case needed by the repro. Symbolic group_norm inputs clone into a statically known-safe memory format instead of invoking guard-producing contiguity checks. After rebasing over #186414, native_group_norm owns concrete input and affine contiguity. Keep only the high-level symbolic input clone here and pass weight and bias through unchanged, avoiding duplicate validation and conversions while retaining the guard-free symbolic path. Accuracy runs also reapply the existing determinism setup after benchmark model construction. Some model constructors reset global determinism flags, which otherwise makes the eager-vs-eager check fail before the compiler path runs. Fixes #143463 Generated by my agent Test Plan: ```bash .venv/bin/python -m pip install -e . -v --no-build-isolation .venv/bin/python test/export/test_export.py TestDynamismExpression.test_reshape_view_static_size_one_before_dynamic_dim TestDynamismExpression.test_group_norm_spatial_dynamic_temporal_dim TestDynamismExpression.test_reshape_view_backed_size_oblivious TestDynamismExpression.test_view_unify_cross_symbols -q .venv/bin/python test/export/test_export.py TestDynamismExpression.test_group_norm_spatial_dynamic_temporal_dim_cuda -q .venv/bin/python test/export/test_export.py TestExport.test_dim_dynamic -q .venv/bin/python test/test_dynamic_shapes.py TestUbackedOps.test_unbacked_reshape1 TestUbackedOps.test_backed_size_oblivious_broadcast -q .venv/bin/python -m py_compile torch/_refs/__init__.py test/export/test_export.py CPATH=/usr/lib/gcc/x86_64-redhat-linux/11/include lintrunner -a git diff --check git diff --cached --check ``` ghstack-source-id: e954362 Pull-Request: #186032
|
My agent says this PR is being closed as part of a cleanup of open agentic PRs to focus review bandwidth on a smaller set; the linked issue remains open. |
Stack from ghstack (oldest at bottom):
Root cause: export recorded guards from metadata-only layout, broadcast, and view decisions that used example-shape truth for symbolic size-one checks. In the issue repro, temporal slicing feeds GroupNormSpatial through flatten, reshape, and group_norm; those checks excluded valid values from the declared Dim range.
Use static proofs for optional metadata fast paths that can safely fall back, while preserving guard-based behavior for normal torch.compile broadcasting. Preserve the original requested fake-view shape across retries, avoid specializing unknown source dimensions when reshaping to a size-one target, and directly flatten the statically size-one leading-dimension case needed by the repro. Symbolic group_norm inputs clone into a statically known-safe memory format instead of invoking guard-producing contiguity checks.
After rebasing over #186414, native_group_norm owns concrete input and affine contiguity. Keep only the high-level symbolic input clone here and pass weight and bias through unchanged, avoiding duplicate validation and conversions while retaining the guard-free symbolic path.
Accuracy runs also reapply the existing determinism setup after benchmark model construction. Some model constructors reset global determinism flags, which otherwise makes the eager-vs-eager check fail before the compiler path runs.
Fixes #143463
Generated by my agent
Test Plan:
.venv/bin/python -m pip install -e . -v --no-build-isolation .venv/bin/python test/export/test_export.py TestDynamismExpression.test_reshape_view_static_size_one_before_dynamic_dim TestDynamismExpression.test_group_norm_spatial_dynamic_temporal_dim TestDynamismExpression.test_reshape_view_backed_size_oblivious TestDynamismExpression.test_view_unify_cross_symbols -q .venv/bin/python test/export/test_export.py TestDynamismExpression.test_group_norm_spatial_dynamic_temporal_dim_cuda -q .venv/bin/python test/export/test_export.py TestExport.test_dim_dynamic -q .venv/bin/python test/test_dynamic_shapes.py TestUbackedOps.test_unbacked_reshape1 TestUbackedOps.test_backed_size_oblivious_broadcast -q .venv/bin/python -m py_compile torch/_refs/__init__.py test/export/test_export.py CPATH=/usr/lib/gcc/x86_64-redhat-linux/11/include lintrunner -a git diff --check git diff --cached --check