Skip to content

Skip ATen-mode out-of-range integer clamp/hardtanh death tests - #21933

Open
malfet wants to merge 1 commit into
pytorch:mainfrom
malfet:skip-aten-clamp-oob-integer-death-tests
Open

Skip ATen-mode out-of-range integer clamp/hardtanh death tests#21933
malfet wants to merge 1 commit into
pytorch:mainfrom
malfet:skip-aten-clamp-oob-integer-death-tests

Conversation

@malfet

@malfet malfet commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

pytorch/pytorch#193169 changes how ATen's scalar clamp handles an out-of-range
integer bound. Instead of converting the bound straight to the input dtype
(which raised for signed dtypes and silently wrapped for unsigned ones), ATen
now reconciles the bound by direction: a min below the dtype's range (or a
max above it) is a no-op and is dropped, while the opposite direction is
rejected. hardtanh shares this behavior.

The portable kernels keep their own strict bounds check and are unaffected, but
the ATen-mode death tests (built with -DUSE_ATEN_LIB) assume every out-of-range
integer bound raises, which no longer holds. Skip those integer cases in ATen
mode, matching the existing skips for negative uint8 and out-of-range int32
bounds:

  • op_clamp_test: ByteTensorTooLargeClampDies
  • op_hardtanh_test: ByteTensorTooLargeScalarDies, CharTensorTooSmallScalarDies,
    ShortTensorTooLargeScalarDies (gated in the fixture helper, not the shared
    ScalarOverflowTestMacros.h, which eight suites depend on)

Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com

Summary

[PLEASE REMOVE] See CONTRIBUTING.md's Pull Requests for ExecuTorch PR guidelines.

[PLEASE REMOVE] If this PR closes an issue, please add a Fixes #<issue-id> line.

[PLEASE REMOVE] If this PR introduces a fix or feature that should be the upcoming release notes, please add a "Release notes: " label. For a list of available release notes labels, check out CONTRIBUTING.md's Pull Requests.

Test plan

[PLEASE REMOVE] How did you test this PR? Please write down any manual commands you used and note down tests that you have written if applicable.

pytorch/pytorch#193169 changes how ATen's scalar `clamp` handles an out-of-range
integer bound. Instead of converting the bound straight to the input dtype
(which raised for signed dtypes and silently wrapped for unsigned ones), ATen
now reconciles the bound by direction: a `min` below the dtype's range (or a
`max` above it) is a no-op and is dropped, while the opposite direction is
rejected. `hardtanh` shares this behavior.

The portable kernels keep their own strict bounds check and are unaffected, but
the ATen-mode death tests (built with -DUSE_ATEN_LIB) assume every out-of-range
integer bound raises, which no longer holds. Skip those integer cases in ATen
mode, matching the existing skips for negative uint8 and out-of-range int32
bounds:

- op_clamp_test: ByteTensorTooLargeClampDies
- op_hardtanh_test: ByteTensorTooLargeScalarDies, CharTensorTooSmallScalarDies,
  ShortTensorTooLargeScalarDies (gated in the fixture helper, not the shared
  ScalarOverflowTestMacros.h, which eight suites depend on)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@malfet
malfet requested a review from manuelcandales as a code owner August 19, 2026 06:46
Copilot AI lite review requested due to automatic review settings August 19, 2026 06:46
@pytorch-bot

pytorch-bot Bot commented Aug 19, 2026

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/21933

Note: Links to docs will display an error until the docs builds have been completed.

⚠️ 12 Awaiting Approval, 1 Unrelated Failure

As of commit ae208ea with merge base ed65b12 (image):

AWAITING APPROVAL - The following workflows need approval before CI can run:

FLAKY - The following job failed but was likely due to flakiness present on trunk:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 19, 2026
@github-actions

Copy link
Copy Markdown

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates ExecuTorch kernel death tests to account for upstream ATen behavior changes around out-of-range integer bounds for clamp/hardtanh when building/running in ATen mode (-DUSE_ATEN_LIB). Since ATen now treats some out-of-range integer bounds as a direction-dependent no-op (instead of always erroring), these specific death tests no longer reliably hold under ATen kernels and are now skipped there.

Changes:

  • Skip OpClampOutTest.ByteTensorTooLargeClampDies when SupportedFeatures::get()->is_aten is true.
  • Skip the integral dtype scalar-overflow hardtanh death tests in ATen mode by gating them in OpHardTanhTest::expect_bad_scalar_value_dies.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
kernels/test/op_hardtanh_test.cpp Adds ATen-mode skip for integral hardtanh scalar overflow death tests via the shared fixture helper.
kernels/test/op_clamp_test.cpp Adds ATen-mode skip for the “too large uint8 bound” clamp death test that no longer universally errors in ATen.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants