Repository navigation
Conversation
|
Confirmed that _promote_to_custom_source treated the HF directory layout alone as cache ownership, which hid scan-folder copies from the chat picker. Will get this reviewed. |
# Conflicts: # studio/backend/hub/services/models/local_inventory.py # studio/backend/hub/tests/test_custom_gguf_discovery.py
There was a problem hiding this comment.
@VTplus I would merge this. On a CPU-only Linux box, reverting only the production guard takes the suite from 5 red to 9: the three registered parametrisations of test_local_inventory_lists_a_registered_hf_home_as_custom, whose expectation you flipped, and test_local_inventory_keeps_both_rows_when_the_repo_is_cached_and_parked. Your two cache-preserving tests hold on both sides, so the suite discriminates in both directions.
$ cd studio/backend && python -m pytest hub/tests/test_model_services.py hub/tests/test_custom_gguf_discovery.py -q --timeout=330
5 failed, 365 passed, 1 skipped in 27.57s
# baseline 77b02960, same command: 5 failed, 362 passed, 1 skipped
# the same 5 fail on both sides and predate this branch: the SimpleNamespace stub at
# hub/tests/test_model_services.py:183 has no .source, which utils/hf_cache_settings.py:445 reads
# head with only the _promote_to_custom_source guard reverted, tests kept:
9 failed, 361 passed, 1 skipped
$ cd "$(git rev-parse --show-toplevel)" && python -m pytest tests/studio/test_model_picker_contracts.py -q -> 202 passed
$ python -m pytest studio/backend/tests/test_legacy_ollama_source.py studio/backend/tests/test_ollama_manifest_load_resolution.py -q -> 32 passed
$ ruff 0.15.18 (the .pre-commit-config.yaml pin) check, 6 changed files -> All checks passed!
# not run: the GPU and live-model paths, and the Windows casing case, no hardware for either
path_is_same_or_child compares os.path.realpath and os.path.normcase, which is the same helper the allowed-roots guard at local_inventory.py:622 uses, so a symlinked or differently-cased cache root still reads as the cache.
The "active_cache": None line looks redundant beside common.py:847, which nulls that field for every source but hf_cache, and it is not, because model_copy(update = ...) bypasses that builder and would leave the promoted row as the one custom row carrying a non-null value. No test currently separates the two, since both preference sites compare active_cache is True.
@danielhanchen the one path I could not exercise is the Windows casing branch. Say the word and I will run it against a real cache on hardware you name.
|
Thanks for the thorough review @chrikrah This PR was developed and tested on a Windows machine. Re-tested at the pushed head (d5d146b) after merging current main: the discovery suite passes there (35 passed, including the (The same change also applies and passes on top of current main (124e89a), run as a patch: discovery 35 passed, contracts 202 passed.) One behavior note for the record: parked copies used to show a delete button, but that delete never resolved scan-folder copies (the cache delete only walks configured HF cache roots), so the relabeling removes a dead affordance rather than a working one. Making delete actually work for scan-folder copies could be a follow-up if there's interest. |
…at-picker # Conflicts: # studio/backend/hub/services/models/local_inventory.py
…icker - sync branch with upstream before re-cutting the patch Upstream had evolved hub/services/models/local_inventory.py and tests/studio/test_model_picker_contracts.py since the last sync; the three-way merge takes both sides without conflicts.
…icker - sync branch with upstream before re-cutting the patch 182 upstream commit(s) since the branch base; see git log for the range.
…icker - sync branch with upstream before re-cutting the patch 125 upstream commit(s) since the branch base; see git log for the range.
…icker - sync branch with upstream before re-cutting the patch 165 upstream commit(s) since the branch base; see git log for the range.
…icker - sync branch with upstream 778 upstream commit(s) since the branch base; see git log for the range.
…icker - sync branch with upstream 554 upstream commit(s) since the branch base; see git log for the range.
Pin the cache-only fields on promoted scan-folder rows, cover an oMLX cache root as a real cache root, and keep the legacy-path comment true for this branch's code.
…icker - sync branch with upstream 49 upstream commit(s) since the branch base; see git log for the range.
|
Updated the branch. Together, #12258, #12803, and #13343 improve support for complete model copies stored in registered Custom Folders. |
…icker - sync branch with upstream 664 upstream commit(s) since the branch base; see git log for the range.
…branch with upstream
…icker - sync branch with upstream 1046 upstream commit(s) since the branch base; see git log for the range.
) ## Skip interpreter teardown in the DDP trainable-embeddings worker `tests/test_ddp_find_unused_default.py::test_trainable_embeddings_train_under_ddp_reentrant_checkpointing` has hung on `Repo tests (CPU, rest-2)` twice: on #12258, and on #18220, whose base is current `main`. ``` E Failed: ['.../tests/_ddp_trainable_embeddings_worker.py', '.../ddp'] hung past 150s: E [Gloo] Rank 0 is connected to 1 peer ranks. ... E RANK_OK find_unused=FalseRANK_OK find_unused=False ``` Both ranks had finished. They printed `RANK_OK` after writing their results, and then the processes never exited. Locally the whole test takes about 12 s. ### Cause After `RANK_OK`, `tests/_ddp_trainable_embeddings_worker.py` calls `dist.destroy_process_group()` and returns to normal interpreter teardown. The repo's other gloo workers do not do that. `tests/test_tp_native_gloo.py`, `test_tp_host_input_embedding_gloo.py`, `test_sharded_load_bnb4_gloo.py`, the `pp_*_gloo` workers and others all: - barrier before tearing the group down, because rank 0 hosts the TCPStore; - call `os._exit(0)` once results are saved, because interpreter teardown can wedge or abort on a gloo C++ thread after the work is done. This worker predates that pattern. That is the failure seen here: the run is finished, but the process never exits. I could not trigger the CI hang itself: 48 local torchrun launches, 8 in parallel, all exited 0. So the hang is shown with an injected teardown wedge (see Verification). ### Fix On the distributed path, after `RANK_OK`, the worker now does what the other gloo workers do: - `dist.barrier()`, then `dist.destroy_process_group()`; - flush stdout and stderr, then `os._exit(0)`. Nothing before `RANK_OK` changes. That includes the training steps, the result files and the single-process reference run. The test's assertions are unchanged, and a rank that fails before `RANK_OK` still exits non-zero. ### Verification - `tests/test_ddp_find_unused_default.py`: 63 passed. - Sabotage check: after `RANK_OK` on the distributed path, I injected a thread that never ends, standing in for a teardown thread that wedges. - `main`: `hung past 150s` with both `RANK_OK` lines printed, which is the CI signature. - This change: the test passes in 10.8 s. - ruff is clean.
Addresses the scan-folder variant of #7676 and complements #7680: genuine cache rows stay
hf_cache(the visibility this PR adds), while a physically separate scan-folder copy keeps its actual custom-folder ownership. Same use case (custom scan folders) as #12253/#12254 — that change loads a selected model from the folder without re-downloading it; this one makes the folder's models selectable in the chat picker in the first place.What
Registered custom-folder scans now distinguish a real Hugging Face cache from a physically separate repository copy that merely uses the same directory layout.
_collect_models_from_default_sourcespasses the known active, legacy, default, and previous cache roots to_promote_to_custom_source. A scannedhf_cacherow keeps that source only when its resolved path is the same as or below one of those roots. Otherwise it becomescustom, its cache-onlymodel_idandactive_cachefields are cleared, and its inventory id is rebuilt from the physical custom path.The picker itself is unchanged: it already accepts
customrows from/api/hub/local.Why
A complete repository copied into a registered scan folder can retain the Hugging Face
models--org--name/snapshots/<revision>layout. The scanner correctly recognizes that layout, but the previous promotion step treated the layout alone as proof that the row belonged to a configured cache. The chat picker intentionally excludeshf_cacherows, so the model disappeared even though Model Hub and the local inventory could see it.Scope / guards
hf_cache, including when that cache is also registered as a scan folder.path_is_same_or_childhelper, which returnsFalseon path-resolution errors./api/models/localor/v1/modelsroute, download path, resolver, or inference behavior is changed.Tests
studio/backend/hub/tests/test_model_services.py: 9 focused cases covering HF-cache-layout promotion, a configured cache registered as a scan folder, separate physical copies, preserved Ollama/Hermes ownership, and preserved chat-capability classification.tests/studio/test_model_picker_contracts.py: 3 focused contracts confirming that the visible picker reads/api/hub/local, acceptscustom, excludeshf_cache, and still requires chat capability.The rebuilt Studio backend reports healthy, and its live inventory returns the reproduced
gpt-oss-20b-GGUFrow ascustom, chat-capable, andtext-generation.Known limitations (deliberate)