Fix arange and logit behavior for torch-nightly CI - #2974
Fix arange and logit behavior for torch-nightly CI#2974Justin Chu (justinchuby) with Copilot wants to merge 4 commits into
Conversation
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.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2974 +/- ##
=======================================
Coverage 72.64% 72.64%
=======================================
Files 265 265
Lines 32192 32241 +49
Branches 3038 3048 +10
=======================================
+ Hits 23385 23421 +36
- Misses 7776 7784 +8
- Partials 1031 1036 +5 ☔ View full report in Codecov by Harness. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
Copilot please compute _INT64_ARANGE_NON_INTEGRAL_USES_FLOAT_LENGTH lazily at first use |
Co-authored-by: justinchuby <11205048+justinchuby@users.noreply.github.com>
Done — the probe is now a |
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.