Skip to content

Conversation

@tejapulagam
Copy link
Contributor

Fix type subscript handling in binary_subscr_handler

What does this PR do?

This PR addresses issue #2300 by attempting to fix how the interpreter handles type subscripts (e.g., list[int]) in the binary_subscr_handler.

  • Adds logic in the BINARY_SUBSCR handler to check if tos1 is a type. If it is, it uses class_getitem instead of getitem.

  • Adds a test to test_interpreter.py.

Current Problem:
When using thunder.jit() on functions that return parameterized types, the interpreter incorrectly processes type subscripts through the standard getitem path instead of recognizing them as type operations.

Example failing case:

def fn():
    return list[int]

thunder.jit(fn)()  # Currently fails

Open questions:

  • Is class_getitem the correct fix because currently its usage for this results in a notImplementedError?
  • Is there a better way check for the type subscripts because the current check does not work?

@t-vi t-vi enabled auto-merge (squash) August 1, 2025 15:50
Copy link
Collaborator

@t-vi t-vi left a comment

Choose a reason for hiding this comment

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

Supergood, thank you @tejapulagam

@t-vi t-vi merged commit 4a4efd4 into Lightning-AI:main Aug 1, 2025
49 of 50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants