Repository navigation
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/195373
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit e7645dd with merge base 9dbf0d7 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
db45f26 to
6348954
Compare
6348954 to
02dd7bf
Compare
|
@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 |
Merge failedReason: 2 jobs have failed, first few of them are: trunk / linux-jammy-rocm-py3.10-mi350 / test (default, 1, 8, linux.rocm.gpu.gfx950.1), trunk / linux-jammy-cuda13.0-py3.10-gcc11 / test (default, 9, 14, mt-l-x86aavx2-29-113-l4) Details for Dev Infra teamRaised by workflow job |
`nn.functional.dropout` raised `NotImplementedError` for complex inputs on
CPU (and CUDA), while silently "working" on MPS. Root cause: `_dropout_impl`
allocated the Bernoulli mask (`noise`) in the input's dtype and called
`bernoulli_` on it. For complex inputs that requires a complex `bernoulli_`,
which CPU and CUDA do not implement (both dispatch via
`AT_DISPATCH_ALL_TYPES_AND3`, which does not list complex). MPS only accepted
it because of incidental complex bernoulli Metal kernels that wrote the {0,1}
mask into the real component and zeroed the imaginary part -- a
semantically-undefined result that masked the CPU/MPS divergence.
The dropout mask is real-valued regardless of input dtype, so allocate it in
the real value type (`c10::toRealValueType`); `complex_input * real_mask` is
well-defined and numerically identical to the old MPS behaviour. Complex
inputs are also excluded from `is_fused_kernel_acceptable`, so that on
CUDA/XPU/lazy/privateuseone (whose fused kernels are float-only) they take the
same composite `_dropout_impl` path -- mirroring how MPS already excludes
non-floating inputs there. Complex dropout now works uniformly across backends.
Follow-on cleanup enabled by the above:
- MPS rejects complex `bernoulli_` (matching CPU/CUDA) and the dead complex
Metal kernel instantiations are removed.
- The dropout-family OpInfos declare complex dtypes (previously
`test_dtypes` flagged them as "supported but unlisted"); the
`_refs.nn.functional.alpha_dropout` ref gains the conj/neg-view skips its
`_refs.nn.functional.dropout` sibling already had (dropout's per-call random
mask breaks view invariance).
- The `aten.dropout` decomposition inlines the real-mask math for complex
inputs instead of calling `aten.native_dropout`, whose autograd node
rejects complex outputs (the float path is unchanged).
- `_refs.nn.functional.dropout` skips `test_python_ref_executor` for complex
dtypes: the aten-executor comparison, xfailed for float as non-comparable,
becomes comparable for complex on CUDA/ROCm (unexpected success) but not
MPS, so skip rather than xfail avoids the device-dependent flip.
- The MPS OpInfo lists drop the now-passing dropout-family complex xfails and
the already-dead `new_empty`/`new_empty_strided` complex entries (skipped for
all dtypes by `EMPTY_OPS_SKIPLIST`).
Test Plan:
Incremental build:
```
cd build && ninja torch_cpu
```
CPU OpInfo (was failing before the OpInfo dtype update):
```
python test/test_ops.py -k "dropout" # Ran 338 tests ... OK (skipped=123)
```
MPS OpInfo consistency (Apple Silicon):
```
python test/test_mps.py -k "dropout" # Ran 60 tests ... OK (expected failures=10)
python test/test_mps.py -k "bernoulli" # Ran 14 tests ... OK (expected failures=5)
```
Manual checks: complex64/complex128 `F.dropout` returns a complex tensor with
the correct 1/(1-p) scaling on CPU and MPS; complex `bernoulli_` raises
`NotImplementedError` on MPS; real dtypes, `torch.native_dropout`, and float
dropout are unchanged. CUDA/XPU complex routing is by construction (composite
path) and validated by CI.
This PR was authored with the assistance of an AI coding assistant (Claude).
Co-Authored-By: Claude Opus 4.8 <[email protected]>
02dd7bf to
ce9b619
Compare
3552463 to
73d81d4
Compare
The previous commit skipped `test_python_ref_executor` for complex dtypes on `_refs.nn.functional.dropout` across all devices. The unexpected success only occurs on CUDA/ROCm, where the aten-executor result for complex happens to match eager; on MPS the executor comparison stays non-comparable and the `expectedFailure` still holds. Scope the skip to `device_type="cuda"` (which also covers ROCm) so the MPS xfail is preserved. Test Plan: verified decorator resolution -- cuda+complex -> skip, cuda+float -> xfail, mps+complex -> xfail. `test_python_ref_executor` is `@skipIfMPS`, so this only affects the CUDA/ROCm accelerator runs in practice. Authored with the assistance of an AI coding assistant (Claude). Co-Authored-By: Claude Opus 4.8 <[email protected]>
73d81d4 to
e7645dd
Compare
|
@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 |
## Summary
`nn.functional.dropout` raised `NotImplementedError` for complex inputs on CPU (and CUDA), while silently "working" on MPS.
**Root cause:** `_dropout_impl` allocated the Bernoulli mask (`noise`) in the input's dtype and called `bernoulli_` on it. For complex inputs that requires a complex `bernoulli_`, which CPU and CUDA do not implement (both dispatch via `AT_DISPATCH_ALL_TYPES_AND3`, no complex). MPS only accepted it because of incidental complex bernoulli Metal kernels that wrote the `{0,1}` mask into the real component and zeroed the imaginary part -- a semantically-undefined result that masked the CPU/MPS divergence.
**Fix:** The dropout mask is real-valued regardless of input dtype, so allocate it in the real value type (`c10::toRealValueType`). `complex_input * real_mask` is well-defined and numerically identical to the old MPS behaviour. Complex inputs are also excluded from `is_fused_kernel_acceptable`, so on CUDA/XPU/lazy/privateuseone (whose fused kernels are float-only) they take the same composite `_dropout_impl` path -- mirroring how MPS already excludes non-floating inputs there. Complex dropout now works uniformly across backends.
**Follow-on cleanup enabled by the above:**
- MPS rejects complex `bernoulli_` (matching CPU/CUDA), and the dead complex Metal kernel instantiations (`float2`/`half2`) are removed.
- The dropout-family OpInfos declare complex dtypes (previously `test_dtypes` flagged them as "supported but unlisted"); `_refs.nn.functional.alpha_dropout` gains the conj/neg-view skips its `_refs.nn.functional.dropout` sibling already had (dropout's per-call random mask breaks view invariance).
- The MPS OpInfo lists drop the now-passing dropout-family complex xfails and the already-dead `new_empty`/`new_empty_strided` complex entries (skipped for all dtypes by `EMPTY_OPS_SKIPLIST`).
> This PR was authored with the assistance of an AI coding assistant (Claude); all changes were reviewed by the author.
Pull Request resolved: pytorch#195373
Approved by: https://github.com/Skylion007
Co-authored-by: Claude Opus 4.8 <[email protected]>
## Summary
`nn.functional.dropout` raised `NotImplementedError` for complex inputs on CPU (and CUDA), while silently "working" on MPS.
**Root cause:** `_dropout_impl` allocated the Bernoulli mask (`noise`) in the input's dtype and called `bernoulli_` on it. For complex inputs that requires a complex `bernoulli_`, which CPU and CUDA do not implement (both dispatch via `AT_DISPATCH_ALL_TYPES_AND3`, no complex). MPS only accepted it because of incidental complex bernoulli Metal kernels that wrote the `{0,1}` mask into the real component and zeroed the imaginary part -- a semantically-undefined result that masked the CPU/MPS divergence.
**Fix:** The dropout mask is real-valued regardless of input dtype, so allocate it in the real value type (`c10::toRealValueType`). `complex_input * real_mask` is well-defined and numerically identical to the old MPS behaviour. Complex inputs are also excluded from `is_fused_kernel_acceptable`, so on CUDA/XPU/lazy/privateuseone (whose fused kernels are float-only) they take the same composite `_dropout_impl` path -- mirroring how MPS already excludes non-floating inputs there. Complex dropout now works uniformly across backends.
**Follow-on cleanup enabled by the above:**
- MPS rejects complex `bernoulli_` (matching CPU/CUDA), and the dead complex Metal kernel instantiations (`float2`/`half2`) are removed.
- The dropout-family OpInfos declare complex dtypes (previously `test_dtypes` flagged them as "supported but unlisted"); `_refs.nn.functional.alpha_dropout` gains the conj/neg-view skips its `_refs.nn.functional.dropout` sibling already had (dropout's per-call random mask breaks view invariance).
- The MPS OpInfo lists drop the now-passing dropout-family complex xfails and the already-dead `new_empty`/`new_empty_strided` complex entries (skipped for all dtypes by `EMPTY_OPS_SKIPLIST`).
> This PR was authored with the assistance of an AI coding assistant (Claude); all changes were reviewed by the author.
Pull Request resolved: pytorch#195373
Approved by: https://github.com/Skylion007
Co-authored-by: Claude Opus 4.8 <[email protected]>
Summary
nn.functional.dropoutraisedNotImplementedErrorfor complex inputs on CPU (and CUDA), while silently "working" on MPS.Root cause:
_dropout_implallocated the Bernoulli mask (noise) in the input's dtype and calledbernoulli_on it. For complex inputs that requires a complexbernoulli_, which CPU and CUDA do not implement (both dispatch viaAT_DISPATCH_ALL_TYPES_AND3, no complex). MPS only accepted it because of incidental complex bernoulli Metal kernels that wrote the{0,1}mask into the real component and zeroed the imaginary part -- a semantically-undefined result that masked the CPU/MPS divergence.Fix: The dropout mask is real-valued regardless of input dtype, so allocate it in the real value type (
c10::toRealValueType).complex_input * real_maskis well-defined and numerically identical to the old MPS behaviour. Complex inputs are also excluded fromis_fused_kernel_acceptable, so on CUDA/XPU/lazy/privateuseone (whose fused kernels are float-only) they take the same composite_dropout_implpath -- mirroring how MPS already excludes non-floating inputs there. Complex dropout now works uniformly across backends.Follow-on cleanup enabled by the above:
bernoulli_(matching CPU/CUDA), and the dead complex Metal kernel instantiations (float2/half2) are removed.test_dtypesflagged them as "supported but unlisted");_refs.nn.functional.alpha_dropoutgains the conj/neg-view skips its_refs.nn.functional.dropoutsibling already had (dropout's per-call random mask breaks view invariance).new_empty/new_empty_stridedcomplex entries (skipped for all dtypes byEMPTY_OPS_SKIPLIST).