Skip to content

Resolved range variable index method correctness#174210

Closed
trichmo wants to merge 1 commit intopytorch:mainfrom
trichmo:cpython_range_index
Closed

Resolved range variable index method correctness#174210
trichmo wants to merge 1 commit intopytorch:mainfrom
trichmo:cpython_range_index

Conversation

@trichmo
Copy link
Copy Markdown
Contributor

@trichmo trichmo commented Feb 3, 2026

Fixes: #174207

Change is validated by passing cpython test (not currently xfail or skip).

PYTORCH_TEST_WITH_DYNAMO=1 python test/dynamo/cpython/3_13/test_range.py -k test_count
/workspaces/pytorch-devcontainers/pytorch/torch/jit/_script.py:365: DeprecationWarning: `torch.jit.script_method` is deprecated. Please switch to `torch.compile` or `torch.export`.
  warnings.warn(
frames [('total', 1), ('ok', 1)]
.
----------------------------------------------------------------------
Ran 1 test in 1.156s

OK

cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @kadeng @chauhang @amjames @Lucaskabela @jataylo

@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented Feb 3, 2026

🔗 Helpful Links

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

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

⚠️ 1 Awaiting Approval

As of commit 375aab8 with merge base eeb72da (image):

AWAITING APPROVAL - The following workflow needs approval before CI can run:

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

@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented Feb 3, 2026

This PR needs a release notes: label

If your changes are user facing and intended to be a part of release notes, please use a label starting with release notes:.

If not, please add the topic: not user facing label.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "topic: not user facing"

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

@trichmo
Copy link
Copy Markdown
Contributor Author

trichmo commented Feb 3, 2026

@pytorchbot label "topic: not user facing"

@pytorch-bot pytorch-bot Bot added the topic: not user facing topic category label Feb 3, 2026
Copy link
Copy Markdown
Contributor

@Lucaskabela Lucaskabela left a comment

Choose a reason for hiding this comment

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

@trichmo so just to be clear, this test is currently failing on CI but not disabled or skipped yet? Can you link the failing signal? Once done I can approve - just want to make sure the summary contains all the info we need, thanks!

Can you also link which optimization we landed that broke this test?

@trichmo
Copy link
Copy Markdown
Contributor Author

trichmo commented Feb 3, 2026

@Lucaskabela I'm not super familiar with the CI, but does it run all the tests each commit? I am not aware of the failing test on HUD, but I've added a simple repro below which effectively does the same. It is failing for me locally on viable/strict. For simplicity links to HUD of the ghstack pr of interest and gh stack pr tested

The commit I believe caused the regression is here
The representation of range as a list [start, stop, index] is what causes the issue here - rangevariable just needs its own implementation.

import torch

@torch.compile(backend="eager", fullgraph=True)
def test_range_index():
    return range(3).index(1)

# Expected: 1 (value 1 is at position 1 in [0, 1, 2])
# Actual with bug: 2 (because it's computing [0, 3, 1].index(1))
result = test_range_index()
print(f"range(3).index(1) = {result}")
assert result == 1, f"Expected 1, got {result}"

@guilhermeleobas
Copy link
Copy Markdown
Collaborator

I'm not super familiar with the CI, but does it run all the tests each commit? I am not aware of the failing test on HUD

For the CPython tests, one need to trigger the text exec by adding the label ciflow/dynamo.

@guilhermeleobas guilhermeleobas added the ciflow/dynamo Trigger jobs ran periodically on main for dynamo tests label Feb 3, 2026
@Lucaskabela
Copy link
Copy Markdown
Contributor

Great thanks for adding the tag - think the CI is telling us there are a few failing test we can update to be passing - let's do this then reping :)

@trichmo
Copy link
Copy Markdown
Contributor Author

trichmo commented Feb 3, 2026

@Lucaskabela I think @guilhermeleobas has already tackled these unrelated failures (unexpected success).
See his PR
Let me know if you'd like me to wait for his changes to hit viable/strict - I can rebase and rerun the tests if so.

The failures are showing as the files he removed from the dynamo xfails:

  1. FAILED [0.0894s] dynamo/cpython/3_13/test_userlist.py::UserListTest::test_subscript - RuntimeError: Unexpected success, please remove test/dynamo_expected_failures/CPython313-test_userlist-UserListTest.test_subscript

  2. FAILED [17.5689s] dynamo/cpython/3_13/test_collections.py::TestCollectionABCs::test_Sequence_mixins - RuntimeError: Unexpected success, please remove test/dynamo_expected_failures/CPython313-test_collections-TestCollectionABCs.test_Sequence_mixins

  3. FAILED [0.1170s] dynamo/cpython/3_13/test_userdict.py::UserDictTest::test_write - RuntimeError: Unexpected success, please remove test/dynamo_expected_failures/CPython313-test_userdict-UserDictTest.test_write

@guilhermeleobas
Copy link
Copy Markdown
Collaborator

@trichmo just rebase and CI will be green again

@trichmo trichmo force-pushed the cpython_range_index branch from 18077c3 to 375aab8 Compare February 4, 2026 03:35
@pytorch-bot pytorch-bot Bot removed the ciflow/dynamo Trigger jobs ran periodically on main for dynamo tests label Feb 4, 2026
@trichmo trichmo requested a review from Lucaskabela February 4, 2026 14:45
@albanD albanD requested a review from anijain2305 February 4, 2026 15:27
@albanD albanD added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label Feb 4, 2026
@trichmo
Copy link
Copy Markdown
Contributor Author

trichmo commented Feb 4, 2026

@pytorchbot merge

@pytorch-bot pytorch-bot Bot added the ciflow/trunk Trigger trunk jobs on your pull request label Feb 4, 2026
@pytorchmergebot
Copy link
Copy Markdown
Collaborator

Merge started

Your 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

Advanced Debugging
Check the merge workflow status
here

pytorchmergebot pushed a commit that referenced this pull request Feb 13, 2026
Resolves some xfails that made it in without dynamo ci test.
Fixes repr logic that passed dynamo ci before merge. Fixing similar root issue found in [this PR](#174210)

Pull Request resolved: #174415
Approved by: https://github.com/guilhermeleobas
radeksm pushed a commit to radeksm/pytorch that referenced this pull request Feb 20, 2026
Fixes: pytorch#174207

Change is validated by passing cpython test (not currently xfail or skip).

```
PYTORCH_TEST_WITH_DYNAMO=1 python test/dynamo/cpython/3_13/test_range.py -k test_count
/workspaces/pytorch-devcontainers/pytorch/torch/jit/_script.py:365: DeprecationWarning: `torch.jit.script_method` is deprecated. Please switch to `torch.compile` or `torch.export`.
  warnings.warn(
frames [('total', 1), ('ok', 1)]
.
----------------------------------------------------------------------
Ran 1 test in 1.156s

OK
```

Pull Request resolved: pytorch#174210
Approved by: https://github.com/Lucaskabela
libohao1201 pushed a commit to libohao1201/pytorch that referenced this pull request Mar 2, 2026
Fixes: pytorch#174207

Change is validated by passing cpython test (not currently xfail or skip).

```
PYTORCH_TEST_WITH_DYNAMO=1 python test/dynamo/cpython/3_13/test_range.py -k test_count
/workspaces/pytorch-devcontainers/pytorch/torch/jit/_script.py:365: DeprecationWarning: `torch.jit.script_method` is deprecated. Please switch to `torch.compile` or `torch.export`.
  warnings.warn(
frames [('total', 1), ('ok', 1)]
.
----------------------------------------------------------------------
Ran 1 test in 1.156s

OK
```

Pull Request resolved: pytorch#174210
Approved by: https://github.com/Lucaskabela
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk Trigger trunk jobs on your pull request Merged module: dynamo open source topic: not user facing topic category triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Regression in Cpython Test test_range.py test_count

6 participants