Repository navigation
Conversation
|
This appears to be a diff that was exported from phabricator, but the PR author does not have sufficient permissions to run CI. @rmiao, please do step 2 of internal wiki to get write access so you do not need to get CI approvals in the future. If you think this is a mistake, please contact the Pytorch Dev Infra team. |
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/195812
Note: Links to docs will display an error until the docs builds have been completed. ✅ You can merge normally! (2 Unrelated Failures)As of commit bc696ab with merge base 81deebd ( CRCR (non-blocking) - The following CRCR downstream CI jobs failed but are non-blocking:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
@rmiao has exported this pull request. If you are a Meta employee, you can view the originating Diff in D118577322. |
56f4332 to
0a49c49
Compare
…n empty batch (pytorch#195812) Summary: Attention over zero rows is an empty result, not an error, and CUDA returns it. The ROCm CK entries instead abort with "batch size must be positive" (`mha_fwd_ck.hip:280`, `mha_varlen_fwd_ck.hip:246`), so the same graph serves fine on CUDA and dies on AMD. Eager code rarely notices, because the composite `scaled_dot_product_attention` guards `numel == 0` and returns zeros; a compiled graph does not get that guard, since the sizes are symbolic at trace time and it is traced away, leaving AOTI to call the backend op directly. PrismNet hits this whenever no request routes to a segment and its attention tower is handed zero rows -- normal at serving, and every other op in the graph absorbs it. Both files already have a "nothing to compute" branch for `seqlen_k == 0`, so rather than add a hand-written empty tuple this drops the check and extends that branch to an empty batch. At zero rows the allocations above it are already the correct empty result, which means only the kernel launch is skipped and the empty and non-empty paths cannot drift apart in shape or dtype. While in `mha_fwd_ck`, the two `drop_seed_offset` assignments move above the branch as well: they were set only on the launching path, but the `p_dropout > 0` epilogue below dereferences them unconditionally. Measured on a local MI300X, zero-row `_scaled_dot_product_flash_attention`, `_scaled_dot_product_efficient_attention` and `_flash_attention_forward` now all return the empty result instead of aborting. Probing the rest of the DHEN op mix at zero rows found nothing else to fix -- linear, addmm, matmul, layer_norm, softmax, bmm, baddbmm, cat and sum all already absorb an empty batch -- so attention was the only gap. Test Plan: buck2 test fbcode//mode/opt-amd-gpu -c fbcode.rocm_arch=mi300 fbcode//caffe2/test:test_transformers_cuda -- --regex 'test_fused_attention_empty_batch' https://www.internalfb.com/intern/testinfra/testrun/22236523204207138 Reviewed By: kqfu Differential Revision: D118577322
…n empty batch (pytorch#195812) Summary: Attention over zero rows is an empty result, not an error, and CUDA returns it. The ROCm CK entries instead abort with "batch size must be positive" (`mha_fwd_ck.hip:280`, `mha_varlen_fwd_ck.hip:246`), so the same graph serves fine on CUDA and dies on AMD. Eager code rarely notices, because the composite `scaled_dot_product_attention` guards `numel == 0` and returns zeros; a compiled graph does not get that guard, since the sizes are symbolic at trace time and it is traced away, leaving AOTI to call the backend op directly. PrismNet hits this whenever no request routes to a segment and its attention tower is handed zero rows -- normal at serving, and every other op in the graph absorbs it. Both files already have a "nothing to compute" branch for `seqlen_k == 0`, so rather than add a hand-written empty tuple this drops the check and extends that branch to an empty batch. At zero rows the allocations above it are already the correct empty result, which means only the kernel launch is skipped and the empty and non-empty paths cannot drift apart in shape or dtype. While in `mha_fwd_ck`, the two `drop_seed_offset` assignments move above the branch as well: they were set only on the launching path, but the `p_dropout > 0` epilogue below dereferences them unconditionally. Measured on a local MI300X, zero-row `_scaled_dot_product_flash_attention`, `_scaled_dot_product_efficient_attention` and `_flash_attention_forward` now all return the empty result instead of aborting. Probing the rest of the DHEN op mix at zero rows found nothing else to fix -- linear, addmm, matmul, layer_norm, softmax, bmm, baddbmm, cat and sum all already absorb an empty batch -- so attention was the only gap. Test Plan: buck2 test fbcode//mode/opt-amd-gpu -c fbcode.rocm_arch=mi300 fbcode//caffe2/test:test_transformers_cuda -- --regex 'test_fused_attention_empty_batch' https://www.internalfb.com/intern/testinfra/testrun/22236523204207138 Reviewed By: kqfu Differential Revision: D118577322
…n empty batch (pytorch#195812) Summary: Attention over zero rows is an empty result, not an error, and CUDA returns it. The ROCm CK entries instead abort with "batch size must be positive" (`mha_fwd_ck.hip:280`, `mha_varlen_fwd_ck.hip:246`), so the same graph serves fine on CUDA and dies on AMD. Eager code rarely notices, because the composite `scaled_dot_product_attention` guards `numel == 0` and returns zeros; a compiled graph does not get that guard, since the sizes are symbolic at trace time and it is traced away, leaving AOTI to call the backend op directly. PrismNet hits this whenever no request routes to a segment and its attention tower is handed zero rows -- normal at serving, and every other op in the graph absorbs it. Both files already have a "nothing to compute" branch for `seqlen_k == 0`, so rather than add a hand-written empty tuple this drops the check and extends that branch to an empty batch. At zero rows the allocations above it are already the correct empty result, which means only the kernel launch is skipped and the empty and non-empty paths cannot drift apart in shape or dtype. While in `mha_fwd_ck`, the two `drop_seed_offset` assignments move above the branch as well: they were set only on the launching path, but the `p_dropout > 0` epilogue below dereferences them unconditionally. Measured on a local MI300X, zero-row `_scaled_dot_product_flash_attention`, `_scaled_dot_product_efficient_attention` and `_flash_attention_forward` now all return the empty result instead of aborting. Probing the rest of the DHEN op mix at zero rows found nothing else to fix -- linear, addmm, matmul, layer_norm, softmax, bmm, baddbmm, cat and sum all already absorb an empty batch -- so attention was the only gap. Test Plan: buck2 test fbcode//mode/opt-amd-gpu -c fbcode.rocm_arch=mi300 fbcode//caffe2/test:test_transformers_cuda -- --regex 'test_fused_attention_empty_batch' https://www.internalfb.com/intern/testinfra/testrun/22236523204207138 Reviewed By: kqfu Differential Revision: D118577322
…n empty batch (pytorch#195812) Summary: Attention over zero rows is an empty result, not an error, and CUDA returns it. The ROCm CK entries instead abort with "batch size must be positive" (`mha_fwd_ck.hip:280`, `mha_varlen_fwd_ck.hip:246`), so the same graph serves fine on CUDA and dies on AMD. Eager code rarely notices, because the composite `scaled_dot_product_attention` guards `numel == 0` and returns zeros; a compiled graph does not get that guard, since the sizes are symbolic at trace time and it is traced away, leaving AOTI to call the backend op directly. PrismNet hits this whenever no request routes to a segment and its attention tower is handed zero rows -- normal at serving, and every other op in the graph absorbs it. Both files already have a "nothing to compute" branch for `seqlen_k == 0`, so rather than add a hand-written empty tuple this drops the check and extends that branch to an empty batch. At zero rows the allocations above it are already the correct empty result, which means only the kernel launch is skipped and the empty and non-empty paths cannot drift apart in shape or dtype. While in `mha_fwd_ck`, the two `drop_seed_offset` assignments move above the branch as well: they were set only on the launching path, but the `p_dropout > 0` epilogue below dereferences them unconditionally. Measured on a local MI300X, zero-row `_scaled_dot_product_flash_attention`, `_scaled_dot_product_efficient_attention` and `_flash_attention_forward` now all return the empty result instead of aborting. Probing the rest of the DHEN op mix at zero rows found nothing else to fix -- linear, addmm, matmul, layer_norm, softmax, bmm, baddbmm, cat and sum all already absorb an empty batch -- so attention was the only gap. Test Plan: buck2 test fbcode//mode/opt-amd-gpu -c fbcode.rocm_arch=mi300 fbcode//caffe2/test:test_transformers_cuda -- --regex 'test_fused_attention_empty_batch' https://www.internalfb.com/intern/testinfra/testrun/22236523204207138 Reviewed By: kqfu Differential Revision: D118577322
0a49c49 to
497459d
Compare
…n empty batch (pytorch#195812) Summary: Attention over zero rows is an empty result, not an error, and CUDA returns it. The ROCm CK entries instead abort with "batch size must be positive" (`mha_fwd_ck.hip:280`, `mha_varlen_fwd_ck.hip:246`), so the same graph serves fine on CUDA and dies on AMD. Eager code rarely notices, because the composite `scaled_dot_product_attention` guards `numel == 0` and returns zeros; a compiled graph does not get that guard, since the sizes are symbolic at trace time and it is traced away, leaving AOTI to call the backend op directly. PrismNet hits this whenever no request routes to a segment and its attention tower is handed zero rows -- normal at serving, and every other op in the graph absorbs it. Both files already have a "nothing to compute" branch for `seqlen_k == 0`, so rather than add a hand-written empty tuple this drops the check and extends that branch to an empty batch. At zero rows the allocations above it are already the correct empty result, which means only the kernel launch is skipped and the empty and non-empty paths cannot drift apart in shape or dtype. While in `mha_fwd_ck`, the two `drop_seed_offset` assignments move above the branch as well: they were set only on the launching path, but the `p_dropout > 0` epilogue below dereferences them unconditionally. Measured on a local MI300X, zero-row `_scaled_dot_product_flash_attention`, `_scaled_dot_product_efficient_attention` and `_flash_attention_forward` now all return the empty result instead of aborting. Probing the rest of the DHEN op mix at zero rows found nothing else to fix -- linear, addmm, matmul, layer_norm, softmax, bmm, baddbmm, cat and sum all already absorb an empty batch -- so attention was the only gap. Test Plan: buck2 test fbcode//mode/opt-amd-gpu -c fbcode.rocm_arch=mi300 fbcode//caffe2/test:test_transformers_cuda -- --regex 'test_fused_attention_empty_batch' https://www.internalfb.com/intern/testinfra/testrun/22236523204207138 Reviewed By: kqfu Differential Revision: D118577322
…n empty batch (pytorch#195812) Summary: Attention over zero rows is an empty result, not an error, and CUDA returns it. The ROCm CK entries instead abort with "batch size must be positive" (`mha_fwd_ck.hip:280`, `mha_varlen_fwd_ck.hip:246`), so the same graph serves fine on CUDA and dies on AMD. Eager code rarely notices, because the composite `scaled_dot_product_attention` guards `numel == 0` and returns zeros; a compiled graph does not get that guard, since the sizes are symbolic at trace time and it is traced away, leaving AOTI to call the backend op directly. PrismNet hits this whenever no request routes to a segment and its attention tower is handed zero rows -- normal at serving, and every other op in the graph absorbs it. Both files already have a "nothing to compute" branch for `seqlen_k == 0`, so rather than add a hand-written empty tuple this drops the check and extends that branch to an empty batch. At zero rows the allocations above it are already the correct empty result, which means only the kernel launch is skipped and the empty and non-empty paths cannot drift apart in shape or dtype. While in `mha_fwd_ck`, the two `drop_seed_offset` assignments move above the branch as well: they were set only on the launching path, but the `p_dropout > 0` epilogue below dereferences them unconditionally. Measured on a local MI300X, zero-row `_scaled_dot_product_flash_attention`, `_scaled_dot_product_efficient_attention` and `_flash_attention_forward` now all return the empty result instead of aborting. Probing the rest of the DHEN op mix at zero rows found nothing else to fix -- linear, addmm, matmul, layer_norm, softmax, bmm, baddbmm, cat and sum all already absorb an empty batch -- so attention was the only gap. Test Plan: buck2 test fbcode//mode/opt-amd-gpu -c fbcode.rocm_arch=mi300 fbcode//caffe2/test:test_transformers_cuda -- --regex 'test_fused_attention_empty_batch' https://www.internalfb.com/intern/testinfra/testrun/22236523204207138 Reviewed By: kqfu Differential Revision: D118577322
…n empty batch (pytorch#195812) Summary: Attention over zero rows is an empty result, not an error, and CUDA returns it. The ROCm CK entries instead abort with "batch size must be positive" (`mha_fwd_ck.hip:280`, `mha_varlen_fwd_ck.hip:246`), so the same graph serves fine on CUDA and dies on AMD. Eager code rarely notices, because the composite `scaled_dot_product_attention` guards `numel == 0` and returns zeros; a compiled graph does not get that guard, since the sizes are symbolic at trace time and it is traced away, leaving AOTI to call the backend op directly. PrismNet hits this whenever no request routes to a segment and its attention tower is handed zero rows -- normal at serving, and every other op in the graph absorbs it. Both files already have a "nothing to compute" branch for `seqlen_k == 0`, so rather than add a hand-written empty tuple this drops the check and extends that branch to an empty batch. At zero rows the allocations above it are already the correct empty result, which means only the kernel launch is skipped and the empty and non-empty paths cannot drift apart in shape or dtype. While in `mha_fwd_ck`, the two `drop_seed_offset` assignments move above the branch as well: they were set only on the launching path, but the `p_dropout > 0` epilogue below dereferences them unconditionally. Measured on a local MI300X, zero-row `_scaled_dot_product_flash_attention`, `_scaled_dot_product_efficient_attention` and `_flash_attention_forward` now all return the empty result instead of aborting. Probing the rest of the DHEN op mix at zero rows found nothing else to fix -- linear, addmm, matmul, layer_norm, softmax, bmm, baddbmm, cat and sum all already absorb an empty batch -- so attention was the only gap. Test Plan: buck2 test fbcode//mode/opt-amd-gpu -c fbcode.rocm_arch=mi300 fbcode//caffe2/test:test_transformers_cuda -- --regex 'test_fused_attention_empty_batch' https://www.internalfb.com/intern/testinfra/testrun/22236523204207138 Reviewed By: kqfu Differential Revision: D118577322
497459d to
bc696ab
Compare
…n empty batch (pytorch#195812) Summary: Attention over zero rows is an empty result, not an error, and CUDA returns it. The ROCm CK entries instead abort with "batch size must be positive" (`mha_fwd_ck.hip:280`, `mha_varlen_fwd_ck.hip:246`), so the same graph serves fine on CUDA and dies on AMD. Eager code rarely notices, because the composite `scaled_dot_product_attention` guards `numel == 0` and returns zeros; a compiled graph does not get that guard, since the sizes are symbolic at trace time and it is traced away, leaving AOTI to call the backend op directly. PrismNet hits this whenever no request routes to a segment and its attention tower is handed zero rows -- normal at serving, and every other op in the graph absorbs it. Both files already have a "nothing to compute" branch for `seqlen_k == 0`, so rather than add a hand-written empty tuple this drops the check and extends that branch to an empty batch. At zero rows the allocations above it are already the correct empty result, which means only the kernel launch is skipped and the empty and non-empty paths cannot drift apart in shape or dtype. While in `mha_fwd_ck`, the two `drop_seed_offset` assignments move above the branch as well: they were set only on the launching path, but the `p_dropout > 0` epilogue below dereferences them unconditionally. Measured on a local MI300X, zero-row `_scaled_dot_product_flash_attention`, `_scaled_dot_product_efficient_attention` and `_flash_attention_forward` now all return the empty result instead of aborting. Probing the rest of the DHEN op mix at zero rows found nothing else to fix -- linear, addmm, matmul, layer_norm, softmax, bmm, baddbmm, cat and sum all already absorb an empty batch -- so attention was the only gap. Test Plan: buck2 test fbcode//mode/opt-amd-gpu -c fbcode.rocm_arch=mi300 fbcode//caffe2/test:test_transformers_cuda -- --regex 'test_fused_attention_empty_batch' https://www.internalfb.com/intern/testinfra/testrun/22236523204207138 Reviewed By: kqfu Differential Revision: D118577322
|
@pytorchbot merge (Initiating merge automatically since Phabricator Diff has merged) |
|
Adding the |
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 |
…lable (#196643) test_fused_attention_empty_batch (#195812) forces preferred_rocm_fa_library("ck") on ROCm, and setting that preference raises on architectures without CK SDPA support, so the test has failed on every mi200 (gfx90a) run of rocm-mi200.yml since it landed (34 jobs between 2026-09-04 and 2026-09-10). Falling back to the default library is not an option: with AOTriton the same test aborts in backward with "batch size must be positive" (verified on gfx950), so the empty-batch fix covers the CK path only. This gates the test on PLATFORM_SUPPORTS_CK_SDPA, the predicate the other CK-only tests in this file already use, so gfx90a skips instead of erroring. Test plan is in the commit message; gfx90a validation via ciflow/rocm-mi200 (expect the test to report skipped in the shard that runs test_transformers.py), gfx942/gfx950 keep running it. This PR was authored with the assistance of an AI agent (Claude). The analysis and test results were verified by hand. Pull Request resolved: #196643 Approved by: https://github.com/jeffdaily Co-authored-by: Jeff Daily <[email protected]>
Summary:
Attention over zero rows is an empty result, not an error, and CUDA returns it. The ROCm
CK entries instead abort with "batch size must be positive" (
mha_fwd_ck.hip:280,mha_varlen_fwd_ck.hip:246), so the same graph serves fine on CUDA and dies on AMD. Eagercode rarely notices, because the composite
scaled_dot_product_attentionguardsnumel == 0and returns zeros; a compiled graph does not get that guard, since the sizesare symbolic at trace time and it is traced away, leaving AOTI to call the backend op
directly. PrismNet hits this whenever no request routes to a segment and its attention
tower is handed zero rows -- normal at serving, and every other op in the graph absorbs it.
Both files already have a "nothing to compute" branch for
seqlen_k == 0, so rather thanadd a hand-written empty tuple this drops the check and extends that branch to an empty
batch. At zero rows the allocations above it are already the correct empty result, which
means only the kernel launch is skipped and the empty and non-empty paths cannot drift
apart in shape or dtype. While in
mha_fwd_ck, the twodrop_seed_offsetassignments moveabove the branch as well: they were set only on the launching path, but the
p_dropout > 0epilogue below dereferences them unconditionally.Measured on a local MI300X, zero-row
_scaled_dot_product_flash_attention,_scaled_dot_product_efficient_attentionand_flash_attention_forwardnow all return theempty result instead of aborting. Probing the rest of the DHEN op mix at zero rows found
nothing else to fix -- linear, addmm, matmul, layer_norm, softmax, bmm, baddbmm, cat and sum
all already absorb an empty batch -- so attention was the only gap.
Test Plan:
buck2 test fbcode//mode/opt-amd-gpu -c fbcode.rocm_arch=mi300 fbcode//caffe2/test:test_transformers_cuda -- --regex 'test_fused_attention_empty_batch'
https://www.internalfb.com/intern/testinfra/testrun/22236523204207138
Reviewed By: kqfu
Differential Revision: D118577322
cc @jeffdaily @sunway513 @jithunnair-amd @pruthvistony @ROCmSupport @jataylo @hongxiayang @naromero77amd @pragupta @jerrymannil @xinyazhang