skillfed

depyf

Decompile python functions, from bytecode to source code!

depyf v0.20.0 3.4M downloads/30d#2,640 on PyPI815
Permissive license MIT AGING released

What it is and what it does

depyf is a debugging and introspection tool for PyTorch's torch.compile compiler. It intercepts the bytecode and intermediate representations generated during compilation and writes them to disk in human-readable form, letting you see what torch.compile is actually doing to your code. The tool outputs the original source, transformed Python code, raw bytecode (loadable via dill), and the computation graphs at each optimization stage (captured graph, joint graph, forward/backward graphs, and compiled kernels).

The package is designed for machine learning researchers and practitioners who need to understand, debug, or optimize code compiled with torch.compile. It wraps your code in context managers that intercept compilation artifacts, and optionally integrates with debuggers so you can step through the compiled code. It requires PyTorch 2.2.0 or newer and depends on astor and dill for code generation and bytecode serialization.

Use it for:

  • Debug why torch.compile is not optimizing a function as expected by inspecting the captured and optimized graphs.
  • Understand the bytecode transformations torch.compile applies to your code to identify performance bottlenecks.
  • Inspect forward and backward graphs generated by AOTAutograd to verify gradient computation correctness.
  • Step through compiled code in a debugger to trace execution flow and set breakpoints in generated functions.
  • Analyze compiled CPU/GPU kernels produced by Inductor to understand hardware-level optimizations.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Decompile and inspect the internal bytecode and optimization graphs generated by PyTorch's torch.compile, converting compiled code back to readable Python source and intermediate representations.

Yes, if you use torch.compile and need to understand or debug its behavior. The tool fills a genuine gap—existing decompilers fail on PyTorch bytecode—and is backed by the PyTorch team. The aging maintenance status (305 days since last release) is a minor concern, but the repository is not archived and remains active. Install only if you have PyTorch>=2.2.0 available.

Install

depyf on PyPI

pip

pip install depyf

uv

uv add depyf

poetry

poetry add depyf

Installing depyf

Before you install

Low friction: pure Python wheel with only two runtime dependencies (astor, dill). Maintenance status is aging—last release was 305 days ago—but the repository remains active with 815 stars and backed by PyTorch team collaboration.

License in practice

MIT license is permissive; you can use, modify, and distribute depyf freely in commercial and private projects without restriction.

Quickstart

pip install depyf

import depyf

with depyf.prepare_debug("./debug_output"):
    # wrap your torch.compile code here
    pass

Requires PyTorch>=2.2.0 (PyTorch nightly recommended). The package inspects internal torch.compile artifacts that depend on very recent PyTorch features.

Verify before relying

  • Whether depyf works reliably with PyTorch versions between 2.2.0 and the current stable release, or if nightly is truly necessary for most use cases.
  • Performance overhead or memory impact when running code under depyf.prepare_debug() or depyf.debug() context managers.
  • Compatibility with custom torch.compile backends or non-standard compilation configurations.

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.7)
Install friction low — pure-Python wheel
Runtime dependencies 2 — astor, dill
Maintenance aging — 305 days since the last release
Last repo commit
First released
Downloads 3,386,060/month — #2,640 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: depyf-0.20.0-py3-none-any.whl

Tags

torch.compile debuggingpytorch bytecode decompilerinspect torch.compile internalspytorch compiler visualizationunderstand torch.compile outputpytorch graph inspectiontorch.compile troubleshooting
pytorch-debuggingcompiler-inspectionbytecode-decompiler

More Artificial Intelligence packages