mstar.model.whisper.components.decoder#

Whisper text decoder built on the shared mstar components.

The decoder is a standard pre-norm transformer with three sublayers per block: causal self-attention (paged KV cache via the engine resources), cross-attention over the audio encoder’s output, and a plain GELU FFN.

Whisper has no RoPE — positions are a learned embed_positions table, looked up on the position ids the position resource plans for the step — so the self-attention layers bind no position resource (pos_key=None).

Cross-attention K/V depend only on the (static) encoder output, so they are computed once per request at prefill (write_cross_kv) and written into the context KV stream the cross-attention resource attends. Every later step declares a zero-span segment on that label and runs the planned wrapper — nothing is recomputed or rewritten.

HF checkpoint quirks handled here:
  • self_attn.out_projself_attn.o_proj (name_remapper in whisper_model.py).

  • k_proj has no bias in the checkpoint while q/v_proj do; the shared Attention uses one qkv_bias flag, so k_proj.bias is allocated and zeroed post-load (zero_missing_biases).

Classes

WhisperDecoderLayer(config)

WhisperDecoderModel(config)

Decoder stack; parameter paths mirror HF's model.decoder.*.

class mstar.model.whisper.components.decoder.WhisperDecoderLayer(config)[source]#

Bases: Module

Parameters:

config (WhisperModelConfig)

forward(hidden_states)[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

Parameters:

hidden_states (Tensor)

Return type:

Tensor

class mstar.model.whisper.components.decoder.WhisperDecoderModel(config)[source]#

Bases: Module

Decoder stack; parameter paths mirror HF’s model.decoder.*.

Parameters:

config (WhisperModelConfig)

embed(input_ids, position_ids)[source]#

Token + learned position embeddings.

position_ids is the position resource’s plan for this step — under a captured graph it is the slot’s static buffer, so the lookup rides inside the capture instead of being staged as an embedding.

Parameters:
Return type:

Tensor

forward(input_embeds, *, label)[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

Parameters:
Return type:

Tensor

lm_head(hidden_states)[source]#
Parameters:

hidden_states (Tensor)

Return type:

Tensor

write_cross_kv(encoder_states)[source]#

Project the encoder output to per-layer K/V and write it into the context stream the cross-attention resource attends.

Called once per request, from the prefill forward, under a step that declared a CONTEXT_LABEL segment spanning the encoder output. For a batch, encoder_states is the requests’ outputs concatenated in the step’s segment order.

Parameters:

encoder_states (Tensor)

Return type:

None

zero_missing_biases()[source]#

Zero the self-attn k_proj biases absent from the HF checkpoint (allocated because the shared Attention has one qkv_bias flag).

Return type:

None