mstar.engine.resources.lora.identity#

Which weights an adapter name stands for, as the prefix cache keys them.

A request on an adapter fills KV pages that differ from the base model’s for the same tokens, so its prompt’s key chain hangs from a root that names the adapter’s weights (AdapterPrefixRoots). The preprocess worker, which keys prompts, reads each adapter once when it is registered; nothing about an adapter travels per step.

Functions

adapter_digest(adapter)

SHA-256 over everything an adapter's delta depends on, rank-independent.

adapter_prefix_root(digest)

The root an adapter's key chains hang from.

read_adapter_digest(spec, path)

The digest of the adapter at path, read as the pool reads it (spec.convert_keys).

Classes

AdapterPrefixRoots([roots])

Adapter name -> the root its requests' key chains hang from.

class mstar.engine.resources.lora.identity.AdapterPrefixRoots(roots=None)[source]#

Bases: object

Adapter name -> the root its requests’ key chains hang from.

A name that is not registered has no root, and a request on it must not be keyed at all: keyed under the base model’s empty root, its pages would serve base requests. register and unregister are the hooks for loading and unloading an adapter at runtime; reads happen on the request-preparation threads (the prepare pool, or the preprocess thread inline), writes on whichever thread registers.

Parameters:

roots (dict[str, bytes] | None)

classmethod read(spec, digests=None)[source]#

Register every adapter spec (a LoraSpec) serves under digests, or, for one not in it, under the digest of its file, read once.

Parameters:

digests (dict[str, bytes] | None)

Return type:

AdapterPrefixRoots

register(name, digest)[source]#
Parameters:
Return type:

None

root(name)[source]#
Parameters:

name (str)

Return type:

bytes | None

unregister(name)[source]#
Parameters:

name (str)

Return type:

None

mstar.engine.resources.lora.identity.adapter_digest(adapter)[source]#

SHA-256 over everything an adapter’s delta depends on, rank-independent.

adapter is a LoraAdapter as read_lora_file returns it: every module’s name, alpha (the sidecar’s included), and A and B with their dtype and shape, so that equal bytes of a different shape or dtype digest apart.

Return type:

bytes

mstar.engine.resources.lora.identity.adapter_prefix_root(digest)[source]#

The root an adapter’s key chains hang from.

The digest alone, not the name: KV depends on the weights, so two names for the same weights share pages, and one name reloaded with other weights does not.

Parameters:

digest (bytes)

Return type:

bytes

mstar.engine.resources.lora.identity.read_adapter_digest(spec, path)[source]#

The digest of the adapter at path, read as the pool reads it (spec.convert_keys).

Parameters:

path (str)

Return type:

bytes