Repository navigation
[BE][Test] Trim linear_cross_entropy OpInfo sample inputs - #203278
jbschlosser wants to merge 15 commits into
Conversation
PR Status: Approved 🚀Please fix all CI failures and trigger merge by commenting "@pytorchbot merge". ✅ AUTOMATED REVIEW - Ready for human review:
Findings (5): Reviewed commit: 🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/203278
Note: Links to docs will display an error until the docs builds have been completed. ✅ You can merge normally! (4 Unrelated Failures)As of commit 3b7b5ed with merge base 51f0eeb ( 🟡 GREEN LIGHT - OUTDATED (earlier commit) - PR requires human review:
reason: FLAKY - The following jobs failed but were likely due to flakiness present on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
No Trims down the cross product of OpInfo sample inputs for the `nn.functional.linear_cross_entropy` entry. Authored with an AI assistant (Metamate). `nn.functional.linear_cross_entropy` is the #3 most expensive OpInfo entry in CI over the last week (~3.1M test-sec; its `chunked` and `chunked_none` variants add ~1.6M more). The generator crossed every kwargs/target-type combination with the full `sample_inputs_linear` sweep, whose shapes exist to test the matmul and are already covered by `nn.functional.linear`'s own OpInfo. The generator now builds its own three (input, linear_weight) shapes instead of filtering and swapping `sample_inputs_linear`'s: unbatched, a 2-D batch, and an N-D `linear_weight` (the K-dim loss that falls back from the chunked path). Probability targets are also no longer crossed with `linear_bias`, which only shifts the logits and doesn't interact with the target type. All reductions and the `weight` / `ignore_index` / `linear_bias` / chunking kwargs are kept. With no caller left passing `include_empty=False`, that parameter of `sample_inputs_linear` is removed; `nn.functional.linear`'s samples are unchanged (25 per dtype). Samples per dtype (CPU, float32 / float16): | variant | before | after | |---|---|---| | default | 121 | 47 | | chunked | 135 / 163 | 53 / 65 | | chunked_none | 79 / 93 | 29 / 35 | Samples that actually reach the chunked ops (what the cutedsl variants keep) go from 78 to 36 for `chunked` and 46 to 20 for `chunked_none` (float32, no grad). ghstack-source-id: 84991dc Pull-Request: #203278
Trims down the cross product of OpInfo sample inputs for the `nn.functional.linear_cross_entropy` entry. > Authored with an AI assistant (Metamate). > > `nn.functional.linear_cross_entropy` is the #4 most expensive OpInfo entry in CI over the last week (~8.8M test-sec; its `chunked` and `chunked_none` variants add ~3.7M more). The generator crossed every kwargs/target-type combination with the full `sample_inputs_linear` sweep, whose shapes exist to test the matmul and are already covered by `nn.functional.linear`'s own OpInfo. > > The generator now builds its own three non-empty (input, linear_weight) shapes instead of filtering and swapping `sample_inputs_linear`'s: unbatched, a 1-D batch, and an N-D `linear_weight` with a size-1 dim (`(2, 1, 5, 4, 3)`, giving 5-D logits for the K-dim loss that falls back from the chunked path). All reductions, target types and the `weight` / `ignore_index` / `linear_bias` / chunking kwargs are kept. With no caller left passing `include_empty=False`, that parameter of `sample_inputs_linear` is removed; `nn.functional.linear`'s samples are unchanged (25 per dtype). > > Samples per dtype (CPU, float32 / float16): > > | variant | before | after | > |---|---|---| > | default | 121 | 53 | > | chunked | 135 / 163 | 59 / 71 | > | chunked_none | 79 / 93 | 35 / 41 | ghstack-source-id: e87c5a0 Pull-Request: #203278
[ghstack-poisoned]
Withdrawn: the automated review of 6eab8b8 found nothing blocking.
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
albanD
left a comment
There was a problem hiding this comment.
Very nice cleanup as well!
[ghstack-poisoned]
There was a problem hiding this comment.
Automated review of 3b7b5ed: nothing blocking; ready for human review.
The PR trims the nn.functional.linear_cross_entropy OpInfo samples to three shapes that the generator builds itself, with no K-dim shape in the chunked variants. It also removes sample_inputs_linear's include_empty parameter and drops or narrows decorators that only the K-dim fallback needed. Recommendation: Approve; every remaining point is non-blocking, and the CUDA bf16 TestDecomp exposure on the scalar chunked/cutedsl variants is the one most worth checking before landing.
⚪ 5 non-blocking findings
Unverified CUDA decorator changes, now including bf16 on the scalar variants (non-blocking; extends earlier finding 3). The PR only has ciflow/mps, so none of the CUDA or CuTeDSL decorator changes run in its CI. Removing the all-dtype CUDA TestDecomp skip from chunked (~15348) and cutedsl (23084) turns on bf16 TestDecomp.test_comprehensive on CUDA for the scalar (mean/sum) path for the first time. That path calls dot.default in its forward (torch/nn/modules/linear_cross_entropy.py:969, :995, :1034, :1048), the same index-loop dots the _none variants' backward reuses, which the new skips at 15403-15404 and 23098-23099 blame ("seen on CUDA"). CPU chunked already ran bf16 TestDecomp without a skip, which suggests the scalar samples pass, but CUDA has never been checked. Requested fix: add ciflow/trunk, or say that test_decomp.py -k linear_cross_entropy (chunked and cutedsl variants) passed locally on CUDA in bf16.
bf16 dot.default skips have no evidence (non-blocking). The skips at 15403-15404 and 23098-23099 give no observed max diff and no issue link, unlike the default variant's skip at 15297-15307. The chunked_none skip has no device_type, so it also turns off bf16 TestDecomp on CPU (still narrower than the all-dtype skip it replaces). Requested fix: add the observed diff or an issue link.
MPS bf16 overrides that never apply (non-blocking). The device_type="mps" bf16 toleranceOverrides on TestConsistency.test_output_match at 15343-15346 (chunked) and 15392-15395 (chunked_none) never take effect: the MPS fp16/bf16 unittest.skips on the same test (15354-15357 and 15405-15408) mean the test never runs. This matters more now because the override is the only entry left in chunked's decorators. Requested fix: remove both overrides, or say why they stay.
Probability-target samples in the chunked variants still take the reference path in grad tests (non-blocking, pre-existing code). The probability target is built with requires_grad=requires_grad (7440-7447); the gate at torch/nn/functional.py:3762-3766 turns away any probability target that requires grad, so in every grad test of chunked / chunked_none those samples run the same reference path as the default variant the same redundancy this PR cites for dropping the chunked K-dim samples. The cutedsl generators already filter these out (7523, 7532). Possible fix: when chunked, build that target without requires_grad so the samples reach the chunked op (this would also change what test_sample_filter_matches_the_gate sees).
Dead guard (non-blocking). At line 7460, the and 0 not in target.shape check can never be false: the only targets are (), (8,) and (4, 1, 5, 6), all built from the fixed non-empty shapes at 7405-7408. It was already dead before this PR because of the removed if 0 in target_shape: continue. Remove it, but keep the target\[0 if target.shape else ()\] indexing, which the unbatched target still needs.
This review is AI-generated and advisory. Each new automated review replaces the previous one. Report a bad review
|
@pytorchbot merge |
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 |
|
Starting merge as part of PR stack under #203277 |
Removes a duplicate sample and shrinks the large-slice sample for the `mode` OpInfo entry. > Authored with an AI assistant (Metamate). > > Removed duplication: > - the no-arg 0-d sample: on a 0-d tensor the default `dim=-1` wraps to 0, so it is identical to the `dim=0` sample (the `dim=0, keepdim=True` one stays, since forward AD and the vmap batch rule branch on keepdim) > > Dropped coverage: none. `(3000,)`, which exists to hit the non-fused CUDA kernel (slice size > `2 * MAX_BLOCK_SIZE`: 2048 on CUDA, 512 on ROCm), shrinks to `(2052,)`, the smallest size above 2048 that the 4-rank DTensor op-db tests can still `Shard(0)`. > > Test-config cleanup: the stale numbers in the `test_compare_cpu` skip comment are replaced with the cause (the test only runs on ROCm): CPU returns the index at the end of a run of the repeated mode value and the non-fused CUDA path the index at the start. > > Samples per dtype, unique in parentheses: > > | OpInfo | before | after | > |---|---|---| > | mode | 7 (6) | 6 | Pull Request resolved: #203277 Approved by: https://github.com/albanD ghstack dependencies: #203270, #203278
…3278) Trims down the cross product of OpInfo sample inputs for the `nn.functional.linear_cross_entropy` entry. > Authored with an AI assistant (Metamate). > > `nn.functional.linear_cross_entropy` is the pytorch#4 most expensive OpInfo entry in CI over the last week (~8.8M test-sec; its `chunked` and `chunked_none` variants add ~3.7M more). > > The generator crossed every kwargs / target-type combination with 7 (input, linear_weight) shapes borrowed from `sample_inputs_linear`. It now builds 3 itself: unbatched, a 1-D batch, and a K-dim `(4, 3)` x `(2, 1, 5, 6, 3)` (no dim aliases the batch size). Every kwargs / reduction / target-type combination is still crossed with every shape. > > Removed redundancy: > - a second unbatched and a second 1-D batch shape differing only in feature sizes (square 8x8 `linear_weight`), which matter to the matmul that `nn.functional.linear`'s OpInfo covers > - two of the three K-dim shapes: all gave 3-D or 5-D logits, which take the same `nll_loss_nd` branch (reshape to 4-D, then `nll_loss2d`) > - K-dim samples in the `chunked` / `chunked_none` variants: the chunked path rejects them, so they ran the same reference path as the default variant > > Dropped coverage: with no K-dim sample in the chunked variants, `test_sample_filter_matches_the_gate` no longer sees the chunked path's `not out_features` rejection. The fallback and its warning stay covered by `test_linear_cross_entropy_linear_bias_chunked_kdim_fallback_warns`. > > Test-config cleanup that follows from dropping the chunked K-dim samples: > - the chunked fp16 `test_redispatch` tolerance override, justified by that fallback, is removed > - the `TestDecomp` skips blamed `nll_loss2d`, which only the fallback reached: removed for `chunked`, narrowed to bfloat16 for `chunked_none` (the `dot.default` decomposition still misses tolerance); `cutedsl` / `cutedsl_none`, which run the same accumulator on chunk-eligible samples only, get the same treatment > > No caller passes `sample_inputs_linear`'s `include_empty` anymore, so it is removed; `nn.functional.linear`'s samples are unchanged (25 per dtype). > > Samples per dtype (CPU, float32 / float16): > > | variant | before | after | > |---|---|---| > | default | 121 | 53 | > | chunked | 135 / 163 | 40 / 48 | > | chunked_none | 79 / 93 | 24 / 28 | Pull Request resolved: pytorch#203278 Approved by: https://github.com/slayton58, https://github.com/albanD ghstack dependencies: pytorch#203270
Removes a duplicate sample and shrinks the large-slice sample for the `mode` OpInfo entry. > Authored with an AI assistant (Metamate). > > Removed duplication: > - the no-arg 0-d sample: on a 0-d tensor the default `dim=-1` wraps to 0, so it is identical to the `dim=0` sample (the `dim=0, keepdim=True` one stays, since forward AD and the vmap batch rule branch on keepdim) > > Dropped coverage: none. `(3000,)`, which exists to hit the non-fused CUDA kernel (slice size > `2 * MAX_BLOCK_SIZE`: 2048 on CUDA, 512 on ROCm), shrinks to `(2052,)`, the smallest size above 2048 that the 4-rank DTensor op-db tests can still `Shard(0)`. > > Test-config cleanup: the stale numbers in the `test_compare_cpu` skip comment are replaced with the cause (the test only runs on ROCm): CPU returns the index at the end of a run of the repeated mode value and the non-fused CUDA path the index at the start. > > Samples per dtype, unique in parentheses: > > | OpInfo | before | after | > |---|---|---| > | mode | 7 (6) | 6 | Pull Request resolved: pytorch#203277 Approved by: https://github.com/albanD ghstack dependencies: pytorch#203270, pytorch#203278
Stack from ghstack (oldest at bottom):
Trims down the cross product of OpInfo sample inputs for
the
nn.functional.linear_cross_entropyentry.