mstar.engine.resources.kv.bounded#
- class mstar.engine.resources.kv.bounded.BoundedKVConfig(num_layers: int, num_heads: int, head_dim: int, rows_per_request: int, max_source_len: int, retention: collections.abc.Callable[[int], mstar.engine.resources.kv.bounded.config.SinkWindow] | mstar.engine.resources.kv.bounded.config.SinkWindow, max_slots: int = 32, min_source_len: int = 0, dtype: torch.dtype | None = torch.float32, reverse_step_order: bool = False, query_window: int | None = None)[source]#
Bases:
object- Parameters:
- retention: Callable[[int], SinkWindow] | SinkWindow#
- class mstar.engine.resources.kv.bounded.BoundedKVSpec(resource_key: str, nodes: set[str], config: mstar.engine.resources.kv.bounded.config.BoundedKVConfig)[source]#
Bases:
NodeResourceSpec- Parameters:
resource_key (str)
config (BoundedKVConfig)
- apply_yaml_overrides(max_slots=None)[source]#
Patch declared parameters from this resource’s YAML block.
The model declares shapes that suit the model; a deployment tunes what suits the box it runs on. The block is scoped to this spec’s
resource_key(seeapply_yaml_overridesbelow), so an unrecognized key here is a typo, not another resource’s setting — subclasses name exactly what they accept and let the rest raise.TODO: generalize. Matching YAML keys against the spec’s (and its config’s) dataclass fields would remove these per-resource implementations, at the cost of silently accepting anything named alike.
- Parameters:
max_slots (int | None)
- config: BoundedKVConfig#
- class mstar.engine.resources.kv.bounded.BoundedKVStep(segments=None, positions=<factory>)[source]#
Bases:
ResourceStepEach segment’s
spanis what its request writes this step (0 reads only).The positions come from the model, not the resource, so a plan never waits on the previous step’s commit and planning the same step twice (a piecewise region inside a forward that declared it too) is harmless.
- Parameters:
positions (Mapping[str, StreamPosition])
- positions: Mapping[str, StreamPosition]#
- class mstar.engine.resources.kv.bounded.SinkWindow(sink, window, window_includes_step=False)[source]#
Bases:
NamedTupleKeep the stream’s first
sinkand lastwindowentries. Withwindow_includes_stepthe window counts the step’s own tokens, so a step that writesspanattends only the lastwindow - spanretained ones.
- class mstar.engine.resources.kv.bounded.StreamPosition(source_len, written, source=0)[source]#
Bases:
NamedTupleWhere a request’s stream stands when a step starts.
Modules