mstar.engine.resources.position.manager#
does plan_rope/apply_rope of cache_manager.py
has ownership of per-(request,label) position counter
Classes
|
Where each of a request's streams has reached. |
|
rotary position on top flashinfer in-place kernels |
- class mstar.engine.resources.position.manager.PositionManager[source]#
Bases:
Resource- classmethod build(spec, info)[source]#
- Parameters:
spec (PositionSpec)
info (EngineResourceInfo)
- class mstar.engine.resources.position.manager.PublishedPositionInfo(counters=<factory>)[source]#
Bases:
PublishedInfoWhere each of a request’s streams has reached. label -> next position.
- update(other)[source]#
- Parameters:
other (PublishedPositionInfo)
- Return type:
None
- class mstar.engine.resources.position.manager.RopeManager(config, device, max_seq_len=32768, head_dim=None, dtype=torch.bfloat16)[source]#
Bases:
PositionManagerrotary position on top flashinfer in-place kernels
- Parameters:
config (PositionConfig)
device (device)
max_seq_len (int)
head_dim (int | None)
dtype (dtype)
- admit_retrieve(rid, node_name, graph_walk, published)[source]#
Take on the counters a stream was published with.
A node that receives another node’s KV (a CFG branch on its own GPU, a decode engine after disaggregated prefill) has never advanced these streams itself, so its counters start at zero while the KV it just pulled in is many tokens long. Monotonic, like the KV lengths beside them: a stale echo of this node’s own publish never rewinds it.
- Parameters:
rid (str)
node_name (str)
graph_walk (str)
published (PublishedPositionInfo | None)
- Return type:
- apply_cached_prefix(rid, node_name, graph_walk, inputs, prefix)[source]#
Move the stream’s counter past what the cache holds of this walk.
The counter moves here and not at admit. A walk the cache serves never admits, and the walk after it can place its positions in prepare_inputs, before its own admit, so a counter seeded at admit would put that walk on top of the served ones. The position is absolute, so a repeated probe moves nothing.
- Parameters:
rid (str)
node_name (str)
graph_walk (str)
prefix (CachedPrefix | None)
- Return type:
None
- apply_qk(q, k, label, rotary_dim=None, interleave=None, rope_scale=None, rope_theta=None, rope_dtype=None, **kwargs)[source]#
- commit(step, ctx)[source]#
record step consumption
- Parameters:
step (PositionStep)
ctx (StepContext)
- fingerprint()[source]#
What this resource contributes to the prefix cache’s root.
Everything a stored page depends on beyond its own tokens. None leaves the resource out of the root, which is right only where it cannot change what a page holds.
- Return type:
- property force_double_buffer#
Whether this resource needs double-buffering even off the pre-plan path.
A resource that stages a step’s layout into a reused host buffer and issues a non-blocking H2D into a graph-read device buffer has a race the moment the CPU runs ahead of the GPU: plan(N+1) can overwrite the buffer before step N’s DMA has retired, and the replay attends with N+1’s data. The buffer need not be ours — FlashInfer’s
planholds one per wrapper, which is why the attention managers key theirs per slot. The main runner already double-buffers whenever a resourcesupports_preplan; this flag extends that to a runner that has no pre-plan path but still replays such a resource — notably the piecewise runner — and makes_exec_per_requestfence before it reuses a slot, since its sub-steps all run inside one step. Off by default; a resource opts in only if it has this hazard.
- ingest_request(rid, overrides=None)[source]#
Must be idempotent: the conductor sends one NewRequest per partition, so a worker serving several partitions of a request ingests it once for each, possibly after a node has already run a step for it.
- Parameters:
rid (str)
- plan(step, ctx)[source]#
submits one position id vector for each plan label
plan labels and token ordering comes from KV plan output
- Parameters:
step (PositionStep)
ctx (StepContext)
- Return type:
- publish(request_id)[source]#
- Parameters:
request_id (str)
- Return type:
PublishedPositionInfo | None
- publish_from_snapshot(request_id, snapshot, node_name, graph_walk)[source]#
Finish a
publish_snapshot_for_steprecord into the published info.
- publish_snapshot_for_step(request_id, node_name, graph_walk)[source]#
A cheap record of what
publish_for_stepwould export right now.The worker finishes it with
publish_from_snapshotonly for the requests whose frame or completion carries the publication, which in a steady decode loop is none of them. The default takes the eager publication itself, so a resource is correct without overriding; one whose publish builds something per request (a page list, a transfer descriptor) overrides both to record a few scalars here instead.
- property supports_preplan#