--- id: depyf version: "0.20.0" license: MIT license_treatment: permissive maintenance: aging --- # depyf — Decompile python functions, from bytecode to source code! License: permissive · Maintenance: aging · Downloads: 3.4M/mo ## 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 above — 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 pip install depyf uv add depyf 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_current - Install friction: low - Maintenance: aging - Downloads: 3.4M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags torch.compile debugging, pytorch bytecode decompiler, inspect torch.compile internals, pytorch compiler visualization, understand torch.compile output, pytorch graph inspection, torch.compile troubleshooting, pytorch-debugging, compiler-inspection, bytecode-decompiler [View on SkillFed](https://skillfed.io/packages/depyf) · [View on PyPI](https://pypi.org/project/depyf/)