tilelang.tools.lower_trace.core¶
IR lower tracing implemented as a per-compilation instrumentation tool.
enable() only registers configuration for future compilations. Every
compiler front door snapshots that configuration into a distinct
LowerTraceSession which owns its records, pass numbering, pipeline scopes,
and report lifecycle. No TVM global function or default PassContext is
patched.
Attributes¶
Classes¶
Result of running a single compiler pass or codegen boundary. |
|
All mutable lower-trace state for one logical compilation. |
Functions¶
Return the most recent session in the current execution context. |
|
Return lower trace state for the current compile context, if present. |
|
Create an instrument for the active session (standalone if necessary). |
|
|
Enable lower tracing for future compile sessions. |
|
Stop adding lower trace to future compilations. |
|
Reset only the compile session active in the current execution context. |
Module Contents¶
- tilelang.tools.lower_trace.core.STATUS_COMPLETED = 'completed'¶
- tilelang.tools.lower_trace.core.STATUS_FAILED = 'failed'¶
- tilelang.tools.lower_trace.core.STATUS_SKIPPED = 'skipped'¶
- tilelang.tools.lower_trace.core.STATUS_CODEGEN = 'codegen'¶
- class tilelang.tools.lower_trace.core.LowerRecord¶
Result of running a single compiler pass or codegen boundary.
- phase: str¶
- name: str¶
- index: int¶
- before_text: str¶
- after_text: str¶
- add_lines: int = 0¶
- del_lines: int = 0¶
- status: str = 'completed'¶
- error_msg: str = ''¶
- depth: int = 0¶
- parent_index: int | None = None¶
- class tilelang.tools.lower_trace.core.LowerTraceSession(*, mode, trace_dir, codegen_output=_UNSET)¶
Bases:
tilelang.instrumentation.PassInstrumentationToolAll mutable lower-trace state for one logical compilation.
- Parameters:
mode (str | None)
trace_dir (str)
codegen_output (str | None | object)
- mode¶
- trace_dir¶
- codegen_output¶
- records: list[LowerRecord] = []¶
- section_cache: dict[tuple[str, int], str]¶
- pass_index = 0¶
- pipeline_count = 0¶
- script_dir: str | None = None¶
- run_dir: str | None = None¶
- ensure_script_dir()¶
- Return type:
str
- ensure_run_dir()¶
- Return type:
str
- get_codegen_output_path()¶
- Return type:
str | None
- allocate_index()¶
- Return type:
int
- append_record(record)¶
- Parameters:
record (LowerRecord)
- Return type:
None
- save_raw_files(record)¶
Persist snapshots without allowing tracing I/O to fail compilation.
- Parameters:
record (LowerRecord)
- Return type:
None
- update_html_link(run_html_path)¶
- Parameters:
run_html_path (str)
- Return type:
None
- flush_html()¶
- Return type:
None
- create_pass_instrument()¶
Create fresh callback state for one TVM PassContext.
- Return type:
tilelang.instrumentation.StackedPassInstrument | None
- pipeline_scope(base_phase)¶
Return the scope entered around one backend pass pipeline.
- Parameters:
base_phase (str)
- Return type:
collections.abc.Generator[None, None, None]
- abort_active_instruments(error)¶
- Parameters:
error (BaseException)
- Return type:
None
- run_codegen(event, next_call)¶
Observe or wrap codegen, delegating to
next_callexactly once.- Parameters:
event (tilelang.instrumentation.CodegenEvent)
next_call (collections.abc.Callable[[], Any])
- Return type:
Any
- finish(error)¶
Finalize this tool after its owning compile session exits.
- Parameters:
error (BaseException | None)
- Return type:
None
- reset()¶
Clear this session’s records; primarily useful to unit tests.
- Return type:
None
- tilelang.tools.lower_trace.core.get_last_session()¶
Return the most recent session in the current execution context.
- Return type:
LowerTraceSession | None
- tilelang.tools.lower_trace.core.current_lower_trace_session()¶
Return lower trace state for the current compile context, if present.
- Return type:
LowerTraceSession | None
- tilelang.tools.lower_trace.core.create_pass_instrument()¶
Create an instrument for the active session (standalone if necessary).
- Return type:
tilelang.instrumentation.StackedPassInstrument
- tilelang.tools.lower_trace.core.enable(*, mode=_UNSET, trace_dir=_UNSET, codegen_output=_UNSET)¶
Enable lower tracing for future compile sessions.
An already-running compilation keeps the immutable configuration snapshot with which it started. Calling
enableordisabletherefore never mutates another kernel’s active instrumentation.- Return type:
None
- tilelang.tools.lower_trace.core.disable()¶
Stop adding lower trace to future compilations.
- Return type:
None
- tilelang.tools.lower_trace.core.reset()¶
Reset only the compile session active in the current execution context.
- Return type:
None