mstar.engine.resources.kv.plan#
The KV plan: what KVManager.plan hands its dependents.
Attention and positions read this and nothing else of the KV resource — the packed ordering, one view per (request, label) stream, and the index tensors a paged-attention wrapper plans against. Kept apart from the manager so a consumer depends on the contract rather than on the cache.
Functions
|
|
|
Segments per plan label in order of packed forward view |
Classes
|
Output of KVManager.plan for a single label |
|
Plan label -> output, plus the label forks of the step it came from. |
|
The four int32 index tensors a FlashInfer prefill/decode wrapper's |
|
One (request, label) stream as this step sees it. |
- class mstar.engine.resources.kv.plan.KVPlanOutput(cpu_indptrs, views, cuda_indptrs=None)[source]#
Bases:
objectOutput of KVManager.plan for a single label
- Parameters:
cpu_indptrs (PagedIndptrs)
views (list[SequenceView])
cuda_indptrs (PagedIndptrs | None)
- cpu_indptrs: PagedIndptrs#
- cuda_indptrs: PagedIndptrs | None = None#
- views: list[SequenceView]#
- class mstar.engine.resources.kv.plan.KVPlanOutputs(mapping=None, pre_forks=(), post_forks=())[source]#
Bases:
dict[str,KVPlanOutput]Plan label -> output, plus the label forks of the step it came from.
A dict subclass so consumers that only want the per-label plans keep reading it as the mapping it is. Positions need the forks too — a fork target inherits the source’s counter the way it inherits its pages — and a fork target is not necessarily a segment of the step, so it has nowhere else to ride.
- Parameters:
- post_forks#
- pre_forks#
- class mstar.engine.resources.kv.plan.PagedIndptrs(qo_indptr, paged_kv_indptr, paged_kv_indices, paged_kv_last_page_len)[source]#
Bases:
NamedTupleThe four int32 index tensors a FlashInfer prefill/decode wrapper’s
planconsumes, built on CPU (so wrapper.plan’s.to("cpu")is a no-op — seeFlashInferAttentionManager.plan).- Parameters:
- class mstar.engine.resources.kv.plan.SequenceView(request_id, label, page_idxs, length, to_compute, start=0, generation=0)[source]#
Bases:
NamedTupleOne (request, label) stream as this step sees it. A NamedTuple because it is built per segment per step and never mutated.
- Parameters:
- mstar.engine.resources.kv.plan.build_paged_indptrs(segments, page_size)[source]#
- Parameters:
segments (list[SequenceView])
page_size (int)
- Return type:
- mstar.engine.resources.kv.plan.group_by_plan_label(segments, combined_labels)[source]#
Segments per plan label in order of packed forward view
combined plan concats source labels in label major order. standalone keeps og batch order. KV should be sole producer of this ordering and eveyrone else will read plan output of KV
NOTE: combined key with a source label with no segments in step will cause KeyError