mstar.engine.resources.attn.ragged.config#
What a model declares about cacheless (ragged) attention.
Kept free of the manager and its kernels, like the other resources’ configs, so a submodule can declare a step without pulling FlashInfer in behind it.
Functions
|
The plan a cross-attention pair runs under: |
Classes
|
Varlen attention over segments packed into one forward, with no KV cache: the whole layout is this step's, and nothing carries to the next. |
|
Cacheless self-attention within each declared span ( |
|
|
|
Cacheless block-causal self-attention within each declared span: a token in block |
|
Cacheless cross-attention between two spans of each request: a forward's |
|
A ragged cross-attention step: which spans attend which. |
- class mstar.engine.resources.attn.ragged.config.RaggedAttentionConfig(num_qo_heads, num_kv_heads, head_dim, sm_scale=None, max_segments_per_request=1, max_tokens_per_request=None, backend=RaggedAttnBackend.AUTO, flashinfer_backend='auto', dtype=None)[source]#
Bases:
objectVarlen attention over segments packed into one forward, with no KV cache: the whole layout is this step’s, and nothing carries to the next. The config of both
RaggedAttentionSpec(self-attention within each span) andRaggedCrossAttentionSpec(one span attending another).Head counts are pre-sharding; the engine narrows them to the rank’s slice at build, as it does for a
KVConfig.- Parameters:
- backend: RaggedAttnBackend = 'auto'#
- class mstar.engine.resources.attn.ragged.config.RaggedAttentionSpec(resource_key, nodes, config)[source]#
Bases:
_RaggedSpecBaseCacheless self-attention within each declared span (
AttentionStep).- Parameters:
resource_key (str)
config (RaggedAttentionConfig)
- class mstar.engine.resources.attn.ragged.config.RaggedAttnBackend(*values)[source]#
Bases:
Enum- AUTO = 'auto'#
- FLASHINFER = 'flashinfer'#
- class mstar.engine.resources.attn.ragged.config.RaggedBlockCausalAttentionSpec(resource_key, nodes, config, block_size)[source]#
Bases:
_RaggedSpecBaseCacheless block-causal self-attention within each declared span: a token in block
bof its span (block_sizetokens a block, from the span’s start) attends every key of blocks0..b. Declared withAttentionStep(causal=False), since the block structure is the whole mask.Its own kind, not a flag on
RaggedAttentionSpec: it runs a different kernel (paged prefill over one-token pages, seeattn.ragged.block_causal).- Parameters:
resource_key (str)
config (RaggedAttentionConfig)
block_size (int)
- class mstar.engine.resources.attn.ragged.config.RaggedCrossAttentionSpec(resource_key, nodes, config)[source]#
Bases:
_RaggedSpecBaseCacheless cross-attention between two spans of each request: a forward’s
(q_label, kv_label)pairs (RaggedCrossAttentionStep), each run throughRaggedAttentionCallable(resource, cross_label(q_label, kv_label)).Separate from
RaggedAttentionSpecso a resource is one kind of attention: a model with both declares one of each per head geometry.- Parameters:
resource_key (str)
config (RaggedAttentionConfig)
- class mstar.engine.resources.attn.ragged.config.RaggedCrossAttentionStep(segments=None, pairs=())[source]#
Bases:
ResourceStepA ragged cross-attention step: which spans attend which.
Each label in
segmentsis one span per request (video tokens, text tokens, …). Each(q_label, kv_label)inpairsis one attention: every request’sq_labelspan attends that request’skv_labelspan, so both labels must be declared for the same requests in the same order. Never causal.