mstar.engine.resources.attn.base#
The attention resource’s shared machinery: the spec-time factory, the custom op every backend attends through, and the workspace pool.
The backends themselves live beside this — flashinfer, cross, dense — and AttentionManager.build reaches them by deferred import, so naming a backend in a spec does not load the other two.
Classes
|
Fingerprint of a wrapper |
|
FlashInfer workspace buffers, one per (plan label, cg slot). |
- class mstar.engine.resources.attn.base.AttentionManager[source]#
Bases:
AttentionResource- classmethod build(spec, info)[source]#
- Parameters:
spec (AttentionSpec)
info (EngineResourceInfo)
- property requires_kv_write: bool#
Whether a layer must write this step’s K/V through the KV resource before calling
run.False only for backends that take the fresh K/V straight into the kernel (the dense one). A layer therefore reads
- if self.attn.requires_kv_write:
self.kv.write_kv(k, v, layer_idx=i, label=label)
out = self.attn.run(q, label, kv.layer_view(i), k=k, v=v, layer_idx=i)
and stays correct whichever backend the spec named.
- class mstar.engine.resources.attn.base.PlanCacheKey(q_seq_lens, page_indices, last_page_lens)[source]#
Bases:
NamedTupleFingerprint of a wrapper
plancall’s inputs. When it is unchanged between steps the re-plan is skippable.