nemo_automodel.components.models.qwen3.model
nemo_automodel.components.models.qwen3.model
Dense Qwen3 implementation with packed THD context parallelism.
Module Contents
Classes
Data
API
Bases: HFQwen3Attention
HuggingFace Qwen3 attention extended with a packed THD TE path.
Run Qwen3 attention over padded BSHD or packed THD states.
Parameters:
Hidden states [B, S, H] or packed local states
[T, H]. B is batch, S is sequence, T is local
total tokens, and H is hidden size.
RoPE tensors (cos, sin) or fused
(cos, sin, freqs_cis). Local tensors use [B, S, D] or
[T, D] and the fused raw table uses [S, 1, 1, D].
Padded attention mask for BSHD; THD uses cumulative
document lengths from kwargs.
Optional BSHD KV cache; unsupported for THD.
THD requires qkv_format='thd' and cu_seqlens
[N + 1]; CP additionally supplies cp_size and cp_rank.
Returns: torch.Tensor
Attention output shaped like hidden_states and optional BSHD
Bases: HFQwen3DecoderLayer
Qwen3 decoder layer using the packed-aware attention implementation.
Bases: HFCheckpointingMixin, Qwen3PreTrainedModel, GenerationMixin
Dense Qwen3 causal LM with packed THD context parallelism.
Run causal LM projection for BSHD or packed THD inputs.
Parameters:
Token IDs [B, S] or packed local IDs [T].
Optional padded mask. THD uses cu_seqlens.
Position IDs [B, S] or packed local IDs [T].
Optional BSHD KV cache; unsupported for THD.
Optional hidden inputs [B, S, H] or [T, H].
Optional labels [B, S] or packed [T].
Whether to update the BSHD KV cache.
Whether to request attention outputs.
Whether to return per-layer hidden states.
Whether to return CausalLMOutputWithPast.
Optional BSHD cache positions [S].
Positions to project from hidden size H to
vocabulary size V.
THD metadata. cu_seqlens is [N + 1] and CP adds
cp_size and cp_rank.
Returns: CausalLMOutputWithPast
Causal LM output with BSHD logits [B, S, V]. Packed local
Bases: Qwen3PreTrainedModel
Dense Qwen3 decoder supporting padded BSHD and packed THD layouts.
Run the Qwen3 decoder in padded BSHD or packed THD layout.
Parameters:
Token IDs [B, S] or packed local IDs [T].
Optional padded mask [B, S]. THD uses packed
document boundaries instead.
Position IDs [B, S] or packed local IDs [T].
Optional BSHD generation cache; unsupported for THD.
Alternative hidden inputs [B, S, H] or [T, H].
Whether to update the BSHD KV cache.
Whether to request attention outputs.
Whether to retain per-layer hidden states.
Whether to return BaseModelOutputWithPast.
Optional BSHD cache positions [S].
THD metadata including qkv_format, cu_seqlens,
max_seqlen, cp_size, and cp_rank.
Returns: BaseModelOutputWithPast
Decoder output with final states [B, S, H] or packed local
Bases: PreTrainedModel
Base class for the dense Qwen3 implementation.