Skip to content
Draft
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
c6375a3
feat(model_card): add ArtifactRef and ArtifactRole types (gh-8749 §2.1)
nnshah1 Apr 27, 2026
c296cc6
feat(model_card): add files vector to MDC and populate at registratio…
nnshah1 Apr 27, 2026
c42d146
feat(local_model): add self_host_metadata field on LocalModelBuilder …
nnshah1 Apr 27, 2026
e6fd1a8
feat(local_model): add self_host_base_url + detect_routable_ip helper…
nnshah1 Apr 27, 2026
82c3822
feat(runtime): add metadata artifact registry and /v1/metadata route …
nnshah1 Apr 27, 2026
a8ac39d
feat(local_model): wire self-host opt-in path through registration (g…
nnshah1 Apr 27, 2026
ba0803a
feat(py-bindings): add self_host_metadata kwarg to register_model (gh…
nnshah1 Apr 27, 2026
c7a876a
feat(model_card): frontend self-host download path with blake3 verify…
nnshah1 Apr 27, 2026
daa71a9
test(model_card): unit tests for the self-host metadata path (gh-8749…
nnshah1 Apr 27, 2026
0d4ab6d
refactor(runtime/metadata_registry): drop dead methods (gh-8749)
nnshah1 Apr 27, 2026
09c32dd
revert(runtime/metadata_registry): keep register/unregister/len/is_em…
nnshah1 Apr 27, 2026
05dc2fe
refactor: rename self-host functions to use codebase-conventional nam…
nnshah1 Apr 27, 2026
b1dc31b
refactor(model_card): drop dedicated cache for downloaded MDC files (…
nnshah1 Apr 27, 2026
d5b24d0
feat(model_card): unify download path + content-addressed cache (gh-8…
nnshah1 Apr 27, 2026
f943752
test(model_card): integration tests for files vector + download path …
nnshah1 Apr 27, 2026
cff199b
feat(local_model): DYN_SELF_HOST_METADATA env var flips builder defau…
nnshah1 Apr 27, 2026
49d6832
refactor: trim comments to match surrounding style + add vLLM e2e tes…
nnshah1 Apr 27, 2026
f80f4d0
test(self-host): validate http path + DRT-level e2e + parallel-safe (…
nnshah1 Apr 27, 2026
ceb6ce6
fix(test): allow dead_code on IsolatedHome::path
nnshah1 Apr 27, 2026
ada70f7
fix: address CodeRabbit review feedback (gh-8749)
nnshah1 Apr 27, 2026
0189da2
fix(local_model): drop the LocalModel::Drop registry cleanup (gh-8749)
nnshah1 Apr 27, 2026
3f9ea6a
fix(test): clippy::cmp_owned on poll_for_card slug compare (gh-8749)
nnshah1 Apr 27, 2026
2df277c
fix(mdc-cache): isolate per-(slug, mdcsum) symlinks (gh-8749)
nnshah1 Apr 27, 2026
ce609dc
fix(self-host-metadata): bound http body, share request-plane resolve…
nnshah1 Apr 27, 2026
f33ab89
refactor(self-host-metadata): collapse to typed-enum, single source o…
nnshah1 Apr 28, 2026
14a0c81
fix(self-host): coordinate concurrent fetches; mocker multi-replica e…
nnshah1 Apr 28, 2026
8eb74e3
fix(self-host): atomic publish for blobs and symlinks; multi-frontend…
nnshah1 Apr 28, 2026
7cd79b9
test(self-host): align file:// path; parametrize mocker over 3 scheme…
nnshah1 Apr 28, 2026
f966a39
docs(self-host): tighten comments on metadata-cache helpers (gh-8749)
nnshah1 Apr 28, 2026
cec0fc1
fix(self-host): cargo fmt + black on comment-cleanup commit (gh-8749)
nnshah1 Apr 28, 2026
a038da9
fix(self-host): regenerate lib/bindings/kvbm/Cargo.lock (gh-8749)
nnshah1 Apr 28, 2026
6f22920
feat(self-host): default self_host_metadata to ON, skip gracefully (g…
nnshah1 Apr 28, 2026
f32f33a
docs(frontend): describe worker self-hosted metadata as the default (…
nnshah1 Apr 28, 2026
b2339de
docs(frontend): recommend self-host metadata; drop legacy recommendat…
nnshah1 Apr 28, 2026
6880a9f
fix(self-host): warn when enabled without system_status_server (gh-8749)
nnshah1 Apr 28, 2026
bd86bf9
fix(self-host): apply review nits from grahamking (gh-8749)
nnshah1 Apr 28, 2026
6b40fb2
fix(self-host): residual review-pattern cleanups (gh-8749)
nnshah1 Apr 28, 2026
262f314
fix(self-host): preserve original filename when worker has HF cache s…
nnshah1 Apr 29, 2026
1257fe0
fix(self-host): rewrite custom chat template path after resolve (gh-8…
nnshah1 Apr 29, 2026
2098e32
docs(self-host): tighten review-comment blocks per graham's lessons (…
nnshah1 Apr 29, 2026
6372847
refactor(self-host): reuse Checksum accessor + parking_lot::RwLock (g…
nnshah1 Apr 29, 2026
5a9095c
docs(self-host): trim obvious 'what' comments per graham-code-review …
nnshah1 Apr 29, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions docs/components/frontend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ This starts an OpenAI-compatible HTTP server with integrated pre/post processing

The frontend does the pre and post processing. To do this it will need access to the model configuration files: `config.json`, `tokenizer.json`, `tokenizer_config.json`, etc. It does not need the weights.

Frontend will download the files it needs from Hugging Face, no setup is required. However we recommend setting up [modelexpress-server](https://github.com/ai-dynamo/modelexpress) and a shared folder such as a Kubernetes PVC. This ensures the model is only downloaded once across the whole cluster.
**Recommended: worker-self-hosted metadata.** Each worker exposes its metadata files on its system status server (`DYN_SYSTEM_PORT`, automatically set to `9090` by the Kubernetes operator). At registration the frontend fetches each file over HTTP from `http://<worker>/v1/metadata/<slug>/<filename>` and verifies its blake3 checksum against the model's discovery card before caching it under `~/.cache/dynamo/mdc/`. This path requires no shared filesystem and no HuggingFace access on the frontend pod, works uniformly for public, private, and custom models, and is the default. Set `DYN_SELF_HOST_METADATA=false` on the worker (or pass `self_host_metadata=False` to `register_model(...)`) only if you have a specific reason to opt out. For non-Kubernetes setups, set `DYN_SYSTEM_PORT` explicitly on the worker — otherwise the system status server doesn't run and self-host silently no-ops, falling through to the legacy paths below.

If the model is not available on Hugging Face, such as a private or customized model, you will need to make the model files available locally at the same file path as on the backend. The backend's `--model-path <here>` will need to exist on the frontend and contain at least the configuration (JSON) files.
**Legacy fallback paths** (used for opt-out workers, pre-PR workers, or environments where `DYN_SYSTEM_PORT` isn't set): the frontend can download files directly from Hugging Face for public models (optionally via [modelexpress-server](https://github.com/ai-dynamo/modelexpress) when configured), or read them from the same local path the worker used — the backend's `--model-path <here>` must exist on the frontend pod with at least the configuration JSON files. For private or customized models not on Hugging Face, the local-path approach is the only legacy option.

### KServe gRPC Frontend

Expand Down
1 change: 1 addition & 0 deletions lib/bindings/kvbm/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lib/bindings/python/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion lib/bindings/python/rust/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ fn lora_name_to_id(lora_name: &str) -> i32 {
/// For LoRA mode, both `lora_name` and `base_model_path` must be provided together.
/// Providing only one of them will result in an error.
#[pyfunction]
#[pyo3(signature = (model_input, model_type, endpoint, model_path, model_name=None, context_length=None, kv_cache_block_size=None, router_config=None, runtime_config=None, user_data=None, custom_template_path=None, media_decoder=None, media_fetcher=None, lora_name=None, base_model_path=None))]
#[pyo3(signature = (model_input, model_type, endpoint, model_path, model_name=None, context_length=None, kv_cache_block_size=None, router_config=None, runtime_config=None, user_data=None, custom_template_path=None, media_decoder=None, media_fetcher=None, lora_name=None, base_model_path=None, self_host_metadata=None))]
#[allow(clippy::too_many_arguments)]
fn register_model<'p>(
py: Python<'p>,
Expand All @@ -283,6 +283,7 @@ fn register_model<'p>(
media_fetcher: Option<MediaFetcher>,
lora_name: Option<&str>,
base_model_path: Option<&str>,
self_host_metadata: Option<bool>,
) -> PyResult<Bound<'p, PyAny>> {
// Validate Prefill model type requirements
if model_type.inner == llm_rs::model_type::ModelType::Prefill
Expand Down Expand Up @@ -406,6 +407,10 @@ fn register_model<'p>(
.custom_template_path(custom_template_path_owned)
.media_decoder(media_decoder.map(|m| m.inner))
.media_fetcher(media_fetcher.map(|m| m.inner));
// Absence falls through to the DYN_SELF_HOST_METADATA env var default.
if let Some(enabled) = self_host_metadata {
builder.self_host_metadata(enabled);
}

let mut local_model = builder.build().await.map_err(to_pyerr)?;

Expand Down
1 change: 1 addition & 0 deletions lib/llm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ futures = { workspace = true }
futures-util = { workspace = true }
hf-hub = { workspace = true }
ipnet = { workspace = true }
libc = { workspace = true }
rand = { workspace = true }
oneshot = { workspace = true }
parking_lot = { workspace = true }
Expand Down
54 changes: 51 additions & 3 deletions lib/llm/src/common/checked_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,16 @@ use url::Url;

#[derive(Clone, Debug)]
pub struct CheckedFile {
/// Either a path on local disk or a remote URL (usually nats object store)
/// Either a path on local disk or a remote URL.
path: Either<PathBuf, Url>,

/// Checksum of the contents of path
checksum: Checksum,

/// File size in bytes. `None` when deserialized from a pre-size MDC
/// (legacy wire format) — used as a "this is a new-format MDC" discriminant
/// downstream so consumers can keep cross-version compat.
size: Option<u64>,
}

#[derive(Debug, Clone, Eq, PartialEq)]
Expand All @@ -48,11 +53,13 @@ impl CheckedFile {
if !path.is_file() {
anyhow::bail!("Not a file: {}", path.display());
}
let size = std::fs::metadata(&path)?.len();
let hash = b3sum(&path)?;

Ok(CheckedFile {
path: Either::Left(path),
checksum: Checksum::blake3(hash),
size: Some(size),
})
}

Expand Down Expand Up @@ -86,6 +93,10 @@ impl CheckedFile {
&self.checksum
}

pub fn size(&self) -> Option<u64> {
self.size
}

/// Does the given file checksum to the same value as this CheckedFile?
pub fn checksum_matches<P: AsRef<Path> + std::fmt::Debug>(&self, disk_file: P) -> bool {
match b3sum(&disk_file) {
Expand Down Expand Up @@ -144,21 +155,28 @@ impl Serialize for CheckedFile {
where
S: Serializer,
{
let mut cf = serializer.serialize_struct("CheckedFile", 2)?;
let n = if self.size.is_some() { 3 } else { 2 };
let mut cf = serializer.serialize_struct("CheckedFile", n)?;
match &self.path {
Either::Left(path) => cf.serialize_field("path", &path)?,
Either::Right(url) => cf.serialize_field("path", &url)?,
};
cf.serialize_field("checksum", &self.checksum)?;
if let Some(size) = self.size {
cf.serialize_field("size", &size)?;
}
cf.end()
}
}

/// Internal type to simplify deserializing
/// Internal type to simplify deserializing. `size` is `#[serde(default)]`
/// so old MDC bytes (no size field) deserialize cleanly with `size = None`.
#[derive(Deserialize)]
struct WireCheckedFile {
path: String,
checksum: Checksum,
#[serde(default)]
size: Option<u64>,
}

// Convert from the temporary struct to CheckedFile with path type logic.
Expand All @@ -169,10 +187,12 @@ impl From<WireCheckedFile> for CheckedFile {
Ok(url) => CheckedFile {
path: Either::Right(url),
checksum: temp.checksum,
size: temp.size,
},
Err(_) => CheckedFile {
path: Either::Left(PathBuf::from(temp.path)),
checksum: temp.checksum,
size: temp.size,
},
}
}
Expand Down Expand Up @@ -362,5 +382,33 @@ mod tests {
let expected =
Checksum::blake3("62bc124be974d3a25db05bedc99422660c26715e5bbda0b37d14bd84a0c65ab2");
assert_eq!(expected, *cf.checksum());
assert_eq!(Some(560), cf.size(), "TinyLlama config.json is 560 bytes");
}

/// Old MDC bytes (no `size` field) deserialize cleanly with
/// `size = None`, preserving cross-version compat.
#[test]
fn test_legacy_wire_format_omits_size() {
let legacy = r#"{"path":"/x/config.json","checksum":"blake3:abc"}"#;
let cf: CheckedFile = serde_json::from_str(legacy).unwrap();
assert_eq!(None, cf.size());
assert_eq!("/x/config.json", cf.path().unwrap().to_str().unwrap());
}

/// New-format CheckedFiles round-trip with the size field.
#[test]
fn test_new_wire_format_carries_size() {
let cf = CheckedFile {
path: Either::Left(PathBuf::from("/x/tokenizer.json")),
checksum: Checksum::blake3("abc"),
size: Some(12345),
};
let json = serde_json::to_string(&cf).unwrap();
assert!(
json.contains("\"size\":12345"),
"expected size field in serialization, got: {json}"
);
let back: CheckedFile = serde_json::from_str(&json).unwrap();
assert_eq!(Some(12345), back.size());
}
}
Loading
Loading