Trace¶
tileops.trace.trace — the in-kernel timeline tracer: annotate a kernel body,
wire the markers into a @tilelang.jit builder, run, and export a timeline.
For a walkthrough, see the In-Kernel Timeline Trace guide.
The trace namespace; use the singleton trace.
enabled
property
¶
Whether tracing is on for this process (default False).
Example
output
property
¶
Output directory for dumped artifacts (default "debug").
Example
enable
¶
Turn tracing on for this process and set the output directory.
Call before any traced kernel is built: a builder reads enabled at build time.
Parameters:
-
output(str, default:'debug') –Directory for dumped artifacts (created on first
dump). Defaults to"debug"(gitignored).
group
¶
Declare the logical work-group enclosed markers belong to.
Governs only who records (the elected writer is tx == lead); the
enclosed compute still runs on all threads.
Parameters:
-
name(str) –Work-group name, interned to a stable group id.
-
lead(int) –Branch-baseline thread id of the electing writer.
Returns:
-
GroupScope–A
withcontext manager.
range
¶
Time a span: RANGE_BEGIN on enter, RANGE_END on exit.
Parameters:
-
name(str) –Range name, interned to a stable event id.
-
lane(str, default:DEFAULT_LANE) –Render sub-lane, interned dynamically (default
"main"). -
payload–Optional i32 tag recorded in both BEGIN and END — a Python
intor a runtime PrimExpr (e.g. a loop index).Nonerecords 0.
Returns:
-
RangeScope–A
withcontext manager.
range_start
¶
Open a range explicitly (use when with does not fit the control flow).
Parameters:
-
name(str) –Range name, interned to a stable event id.
-
lane(str, default:DEFAULT_LANE) –Render sub-lane, interned dynamically (default
"main"). -
payload–Optional i32 tag, as for
range.
Returns:
-
AnnoToken–A token to pass to
range_end.
range_end
¶
Close the range opened for tok (None no-ops).
Parameters:
-
tok(AnnoToken | None) –The token returned by
range_start.
Example
record
¶
Emit a single instant event (a zero-width mark).
Parameters:
-
name(str) –Event name, interned to a stable event id.
-
payload–Optional i32 tag, as for
range. -
lane(str, default:DEFAULT_LANE) –Render sub-lane, interned dynamically (default
"main").
Example
dag
¶
Declare a dependency arrow from one named range to another.
Call once in the kernel body. Emits no device marker; at render time each
CTA's src_name slices are paired with its dst_name slices in
timestamp order, drawing one arrow per pair.
Parameters:
-
src_name(str) –Source (producer-side) range name.
-
dst_name(str) –Destination (consumer-side) range name.
Example
out_idx
¶
The out_idx for n_outputs real outputs, plus the trailing slots when traced.
Parameters:
-
n_outputs(int) –Number of real (non-
slots) outputs. -
traced(bool | None, default:None) –Whether this build is traced;
Nonereadsenabled. A cached builder must pass it and include it in its cache key.
Returns:
-
list[int]–Negative output indices for
@tilelang.jit.
finalize
¶
Lower the markers when traced, else strip them. Pass the same traced as to
out_idx.
Parameters:
-
primfunc–The built kernel; its body carries
trace.*markers. -
traced(bool | None, default:None) –As for
out_idx. -
max_events(int, default:MAX_EVENTS_DEFAULT) –Per-slot event capacity when lowering.
Returns:
-
–
A
PrimFuncready for@tilelang.jit(with a trailingslots -
–
output when traced).
lower
¶
Materialize the markers and append the slots output, whatever the switch says.
Parameters:
-
primfunc–The built kernel; its body carries
trace.*markers. -
max_events(int, default:MAX_EVENTS_DEFAULT) –Per-slot event capacity (compile-time cursor bound).
Returns:
-
–
The lowered
PrimFuncwith a trailingslotsint64 output.
Example
strip
¶
No-op every marker, whatever the switch says; the generated CUDA is identical to an un-instrumented build.
Parameters:
-
primfunc–The built kernel; its body may carry
trace.*markers.
Returns:
-
–
A
PrimFuncwith markers no-opped, signature unchanged.
Example
run
¶
Run a kernel and, when tracing is on, dump its timeline.
A traced build's trailing slots output is always split off; with tracing on it
is decoded and written through dump, a fresh file each call.
Parameters:
-
compiled–A compiled kernel, traced or not; how it was built decides whether it carries
slots. -
inputs(tuple) –Tuple of positional tensors to pass to
compiled. -
stem(str) –Descriptive file stem (op name + shape); see
dump. -
traced(bool | None, default:None) –Whether
compiledwas built traced;Nonereads it fromcompiled.
Returns:
-
–
The kernel's real outputs: a single tensor, or a tuple in order.
decode
¶
Decode a returned slots tensor into render-ready events.
Parameters:
-
compiled–The compiled traced kernel (carries the host maps).
-
slots–The trailing
slotsint64 tensor the kernel returned.
Returns:
-
list–A flat list of
Slice/Instantevents.
dump
¶
Write events as an HTML timeline at {output}/{stem}, or {stem}_1, _2,
... when taken.
Parameters:
-
events(list) –Event list from
decode. -
compiled–The compiled traced kernel (carries the host maps).
-
stem(str) –File stem (no directory, no extension), e.g. op name + shape.
Returns:
-
str–The base path written (no extension);
{base}.htmlexists.
export_html
¶
Write events as a self-contained Plotly HTML timeline.
Parameters:
-
events(list) –Event list from
decode. -
path(str) –Destination
.htmlpath. -
compiled–The compiled traced kernel (carries the host maps).
-
title(str, default:'') –Base figure title; the CTA index is appended per tab.
-
sm_clock_ghz(float, default:1.5) –Locked SM clock in GHz for the
~nshover column.