Skip to content

fix(decision): restore custom model cache versions after restart - #6313

Open
Jackmeson1 wants to merge 2 commits into
xorbitsai:mainfrom
Jackmeson1:fix/decision-custom-cache-restart
Open

Jackmeson1 wants to merge 2 commits into
xorbitsai:mainfrom
Jackmeson1:fix/decision-custom-cache-restart

Conversation

@Jackmeson1

@Jackmeson1 Jackmeson1 commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #6312

After a restart, persisted custom Decision models report their versions again. Existing cache entries appear in the cache API, and DELETE can remove them from disk.

Registration records each custom spec in the cache tracker. At startup, the Decision description provider rebuilt that inventory from built-in families alone. It now includes registered custom families using the same description generator as registration.

The regression registers one family with Hugging Face and ModelScope specs, caches both through HTTP, and restarts the local cluster with the same home. It checks the version IDs, listed paths, on-disk removal and survival of the local source. A built-in d3-edge cache goes through the same checks.

Startup now merges version lists for model types that share a name, preserving provider order and LLM projector rows. The cache tracker matches worker reports by model type and version ID, and checks for ambiguous cache paths before an all-worker deletion starts. The restart regression covers a persisted Decision model named bge-small-en-v1.5 alongside the built-in embedding and verifies that deleting both Decision versions preserves the embedding checkpoint.

Validated on Ubuntu 24.04: the changed tests pass on Python 3.12 with Transformers 5.25.1 and 4.57.6 and on Python 3.10 (7 each). With the production file from 2feca74e, the restart regression fails with assert [] == ['dedicated--...'] (test_decision_backend.py:154). The consumer tests (35 passed, 1 skipped), pre-commit and mypy over the repository (1,288 files) pass.

The follow-up commit 6c78a579 (shared names across types) passed on Ubuntu 24.04: pre-commit and mypy over the repository (1,288 files) pass; with the production files from 3bf6ec24, the shared-name inventory and differing-worker assertions fail; the changed and consumer test files show no failures beyond those that also fail on 3bf6ec24 (MLX-only audio engine cases and existing worker tests).

AI disclosure: this was prepared with AI assistance (Claude Code with Claude Opus 5.5, and OpenAI Codex with GPT-6.2).

🤖 Generated with Claude Code

Include persisted custom Decision families in the startup version inventory so cache listing and removal work after a restart. Verify the cache APIs across a local restart alongside a built-in Decision control.

Signed-off-by: Jackmeson1 <130693642+Jackmeson1@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JfvcPYCd12wEedB3EKJ39R

@qinxuye qinxuye left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found one restart regression involving models that share a name across types. The inline comment includes the HTTP reproduction.

model_name: [spec.to_version_info() for spec in families[0].model_specs]
for model_name, families in BUILTIN_DECISION_MODELS.items()
}
for family in registry.get_custom_models():

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Preserve cached versions for models that share a name across types

Decision registration checks names within its own model type, so a persisted Decision model can share a name with an existing embedding model. The startup inventory in core/cache_metadata.py adds Decision after embedding and uses dict.update() keyed by model name. Adding the custom Decision entry here replaces the embedding version list.

I reproduced this through the local HTTP APIs with a custom Decision model named bge-small-en-v1.5. GET /v1/cache/models?model_name=bge-small-en-v1.5 lists both types before restart. After restart, the base still lists the embedding cache. This commit lists only the Decision cache even though the embedding checkpoint is still on disk.

Please merge version lists for shared names when building the startup inventory, and cover a restart where both model types keep their cache entries.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated startup to merge version lists for model types that share a name. The restart test uses bge-small-en-v1.5, checks the paths for both Decision versions and the embedding, then deletes both Decision caches and verifies the embedding checkpoint is still listed and on disk. I also covered worker-specific registrations so an image reported by one worker can’t relabel another worker’s cached reranker. Merging the lists alone let the tracker, which matched worker reports by version ID only, attach one type's cache path to another type with the same ID, so the tracker now also keys rows by model type. If you'd rather review that part separately, I can split it into its own PR.

Merge startup versions in provider order and keep each shared version ID once.
Cover shared embedding and Decision caches across restart and removal.

Signed-off-by: Jackmeson1 <130693642+Jackmeson1@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JfvcPYCd12wEedB3EKJ39R

