Skip to Main Content
Talk Intermediate BSD-3-Clause (PyTorch), Talk Materials License CC BY-SA 4.0

From First PR to PyTorch: Debugging Python Semantics in a Large Open-Source Framework

Proposal status is Review Pending
Session Description

Contributing to PyTorch taught me that even small Python compatibility issues can require understanding compiler internals, reproducing subtle failures, and writing tests that protect existing behavior.

In this talk, I'll share my journey contributing to PyTorch's TorchDynamo, the infrastructure behind torch.compile, through three contributions that landed upstream and one ongoing pull request.

What I'll cover:

  • Getting started through CPython tests (PR #196587): My first landed contribution involved porting CPython's test_enumerate tests into TorchDynamo's compatibility suite. I'll discuss adapting the tests, handling expected failures, and incorporating maintainer feedback.

  • Compiler correctness and tensor guards (PR #197224): How Tensor.storage_offset() required a property-specific guard to prevent compiled code from reusing an invalid constant when tensor storage offsets changed.

  • Debugging Python object reconstruction (PR #198857): How Dynamo's object.__reduce_ex__ polyfill could reconstruct list and dictionary subclasses without preserving their contents. I'll walk through the bug, the small implementation change, and the regression tests that helped validate it.

  • Real-world upstream review (PR #197415, ongoing): What I learned while working on exception-note handling, discussing side-effect ownership and Python semantics with maintainers, and coordinating changes with related upstream work.

I'll also share practical lessons about reproducing bugs, comparing eager and compiled behavior, using CPython tests, interpreting CI failures, and responding to code reviews.

The goal is to show how meaningful contributions to a large open-source framework grow from careful investigation, incremental fixes, and collaboration—not necessarily from building major new features.

Attendees will leave with a practical approach to starting and improving their own open-source contributions.

Key Takeaways
  • How to find manageable entry points into large open-source projects such as PyTorch.

  • How to debug Python semantic differences between eager execution and torch.compile.

  • Why compiler guards are essential for correctness when runtime assumptions change.

  • How regression tests uncover subtle object reconstruction and compatibility bugs.

  • How to handle maintainer feedback, CI failures, upstream dependencies, and ongoing PR reviews.

References

Session Categories

Contributing to FOSS
Engineering practice - productivity, debugging
Talk License: BSD-3-Clause (PyTorch), Talk Materials License CC BY-SA 4.0
Speakers are hidden and anonymized for this event.