Skip to content

feat: add model state artifacts linked through subject - #240

Open
JGalego wants to merge 2 commits into
modelpack:mainfrom
JGalego:feat/model-state-artifacts
Open

JGalego wants to merge 2 commits into
modelpack:mainfrom
JGalego:feat/model-state-artifacts

Conversation

@JGalego

@JGalego JGalego commented Nov 12, 2026 •

Copy link
Copy Markdown

Description

Adds OCI artifacts for runtime state, such as prompt caches and saved conversations.

  • Manifest: application/vnd.cncf.model.state.manifest.v1+json with a required subject referencing the model artifact's manifest.
  • Config: application/vnd.cncf.model.state.config.v1+json with required format (encoding and version) and tokens, and optional precision.
  • Layers: application/vnd.cncf.model.state.v1.raw, .tar, .tar+gzip, and .tar+zstd.
  • Discovery: OCI referrers API with the referrers tag schema as a fallback.

Adds Go types and constants, a JSON schema, typed config validation, and tests for invalid configs and the documentation example.

State encoding is runtime-specific and identified by format. Loading rules:

  • A state MUST NOT be loaded for a model other than the one its subject references, or by a runtime that does not support its format.
  • A runtime SHOULD produce the same output as it would by processing the state's tokens without the state.
  • Runtimes SHOULD load only states they trust, not every state listed as a referrer of the model.

States built from images, audio or other non-token input, or with an adapter applied, are out of scope. Existing media types and the model config schema are unchanged.

Related Issue

Closes #239

Motivation and Context

ModelPack does not currently define how to package reusable runtime state. This supports two use cases:

  • Replicas, including new ones during autoscaling, load a precomputed prompt cache instead of reprocessing a shared prompt or document.
  • A saved conversation resumes on another machine.

Linking through subject leaves the model artifact unchanged and lets multiple states be published independently. As discussed on #60, the doc notes that this link is advisory.

This PR proposes defining state artifacts in ModelPack rather than a separate spec.

Define an artifact for state that a runtime builds while running a
model, such as a prompt cache or a saved conversation. Its manifest
references the model artifact through subject, and its config records
the state's format, the tokens it was built from and, optionally, its
precision.

Refs modelpack#239

Signed-off-by: João Galego <jgalego1990@gmail.com>
Add the artifact, config and layer media types for model state
artifacts, a State type for the config, and a JSON schema registered
under ValidatorMediaTypeModelStateConfig. As with model configs, the
validator decodes a state config into its Go type before validating it
against the schema.

Refs modelpack#239

Signed-off-by: João Galego <jgalego1990@gmail.com>
@JGalego
JGalego force-pushed the feat/model-state-artifacts branch from 1435155 to dc063a4 Compare November 12, 2026 10:56
@JGalego
JGalego marked this pull request as ready for review November 12, 2026 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Model state artifacts: prompt caches and primed sessions linked to their model through subject

1 participant