Models / qwen3-8b-fp8

Qwen3 8B FP8

Qwen3 8B with every decoder projection in FP8 E4M3, one scale per block of 128 by 128 weights: Qwen's own FP8 checkpoint. 60% of bf16's memory, faster decoding.

8.2B parametersqwen3Apache-2.0text-generationdecoder-onlygrouped-query-attentionqk-normfp8

The forward entry with one level of blocks expanded. Every edge carries the tensor type the compiler inferred at that point, in the model's own generics.

Qwen3 8B FP8: forwardQwen3 8B FP8: forward

Entries ​

EntrySignature
forwardforward<B: Dim, S: Dim>(tokens: Tensor[B, S; i32]) -> Tensor[B, S, Vocab; T]
next_tokennext_token<B: Dim, S: Dim>(tokens: Tensor[B, S; i32]) -> Tensor[B, Vocab; T]
decodedecode(token: Tensor[Batch, 1; i32], pos: i32) -> Tensor[Batch, Vocab; T]
prefillprefill<S: Dim>(tokens: Tensor[Batch, S; i32], pos: i32) -> Tensor[Batch, Vocab; T]
decode_rowsdecode_rows(tokens: Tensor[Batch, 1; i32], positions: Tensor[Batch; i32]) -> Tensor[Batch, Vocab; T]
prefill_slotsprefill_slots<M: Dim, S: Dim>(tokens: Tensor[M, S; i32], slots: Tensor[M; i32], lengths: Tensor[M; i32]) -> Tensor[M, Vocab; T]
loss_packedloss_packed<P: Dim>(tokens: Tensor[P; i32], positions: Tensor[P; i32], segments: Tensor[P; i32], targets: Tensor[P; i64], weights: Tensor[P; f32]) -> f32
log_probs_packedlog_probs_packed<P: Dim>(tokens: Tensor[P; i32], positions: Tensor[P; i32], segments: Tensor[P; i32], targets: Tensor[P; i64]) -> Tensor[P; f32]
hidden_packedhidden_packed<P: Dim>(tokens: Tensor[P; i32], positions: Tensor[P; i32], segments: Tensor[P; i32]) -> Tensor[P, H; T]
prefill_packedprefill_packed<P: Dim>(tokens: Tensor[P; i32], rows: Tensor[P; i32], positions: Tensor[P; i32], segments: Tensor[P; i32], last: Tensor[Batch; i32]) -> Tensor[Batch, Vocab; T]
step_packedstep_packed<P: Dim>(tokens: Tensor[P; i32], rows: Tensor[P; i32], positions: Tensor[P; i32], segments: Tensor[P; i32], last: Tensor[Batch; i32], step_tokens: Tensor[Batch, 1; i32], step_positions: Tensor[Batch; i32]) -> Tensor[2 * Batch, Vocab; T]
decode_pageddecode_paged<Rows: Dim, Pages: Dim>(tokens: Tensor[Rows, 1; i32], positions: Tensor[Rows; i32], table: Tensor[Rows, Pages; i32]) -> Tensor[Rows, Vocab; T]
prefill_pagedprefill_paged<P: Dim, Rows: Dim, Pages: Dim>(tokens: Tensor[P; i32], positions: Tensor[P; i32], rows: Tensor[P; i32], slots: Tensor[P; i32], last: Tensor[Rows; i32], table: Tensor[Rows, Pages; i32]) -> Tensor[Rows, Vocab; T]
step_pagedstep_paged<P: Dim, Rows: Dim, Pages: Dim>(tokens: Tensor[P; i32], positions: Tensor[P; i32], rows: Tensor[P; i32], slots: Tensor[P; i32], last: Tensor[Rows; i32], step_tokens: Tensor[Rows, 1; i32], step_positions: Tensor[Rows; i32], table: Tensor[Rows, Pages; i32]) -> Tensor[2 * Rows, Vocab; T]
generategenerate<Steps: Dim>(token: Tensor[Batch, 1; i32], pos: i32) -> Tensor[Batch, Steps; i32]
samplesample<Steps: Dim>(token: Tensor[Batch, 1; i32], pos: i32, key: Tensor[2; i64], temperature: f32) -> Tensor[Batch, Steps; i32]
generate_untilgenerate_until<MaxNew: Dim>(token: Tensor[Batch, 1; i32], pos: i32, eos: i32) -> (Tensor[Batch, MaxNew; i32], i32)

