[Core] Reuse OCI model artifacts by Hugging Face origin#664
Open
op109lvb wants to merge 2 commits into
Open
Conversation
op109lvb
requested review from
beiguo218,
pallasathena92,
slin1237 and
truddy0
as code owners
July 13, 2026 07:57
op109lvb
force-pushed
the
oci-reuse-latest
branch
from
July 13, 2026 08:26
1a164c8 to
4fc08a0
Compare
EdHasNoLife
reviewed
Jul 13, 2026
| } | ||
|
|
||
| func canonicalHuggingFaceArtifactPath(destPath string, identity ArtifactIdentity) string { | ||
| return filepath.Join(filepath.Dir(destPath), constants.ModelArtifactsDirectory, filepath.FromSlash(strings.Trim(strings.TrimSpace(identity.HFModelID), "/")), strings.ToLower(identity.HFCommitSHA)) |
There was a problem hiding this comment.
shall we add sanitization against ../ sequences
Collaborator
Author
There was a problem hiding this comment.
HF model IDs should not contain those sequences per Hugging Face repo ID rules, and upstream should already validate that. I still addressed this by adding model-agent-side validation as defense-in-depth before using the annotation to build local artifact paths.
EdHasNoLife
reviewed
Jul 13, 2026
| if task != nil && task.BaseModel != nil { | ||
| return canonicalHuggingFaceArtifactPath(destPath, identity) | ||
| } | ||
| return filepath.Join(modelRootDir, filepath.FromSlash(strings.Trim(strings.TrimSpace(identity.HFModelID), "/")), strings.ToLower(identity.HFCommitSHA)) |
op109lvb
force-pushed
the
oci-reuse-latest
branch
from
July 15, 2026 00:50
4fc08a0 to
a86518f
Compare
EdHasNoLife
approved these changes
Jul 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does
This PR adds shared node-local artifact reuse for HF-origin OCI Object Storage models by using HF model ID + commit SHA as the artifact identity. It downloads once to a canonical parent, symlinks model-local paths to that parent, tracks parent/child relationships, and adds restart/retry handling so shared parents are recovered or validated safely after model-agent restarts.
More details
Adds node-local reuse for HF-origin OCI Object Storage artifacts when a model CR provides HF model ID, HF commit SHA,
ReuseIfExists, and a SHA-scoped OCI Object Storage URI.Model-agent now treats
<hf-model-id>/<sha>as the shared artifact identity:_artifacts/<hf-model-id>/<sha>.It also adds lifecycle handling for the shared parent:
DownloadOverriderepairs/redownloads the shared parent, since all children point to the same files.Restart and concurrency safety is included:
Updatingstate to ensure only one worker validates or rebuilds a shared parent at a time.Updating: if the ready marker exists, marks the parentReady; if missing, marks itFailedso later child tasks can rebuild.Legacy behavior is preserved for model CRs that do not provide the HF reuse metadata. Backfill is out of scope.
Why we need it
Multiple model CRs can point to the same HF model revision after the artifact has been copied into OCI Object Storage. Reusing the node-local artifact by HF model ID + SHA avoids duplicate downloads and saves node disk space, while still preserving repair behavior for corrupted files.
Fixes #
How to test
Run model-agent unit tests covering HF parent path selection, symlink reuse, child tracking, delete cleanup, startup recovery, startup validation, and DownloadOverride repair behavior.
E2E: create two model CRs with the same HF model ID + SHA,
ReuseIfExists, and the same SHA-scoped OCI Object Storage URI. Verify the first model downloads to_artifacts/<hf-model-id>/<sha>and the second model-local path is a symlink to the same parent.E2E coverage:
_artifacts/<hf-model-id>/<sha>.Updatingparent entries recover or fail safely.DownloadOverrideredownloads the parent artifact.Checklist
make testpasses locally