mstar.engine.resources.spec#

Resource declarations models hand to the engine.

The engine builds each node’s resources once, at load time, from these specs. A spec names what to build and its parameters; the model declares, the engine constructs. The default declaration wraps a model’s KV cache configs unchanged, so a model only overrides it to add resources beyond what those configs already describe.

Functions

apply_yaml_overrides(specs, model_config)

Apply a deployment's resources: block to the specs it names.

resolve_spec_dependencies(specs)

Index specs by resource key, checking uniqueness and depends_on.

Classes

NodeResourceSpec(resource_key, nodes)

ResourceReqConfig()

Per-request parameters for one resource, carried on the request and handed to that resource at ingest.

class mstar.engine.resources.spec.NodeResourceSpec(resource_key: str, nodes: set[str])[source]#

Bases: ABC

Parameters:
apply_yaml_overrides(**kwargs)[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 (see apply_yaml_overrides below), 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.

depends_on()[source]#

Keys whose specs this one builds against; the engine resolves them into EngineResourceInfo.dependencies.

Return type:

set[str]

nodes: set[str]#
abstract property resource_class: type[Resource]#

What builds this spec. Imported inside the property, so declaring a resource stays free of the manager and its kernels.

The builder, not necessarily the class built: an attention spec names AttentionManager, whose build picks a backend subclass.

resource_key: str#
class mstar.engine.resources.spec.ResourceReqConfig[source]#

Bases: object

Per-request parameters for one resource, carried on the request and handed to that resource at ingest. Keyed by resource key, so it needs no tag of its own — a marker base, with no contract beyond the hook below.

apply_conductor_config(**kwargs)[source]#
mstar.engine.resources.spec.apply_yaml_overrides(specs, model_config)[source]#

Apply a deployment’s resources: block to the specs it names.

resources: {<resource_key>: {...}}, one block per resource, so a model with two pools of the same kind (whisper’s decoder cache and its encoder context) can have each tuned on its own. An unknown key is an error: it would otherwise be a silently ineffective setting.

Parameters:
Return type:

None

mstar.engine.resources.spec.resolve_spec_dependencies(specs)[source]#

Index specs by resource key, checking uniqueness and depends_on.

Parameters:

specs (Sequence[NodeResourceSpec])

Return type:

dict[str, NodeResourceSpec]