training#
Training forwards with a chunked prefill prefix and recurrent decode suffix.
Functions
Return serving-policy layers from a module or iterable of model chunks. |
|
Supply per-sequence phases to a module or iterable of model chunks/layers. |
- get_linear_attention_layers(model, *, enabled_only=False, unphased_only=False)#
Return serving-policy layers from a module or iterable of model chunks.
Disabled state quantizers are included by default so a baseline can use the same serving arithmetic and phase as QAT. Use
enabled_onlyfor setup checks andunphased_onlyto select layers needing adapter-provided defaults.
- linear_attention_training_phase(model, prefill_lengths, *, sequence_lengths=None, cu_seqlens=None, preserve_existing=False)#
Supply per-sequence phases to a module or iterable of model chunks/layers.
Enabled state quantization requires a phase, including calibration/eval. Disabled quantizers use the original module outside a phase and serving arithmetic inside. Megatron selective recompute captures the phase for backward after context exit.
sequence_lengthsexcludes right padding in dense rows or padded THD segments.cu_seqlensdescribes physical packed storage, including alignment padding. Megatron derives omitted valid lengths from unpaddedcu_seqlens_qmetadata; padded-only metadata requires explicitsequence_lengths. Padding produces zero attention outputs and never updates the recurrent state.preserve_existing=Trueinstalls defaults only on layers without a phase. Empty pipeline stages participate as no-ops.