pytorch/pytorch

Set-family VariableTracker hierarchy diverges from CPython

Aperta

#192.874 aperta il 11 ago 2026

 (8 commenti) (0 reazioni) (0 assegnatari)Python (28.880 fork)batch import
bot-triagedenhancementgood first issuemodule: dynamooncall: pt2triaged

Metriche repository

Star
 (102.396 stelle)
Metriche merge PR
 (Merge medio 1g 10h) (42 PR mergiate in 30 g)

Descrizione

As part of a larger effort to align Dynamo with CPython semantics, this issue proposes fixing incorrect inheritance relationships between VariableTrackers. For instance, FrozensetVariable and SetVariable share an inheritance but one is not a subclass of the other in CPython.

The table below was created by claude with inheritances that do not match CPython.

  ┌─────────────────────────────────────────────────────────────────────────────┬───────────────────────────────────────────────────────────────────────────────┐
  │                            VT subclass relation                             │                                CPython reality                                │
  ├─────────────────────────────────────────────────────────────────────────────┼───────────────────────────────────────────────────────────────────────────────┤
  │ FrozensetVariable(SetVariable)                                              │ frozenset ⊄ set                                                               │
  ├─────────────────────────────────────────────────────────────────────────────┼───────────────────────────────────────────────────────────────────────────────┤
  │ DictKeySetVariable(SetVariable)                                             │ dict_keys ⊄ set                                                               │
  ├─────────────────────────────────────────────────────────────────────────────┼───────────────────────────────────────────────────────────────────────────────┤
  │ OrderedSetVariable(SetVariable)                                             │ OrderedSet ⊄ set (pure-Python, MutableSet ABC)                                │
  ├─────────────────────────────────────────────────────────────────────────────┼───────────────────────────────────────────────────────────────────────────────┤
  │ TupleIteratorVariable(ListIteratorVariable)                                 │ tuple_iterator ⊄ list_iterator                                                │
  ├─────────────────────────────────────────────────────────────────────────────┼───────────────────────────────────────────────────────────────────────────────┤
  │ DequeIteratorVariable(ListIteratorVariable)                                 │ _deque_iterator ⊄ list_iterator                                               │
  ├─────────────────────────────────────────────────────────────────────────────┼───────────────────────────────────────────────────────────────────────────────┤
  │ DequeReverseIteratorVariable(DequeIteratorVariable)                         │ _deque_reverse_iterator ⊄ _deque_iterator                                     │
  ├─────────────────────────────────────────────────────────────────────────────┼───────────────────────────────────────────────────────────────────────────────┤
  │ UserMethodVariable(UserFunctionVariable)                                    │ MethodType ⊄ FunctionType                                                     │
  ├─────────────────────────────────────────────────────────────────────────────┼───────────────────────────────────────────────────────────────────────────────┤
  │ WrapperUserMethodVariable(WrapperUserFunctionVariable)                      │ same                                                                          │

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

Guida contributor