Skip to main content

Module work

Module work 

Source
Expand description

THE WORK MODEL — what a program makes the machine do, counted from the program itself.

★ THIS IS NOT A FITTED MODEL, AND THAT IS THE POINT. Every number here is a COUNT of things the choreography does — tiles read, transactions initiated, matmuls retired — walked off the same Schedule the backends print from. There is no regression, no free parameter, and no way for the model to describe a program the compiler does not emit, because it reads the emitted structure.

It exists because the alternative was measured and found to be unusable. ttsim_instrument_audit.json sweeps the reduction depth 8x and watches every clock on the simulator stand still: the bracket counter moves 0.08%, the device’s own per-core cycle register 0.3%. A cost model fitted to either is fitted to noise, and the consequence was not theoretical — at 512^3 it ranked the plan issuing 2.9x the instructions and 4.1x the NOC transactions FIRST, because that plan happened to score a lower clock.

What the simulator can report is what the machine did, and the instrumented build does: Tensix instructions issued, NOC transactions, NOC bytes, and matmuls RETIRED. Over that same 8x sweep those move 8.11x / 7.40x / 7.59x / 8.000x. So this module PREDICTS them and spatial_work_model_lock checks the prediction against the machine. A disagreement is a bug in the compiler’s model of itself — never a constant to be re-fitted away.

ONE law is closed-form and exact, and it anchors everything else:

matmul_retired = mt * nt * kt * MVMUL_PER_TILE_MATMUL

Two programs computing the same GEMM retire the same count whoever emitted them, so with it holding a difference in instructions or bytes is a difference in HOW the same computation was carried out. That is what makes an efficiency claim checkable rather than rhetorical.

Structs§

GemmWidths
The tile widths a GEMM’s movement is priced at. A transfer moves its tensor’s stored bytes, so each operand is read at its own tensor’s width and the result written at the output’s — an exact accumulator writes a wider result than the operands it reads (fp32 under bf16, int32 or int64 under int8) — and a multicast moves the sender’s buffer, at that buffer’s width.
Work
What a program costs the machine, in the units the machine can actually report.

Enums§

Objective

Constants§

HOST_TXNS_PER_SITE
NOC transactions the HOST issues per participating site, outside the kernel choreography: the program dispatch handshake and the read-back of that site’s cycle buffer. The choreography cannot contain them — they are the runtime’s, not the kernel’s — but the meter counts them, so a model that predicts what the meter will say has to.
MVMUL_PER_TILE_MATMUL_PER_PASS
MVMUL issues one 32x32 tile-matmul retires PER FIDELITY PASS. The matrix unit walks the tile in 16 steps, and math fidelity is literally how many times it walks it: LoFi takes the operands’ top mantissa bits in one pass, HiFi4 makes four. So the fidelity knob is not a fitted scale factor on the compute term — it is an exact integer multiplier on the work, and the machine says so.
NOC_MAX_BURST_BYTES
The largest payload one NOC command carries. A transfer longer than this is split by ncrisc_noc_fast_write_any_len into burst-sized commands, each of which the network interface issues — and counts — separately.

Functions§

commands_for
NOC commands a transfer of bytes costs.
fidelity_passes
Passes the matrix unit makes over a tile at each math fidelity.
gemm_retired_floor
★ THE FLOOR THE WHOLE MODEL IS ANCHORED ON: the fewest MVMULs a GEMM of this shape CAN retire at this fidelity — the tile-matmuls the mathematics demands, times the passes the fidelity costs.
mvmul_per_tile_matmul
MVMULs one tile-matmul retires at a fidelity.
work_at
The work of the run in which each trip t counts counts[t] — a decode step’s at its position.
work_of
What the program makes the machine do. Walks the scheduled choreography — the same structure the backends print — so the model cannot drift from the code that runs.
work_of_plan
★ THE SAME WORK, PRICED FROM A PLAN INSTEAD OF A BUILT PROGRAM.

Type Aliases§

RankKey
★ WHAT THE COMPILER IS MINIMIZING, SAID OUT LOUD — and the knob for changing it.