Skip to content

gemma3_text

gemma3_text

Gemma 3 (text) on vLLM (vllm.model_executor.models.gemma3).

Llama's names and a fused block, with Gemma's sandwich norms: what the block adds is each sublayer's post norm's output, not the module's, as on transformers, so the contributions point at the sibling norms. The attention norms its queries and keys. The sqrt(hidden_size) scaling of the embeddings is applied by the model after embed_tokens, not inside it as on transformers, so token_embeddings is the unscaled lookup and layers[0].layer_input the scaled stream.

RENAME module-attribute

RENAME = {'model.embed_tokens': 'embed_tokens', 'model.layers': 'layers', 'model.norm': 'norm'}

ENVOYS module-attribute

ENVOYS = {Gemma3DecoderLayer: Layer, Gemma3Attention: Attention, Gemma3MLP: Mlp}

Layer

Layer(*args: Any, **kwargs: Any)

Bases: FusedLayer

Gemma-3's decoder block: forward(positions, hidden_states, residual) -> (hidden_states, residual).

layer_mid class-attribute instance-attribute

layer_mid = summed('pre_feedforward_layernorm.inputs', description='The residual stream after the attention add: hidden_states + residual, [1, tokens, hidden_size]')

mlp_norm_output

mlp_norm_output(value) -> Residual