Repository navigation
Studio: persist local-checkpoint tier probe verdicts across workers - #17496
Conversation
|
@codex review |
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Bravo. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
…s a live probe does [skip ci]
|
@codex review |
|
Codex Review: Didn't find any major issues. Delightful! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
…#17592) ## Summary `Repo tests (CPU, studio)` fails on main since #17213, and on every PR based on it (seen in staging runs for #17496 and #17557): ``` tests/studio/test_desktop_reliability_frontend_contract.py::test_fixed_sheets_start_below_the_custom_titlebar E assert 'set("--studio-custom-titlebar-height", usesCustomTitlebar ? "34px" : null)' in '...' ``` #17213 (F11 fullscreen) hides the custom titlebar in fullscreen, so the `<html>` mirror in `provider.tsx` now reads: ```ts const customTop = customTitlebarHidden ? "0px" : "34px"; set("--studio-custom-titlebar-height", usesCustomTitlebar ? customTop : null); ``` That is correct: in fullscreen the titlebar band is gone, and portalled sheets should start at the top edge. The test pinned the old line character for character, so it failed on a change that keeps everything it was written to protect. The mirror is still there, and it still gives 34px whenever the titlebar shows. ## Change `tests/studio/test_desktop_reliability_frontend_contract.py`: - `_mirrored_titlebar_heights()` finds the `set("--studio-custom-titlebar-height", usesCustomTitlebar ? <value> : null)` call and resolves `<value>`. A string literal is read directly; a local such as `customTop` is read from its `const` declaration. - `test_fixed_sheets_start_below_the_custom_titlebar` now asserts that the mirror exists, that it yields `34px`, and that it yields nothing other than `34px` or the fullscreen `0px`. The rest of the test is unchanged. - `test_the_titlebar_mirror_reader_follows_a_local` covers the reader: the old literal form, the new local form, and a different property that must not match. No app code changes. ## Testing - `tests/studio/test_desktop_reliability_frontend_contract.py`: 46 passed (1 failed on main). - With the mirror line removed from `provider.tsx`, the test fails. With the shown height changed from `34px` to `30px`, it also fails.
Studio picks the transformers tier for a model inside the worker it spawns for that model:
activate_transformers_for_subprocessin the inference, export, training and token preview workers._probe_tierkeeps its verdicts in the in-process dict_probe_tier_cache, but that dict is always empty in a new worker. A local checkpoint whoseconfig.jsonwas saved by transformers 5.x, and whosemodel_typethe default tier already knows (for examplellama), reaches_probe_tier(..., include_default=True, floor="default")on every load. That spawnspython -cto import transformers and runAutoConfig.from_pretrained, which costs 3.5 to 4 s. These checkpoints are common: Studio's merged 16-bit exports (save_pretrained_merged) and full fine-tune outputs (trainer.save_model) both write aconfig.jsonstamped with the default transformers version, which is 5.5.0 on Python 3.10 and newer. So every chat load, export or further training run of such a model paid this probe again, even though the answer had not changed. LoRA outputs are not affected, because PEFT writes onlyadapter_config.json, and Hub ids are left as they are.Change
studio/backend/utils/transformers_version.py:_probe_tieralso keeps verdicts on disk in<studio>/cache/transformers_tier_probe.json, but only for local directories.config.jsonbytes, the probe mode (floor,include_default) and the tier walk order. The entry also records the installed transformers version of every tier the walk probed. For a sidecar that is thetransformers-*.dist-infoversion in its target dir. For the default tier it isimportlib.metadata.version("transformers"), which does not import transformers. On lookup each recorded version is read again. If a walked tier was upgraded or removed, or the config was rewritten, the model is probed again. A pinnedlatestsidecar changes the walk order, so it changes the key.UNSLOTH_DISABLE_TIER_PROBE, and walks where any tier's version cannot be read are never stored.config.jsonis hashed again after the probe, and the verdict is stored only if the hash is unchanged.os.replace. The file holds at most 256 entries, oldest dropped first. A missing, corrupt or unreadable file reads as empty, so the probe runs as today. Two workers writing at once can drop each other's new entry, which only means one more probe later.latestverdict is ignored when that tier is disabled, needs repair or is unpinned, the same rule the in-memory cache follows.ensure_fnstill returns True, as a live probe requires. A damaged sidecar that cannot be repaired right now (offline, rebuild lock held,latestinside a worker) therefore walks on to the next tier as today instead of failing activation.ensure_fncalls, skipped tier handling and floor rules are unchanged.Results
get_transformers_activation_tieron a local llamaconfig.jsonwithtransformers_version: 5.1.0. Each run is a fresh Python process, the way a worker starts, sharing one Studio home per arm:The tier is
defaultin every run, on both sides.Tests
studio/backend/tests/test_transformers_tier_probe_disk_cache.py(21 cases). A second process reuses adefault, an escalated (550) and a floor verdict without probing. A rewritten config, an upgraded sidecar that was walked, or an upgraded default transformers triggers a new probe, while an upgrade to a tier the walk never reached does not. A floor530caller does not reuse adefaultverdict. Transient results, skipped tiers, a sidecar with no readable version, Hub ids, a config rewritten during the probe andUNSLOTH_DISABLE_TIER_PROBEare never persisted. A cached tier whose sidecar is unavailable walks on to the next tier. A corrupt or wrong-shape cache file falls back to probing and is replaced. The file stays bounded. 10 of these fail on main (the ones that need the disk cache), and the 10 that check behaviour that must not change pass on both.test_transformers_version.py,test_transformers_version_optional_tiktoken.pyandtest_transformers_latest.py: 484 passed on main and 484 passed on this branch, with no failures on either side; with the new file, 505 passed.