Expand description
A model’s computation written as a LOGOS program, from its ModelSpec.
Every program here is ordinary LOGOS tensor sugar — the claim “the model is authored in LOGOS” rests on it — and
nothing in it is written for one model: a layer’s statements follow from its mixer, its feed-forward block and
its norms. The forms are the ones a deployment runs: the single-token forward, a decode step over KV caches and
recurrent state, a prefill chunk, a batch of decode steps; each also cut into its embedding, its layers and its
head, so a backend can lower a layer at a time. Weights are declared as tensors the host fills, and recorded with
the file each is loaded from: <var>.f (f32) or <var>.q/<var>.s (Q8_0 quants and block scales).
A stacked form (prefill, batch) carries its tensors with a b prefix (bxn0); per-sequence state carries a
_s{b} suffix (Kc3_s1).
Structs§
- NotYet
- Why a spec cannot be written as a program yet.
Enums§
- Attn
Form - How an attention layer reads its keys and values.
- RowState
- Whose carried state the rows of a stacked step update.
Functions§
- check
- Can every layer of
specbe written in the language as it stands? The sugar’s rotation is NEOX-paired (an interleaved checkpoint is bound through a per-head permutation of its Q and K rows, a fused projection through each part’s rows); an attention reads values of any width at the scale it gives, its scores and the logits soft-capped where the model caps them, and a latent attention its latent at the scale it gives. - check_
tp - Can
specbe split overtpchips? At any width of at least one chip (share), when every attention is unbiased and sinkless and every FFN is dense (its columns split; an expert mixture would split by experts). - decode_
batch - B DECODE STEPS AT ONCE: sequence
bbrings tokentok_bat positionpos_b(1-based) and its own carried state, and every sequence emits its own next token. The hidden states are stacked into aB × dmatrix and everything that reads a weight runs on the stack; what depends on one sequence’s position or state runs per sequence, on that sequence’s row, exactly as the single step writes it. - decode_
batch_ embed - A batched decode step’s embedding lookups alone: the stacked
Xout. - decode_
batch_ head - A batched decode step’s head alone: the last layer’s stacked output in, every sequence’s next token out.
- decode_
embed - A decode step’s embedding lookup alone: token
tokin, the first hidden statexout. - decode_
head - A decode step’s head alone: the final norm, the LM head and the arg-max.
- decode_
layer - Layer
lof a decode step alone, its attention reading a KV cache ofctxpositions up topos. - decode_
step - ONE DECODE STEP: token
tokat positionpos(1-based) in, the next token out. Every attention layer appends this token’s key and value to its KV cache (ctxpositions, the step’s carried state alongside any recurrent memories and conv rings) and attends over the firstposrows; the step ends with the arg-max of the logits. - forward
- The single-token forward with no history: the token’s hidden state
xin, the logits out. - head
- The final norm and LM head alone, reading the last layer’s output.
- layer
- Layer
lalone, as the forward writes it: its incoming hidden state declared as an input, the RoPE tables when it is an attention layer, then the layer. - layer_
input - The hidden-state tensor layer
lreads:xfor the first layer, the previous layer’s output after. - prefill
- A PREFILL CHUNK: the tokens
toksof ONE sequence at positionspos0, pos0 + 1, …(1-based) as one step, the next token after the last of them out. The hidden states are stacked into aT × dmatrix, so every projection, norm, FFN and residual reads its weights once for the chunk; the chunk’s keys and values append to the cache as one block frompos0, and the rows attend as one causal block. The state is the decode step’s own, so a decode step continues where the chunk stops; the LM head reads the last row only. - prefill_
head - A prefill chunk’s head alone: the last layer’s stacked output in, the next token after the chunk’s last out.
- stacked_
layer - Layer
lof a stacked step alone, its rows’ state held asrowssays: the positions the rows read, the stacked input, the RoPE tables when it is an attention layer, then the layer. - stacked_
layer_ input - The stacked hidden states layer
lof a stacked step reads:Xfor the first layer, the previousbxoafter. - tp_
decode_ batch - A BATCHED decode step over
tpchips — the serving shape: the stacked sequences with every layer split, the embedding and the head on the replicated spine. - tp_
decode_ layer - Layer
lof a tensor-parallel decode step alone: its input and position declared, the rotary tables for an attention layer, then the split layer. - tp_
decode_ step - A whole decode step over
tpchips: the embedding lookup and the head replicated, every layer split. - tp_
stacked_ layer - Layer
lof a batched tensor-parallel decode step alone.
Type Aliases§
- Authored
- A program and its weight manifest:
(source, f32 weights → (file, count), q8 weights → file stem). - TpAuthored
- A tensor-parallel program, its weight manifest, and its placement.