Generics ​

The root block's generics as this checkpoint binds them.

Vocab151936
H4096
Heads32
KvHeads8
HeadDim128
Inner12288
Layers36
Batch1
MaxSeq40960
Tbf16

Blocks ​

Every block of the program with its members and functions, as linnet inspect prints them.

DecoderLayer ​

text
qwen3::DecoderLayer<H: Dim, Heads: Dim, KvHeads: Dim, HeadDim: Dim, Inner: Dim, Batch: Dim, MaxSeq: Dim, T: Float, Shards: Dim = 1, PageSize: Dim = 64>
  sub attention_norm: RmsNorm<H, T>
  sub attention: GroupedQueryAttention<H, Heads, KvHeads, HeadDim, Batch, MaxSeq, T, Shards, PageSize>
  sub mlp_norm: RmsNorm<H, T>
  sub mlp: Fp8BlockSwiGlu<H, Inner / Shards, T>
  pub fn forward<B: Dim, S: Dim>(x: Tensor[B, S, H; T]) -> Tensor[B, S, H; T]
  pub fn decode(x: Tensor[Batch, 1, H; T], pos: i32) -> Tensor[Batch, 1, H; T]
  pub fn prefill<S: Dim>(x: Tensor[Batch, S, H; T], pos: i32) -> Tensor[Batch, S, H; T]
  pub fn decode_rows(x: Tensor[Batch, 1, H; T], positions: Tensor[Batch; i32]) -> Tensor[Batch, 1, H; T]
  pub fn prefill_slots<M: Dim, S: Dim>(x: Tensor[M, S, H; T], slots: Tensor[M; i32]) -> Tensor[M, S, H; T]
  pub fn prefill_packed<P: Dim>(x: Tensor[1, P, H; T], rows: Tensor[P; i32], positions: Tensor[P; i32], segments: Tensor[P; i32]) -> Tensor[1, P, H; T]
  pub fn packed<P: Dim>(x: Tensor[1, P, H; T], positions: Tensor[P; i32], segments: Tensor[P; i32]) -> Tensor[1, P, H; T]
  pub fn step_packed<P: Dim>(x: Tensor[1, Batch + P, H; T], rows: Tensor[P; i32], positions: Tensor[P; i32], segments: Tensor[P; i32], step_positions: Tensor[Batch; i32]) -> Tensor[1, Batch + P, H; T]
  pub fn decode_paged<Rows: Dim, Pages: Dim>(x: Tensor[Rows, 1, H; T], positions: Tensor[Rows; i32], table: Tensor[Rows, Pages; i32]) -> Tensor[Rows, 1, H; T]
  pub fn prefill_paged<P: Dim, Rows: Dim, Pages: Dim>(x: Tensor[1, P, H; T], positions: Tensor[P; i32], rows: Tensor[P; i32], slots: Tensor[P; i32], table: Tensor[Rows, Pages; i32]) -> Tensor[1, P, H; T]
  pub fn step_paged<P: Dim, Rows: Dim, Pages: Dim>(x: Tensor[1, P + Rows, H; T], positions: Tensor[P; i32], rows: Tensor[P; i32], slots: Tensor[P; i32], step_positions: Tensor[Rows; i32], table: Tensor[Rows, Pages; i32]) -> Tensor[1, P + Rows, H; T]

Embedding ​

text
std.nn.embedding::Embedding<Vocab: Dim, H: Dim, T: Float = bf16>
  param weight: Tensor[Vocab, H; T]
  pub fn forward<*S: Shape>(ids: Tensor[*S; i32]) -> Tensor[*S, H; T]

Fp8BlockLinear ​

