Fix arange and logit behavior for torch-nightly CI - #2974
Open
justinchuby with Copilot wants to merge 2 commits into
Open
Fix arange and logit behavior for torch-nightly CI#2974justinchuby with Copilot wants to merge 2 commits into
justinchuby with Copilot wants to merge 2 commits into
Conversation
Open
Copilot
AI
changed the title
[WIP] Fix CI by cherry picking commit 6c844d3
Fix arange and logit behavior for torch-nightly CI
Jul 24, 2026
justinchuby
marked this pull request as ready for review
July 24, 2026 15:33
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the TorchLib ONNX-function implementations in core.py to match recent torch-nightly behavioral changes that were causing CI failures, specifically around aten::arange* integer-dtype edge cases with non-integral inputs and aten::logit clamping when eps > 0.5.
Changes:
- Add an import-time torch behavior probe and route mixed integral/float
arangeinputs through a new helper that computes sequence length in float. - Adjust
aten::arange.start_stepbranching so the “special integral dtype” adjustment applies in the intended cases. - Fix
aten::logitclamping order to matchtorch.clampsemantics foreps > 0.5.
Comment on lines
+59
to
+61
| _INT64_ARANGE_NON_INTEGRAL_USES_FLOAT_LENGTH = ( | ||
| torch.arange(3.1, dtype=torch.int64).numel() == 4 | ||
| ) |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2974 +/- ##
=======================================
Coverage 72.64% 72.64%
=======================================
Files 265 265
Lines 32192 32222 +30
Branches 3038 3044 +6
=======================================
+ Hits 23385 23408 +23
- Misses 7776 7781 +5
- Partials 1031 1033 +2 ☔ View full report in Codecov by Harness. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cherry-pick of commit
6c844d3fromcopilot/follow-up-bincount-index-putto fix torch-nightly CI failures inaten_arangeandaten_logit.aten_arange/aten_arange_start/aten_arange_start_steptorch-nightly changed the semantics of
arangewhen an integraldtypeis requested but one or more inputs are non-integral (e.g.torch.arange(3.1, dtype=torch.int64)now returns 4 elements, not 3). The fix:_INT64_ARANGE_NON_INTEGRAL_USES_FLOAT_LENGTH_arange_integral_dtype_with_non_integral_argsthat computes the length in float then indexes viaRange(0, length, 1)multiplied by step, rather than passing the raw float bounds toop.Rangeaten_logitThe previous two-step clamp (
minthenmax) gave wrong results wheneps > 0.5because1 - eps < eps. Fixed by applyingmax(lower bound) first, thenmin(upper bound), matchingtorch.clamporder.