@qinxuye qinxuye left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The restart regression now keeps both model types in the cache inventory. The 52 focused tests and pre-commit passed on 6c78a579. The remaining issues are type isolation in version queries and unregistration, and making the all-worker delete honor the targets it checked.

):
result.update(tag_model_type(get_versions(), model_type))
for name, versions in tag_model_type(get_versions(), model_type).items():
result.setdefault(name, []).extend(versions)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Scope version queries and unregistration to the requested model type

The merged inventory now keeps both types under the same name, but SupervisorActor.get_model_versions() ignores model_type, the registration counts still look up by name, and unregister_model_version() removes the entire name bucket. I reproduced this after restarting with a persisted Decision model named bge-small-en-v1.5. Both the Decision and embedding /versions endpoints returned the same three rows. DELETE /v1/model_registrations/decision/bge-small-en-v1.5 then removed the embedding's version and cache listing even though its checkpoint was still on disk. The current restart test filters the response itself, so it misses the mixed /versions result.

Please carry the requested type through lookup, version counts and unregistration, preserving the other type's rows and worker paths. Extend the restart regression to assert that each typed /versions response contains only its own versions, then unregister Decision and assert that the embedding version and cached path remain visible.

)
return ret
if len(self._worker_address_to_worker) > 1:
await self._cache_tracker_ref.get_deletion_paths(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Delete only the worker targets selected by preflight

get_deletion_paths() returns the checked paths, but the supervisor discards them and asks every worker to resolve the bare version ID again. In a two-worker test of this flow, only worker A's reranker was present at preflight. Worker B reported an image with the same version ID while the supervisor was awaiting A. B then resolved that image as its only local match, so the delete could remove a cache the preflight never saw.

Please keep the selected worker and cache identities from preflight, dispatch only to those workers, and have each worker verify the expected target before removing files or updating the tracker. Add a regression where B reports the colliding image while A is being processed and verify that B's new cache is left alone.

@Jackmeson1

Copy link
Copy Markdown
Contributor Author

@qinxuye, my local 84e9e48d fixes both reproductions. After restarting with a Decision model named bge-small-en-v1.5, the typed /versions endpoints return two Decision rows and one embedding row respectively. Version counts are scoped by type. Unregistering Decision preserves the embedding checkpoint and its cache listing. In the two-worker DELETE, only A receives the request when B first reports its image after preflight.

A version-only DELETE should remove only files owned exclusively by the caches selected on each worker. Two cases still break that guarantee on a selected worker:

  • A reranker owns path p at preflight. An image then reports p too. DELETE succeeds and clears the file and both listings.
  • The reranker moves and the image takes p just after the final ownership check. DELETE returns false after unlinking the image, which remains listed.

There’s also a separate metadata issue. After unregistering image, a rerank inventory refresh can relabel an older worker’s untyped path as rerank.

  • A. Keep typed operations and selected-worker dispatch, fix the legacy-row merge, and document concurrent same-path deletion as a follow-up.
  • B. Coordinate publication with the final ownership check, file discovery, unlink, and tracker update on each worker. This preserves shared names and changes the download and registration paths.
  • C. Reject new cross-type custom names. On upgrade, stop before publishing a persisted collision and identify the registrations to rename. Their files stay intact.
  • D. Land B separately first. The rerank/image case needs no Decision model. Then fix(decision): restore custom model cache versions after restart #6313 is the Decision startup fix and its restart test.

I recommend D so the deletion guarantee gets its own review. Which scope would you prefer?

qinxuye commented Dec 5, 2026

Copy link
Copy Markdown
Contributor

@Jackmeson1 I'd go with D. The reranker/image race is independent of Decision, and it can unlink a checkpoint even when DELETE reports failure. Please land the shared cache fix first and keep support for names shared across model types.

  • Shared cache PR — Preserve the exact workers and cache identities selected by preflight. On each selected worker, coordinate publication with the final ownership check, file discovery, unlink, and tracker update. Cover both same-path races on a selected worker, a late collision on another worker after preflight, and the legacy untyped path after unregistering one type and refreshing another.
  • fix(decision): restore custom model cache versions after restart #6313 — Then rebase the Decision startup fix on that change. Keep the restart regression with a custom Decision registration sharing an embedding name. Check that version queries and counts are scoped by type, and that deleting Decision cache entries or unregistering Decision preserves the embedding listing and checkpoint.

Please link the shared cache PR here so we can review it first.

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.

Restart hides cached versions of persisted custom Decision models

2 participants