text
std.quant::Fp8BlockLinear<In: Dim, Out: Dim, Block: Dim = 128, T: Float = bf16>
  param weight: Tensor[Out, In; u8]
  param scale: Tensor[Out / Block, In / Block; T]
  param bias: Tensor[Out; T]?
  pub fn forward<*S: Shape>(x: Tensor[*S, In; T]) -> Tensor[*S, Out; T]

Fp8BlockSwiGlu ​

text
qwen3::Fp8BlockSwiGlu<H: Dim, Inner: Dim, T: Float = bf16>
  sub gate: Fp8BlockLinear<H, Inner, 128, T>
  sub up: Fp8BlockLinear<H, Inner, 128, T>
  sub down: Fp8BlockLinear<Inner, H, 128, T>
  pub fn forward<*S: Shape>(x: Tensor[*S, H; T]) -> Tensor[*S, H; T]

Fp8Linear ​

text
std.quant::Fp8Linear<In: Dim, Out: Dim, T: Float = bf16>
  param weight: Tensor[Out, In; u8]
  param scale: Tensor[Out, 1; T]
  param bias: Tensor[Out; T]?
  pub fn forward<*S: Shape>(x: Tensor[*S, In; T]) -> Tensor[*S, Out; T]

GroupedQueryAttention ​

text
qwen3.attention::GroupedQueryAttention<H: Dim, Heads: Dim, KvHeads: Dim, HeadDim: Dim, Batch: Dim, MaxSeq: Dim, T: Float, Shards: Dim = 1, PageSize: Dim = 64>
  sub q_proj: Fp8BlockLinear<H, (Heads / Shards) * HeadDim, 128, T>
  sub q_norm: RmsNorm<HeadDim, T>
  sub k_proj: Fp8BlockLinear<H, HeadDim * (KvHeads / Shards), 128, T>
  sub k_norm: RmsNorm<HeadDim, T>
  sub v_proj: Fp8BlockLinear<H, HeadDim * (KvHeads / Shards), 128, T>
  sub o_proj: Fp8BlockLinear<(Heads / Shards) * HeadDim, H, 128, T>
  state cache_k: Tensor[Batch, KvHeads / Shards, MaxSeq, HeadDim; T]
  state cache_v: Tensor[Batch, KvHeads / Shards, MaxSeq, HeadDim; T]
  pub fn forward<B: Dim, S: Dim>(x: Tensor[B, S, H; T]) -> Tensor[B, S, H; T]
  pub fn decode(x: Tensor[Batch, 1, H; T], pos: i32) -> Tensor[Batch, 1, H; T]
  pub fn prefill<S: Dim>(x: Tensor[Batch, S, H; T], pos: i32) -> Tensor[Batch, S, H; T]
  pub fn decode_rows(x: Tensor[Batch, 1, H; T], positions: Tensor[Batch; i32]) -> Tensor[Batch, 1, H; T]
  pub fn prefill_slots<M: Dim, S: Dim>(x: Tensor[M, S, H; T], slots: Tensor[M; i32]) -> Tensor[M, S, H; T]
  pub fn prefill_packed<P: Dim>(x: Tensor[1, P, H; T], rows: Tensor[P; i32], positions: Tensor[P; i32], segments: Tensor[P; i32]) -> Tensor[1, P, H; T]
  pub fn packed<P: Dim>(x: Tensor[1, P, H; T], positions: Tensor[P; i32], segments: Tensor[P; i32]) -> Tensor[1, P, H; T]
  pub fn step_packed<P: Dim>(x: Tensor[1, Batch + P, H; T], rows: Tensor[P; i32], positions: Tensor[P; i32], segments: Tensor[P; i32], step_positions: Tensor[Batch; i32]) -> Tensor[1, Batch + P, H; T]
  pub fn decode_paged<Rows: Dim, Pages: Dim>(x: Tensor[Rows, 1, H; T], positions: Tensor[Rows; i32], table: Tensor[Rows, Pages; i32]) -> Tensor[Rows, 1, H; T]
  pub fn prefill_paged<P: Dim, Rows: Dim, Pages: Dim>(x: Tensor[1, P, H; T], positions: Tensor[P; i32], rows: Tensor[P; i32], slots: Tensor[P; i32], table: Tensor[Rows, Pages; i32]) -> Tensor[1, P, H; T]
  pub fn step_paged<P: Dim, Rows: Dim, Pages: Dim>(x: Tensor[1, P + Rows, H; T], positions: Tensor[P; i32], rows: Tensor[P; i32], slots: Tensor[P; i32], step_positions: Tensor[Rows; i32], table: Tensor[Rows, Pages; i32]) -> Tensor[1, P + Rows, H; T]

