🕵️ SicherheitslückenHak5: Hackers Just Poisoned the Rust Supply Chain | Threat Wire(01.09.2026 um 14:00 Uhr)
🕵️ SicherheitslückenHak5: Hackers Found a Way Into Humanoid Robots | Threat Wire(04.09.2026 um 15:04 Uhr)
🔧 AI Nachrichten Bits und so #1021 (Passwort für Laufwerk)(31.08.2026 um 22:15 Uhr)
🔧 AI Nachrichten Bits und so #1022 (Wie Weißbier)(06.09.2026 um 20:39 Uhr)
🍏 iOS / Mac OSHue-App 6.0 ist da: das sind die Neuerungen(07.09.2026 um 17:21 Uhr)
🕵️ SicherheitslückenHak5: Hackers Just Poisoned the Rust Supply Chain | Threat Wire(01.09.2026 um 14:00 Uhr)
🕵️ SicherheitslückenHak5: Hackers Found a Way Into Humanoid Robots | Threat Wire(04.09.2026 um 15:04 Uhr)
🔧 AI Nachrichten Bits und so #1021 (Passwort für Laufwerk)(31.08.2026 um 22:15 Uhr)
🔧 AI Nachrichten Bits und so #1022 (Wie Weißbier)(06.09.2026 um 20:39 Uhr)
🍏 iOS / Mac OSHue-App 6.0 ist da: das sind die Neuerungen(07.09.2026 um 17:21 Uhr)

💾 Downloads 🕛 kürzlich 3 Min Lesezeit
0

ciflow/trunk/186323: Type annotations (and runtime fallout) for torch/__init__.py (#186323)

↗ Quelle (GitHub · github.com)
🗣️ Stimme:
🐙
$ git clone https://github.com/pytorch/pytorch.git

Summary:

Pull Request resolved: #186323


Removes # mypy: allow-untyped-defs from torch/__init__.py (and adds a matching pyrefly.toml sub-config) and reworks how the magic methods on SymInt, SymFloat, and SymBool are typed.


Previously each class carried a long hand-written list of placeholder stubs like def __add__(self, other) -> "SymInt": .... These didn't model the actual promotion rules — e.g. SymInt + float returns SymFloat, Tensor + SymT returns Tensor, and arithmetic on SymBool promotes to SymInt. Three new generic mixins encode those rules once and are reused across all three classes:



  • _SymTypingMagicAlsoBool[_PrimType, _BecomesIntPrimType, _BecomesIntSymType, _FloatPromotionType] — comparisons (==, !=, <, <=, >, >=) and the bool-promoting arithmetic ops (+, -, *, plus their r-variants), with _FloatPromotionType controlling whether the result can be SymFloat.

  • _SymTypingMagic[_PrimType, _SymType, _FloatPromotionType] — the rest of the numeric magic methods (abs, neg, floor, ceil, trunc, mod, lshift/rshift, pow_by_natural, the __sym_*__ math wrappers, __int_truediv__ / __int_floordiv__, etc.).

  • _SymTypingMagicBitwise[_BitwiseLikeType]__and__, __or__, __xor__ and their reflected forms.


SymInt/SymFloat/SymBool then become small concrete subclasses parameterized over the right operand and result types (e.g. SymFloat's float-promotion type is _Never since it doesn't promote further).


Runtime side, sym_node.py gains a real xor entry in bitwise_ops, only_bool_magic_methods, and the dispatch table (with a new _sympy_xor), and also_bool_magic_methods is widened from just {"eq"} to the full comparison set {"eq", "ge", "gt", "le", "lt", "ne"} so the methods installed at runtime line up with what the new mixin advertises. A magic_methods_excl helper set is added for the remainder.


Other fallout from removing allow-untyped-defs:



  • PySymType is exported from torch._C stubs and threaded into the asymmetric comparison-op signatures generated by tools/pyi/gen_pyi.py, so Tensor.__lt__(SymInt) etc. type-check.

  • SymInt.has_hint(), SymInt.hint, SymInt.constant move from ad-hoc .node.* access to typed property accessors; definitely_true_hint/etc. are updated to use them.

  • SymNode.shape_env is Optional, so callers in symbolic_shapes.py now raise explicit AssertionError("shape_env should not be None") instead of relying on it being set. A couple of maybe_as_int() / maybe_as_float() call sites are tightened with walrus assignment to avoid calling the method twice.

  • # pyrefly: ignore[missing-attribute] is added where SymInt.node is duck-typed across SymNode | NestedIntNode | ConstantIntNode | LocalIntNode and the attribute only exists on some.


Review order: start with torch/__init__.py — the three new mixins and the rewritten SymInt/SymFloat/SymBool definitions are where the design lives. Then torch/fx/experimental/sym_node.py for the runtime registration of xor and the broadened also_bool_magic_methods. Everything else is small call-site adjustments to satisfy the stricter typing.


Test Plan:

CI.


Authored with Claude.


Reviewed By: bobrenjc93


Differential Revision: D106389841

Vollständiger Original-Bericht
Ausführliche Details, Code-Beispiele & Hersteller-Stellungnahme auf github.com.
↗ Original-Artikel auf github.com lesen
Wie bewertest du diesen Beitrag?
1 Klick Feedback
Teilen mit Netzwerk & Team:

Community-Analysen & Experten-Meinungen 0

Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
Community Pulse: Relevanz-Einschätzung
1 Klick Experten-Votum
🔴 Akute Relevanz 0%
🟡 In Evaluierung 0%
🟢 Keine Auswirkung 0%
Spannende Innovation 0%
Verwandte Story-Cluster & Quellen (Vektor-KI)
Port 8095 Engine
1 Quelle
Hackers Just Poisoned the Rust Supply Chain | Threat Wire
1 Quelle
Hackers Found a Way Into Humanoid Robots | Threat Wire
1 Quelle
Bits und so #1021 (Passwort für Laufwerk)
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten ciflow/trunk/186323: Type annotations (and runtime fallout) for torch/__init__.py (#186323)

Thematisch verwandte Begriffe: ciflowtrunk186323, Type, annotations, runtime · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...