Skip to content

Conversation

@FindHao
Copy link
Member

@FindHao FindHao commented Nov 20, 2025

This PR includes two improvements to the tritonparse toolset:

1. New IR Extraction Tool (extract_irs.py)

  • Added a command-line tool to extract Triton IRs (TTIR, TTGIR, LLIR, PTX, etc.) from trace logs
  • Supports multiple IR formats and flexible output organization (flat or by-kernel structure)
  • Includes comprehensive documentation in tritonparse/tools/readme.md

2. Fix Logger Undefined Error in Generated Reproducers

  • Fixed NameError: 'logger' is not defined in generated reproducer files
  • Added import logging and logger initialization to reproducer templates
  • The _disable_triton_autotune() function can now access logger without errors

Files Changed:

  • tritonparse/tools/extract_irs.py (new, +244 lines)
  • tritonparse/tools/readme.md (new, +36 lines)
  • tritonparse/reproducer/templates/example.py (+4 lines)
  • **tritonbench.py** (+3 lines)
  • Minor import formatting fixes in placeholder_replacer.py and utils.py

Testing:

  • ✅ All format checks pass (usort, ruff, black)
  • ✅ Generated reproducers now execute without logger errors

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 20, 2025
@meta-codesync
Copy link

meta-codesync bot commented Nov 20, 2025

@FindHao has imported this pull request. If you are a Meta employee, you can view this in D87585819.

Add comprehensive documentation for the extract_irs.py tool that extracts
IR files from NDJSON trace logs. Documentation includes:

- Usage examples with different options
- Argument descriptions (input, line, output, kernel-name)
- List of extracted file types (TTIR, TTGIR, LLIR, PTX, metadata, source)
- Common use cases for IR extraction

This tool helps developers extract and analyze compilation artifacts
from traced kernel executions.
Add logger definition to reproducer templates to fix NameError when
_disable_triton_autotune() function is injected into generated files.
The function uses logger but it was not defined in the template scope.

Changes:
- Add 'import logging' and logger setup to example.py template
- Add 'import logging' and logger setup to tritonbench.py template
- Fix import ordering with usort in affected files
@FindHao FindHao force-pushed the findhao/add_extract_ir_py branch from ea81226 to e14307a Compare November 21, 2025 17:09
@FindHao FindHao changed the title Add extract_irs.py tool with documentation Add IR extraction tool and fix reproducer logger issue Nov 21, 2025
@meta-codesync meta-codesync bot closed this in 91c53e3 Nov 21, 2025
@meta-codesync
Copy link

meta-codesync bot commented Nov 21, 2025

@FindHao merged this pull request in 91c53e3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot. Merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants