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_proj→self_attn.o_proj(name_remapper inwhisper_model.py).k_projhas no bias in the checkpoint whileq/v_projdo; the sharedAttentionuses oneqkv_biasflag, sok_proj.biasis allocated and zeroed post-load (zero_missing_biases).
Classes
|
|
|
Decoder stack; parameter paths mirror HF's |
- 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
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class mstar.model.whisper.components.decoder.WhisperDecoderModel(config)[source]#
Bases:
ModuleDecoder stack; parameter paths mirror HF’s
model.decoder.*.- Parameters:
config (WhisperModelConfig)
- embed(input_ids, position_ids)[source]#
Token + learned position embeddings.
position_idsis 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.
- 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
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- 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_LABELsegment spanning the encoder output. For a batch,encoder_statesis the requests’ outputs concatenated in the step’s segment order.- Parameters:
encoder_states (Tensor)
- Return type:
None