How tenstorrent/tt-llk works
Project type and purpose
• TT-LLK is a header-only C++17 library of low-level compute kernels (“LLKs”) for Tenstorrent AI chips (Blackhole, Wormhole).
• It provides foundational primitives consumed by higher-level stacks (e.g., tt-metal) and includes a rich test environment (RISC-V firmware + Python harness).
File structure
• Top-level directories:
• .github / infra – CI pipelines, Dockerfiles, build scripts
• docs – multi-level documentation (intro, top-level overview, programming model)
• tests – two sub-environments:
– tests/firmware (RISC-V assembler + include headers, tmu-crt0 startup)
– tests/python_tests (pytest harness, helpers, config files)
• tt_llk_blackhole & tt_llk_wormhole_b0 – for each chip:
– common/inc – all kernel headers (ckernel_*.h, SFPU ops)
– instructions/assembly.yaml – instruction definitions, mapping to kernels
– llk_lib – generic kernel templates, math primitives, pack/unpack logic
• Key patterns: header-only design, code-generation via SFPI compiler driven by instructions YAML, separation by chip target, unified llk_lib API.
README
• Confirms header-only LLK library, dependent on SFPI compiler, targeted at ML kernel writers and runtime integration.
• Points to docs for architecture and programming model.
• Emphasizes test environment for validation.
a. Main components to show:
1. LLK Source Modules (per chip target)
– common/inc (kernel headers)
– instructions YAML (defines instruction ↔ kernel mapping)
– llk_lib templates
2. SFPI Compiler / Code Generator
3. Consumer Runtime (tt-metal / higher-level ML stacks)
4. Test Environment
– Python Test Harness (pytest scripts, helpers)
– RISC-V Firmware (tmu-crt0, address maps)
5. CI/CD Infrastructure
– GitHub Actions, Docker Build Scripts, pre-commit hooks
6. Documentation Portal (Sphinx or MkDocs)
b. Relationships & interactions:
– LLK headers + instructions → SFPI Compiler → generated kernels for each chip
– Consumer Runtime links against LLK headers + compiled output → runs on real hardware or simulator
– Python Harness invokes kernels via hardware controller API → flashes RISC-V firmware → collects metrics
– CI pipelines automate build, test (firmware & Python), doc generation, Docker image publication
c. Architectural patterns & design principles:
– Header-only, template-based code for zero linking overhead
– Code generation via external compiler (SFPI) driven by declarative YAML
– Multi-target support (chip variants) via separate include trees
– Clear separation of core library vs. test harness vs. infra
d. Key technologies & frameworks:
– C++17 headers
– SFPI compiler (external)
– Python 3.10 + pytest
– RISC-V firmware + linker scripts (ld/*.ld)
– GitHub Actions, Docker, pre-commit