Skip to content

Commit 8fe51e2

Browse files
Add an option to remove debug info from the module (#6837)
Sometimes having minimal module dump without location info clobbering the IR is usefull.
1 parent 61d3ac6 commit 8fe51e2

File tree

5 files changed

+7
-0
lines changed

5 files changed

+7
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ See [`python/triton/knobs.py`](python/triton/knobs.py) for the full list of conf
212212
- `TRITON_OVERRIDE_DIR` specifies the directory from which to load the IR/ptx/amdgcn files when `TRITON_KERNEL_OVERRIDE` is set to 1.
213213
- `TRITON_F32_DEFAULT` sets the default input precision of `tl.dot` when using 32-bit floats, which can be either `ieee`, `tf32`, or `tf32x3`.
214214
- `TRITON_FRONT_END_DEBUGGING=1` disables exception wrapping when an error occurs in the compiler frontend, allowing the full stack trace to be seen.
215+
- `TRITON_STRIP_DEBUG_INFO` removes all debug information from the module, including location information
215216

216217
N.B. Some of these environment variables don't have a knob in `knobs.py`-- those are only relevant to the C++ layer(s), hence they don't exist in the python layer.
217218

python/src/passes.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ void init_triton_analysis(py::module &&m) {
2525

2626
void init_triton_passes_common(py::module &&m) {
2727
using namespace mlir;
28+
ADD_PASS_WRAPPER_0("add_strip_debug_info", createStripDebugInfoPass);
2829
ADD_PASS_WRAPPER_0("add_sccp", createSCCPPass);
2930
ADD_PASS_WRAPPER_0("add_symbol_dce", createSymbolDCEPass);
3031
ADD_PASS_WRAPPER_0("add_inliner", createInlinerPass);

python/triton/knobs.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@ class compilation_knobs(base_knobs):
358358
disable_line_info: env_bool = env_bool("TRITON_DISABLE_LINE_INFO")
359359
front_end_debugging: env_bool = env_bool("TRITON_FRONT_END_DEBUGGING")
360360
allow_non_constexpr_globals: env_bool = env_bool("TRITON_ALLOW_NON_CONSTEXPR_GLOBALS")
361+
strip_debug_info: env_bool = env_bool("TRITON_STRIP_DEBUG_INFO")
361362
listener: Union[CompilationListener, None] = None
362363

363364

third_party/amd/backend/compiler.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,8 @@ def path_to_rocm_lld():
195195
def make_ttir(mod, metadata, options):
196196
pm = ir.pass_manager(mod.context)
197197
pm.enable_debug()
198+
if knobs.compilation.strip_debug_info:
199+
passes.common.add_strip_debug_info(pm)
198200
passes.common.add_inliner(pm)
199201
passes.ttir.add_rewrite_tensor_pointer(pm)
200202
passes.ttir.add_rewrite_tensor_descriptor_to_pointer(pm)

third_party/nvidia/backend/compiler.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,8 @@ def load_dialects(self, ctx):
207207
def make_ttir(mod, metadata, opt, capability):
208208
pm = ir.pass_manager(mod.context)
209209
pm.enable_debug()
210+
if knobs.compilation.strip_debug_info:
211+
passes.common.add_strip_debug_info(pm)
210212
passes.common.add_inliner(pm)
211213
passes.ttir.add_rewrite_tensor_pointer(pm)
212214
if capability // 10 < 9:

0 commit comments

Comments
 (0)