Int4GroupLinear ​

text
std.quant::Int4GroupLinear<In: Dim, Out: Dim, Group: Dim = 128, T: Float = bf16>
  param weight: Tensor[Out, In / Group, Group / 2; u8]
  param scale: Tensor[Out, In / Group; T]
  param zero: Tensor[Out, In / Group; u8]
  param order: Tensor[In; i32]?
  param bias: Tensor[Out; T]?
  pub fn forward<*S: Shape>(x: Tensor[*S, In; T]) -> Tensor[*S, Out; T]

Int4Linear ​

text
std.quant::Int4Linear<In: Dim, Out: Dim, T: Float = bf16>
  param weight: Tensor[Out, In / 2; i8]
  param scale: Tensor[Out; f32]
  param bias: Tensor[Out; T]?
  pub fn forward<*S: Shape>(x: Tensor[*S, In; T]) -> Tensor[*S, Out; T]

Int8GroupLinear ​

text
std.quant::Int8GroupLinear<In: Dim, Out: Dim, Group: Dim = 128, T: Float = bf16>
  param weight: Tensor[Out, In; i8]
  param scale: Tensor[Out, In / Group; T]
  param bias: Tensor[Out; T]?
  pub fn forward<*S: Shape>(x: Tensor[*S, In; T]) -> Tensor[*S, Out; T]

Int8Linear ​

text
std.quant::Int8Linear<In: Dim, Out: Dim, T: Float = bf16>
  param weight: Tensor[Out, In; i8]
  param scale: Tensor[Out, 1; T]
  param bias: Tensor[Out; T]?
  pub fn forward<*S: Shape>(x: Tensor[*S, In; T]) -> Tensor[*S, Out; T]

Linear ​

text
std.nn.linear::Linear<In: Dim, Out: Dim, T: Float = bf16>
  param weight: Tensor[Out, In; T]
  param bias: Tensor[Out; T]?
  pub fn forward<*S: Shape>(x: Tensor[*S, In; T]) -> Tensor[*S, Out; T]

Model ​

