Repository navigation
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/189953
Note: Links to docs will display an error until the docs builds have been completed. ❌ You can merge normally! (3 Unrelated Failures), 1 Unclassified FailureAs of commit 194114f with merge base 100c32b ( UNCLASSIFIED FAILURE - DrCI could not classify the following job because the workflow did not run on the merge base. The failure may be pre-existing on trunk or introduced by this PR:
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. |
|
Could we extend our current clamp tests to cover these unsigned integer types? I think they aren't covered by optests? |
There was a problem hiding this comment.
Pull request overview
This PR extends the clamp kernel implementations (tensor- and scalar-bound variants) on CPU and CUDA to accept the barebones unsigned integer dtypes (uint16, uint32, uint64) by migrating the dispatch sites to AT_DISPATCH_V2 with AT_BAREBONES_UNSIGNED_TYPES.
Changes:
- Switch CUDA
clamp/clamp_scalardispatch toAT_DISPATCH_V2and includeAT_BAREBONES_UNSIGNED_TYPES. - Switch CPU
clamp/clamp_scalar/clamp_min_scalar/clamp_max_scalardispatch toAT_DISPATCH_V2and includeAT_BAREBONES_UNSIGNED_TYPES. - Add
Dispatch_v2include for the updated CPU dispatch usage.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| aten/src/ATen/native/cuda/TensorCompare.cu | Extend CUDA clamp-family dispatch to include barebones unsigned integer dtypes via AT_DISPATCH_V2. |
| aten/src/ATen/native/cpu/TensorCompareKernel.cpp | Extend CPU clamp-family dispatch to include barebones unsigned integer dtypes via AT_DISPATCH_V2. |
| _barebones_unsigned_types = _dispatch_dtypes((torch.uint16, torch.uint32, torch.uint64)) | ||
|
|
||
|
|
||
| def barebones_unsigned_types(): |
There was a problem hiding this comment.
We don't need a function, we have the internal we can just import above? UNless it needs to be a function for some reason?
There was a problem hiding this comment.
nvm, I guess this is a common idiom here
There was a problem hiding this comment.
@Skylion007 Could you trigger CI when you get the chance?
Thank you.
|
@claude review this PR again |
|
Claude finished @Skylion007's task in 31m 18s —— View job ReviewThe dispatch changes look correct and the test now genuinely exercises the new dtypes, but the test's bound selection avoids the two cases most likely to be broken ( Full review detailsScope noteSince the last review round the PR grew beyond the clamp kernels: it now also widens 1.
|
|
@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 |
|
Successfully rebased |
5f225a2 to
e58136b
Compare
|
What is the fix here? The original seemed like a legitimate internal compiler bug? |
| // The barebones unsigned types have no Vectorized specialization, and gcc-13 | ||
| // ICEs auto-vectorizing the vec_base.h emulation for fixed-length SVE. | ||
| template <typename scalar_t> | ||
| constexpr bool use_vectorized_minmax = |
There was a problem hiding this comment.
We should be specific and only include the affected compiler versions if we are going to use this workaround. It did look like it was surfacing a legit compiler bug
There was a problem hiding this comment.
Yes, I think the fix was too broad in hindsight. I believe the issue was with GCC 13 where a predicate conversion pattern arose where SVE does not have a Vectorized<uint8_t> or Vectorized<Half> specialization, so the clamp_kernel_impl used emulation for uint8 and uint16 types.
I will remove this workaround and leave a guard scoped to GCC < 14 and a fixed length SVE.
|
@Skylion007 I believe the failing check is unrelated to these changes. If there is anything else I should change for merging, please let me know. Thank you. |
|
@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: 1 jobs have failed, first few of them are: linux-binary-manywheel / libtorch-rocm7_14-shared-with-deps-release-extract Details for Dev Infra teamRaised by workflow job |
|
@pytorchbot merge -i |
Merge startedYour change will be merged while ignoring the following 1 checks: linux-binary-manywheel / libtorch-rocm7_14-shared-with-deps-release-extract Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
…189953) Adds `uint16`, `uint32`, and `uint64` support to `clamp` functions on CPU and CUDA. These ops previously rejected the barebones unsigned dtypes because their kernels dispatched through `AT_DISPATCH_ALL_TYPES_AND2`, which omits them. ## Relationship to pytorch#189872 Unblocks pytorch#189872 ("Add Autograd Support for Low-Level Bessel Functions"). That PR restricts the `x > 0` Bessel OpInfos (`special.bessel_y0`, `bessel_y1`, `modified_bessel_k0`, `modified_bessel_k1`) to `domain=(0, None)`, which makes the unary sample generator call `clamp_min` on the sample dtypes. For the barebones unsigned dtypes that call currently raises `NotImplementedError`, so pytorch#189872 marks the `uint16/uint32/uint64` forward reference-numerics tests as `expectedFailure`. With clamp supporting these dtypes, those tests pass and the xfails can be removed there. Pull Request resolved: pytorch#189953 Approved by: https://github.com/Skylion007
…189953) Adds `uint16`, `uint32`, and `uint64` support to `clamp` functions on CPU and CUDA. These ops previously rejected the barebones unsigned dtypes because their kernels dispatched through `AT_DISPATCH_ALL_TYPES_AND2`, which omits them. ## Relationship to pytorch#189872 Unblocks pytorch#189872 ("Add Autograd Support for Low-Level Bessel Functions"). That PR restricts the `x > 0` Bessel OpInfos (`special.bessel_y0`, `bessel_y1`, `modified_bessel_k0`, `modified_bessel_k1`) to `domain=(0, None)`, which makes the unary sample generator call `clamp_min` on the sample dtypes. For the barebones unsigned dtypes that call currently raises `NotImplementedError`, so pytorch#189872 marks the `uint16/uint32/uint64` forward reference-numerics tests as `expectedFailure`. With clamp supporting these dtypes, those tests pass and the xfails can be removed there. Pull Request resolved: pytorch#189953 Approved by: https://github.com/Skylion007
Adds
uint16,uint32, anduint64support toclampfunctions on CPU and CUDA. These ops previously rejected the barebones unsigned dtypes because their kernels dispatched throughAT_DISPATCH_ALL_TYPES_AND2, which omits them.Relationship to #189872
Unblocks #189872 ("Add Autograd Support for Low-Level Bessel Functions"). That PR restricts the
x > 0Bessel OpInfos (special.bessel_y0,bessel_y1,modified_bessel_k0,modified_bessel_k1) todomain=(0, None), which makes the unary sample generator callclamp_minon the sample dtypes. For the barebones unsigned dtypes that call currently raisesNotImplementedError, so #189872 marks theuint16/uint32/uint64forward reference-numerics tests asexpectedFailure. With clamp supporting these dtypes, those tests pass and the xfails can be removed there.cc @jgong5 @mingfeima @XiaobingSuper @sanchitintel @ashokei @jingxu10 @aditew01