Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Triton] Generate local MLIR reproducers when possible #5155

Merged
merged 5 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,9 @@ For detailed instructions on how to debug Triton's frontend, please refer to thi
kernels. Use `MLIR_ENABLE_DUMP=kernelName` to dump for a specific kernel only.
- Triton cache can interfere with the dump. In cases where `MLIR_ENABLE_DUMP=1` does not work, try cleaning your triton cache: `rm -r ~/.triton/cache/*`
- `LLVM_IR_ENABLE_DUMP=1` dumps the IR before every pass run over the LLVM IR.
- `TRITON_REPRODUCER_PATH=<reproducer_path>` will generate an MLIR file at `<reproducer_path>`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need that to generate the reproducer when there is a crash? Can we have the crash one by default?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I can change that

before each MLIR compiler stage. If any of the stages crash, an additional `crash.<reproducer_path>`
file is generated containing a local crash reproducer.
- `TRITON_INTERPRET=1` uses the Triton interpreter instead of running on the
GPU. You can insert Python breakpoints in your kernel code!
- `TRITON_ENABLE_LLVM_DEBUG=1` passes `-debug` to LLVM, printing a lot of
Expand Down
7 changes: 7 additions & 0 deletions python/src/ir.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1707,7 +1707,14 @@ void init_triton_ir(py::module &&m) {
auto anchorName = self.getOpAnchorName();
auto passes = self.getPasses();
Operation *op = mod.getOperation();
// Save a reproducer for the current pass manager invocation
// immediately.
makeReproducer(anchorName, passes, op, reproducerPath);
// But if the pass manager crashes, attempt to generate a local
// reproducer.
mod.getContext()->disableMultithreading();
self.enableCrashReproducerGeneration("crash." + reproducerPath,
/*genLocalReproducer=*/true);
}

if (triton::tools::getBoolEnv("TRITON_ENABLE_LLVM_DEBUG")) {
Expand Down
Loading