mstar.engine.resources.runner#
sequencing for resource call cycle
runner only moves .plan outputs by putting under StepContext.plan_results and handing to next. (in fact, maybe plan should do this and runner only moves StepContext?)
Functions
|
Keys in dependency order; built resources at load, their specs when the conductor validates a deployment. |
Classes
|
drives resources through per-step cycle |
- class mstar.engine.resources.runner.StepRunner(resources, node_resources=None, enable_nvtx=False)[source]#
Bases:
objectdrives resources through per-step cycle
- Parameters:
- admit(step)[source]#
Reserve capacity for step. A refused admit gives back everything the step reserved.
- Parameters:
step (SubmoduleStep)
- Return type:
- admit_retrieve(rid, node_name, graph_walk, published=None)[source]#
bring published state in
gives ready=False when still has inflights; shortcircuit on failure
Swept over node_name’s own resources. Asking a node about resources it does not own is not just wasted work: KVManager.get_labels answers for an unrecognised node with the default [“main”], so the node ends up gated on — and able to allocate against — another node’s cache.
- Parameters:
- Return type:
- apply_cached_prefix(rid, node_name, graph_walk, inputs, prefix)[source]#
Give every resource the agreed prefix, with the untrimmed inputs.
- Parameters:
rid (str)
node_name (str)
graph_walk (str)
prefix (CachedPrefix | None)
- Return type:
None
- build_accelerator_graph_buffers(slots, max_bs, max_seq_len, node_name=None)[source]#
resources preallocate the static buffers captured replays will read
Swept over
node_name’s own resources: another node’s slot count and batch size say nothing about a resource this node’s graphs never touch.- Parameters:
slots (list[CGSlotSpec])
max_bs (int)
max_seq_len (int)
node_name (str | None)
- Return type:
None
- clear_preplan()[source]#
Drop the staged pre-plan on every resource, and the record of it.
- Return type:
None
- commit(step)[source]#
record step consumption
- Parameters:
step (SubmoduleStep)
- Return type:
None
- complete_cached_walk(rid, node_name, graph_walk)[source]#
Tell the node’s resources that the cache served this walk whole.
- extend_prefix_chains(rid, node_name, graph_walk, outputs, keys=None)[source]#
Offer this step’s sampled tokens to the node’s own resources.
- extend_prefix_chains_batch(request_ids, node_name, walk_of, host_rows, outputs, keys)[source]#
extend_prefix_chainsfor a step: a resource with a batch form takes the host rows; the others are offered each request’s host copy.walk_ofrather than one walk for the step, so a combined walk comes through here too instead of falling back to a call per row; a step of one walk passes that walk itself.
- ingest_capture_row(rid)[source]#
open a capture padding row on all resources
- Parameters:
rid (str)
- Return type:
None
- ingest_request(rid, overrides=None)[source]#
open state on all resources; overrides are per-resource. All or nothing: a resource that raises leaves the request on none of them.
- Parameters:
rid (str)
overrides (Mapping[str, ResourceReqConfig] | None)
- Return type:
None
- plan(step)[source]#
plan in dependency order
place plan in step.ctx.plan_results before next plan runs again could possibly move that into plan itself
- Parameters:
step (SubmoduleStep)
- Return type:
- pre_admit(step)[source]#
admit over the pre-planning subset, a step ahead
the later full admit covers the rest; these resources see their own state as already reserved and no-op
Unwound on refusal exactly as
admitis.- Parameters:
step (SubmoduleStep)
- Return type:
- pre_plan(step)[source]#
plan the pre-planning subset, a step ahead
ctx.is_preplan sends each one’s output to its pending slot rather than the live one; the later full plan promotes it. Results are left in ctx.plan_results for the dependents in this same subset.
- Parameters:
step (SubmoduleStep)
- Return type:
- prefix_chain_keys(node_name)[source]#
The node’s resources with a prefix cache open right now. Empty in the common case, which lets the caller skip a per-request sweep that was six no-op calls per request per step.
- publish(request_ids, node_name=None, graph_walk=None, request_walks=None)[source]#
durable state outward publish
non-publish resources noop; pairs with admit_retrieve
Scoped to the node whose step just ran; no other node’s state moved, and merge_publish_info keeps the entry it already published.
- publish_after_stop(request_ids, node_name=None, graph_walk=None, request_walks=None)[source]#
Publish resources configured for the end of a dynamic loop.
- publish_from_snapshots(snapshots, request_ids, node_name=None, graph_walk=None, request_walks=None)[source]#
The published info of
request_idsfrom their snapshots, each under its own walk (seepublish_snapshot).
- publish_snapshot(request_ids, node_name=None, graph_walk=None, request_walks=None)[source]#
publish, deferred: per rid the snapshot each publisher took.Finished by
publish_from_snapshotsfor the rids that need it. A rid with nothing to publish has no entry. Under a combined walk each rid is snapshotted under its own walk (request_walks), aspublishdoes: a publisher may key what it publishes on the walk.
- resolve_cached_prefix(rid, node_name, graph_walk, inputs)[source]#
The longest prefix of this walk every resource on
node_namecan serve.The smallest answer wins, because a step is one span: a resource that holds less than another has to be caught up by the tokens that run. A resource with no opinion is not an answer of zero.
- Parameters:
- Return type:
CachedPrefix | None
- rollback_admit(step)[source]#
Give back everything an admitted step reserved, for a step that will not run: the unwind a refused
admitdoes, over every resource the step declares.- Parameters:
step (SubmoduleStep)
- Return type:
None