Repository navigation
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/183019
Note: Links to docs will display an error until the docs builds have been completed. ⏳ No Failures, 5 PendingAs of commit 044c9b2 with merge base e775750 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
Attention! native_functions.yaml was changedIf you are adding a new function or defaulted argument to native_functions.yaml, you cannot use it from pre-existing Python frontend code until our FC window passes (two weeks). Split your PR into two PRs, one which adds the new C++ functionality, and one that makes use of it from Python, and land them two weeks apart. See https://github.com/pytorch/pytorch/wiki/PyTorch's-Python-Frontend-Backward-and-Forward-Compatibility-Policy#forwards-compatibility-fc for more info. |
Used the metal-kernel skill to port the boolean comparison binary ops to native Metal kernels via the existing TensorIterator stub-dispatch path, dropping the MPSGraph-based implementations. Adds complex `eq`/`ne`. The shared `DEFINE_BINARY_COMPARISON_FUNCTOR` macro can't be reused for complex because `float2 == float2` returns `bool2` (componentwise) in Metal and doesn't implicitly convert to `bool`; `eq_functor`/`ne_functor` are defined inline instead and gain explicit `float2`/`half2` overloads that reduce via `all(a == b)` / `any(a != b)`. A new `REGISTER_COMPLEX_EQ_OP` macro instantiates the complex variants (with castout siblings) for `eq` and `ne` only -- `lt`/`le`/`gt`/`ge` remain real-only. Authored with assistance from Claude. ghstack-source-id: d969cb8 Pull-Request: #183019
|
@pytorchbot merge -f "Lint + MPS are green" |
Merge startedYour change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes). Please use Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Several MPS binary TensorIterator dispatcher fixes, plus tests. **Scalar promotion shortcut** restricted to lossless int-scalar→float-common only. Was building wrong kernel names (`mul_dense_scalar_float2_float` for `complex_convolution`) and rounding float scalars on the host before launch (float16 CrossEntropyLoss drift). The `cast_suffix_type` selection now uses `iter.common_dtype()` (with a `kBool` branch for comparison ops) so cast-kernel name lookups match the post-promotion template instantiation. Fixes `cosine_similarity` `mps_float16` (`half.clamp_min_(float)`). **`natural_output_dtype` contract on `exec_binary_kernel`** + new `binary_strided_castout` kernel template (with a `store_at_offs` helper). Default natural = `iter.dtype(0)`, so arithmetic ops dispatch through the existing `<DTYPEO>_<DTYPEI>` cast-kernel matrix as before. Ops whose kernel produces a fixed natural that may diverge from `iter.dtype(0)` (comparisons → `kBool`) declare it via the new parameter; the dispatcher then routes through `_strided_castout_<DTYPEO>_<DTYPEI>`, which computes at compile-time precision and runtime-casts on store. Castout is explicit opt-in via a separate `REGISTER_BINARY_CASTOUT_OP(NAME, DTYPEI, DTYPEO)` macro -- arithmetic ops don't pay binary size for unused kernels. Missing combos fail loudly via `getPipelineStateForFunc` rather than silent corruption. The contract is used by the comparison-ops migration in #183019 to fix `cdist` `mps_float32` (`linalg_vector_norm(p=0)` → `ne_outf(float, 0, float_out)`) and inductor `test_complex_from_real_imag_mps`. **`C10_METAL_ALL_TYPES_FUNCTOR` extended** to `(EnumName, EnumValue, MetalType)`. `val_at_offs` and `store_at_offs` are generated from the same X-macro instead of hand-written per-type switches. **Caller-tunable ILP threshold** via a new `ilp_threshold` parameter. Float-output default kept at 256K; non-float defaults off. `binary_dense_ilp` is `unsigned ILP`-templated and the unroll width appears in host names (`add_dense_ilp4_float_float`) so future `ilp8`/`ilp16` can coexist. Tests: new `TestBinaryIteratorConformance` (two synthetic functors -- `simple_add` and `simple_ge` -- compiled via `MetalShaderLibrary` and dispatched through the same path real ops use; `simple_ge` opts into castout). Plus `test_binary_kernels` regressions for scalar precision and in-place narrowing. Authored with assistance from Claude. Pull Request resolved: #183055 Approved by: https://github.com/Skylion007
## Summary - Unclassified failures (workflow didn't run on the merge base) were rendered as success: title showed "No Failures", a `:green_heart: Looks good so far!` line was emitted, and the `UNCLASSIFIED FAILURE` `<details>` block was collapsed. Reviewers could easily miss real, potentially PR-introduced breakage. - Now: `:x:` icon fires when `hasUnknownFailures`, "No Failures" and the `:green_heart:` reassurance are suppressed, and the unclassified section is rendered with `<details open>` so affected jobs are immediately visible. - Adds a test covering the unclassified-only case (failure icon present; "No Failures"/`:green_heart:` absent; `<details open>` for the UNCLASSIFIED block). ## Test plan - [x] `yarn jest drci.test.ts` passes (including the new test). - [x] `yarn format --check` passes. - [ ] Spot-check a PR like pytorch/pytorch#183019 in staging to confirm the title and section rendering.
Several MPS binary TensorIterator dispatcher fixes, plus tests. **Scalar promotion shortcut** restricted to lossless int-scalar→float-common only. Was building wrong kernel names (`mul_dense_scalar_float2_float` for `complex_convolution`) and rounding float scalars on the host before launch (float16 CrossEntropyLoss drift). The `cast_suffix_type` selection now uses `iter.common_dtype()` (with a `kBool` branch for comparison ops) so cast-kernel name lookups match the post-promotion template instantiation. Fixes `cosine_similarity` `mps_float16` (`half.clamp_min_(float)`). **`natural_output_dtype` contract on `exec_binary_kernel`** + new `binary_strided_castout` kernel template (with a `store_at_offs` helper). Default natural = `iter.dtype(0)`, so arithmetic ops dispatch through the existing `<DTYPEO>_<DTYPEI>` cast-kernel matrix as before. Ops whose kernel produces a fixed natural that may diverge from `iter.dtype(0)` (comparisons → `kBool`) declare it via the new parameter; the dispatcher then routes through `_strided_castout_<DTYPEO>_<DTYPEI>`, which computes at compile-time precision and runtime-casts on store. Castout is explicit opt-in via a separate `REGISTER_BINARY_CASTOUT_OP(NAME, DTYPEI, DTYPEO)` macro -- arithmetic ops don't pay binary size for unused kernels. Missing combos fail loudly via `getPipelineStateForFunc` rather than silent corruption. The contract is used by the comparison-ops migration in pytorch#183019 to fix `cdist` `mps_float32` (`linalg_vector_norm(p=0)` → `ne_outf(float, 0, float_out)`) and inductor `test_complex_from_real_imag_mps`. **`C10_METAL_ALL_TYPES_FUNCTOR` extended** to `(EnumName, EnumValue, MetalType)`. `val_at_offs` and `store_at_offs` are generated from the same X-macro instead of hand-written per-type switches. **Caller-tunable ILP threshold** via a new `ilp_threshold` parameter. Float-output default kept at 256K; non-float defaults off. `binary_dense_ilp` is `unsigned ILP`-templated and the unroll width appears in host names (`add_dense_ilp4_float_float`) so future `ilp8`/`ilp16` can coexist. Tests: new `TestBinaryIteratorConformance` (two synthetic functors -- `simple_add` and `simple_ge` -- compiled via `MetalShaderLibrary` and dispatched through the same path real ops use; `simple_ge` opts into castout). Plus `test_binary_kernels` regressions for scalar precision and in-place narrowing. Authored with assistance from Claude. Pull Request resolved: pytorch#183055 Approved by: https://github.com/Skylion007
…al (pytorch#183019) Used the metal-kernel skill to port the boolean comparison binary ops (`eq`, `ne`, `lt`, `le`, `gt`, `ge`) to native Metal kernels via the existing TensorIterator stub-dispatch path, dropping the MPSGraph-based implementations. Each stub passes `kBool` as `natural_output_dtype` (the new contract introduced in pytorch#183055) so non-bool `out=` is correctly routed through the strided castout path. Stubs also pass `ilp_threshold = 1u << 18`, matching the floating-point default — measurably faster for small/medium tensors and avoids the 2b-param dispatch cliff in MPSGraph. `torch.eq(a, b, out=c)` on M-series, default dispatcher (us/call, lower is better): | numel | torch 2.11 (MPSGraph) | this PR | speedup | |---|---|---|---| | float32, 65K | 16.6 | 12.7 | 1.3x | | float32, 262K | 111.5 | 18.6 | 6.0x | | float32, 1M | 43.1 | 42.3 | 1.0x | | float32, 16M | 601.7 | 632.6 | 0.95x | | int32, 65K | 16.3 | 3.7 | 4.4x | | int32, 262K | 16.4 | 5.2 | 3.2x | | int32, 1M | 23.3 | 24.4 | 1.0x | | int32, 16M | 613.1 | 606.2 | 1.0x | Authored with assistance from Claude. Pull Request resolved: pytorch#183019 Approved by: https://github.com/Skylion007 ghstack dependencies: pytorch#183055
Several MPS binary TensorIterator dispatcher fixes, plus tests. **Scalar promotion shortcut** restricted to lossless int-scalar→float-common only. Was building wrong kernel names (`mul_dense_scalar_float2_float` for `complex_convolution`) and rounding float scalars on the host before launch (float16 CrossEntropyLoss drift). The `cast_suffix_type` selection now uses `iter.common_dtype()` (with a `kBool` branch for comparison ops) so cast-kernel name lookups match the post-promotion template instantiation. Fixes `cosine_similarity` `mps_float16` (`half.clamp_min_(float)`). **`natural_output_dtype` contract on `exec_binary_kernel`** + new `binary_strided_castout` kernel template (with a `store_at_offs` helper). Default natural = `iter.dtype(0)`, so arithmetic ops dispatch through the existing `<DTYPEO>_<DTYPEI>` cast-kernel matrix as before. Ops whose kernel produces a fixed natural that may diverge from `iter.dtype(0)` (comparisons → `kBool`) declare it via the new parameter; the dispatcher then routes through `_strided_castout_<DTYPEO>_<DTYPEI>`, which computes at compile-time precision and runtime-casts on store. Castout is explicit opt-in via a separate `REGISTER_BINARY_CASTOUT_OP(NAME, DTYPEI, DTYPEO)` macro -- arithmetic ops don't pay binary size for unused kernels. Missing combos fail loudly via `getPipelineStateForFunc` rather than silent corruption. The contract is used by the comparison-ops migration in pytorch#183019 to fix `cdist` `mps_float32` (`linalg_vector_norm(p=0)` → `ne_outf(float, 0, float_out)`) and inductor `test_complex_from_real_imag_mps`. **`C10_METAL_ALL_TYPES_FUNCTOR` extended** to `(EnumName, EnumValue, MetalType)`. `val_at_offs` and `store_at_offs` are generated from the same X-macro instead of hand-written per-type switches. **Caller-tunable ILP threshold** via a new `ilp_threshold` parameter. Float-output default kept at 256K; non-float defaults off. `binary_dense_ilp` is `unsigned ILP`-templated and the unroll width appears in host names (`add_dense_ilp4_float_float`) so future `ilp8`/`ilp16` can coexist. Tests: new `TestBinaryIteratorConformance` (two synthetic functors -- `simple_add` and `simple_ge` -- compiled via `MetalShaderLibrary` and dispatched through the same path real ops use; `simple_ge` opts into castout). Plus `test_binary_kernels` regressions for scalar precision and in-place narrowing. Authored with assistance from Claude. Pull Request resolved: pytorch#183055 Approved by: https://github.com/Skylion007
…al (pytorch#183019) Used the metal-kernel skill to port the boolean comparison binary ops (`eq`, `ne`, `lt`, `le`, `gt`, `ge`) to native Metal kernels via the existing TensorIterator stub-dispatch path, dropping the MPSGraph-based implementations. Each stub passes `kBool` as `natural_output_dtype` (the new contract introduced in pytorch#183055) so non-bool `out=` is correctly routed through the strided castout path. Stubs also pass `ilp_threshold = 1u << 18`, matching the floating-point default — measurably faster for small/medium tensors and avoids the 2b-param dispatch cliff in MPSGraph. `torch.eq(a, b, out=c)` on M-series, default dispatcher (us/call, lower is better): | numel | torch 2.11 (MPSGraph) | this PR | speedup | |---|---|---|---| | float32, 65K | 16.6 | 12.7 | 1.3x | | float32, 262K | 111.5 | 18.6 | 6.0x | | float32, 1M | 43.1 | 42.3 | 1.0x | | float32, 16M | 601.7 | 632.6 | 0.95x | | int32, 65K | 16.3 | 3.7 | 4.4x | | int32, 262K | 16.4 | 5.2 | 3.2x | | int32, 1M | 23.3 | 24.4 | 1.0x | | int32, 16M | 613.1 | 606.2 | 1.0x | Authored with assistance from Claude. Pull Request resolved: pytorch#183019 Approved by: https://github.com/Skylion007 ghstack dependencies: pytorch#183055
Several MPS binary TensorIterator dispatcher fixes, plus tests. **Scalar promotion shortcut** restricted to lossless int-scalar→float-common only. Was building wrong kernel names (`mul_dense_scalar_float2_float` for `complex_convolution`) and rounding float scalars on the host before launch (float16 CrossEntropyLoss drift). The `cast_suffix_type` selection now uses `iter.common_dtype()` (with a `kBool` branch for comparison ops) so cast-kernel name lookups match the post-promotion template instantiation. Fixes `cosine_similarity` `mps_float16` (`half.clamp_min_(float)`). **`natural_output_dtype` contract on `exec_binary_kernel`** + new `binary_strided_castout` kernel template (with a `store_at_offs` helper). Default natural = `iter.dtype(0)`, so arithmetic ops dispatch through the existing `<DTYPEO>_<DTYPEI>` cast-kernel matrix as before. Ops whose kernel produces a fixed natural that may diverge from `iter.dtype(0)` (comparisons → `kBool`) declare it via the new parameter; the dispatcher then routes through `_strided_castout_<DTYPEO>_<DTYPEI>`, which computes at compile-time precision and runtime-casts on store. Castout is explicit opt-in via a separate `REGISTER_BINARY_CASTOUT_OP(NAME, DTYPEI, DTYPEO)` macro -- arithmetic ops don't pay binary size for unused kernels. Missing combos fail loudly via `getPipelineStateForFunc` rather than silent corruption. The contract is used by the comparison-ops migration in pytorch#183019 to fix `cdist` `mps_float32` (`linalg_vector_norm(p=0)` → `ne_outf(float, 0, float_out)`) and inductor `test_complex_from_real_imag_mps`. **`C10_METAL_ALL_TYPES_FUNCTOR` extended** to `(EnumName, EnumValue, MetalType)`. `val_at_offs` and `store_at_offs` are generated from the same X-macro instead of hand-written per-type switches. **Caller-tunable ILP threshold** via a new `ilp_threshold` parameter. Float-output default kept at 256K; non-float defaults off. `binary_dense_ilp` is `unsigned ILP`-templated and the unroll width appears in host names (`add_dense_ilp4_float_float`) so future `ilp8`/`ilp16` can coexist. Tests: new `TestBinaryIteratorConformance` (two synthetic functors -- `simple_add` and `simple_ge` -- compiled via `MetalShaderLibrary` and dispatched through the same path real ops use; `simple_ge` opts into castout). Plus `test_binary_kernels` regressions for scalar precision and in-place narrowing. Authored with assistance from Claude. Pull Request resolved: pytorch#183055 Approved by: https://github.com/Skylion007
…al (pytorch#183019) Used the metal-kernel skill to port the boolean comparison binary ops (`eq`, `ne`, `lt`, `le`, `gt`, `ge`) to native Metal kernels via the existing TensorIterator stub-dispatch path, dropping the MPSGraph-based implementations. Each stub passes `kBool` as `natural_output_dtype` (the new contract introduced in pytorch#183055) so non-bool `out=` is correctly routed through the strided castout path. Stubs also pass `ilp_threshold = 1u << 18`, matching the floating-point default — measurably faster for small/medium tensors and avoids the 2b-param dispatch cliff in MPSGraph. `torch.eq(a, b, out=c)` on M-series, default dispatcher (us/call, lower is better): | numel | torch 2.11 (MPSGraph) | this PR | speedup | |---|---|---|---| | float32, 65K | 16.6 | 12.7 | 1.3x | | float32, 262K | 111.5 | 18.6 | 6.0x | | float32, 1M | 43.1 | 42.3 | 1.0x | | float32, 16M | 601.7 | 632.6 | 0.95x | | int32, 65K | 16.3 | 3.7 | 4.4x | | int32, 262K | 16.4 | 5.2 | 3.2x | | int32, 1M | 23.3 | 24.4 | 1.0x | | int32, 16M | 613.1 | 606.2 | 1.0x | Authored with assistance from Claude. Pull Request resolved: pytorch#183019 Approved by: https://github.com/Skylion007 ghstack dependencies: pytorch#183055
Several MPS binary TensorIterator dispatcher fixes, plus tests. **Scalar promotion shortcut** restricted to lossless int-scalar→float-common only. Was building wrong kernel names (`mul_dense_scalar_float2_float` for `complex_convolution`) and rounding float scalars on the host before launch (float16 CrossEntropyLoss drift). The `cast_suffix_type` selection now uses `iter.common_dtype()` (with a `kBool` branch for comparison ops) so cast-kernel name lookups match the post-promotion template instantiation. Fixes `cosine_similarity` `mps_float16` (`half.clamp_min_(float)`). **`natural_output_dtype` contract on `exec_binary_kernel`** + new `binary_strided_castout` kernel template (with a `store_at_offs` helper). Default natural = `iter.dtype(0)`, so arithmetic ops dispatch through the existing `<DTYPEO>_<DTYPEI>` cast-kernel matrix as before. Ops whose kernel produces a fixed natural that may diverge from `iter.dtype(0)` (comparisons → `kBool`) declare it via the new parameter; the dispatcher then routes through `_strided_castout_<DTYPEO>_<DTYPEI>`, which computes at compile-time precision and runtime-casts on store. Castout is explicit opt-in via a separate `REGISTER_BINARY_CASTOUT_OP(NAME, DTYPEI, DTYPEO)` macro -- arithmetic ops don't pay binary size for unused kernels. Missing combos fail loudly via `getPipelineStateForFunc` rather than silent corruption. The contract is used by the comparison-ops migration in pytorch#183019 to fix `cdist` `mps_float32` (`linalg_vector_norm(p=0)` → `ne_outf(float, 0, float_out)`) and inductor `test_complex_from_real_imag_mps`. **`C10_METAL_ALL_TYPES_FUNCTOR` extended** to `(EnumName, EnumValue, MetalType)`. `val_at_offs` and `store_at_offs` are generated from the same X-macro instead of hand-written per-type switches. **Caller-tunable ILP threshold** via a new `ilp_threshold` parameter. Float-output default kept at 256K; non-float defaults off. `binary_dense_ilp` is `unsigned ILP`-templated and the unroll width appears in host names (`add_dense_ilp4_float_float`) so future `ilp8`/`ilp16` can coexist. Tests: new `TestBinaryIteratorConformance` (two synthetic functors -- `simple_add` and `simple_ge` -- compiled via `MetalShaderLibrary` and dispatched through the same path real ops use; `simple_ge` opts into castout). Plus `test_binary_kernels` regressions for scalar precision and in-place narrowing. Authored with assistance from Claude. Pull Request resolved: pytorch#183055 Approved by: https://github.com/Skylion007
…al (pytorch#183019) Used the metal-kernel skill to port the boolean comparison binary ops (`eq`, `ne`, `lt`, `le`, `gt`, `ge`) to native Metal kernels via the existing TensorIterator stub-dispatch path, dropping the MPSGraph-based implementations. Each stub passes `kBool` as `natural_output_dtype` (the new contract introduced in pytorch#183055) so non-bool `out=` is correctly routed through the strided castout path. Stubs also pass `ilp_threshold = 1u << 18`, matching the floating-point default — measurably faster for small/medium tensors and avoids the 2b-param dispatch cliff in MPSGraph. `torch.eq(a, b, out=c)` on M-series, default dispatcher (us/call, lower is better): | numel | torch 2.11 (MPSGraph) | this PR | speedup | |---|---|---|---| | float32, 65K | 16.6 | 12.7 | 1.3x | | float32, 262K | 111.5 | 18.6 | 6.0x | | float32, 1M | 43.1 | 42.3 | 1.0x | | float32, 16M | 601.7 | 632.6 | 0.95x | | int32, 65K | 16.3 | 3.7 | 4.4x | | int32, 262K | 16.4 | 5.2 | 3.2x | | int32, 1M | 23.3 | 24.4 | 1.0x | | int32, 16M | 613.1 | 606.2 | 1.0x | Authored with assistance from Claude. Pull Request resolved: pytorch#183019 Approved by: https://github.com/Skylion007 ghstack dependencies: pytorch#183055
Several MPS binary TensorIterator dispatcher fixes, plus tests. **Scalar promotion shortcut** restricted to lossless int-scalar→float-common only. Was building wrong kernel names (`mul_dense_scalar_float2_float` for `complex_convolution`) and rounding float scalars on the host before launch (float16 CrossEntropyLoss drift). The `cast_suffix_type` selection now uses `iter.common_dtype()` (with a `kBool` branch for comparison ops) so cast-kernel name lookups match the post-promotion template instantiation. Fixes `cosine_similarity` `mps_float16` (`half.clamp_min_(float)`). **`natural_output_dtype` contract on `exec_binary_kernel`** + new `binary_strided_castout` kernel template (with a `store_at_offs` helper). Default natural = `iter.dtype(0)`, so arithmetic ops dispatch through the existing `<DTYPEO>_<DTYPEI>` cast-kernel matrix as before. Ops whose kernel produces a fixed natural that may diverge from `iter.dtype(0)` (comparisons → `kBool`) declare it via the new parameter; the dispatcher then routes through `_strided_castout_<DTYPEO>_<DTYPEI>`, which computes at compile-time precision and runtime-casts on store. Castout is explicit opt-in via a separate `REGISTER_BINARY_CASTOUT_OP(NAME, DTYPEI, DTYPEO)` macro -- arithmetic ops don't pay binary size for unused kernels. Missing combos fail loudly via `getPipelineStateForFunc` rather than silent corruption. The contract is used by the comparison-ops migration in pytorch#183019 to fix `cdist` `mps_float32` (`linalg_vector_norm(p=0)` → `ne_outf(float, 0, float_out)`) and inductor `test_complex_from_real_imag_mps`. **`C10_METAL_ALL_TYPES_FUNCTOR` extended** to `(EnumName, EnumValue, MetalType)`. `val_at_offs` and `store_at_offs` are generated from the same X-macro instead of hand-written per-type switches. **Caller-tunable ILP threshold** via a new `ilp_threshold` parameter. Float-output default kept at 256K; non-float defaults off. `binary_dense_ilp` is `unsigned ILP`-templated and the unroll width appears in host names (`add_dense_ilp4_float_float`) so future `ilp8`/`ilp16` can coexist. Tests: new `TestBinaryIteratorConformance` (two synthetic functors -- `simple_add` and `simple_ge` -- compiled via `MetalShaderLibrary` and dispatched through the same path real ops use; `simple_ge` opts into castout). Plus `test_binary_kernels` regressions for scalar precision and in-place narrowing. Authored with assistance from Claude. Pull Request resolved: pytorch#183055 Approved by: https://github.com/Skylion007
…al (pytorch#183019) Used the metal-kernel skill to port the boolean comparison binary ops (`eq`, `ne`, `lt`, `le`, `gt`, `ge`) to native Metal kernels via the existing TensorIterator stub-dispatch path, dropping the MPSGraph-based implementations. Each stub passes `kBool` as `natural_output_dtype` (the new contract introduced in pytorch#183055) so non-bool `out=` is correctly routed through the strided castout path. Stubs also pass `ilp_threshold = 1u << 18`, matching the floating-point default — measurably faster for small/medium tensors and avoids the 2b-param dispatch cliff in MPSGraph. `torch.eq(a, b, out=c)` on M-series, default dispatcher (us/call, lower is better): | numel | torch 2.11 (MPSGraph) | this PR | speedup | |---|---|---|---| | float32, 65K | 16.6 | 12.7 | 1.3x | | float32, 262K | 111.5 | 18.6 | 6.0x | | float32, 1M | 43.1 | 42.3 | 1.0x | | float32, 16M | 601.7 | 632.6 | 0.95x | | int32, 65K | 16.3 | 3.7 | 4.4x | | int32, 262K | 16.4 | 5.2 | 3.2x | | int32, 1M | 23.3 | 24.4 | 1.0x | | int32, 16M | 613.1 | 606.2 | 1.0x | Authored with assistance from Claude. Pull Request resolved: pytorch#183019 Approved by: https://github.com/Skylion007 ghstack dependencies: pytorch#183055
Comparison ops have no uint16/uint32/uint64 kernels since migration to metal kernels in #183019. Since CPU and CUDA both support them, it's reasonable for MPS to support them as well. This was first reported in kornia/kornia#4522 Pull Request resolved: #198860 Approved by: https://github.com/malfet
Comparison ops have no uint16/uint32/uint64 kernels since migration to metal kernels in #183019. Since CPU and CUDA both support them, it's reasonable for MPS to support them as well. This was first reported in kornia/kornia#4522 Pull Request resolved: #198860 Approved by: https://github.com/malfet
Stack from ghstack (oldest at bottom):
Used the metal-kernel skill to port the boolean comparison binary ops (
eq,ne,lt,le,gt,ge) to native Metal kernels via the existing TensorIterator stub-dispatch path, dropping the MPSGraph-based implementations.Each stub passes
kBoolasnatural_output_dtype(the new contract introduced in #183055) so non-boolout=is correctly routed through the strided castout path. Stubs also passilp_threshold = 1u << 18, matching the floating-point default — measurably faster for small/medium tensors and avoids the 2b-param dispatch cliff in MPSGraph.torch.eq(a, b, out=c)on M-series, default dispatcher (us/call, lower is better):Authored with assistance from Claude.