What is the builder tool?
mainThe builder is a tool designed for creating TTIR (Tenstorrent Intermediate Representation) and StableHLO operations.
Note: This project is under active development.
repository·main·Indexed 43 days ago
https://github.com/tenstorrent/tt-mlirAn open-source compiler framework built on LLVM's MLIR infrastructure designed to compile and optimize machine learning models for Tenstorrent AI accelerators, specifically targeting Wormhole and Blackhole architectures. It provides custom dialects and transformation passes to translate high-level models (such as StableHLO) into optimized hardware binaries for the TTNN ecosystem.
The builder is a tool designed for creating TTIR (Tenstorrent Intermediate Representation) and StableHLO operations.
Note: This project is under active development.
tt-mlir is an open-source compiler framework built on top of LLVM's MLIR infrastructure. It is designed to compile and optimize machine learning models for Tenstorrent's custom AI hardware, specifically targeting architectures like Wormhole and Blackhole.
Key capabilities include:
ttrt is a Swiss Army knife tool designed for working with FlatBuffers generated by the compiler. Its primary functions are to inspect and run FlatBuffer files, allowing users to execute these files without requiring a front-end runtime.ttnn-standalone is a post-compile tuning and debugging tool. It provides the scaffolding required to run C++ code (generated from compiled ML models like PyTorch, Jax, or ONNX) on device. This allows developers to use generated TTNN library op calls outside of the primary compiler environment.The simulator is exposed through a shadow surface in tools/d2m-jit/sim.py. This module re-exports Layout, dtypes, and config, along with the simulator's host and kernel APIs.
Public Simulator Surface (_src/sim/__init__.py):
SimTensor, SimBlock, to_layout, empty, zeros, full, tilize, untilize, view, view_layout, permute, to_host, reduction_layout.SimKernel (via run.py), core_index, remote_load, remote_store, Semaphore.SIM_OPS and SIM_METHODS providing Torch backings for in-kernel syntax.Backend Switching:
To switch between the device and the simulator, use the config.backend field or the D2M_JIT_BACKEND environment variable.
The d2m-jit simulator is designed for functional verification and serves as a fast inner loop and a golden oracle for on-device tests. It is important to note its specific non-goals to avoid misusing it for hardware-specific analysis:
config.insert_profiler_traces.quirk mode, bit-exactness is only best-effort.The tt-mlir repository is organized into several key functional areas:
env: Environment setup for building dependencies like LLVM and Flatbuffers.include/ttmlir: Public headers for the TTMLIR library. This includes:Dialect: MLIR dialect interfaces and definitions (organized into IR, Passes, and Transforms).Target: Flatbuffer schema definitions that define the binary interface between the compiler and the runtime.lib: The core TTMLIR library implementation, including the CAPI (C API used for Python bindings) and Dialect implementations.runtime: The device runtime implementation. It contains public headers in include/tt/runtime, the implementation in lib, and Python bindings in tools/python (where ttrt is implemented).tools/ttmlir-opt: The TTMLIR optimizer driver tool.test: The project test suite.The tt-mlir ecosystem is part of a broader suite of Tenstorrent tools. Depending on your specific workflow (e.g., XLA integration, ONNX support, or direct Metalium usage), you may need to interact with these related repositories:
tt-metal, providing lower-level hardware access.The d2m-jit kernel-feasibility audit defines what operations can currently be authored as kernels.
Available Today (✅):
_eltwise_block wrapping d2m.tile_*).where for mask-and-blend operations.@, d2m.matmul): Currently limited to single-tile-per-shard with a zeros-prefilled accumulator.remote_load and remote_store for per-shard access.scf.for and scf.if within kernel bodies.async, await, and semaphores for multi-thread sync.view, view_layout, and permute (metadata reinterpretation, no data movement).tilize, untilize, and to_layout for conversions; zeros, full, and empty for host-side fill.reduce_sum, reduce_max, and reduce_mean (per-tile row/col reductions).tile_bcast (row/col/2d shorthands).Limited or Blocked (🟡/🔴):
tilize(dtype=...).permute via views instead).The tt-mlir ecosystem includes several specialized components for different stages of the compilation and optimization pipeline:
tt-mlir components within Python workflows.The TTNN optimizer optimizes TTNN operations for Tenstorrent hardware by focusing on two primary objectives:
Conv2d or specific activation handling.The current implementation uses a greedy, two-pass architecture:
GreedyMemoryLayoutPropagation: Enumerates valid tensor layouts for each operation and greedily propagates these configurations through the graph, inserting reshards where necessary.GreedyL1SpillManagement: Manages the L1 memory budget by spilling tensors to DRAM when the L1 capacity is exceeded.Note: The previous chain-based optimizer (including TTNNOptimizer, DFShardingPolicy, and ShardSolver) has been removed and is superseded by this pass-based design.