text
qwen3::Model<Vocab: Dim, H: Dim, Heads: Dim, KvHeads: Dim, HeadDim: Dim, Inner: Dim, Layers: Dim, Batch: Dim, MaxSeq: Dim, T: Float = bf16, Shards: Dim = 1, PageSize: Dim = 64>
  sub embedding: Embedding<Vocab, H, T>
  sub layers: [DecoderLayer<H, Heads, KvHeads, HeadDim, Inner, Batch, MaxSeq, T, Shards, PageSize>; Layers]
  sub norm: RmsNorm<H, T>
  sub lm_head: Linear<H, Vocab / Shards, T>
  pub entry forward<B: Dim, S: Dim>(tokens: Tensor[B, S; i32]) -> Tensor[B, S, Vocab; T]
  pub entry next_token<B: Dim, S: Dim>(tokens: Tensor[B, S; i32]) -> Tensor[B, Vocab; T]
  pub entry decode(token: Tensor[Batch, 1; i32], pos: i32) -> Tensor[Batch, Vocab; T]
  pub entry prefill<S: Dim>(tokens: Tensor[Batch, S; i32], pos: i32) -> Tensor[Batch, Vocab; T]
  pub entry decode_rows(tokens: Tensor[Batch, 1; i32], positions: Tensor[Batch; i32]) -> Tensor[Batch, Vocab; T]
  pub entry prefill_slots<M: Dim, S: Dim>(tokens: Tensor[M, S; i32], slots: Tensor[M; i32], lengths: Tensor[M; i32]) -> Tensor[M, Vocab; T]
  pub entry loss_packed<P: Dim>(tokens: Tensor[P; i32], positions: Tensor[P; i32], segments: Tensor[P; i32], targets: Tensor[P; i64], weights: Tensor[P; f32]) -> f32
  pub entry log_probs_packed<P: Dim>(tokens: Tensor[P; i32], positions: Tensor[P; i32], segments: Tensor[P; i32], targets: Tensor[P; i64]) -> Tensor[P; f32]
  pub entry hidden_packed<P: Dim>(tokens: Tensor[P; i32], positions: Tensor[P; i32], segments: Tensor[P; i32]) -> Tensor[P, H; T]
  fn packed_states<P: Dim>(tokens: Tensor[P; i32], positions: Tensor[P; i32], segments: Tensor[P; i32]) -> Tensor[P, H; T]
  pub entry prefill_packed<P: Dim>(tokens: Tensor[P; i32], rows: Tensor[P; i32], positions: Tensor[P; i32], segments: Tensor[P; i32], last: Tensor[Batch; i32]) -> Tensor[Batch, Vocab; T]
  pub entry step_packed<P: Dim>(tokens: Tensor[P; i32], rows: Tensor[P; i32], positions: Tensor[P; i32], segments: Tensor[P; i32], last: Tensor[Batch; i32], step_tokens: Tensor[Batch, 1; i32], step_positions: Tensor[Batch; i32]) -> Tensor[2 * Batch, Vocab; T]
  pub entry decode_paged<Rows: Dim, Pages: Dim>(tokens: Tensor[Rows, 1; i32], positions: Tensor[Rows; i32], table: Tensor[Rows, Pages; i32]) -> Tensor[Rows, Vocab; T]
  pub entry prefill_paged<P: Dim, Rows: Dim, Pages: Dim>(tokens: Tensor[P; i32], positions: Tensor[P; i32], rows: Tensor[P; i32], slots: Tensor[P; i32], last: Tensor[Rows; i32], table: Tensor[Rows, Pages; i32]) -> Tensor[Rows, Vocab; T]
  pub entry step_paged<P: Dim, Rows: Dim, Pages: Dim>(tokens: Tensor[P; i32], positions: Tensor[P; i32], rows: Tensor[P; i32], slots: Tensor[P; i32], last: Tensor[Rows; i32], step_tokens: Tensor[Rows, 1; i32], step_positions: Tensor[Rows; i32], table: Tensor[Rows, Pages; i32]) -> Tensor[2 * Rows, Vocab; T]
  pub entry generate<Steps: Dim>(token: Tensor[Batch, 1; i32], pos: i32) -> Tensor[Batch, Steps; i32]
  pub entry sample<Steps: Dim>(token: Tensor[Batch, 1; i32], pos: i32, key: Tensor[2; i64], temperature: f32) -> Tensor[Batch, Steps; i32]
  pub entry generate_until<MaxNew: Dim>(token: Tensor[Batch, 1; i32], pos: i32, eos: i32) -> (Tensor[Batch, MaxNew; i32], i32)
  fn step(token: Tensor[Batch, 1; i32], pos: i32) -> Tensor[Batch, Vocab; T]
  fn logits<R: Dim>(x: Tensor[R, H; T]) -> Tensor[R, Vocab; T]
  fn hidden<B: Dim, S: Dim>(tokens: Tensor[B, S; i32]) -> Tensor[B, S, H; T]
  fn hidden_states<B: Dim, S: Dim>(tokens: Tensor[B, S; i32]) -> Tensor[B, S, H; T]

RmsNorm ​

text
std.nn.norm::RmsNorm<H: Dim, T: Float = bf16>
  param weight: Tensor[H; T]
  pub fn forward<*S: Shape>(x: Tensor[*S, H; T]) -> Tensor[*S, H; T]
  pub fn forward<*S: Shape>(x: Tensor[*S, H; T]) -> Tensor[*S, H; T]