Compiler Options
Code Generation Options
These flags control how TT-Lang compiles operations. Pass them on the command line,
or print the list with --ttl-help:
python my_kernel.py --ttl-help
python my_kernel.py --no-ttl-maximize-dst
Flag |
Default |
Description |
|---|---|---|
|
enabled |
Partition compute iteration spaces into subblocks that maximize DST register utilization, and reorder tile operations within sync regions to group by kind. Disabling falls back to per-tile synchronization. |
|
enabled |
Emit FPU binary elementwise ops ( |
|
enabled |
Emit |
|
disabled |
Refine DFB reserve/push to per-subblock granularity, enabling |
|
enabled |
Combine consecutive |
|
disabled |
Error at compile time if a |
|
enabled |
Insert compiler-allocated intermediate DFBs when an operation requires DFB-attached inputs or fusion would read a source after its DFB is released. When disabled, the compiler emits an error if either materialization is required. |
|
disabled |
Clone each TTKernel function whose control flow branches on a core coordinate once per launch coordinate ( |
Other Ways to Set These
Besides the command line, the same flags can be set through three other mechanisms. When the same flag is set in multiple places, higher-priority sources win and unmentioned flags fall through from lower levels:
Priority |
Mechanism |
Example |
|---|---|---|
1 (lowest) |
|
— |
2 |
|
|
3 |
|
|
4 (highest) |
Command-line arguments ( |
|
The options keyword can also be passed at call time to override the decorator
for a single invocation:
my_kernel(tensor_a, tensor_b, options="--no-ttl-fpu-binary-ops")
Compute Configuration
These two parameters are set on the @ttl.operation decorator (not via command-line
flags) and control the TTNN compute kernel hardware configuration:
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
Enable f32 accumulation in the DST register file. When |
|
|
|
Enable full DST synchronization (single-buffering mode). Doubles DST capacity (f32: 8, f16/bf16: 16) at the cost of a full sync between math and pack threads. |
@ttl.operation(grid=(2, 2), fp32_dest_acc_en=True, dst_full_sync_en=False)
def my_kernel(a, b): ...
Environment Variables
These environment variables control compilation behavior and diagnostic output. They are independent of the code generation flags above.
Variable |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
Compile kernels but do not execute on hardware. |
|
file path |
(unset) |
Write the pre-optimization MLIR module to this file. |
|
file path |
(unset) |
Write the post-optimization MLIR module to this file. |
|
any value |
(unset) |
Print the IR after every pass in the pipeline. Output is very large; redirect to a file. |
|
|
|
Include source locations in printed MLIR (locations are always tracked internally for error messages). |
|
|
|
Include raw MLIR diagnostics in error output. |
|
|
|
Force |
Profiling-related environment variables (TTLANG_AUTO_PROFILE,
TTLANG_PERF_DUMP, TTLANG_PERF_SERV, TTLANG_SIGNPOST_PROFILE,
TTLANG_PROFILE_CSV) are documented in the
Performance Tools reference.
Other Decorator Parameters
The @ttl.operation decorator also accepts these parameters for operation structure
and layout:
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
|
(required) |
Compute grid dimensions, e.g., |
|
|
|
Lambda functions for tile indexing |
|
|
|
|
|
|
|
Number of output tensor arguments |
|
|
|
Memory space for dataflow buffers: |
|
|
|
Use tiled tensor layout |
ttlang-opt Pass Reference
ttlang-opt is the standalone MLIR optimizer driver for the TTL dialect, used
primarily for compiler development and testing. It accepts all standard
mlir-opt flags (run ttlang-opt --help for the full list) plus the
TTL-specific passes and pipeline documented below.
Pipeline: ttl-to-ttkernel-pipeline
The main compilation pipeline, equivalent to what the Python API runs internally.
ttlang-opt input.mlir -p 'ttl-to-ttkernel-pipeline{maximize-dst=true lower-to-emitc=true}'
Option |
Type |
Default |
Description |
|---|---|---|---|
|
bool |
|
Enable DST maximization via subblock compute and scheduling. |
|
bool |
|
Use FPU for binary add/sub/mul. |
|
bool |
|
Lower matmul to block-level hardware calls ( |
|
bool |
|
Refine DFB reserve/push to per-subblock granularity. |
|
bool |
|
Combine consecutive |
|
bool |
|
Error if a |
|
bool |
|
Insert compiler-allocated intermediate DFBs for DFB-only operands and source-lifetime preservation. Error if disabled and any operation requires one. |
|
bool |
|
Clone TTKernel functions that branch on a core coordinate once per launch coordinate ( |
|
bool |
|
Run the TTKernel-to-EmitC backend (produces C++ source). |
The pipeline runs these passes in order:
ttl-materialize-loop-state– replace ranked-tensor loop-carried values with compiler-created DFBsttl-insert-copy-wait– insert missingttl.waitafterttl.copyops whose transfer handle has no wait userttl-annotate-l1-acc-loops– detect+=accumulation loops and annotate for L1 packer accumulationttl-create-producer-compute– create producerttl.computeoperations before intermediate materializationttl-insert-intermediate-dfbs– materialize DFB-only operands and values that must be preserved before source release; verify and error whencompiler-dfbs=falseconvert-ttl-to-compute– lower TTL elementwise tensor ops tottl.computewith tile opsttl-insert-cb-sync, thenttl-coalesce-dfb-acquires– insert missing releases and coalesce compatible DFB acquiresttl-finalize-dfb-indices– allocate physical compiler DFB indices, validate capacity, and emit runtime metadatattl-set-compute-kernel-config– setfp32_dest_acc_en/dst_full_sync_endefaultsttl-assign-dst– DST register allocation (linear scan with copy insertion)ttl-subblock-compute-for-dst– tilettl.computeinto DST-sized subblocks (only ifmaximize-dst=true); optionally refine reserve/push to per-subblock granularity (only ifsubblock-sync=true)ttl-lower-to-loops– lowerttl.computetoscf.forloops; matmul computes are expanded inline viagenerateMatmulComputettl-schedule-operations– reorder tile ops by dependency depth and kind (only ifmaximize-dst=true)ttl-annotate-cb-associations– annotate block args with DFB indicesttl-verify-pipenet-guards, thenttl-verify-dfb-spsc– verify PipeNet synchronization and per-node DFB producer/consumer uniquenessttl-erase-pipenet-scopes– remove verified PipeNet structural markersttl-validate-cb-budget– verify static DFB storage fits the per-core L1 budgetconvert-ttl-to-ttkernel– lower TTL DMA ops to TTKernelttkernel-insert-inits– insert hardware init ops before compute opsttkernel-insert-l1-accumulation– insertpack_reconfig_l1_accguards for+=and reduction loopsttkernel-combine-pack-tiles– combine consecutivepack_tileintopack_tile_block(only ifcombine-pack-tiles=true)Canonicalization and CSE cleanup
ttkernel-specialize-cores, thencanonicalize,cse– per-core clone and const-fold of coordinate branches; tags clones withttl.core_coord(only ifspecialize-cores=true)(if
lower-to-emitc=true)lower-affine,convert-ttkernel-to-emitc,emitc-form-expressions
Individual Pass Options
Each pass can also be run standalone for testing. Only passes with configurable options are listed; the remaining passes have no options.
ttl-insert-intermediate-dfbs
Insert compiler-allocated intermediate DFBs at fusion split points.
Option |
Type |
Default |
Description |
|---|---|---|---|
|
bool |
|
Insert compiler-allocated DFBs. When false, emit an error if any operation requires one. |
ttlang-opt input.mlir -p 'func.func(ttl-insert-intermediate-dfbs{enable=false})'
ttl-set-compute-kernel-config
Set default compute kernel configuration attributes on ttl.compute ops.
Option |
Type |
Default |
Description |
|---|---|---|---|
|
bool |
|
Default |
|
bool |
|
Default |
ttlang-opt input.mlir -p 'func.func(ttl-set-compute-kernel-config{fp32-dest-acc-en=1})'
ttl-assign-dst
DST register allocator using linear scan allocation with in-place operation merging.
Option |
Type |
Default |
Description |
|---|---|---|---|
|
uint32_t |
|
Override DST register capacity. Auto-computed from |
|
bool |
|
Allocate outputs in a separate DST region (needed for reductions and some loop optimizations). |
|
bool |
|
Use FPU for binary add/sub/mul when both operands come from DFBs. When disabled, binary ops use the SFPU path. |
ttlang-opt input.mlir -p 'func.func(ttl-assign-dst{dst-capacity=16 enable-fpu-binary-ops=0})'
ttl-subblock-compute-for-dst
Partition ttl.compute into DST-sized subblocks.
Option |
Type |
Default |
Description |
|---|---|---|---|
|
bool |
|
Refine DFB reserve/push to per-subblock granularity, enabling |
|
bool |
|
Error if a |
ttlang-opt input.mlir -p 'func.func(ttl-subblock-compute-for-dst{subblock-sync=true})'
ttl-dump-cb-flow-graph
Analyze dataflow buffer producer/consumer relationships and dump the flow graph.
Option |
Type |
Default |
Description |
|---|---|---|---|
|
string |
|
Path to write JSON output. Empty string prints to stderr only. |
ttlang-opt input.mlir -p 'ttl-dump-cb-flow-graph{output="/tmp/cb_graph.json"}'
ttkernel-specialize-cores
Clone TTKernel functions that branch on a core coordinate once per launch
coordinate. Requires a module-level ttl.launch_grid attribute (an i64 array
of length 2 with positive entries). Missing or malformed ttl.launch_grid is
a hard error. A valid single-core grid (product <= 1) skips specialization.
Only scf.if conditions derived from ttkernel.my_logical_x_ /
ttkernel.my_logical_y_ trigger cloning. Functions with symbol uses (for
example func.call targets) are left unspecialized with a warning so erasing
the original does not leave dangling SymbolRefAttrs; unrelated functions in
the module are still specialized. Each clone replaces coordinate reads with
arith.constants and is tagged with ttl.core_coord for runtime dispatch.
Downstream canonicalize / cse fold the now-constant branches.
This pass is off by default. Enable it through the pipeline option
specialize-cores (Python: --ttl-specialize-cores):
ttlang-opt input.mlir -p 'ttl-to-ttkernel-pipeline{specialize-cores=true lower-to-emitc=true}'
# Or stand-alone:
ttlang-opt input.mlir -p 'builtin.module(ttkernel-specialize-cores,canonicalize,cse)'