Class QwenBlock
java.lang.Object
smile.llm.model.qwen.QwenBlock
One hybrid decoder block: pre-norm → mixer (DeltaNet or gated attn) → residual
→ post-norm → SwiGLU FFN → residual.
-
Constructor Summary
ConstructorsConstructorDescriptionQwenBlock(int layerId, QwenModelArgs args, DeltaNetStatePool statePool) Constructor.QwenBlock(int layerId, QwenModelArgs args, DeltaNetStatePool statePool, TensorShardSpec shard, TensorParallelGroup tpGroup) Tensor-parallel constructor. -
Method Summary
Modifier and TypeMethodDescriptionReturns the SwiGLU feed-forward.Forward with per-row cache write positions (full-attn layers).Forward pass.intlayerId()Returns the stack layer index.Returns the layer type string.Returns the DeltaNet mixer.selfAttn()Returns the gated full-attention mixer.
-
Constructor Details
-
QwenBlock
Constructor.- Parameters:
layerId- stack layer index.args- model args.statePool- DeltaNet state pool (linear layers; may be null).
-
QwenBlock
public QwenBlock(int layerId, QwenModelArgs args, DeltaNetStatePool statePool, TensorShardSpec shard, TensorParallelGroup tpGroup) Tensor-parallel constructor.- Parameters:
layerId- stack layer index.args- model args.statePool- DeltaNet state pool (linear layers; may be null).shard- local head / FFN shard description, ornullfor full width.tpGroup- tensor-parallel group, ornullfor single-device.
-
-
Method Details
-
layerId
public int layerId()Returns the stack layer index.- Returns:
- stack layer index.
-
layerType
Returns the layer type string.- Returns:
full_attentionorlinear_attention.
-
selfAttn
Returns the gated full-attention mixer.- Returns:
- gated full attention, or
nullfor DeltaNet layers.
-
linearAttn
Returns the DeltaNet mixer.- Returns:
- DeltaNet mixer, or
nullfor full-attention layers.
-
feedForward
-
forward
Forward pass.- Parameters:
x- hidden states.startPos- cache start position (full-attn).cos- partial RoPE cosines for this window (full-attn).sin- partial RoPE sines for this window (full-attn).mask- causal attention mask (full-attn).- Returns:
- block output.
-
forward
Forward with per-row cache write positions (full-attn layers).- Parameters:
x- hidden states.positions- absolute write position per batch row.cos- partial RoPE cosines.sin- partial RoPE sines.mask- causal mask, ornull.- Returns:
- block output.
-