Repository navigation
Installer: recover from and explain an unreadable llama.cpp cache on Windows - #10533
Conversation
Codex Review SummaryThis 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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f263d2e828
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
| if (-not $userSupplied -and -not $homeIsCustom) { | ||
| $asideDir = "$dir.denied-$(Get-Date -Format 'yyyyMMddHHmmss')" | ||
| $moved = $false | ||
| try { | ||
| Move-Item -LiteralPath $dir -Destination $asideDir -ErrorAction Stop |
There was a problem hiding this comment.
Mirror the shared preflight changes into setup.ps1
When users invoke studio/setup.ps1 directly for setup, update, or repair, this recovery branch is absent because the commit changes only install.ps1, even though these helpers are explicitly maintained as byte-identical copies. Those entrypoints therefore still abort on the same unreadable managed cache instead of moving it, and retain the old denial diagnostics; tests/studio/install/test_denied_llama_cpp_preflight.py:65-70 now fails for both Invoke-ManagedLlamaCppPreflight and Get-PathDenialDetail. Apply the corresponding changes to the studio/setup.ps1 copies.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Already handled in 5d1cf9a, which mirrored both functions into studio/setup.ps1 and added scripts/sync_shared_ps1_helpers.py so the copies stay together. The parity failure now names that script in its message.
| if ($attrs -band [System.IO.FileAttributes]::Encrypted) { | ||
| return " (it is EFS-encrypted, so it stays unreadable even elevated unless the encrypting account or its recovery certificate is available)" |
There was a problem hiding this comment.
Do not infer a missing EFS key from a directory attribute
All callers pass a directory path, but the Encrypted attribute on a directory means that encryption is the default for newly created descendants; it does not mean listing that directory requires its EFS certificate. If an EFS-marked directory is unreadable because of its ACL, this branch falsely tells the user that elevation and ACL repair cannot help and that the encrypting certificate is required. Diagnose EFS only from inaccessible encrypted file contents rather than from the directory attribute alone.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Correct, fixed in f581996. The Win32 docs are explicit that FILE_ATTRIBUTE_ENCRYPTED means something different per type: "For a file, all data streams in the file are encrypted. For a directory, encryption is the default for newly created files and subdirectories" (https://learn.microsoft.com/en-us/windows/win32/fileio/file-attribute-constants). Listing a marked directory never needs the certificate, so on an ACL denial that branch was sending people after a recovery certificate instead of takeown. The branch is now gated on the path not being a directory, and directories fall through to the cloud-placeholder and reparse checks and then to the existing ACL guidance.
| try { | ||
| Move-Item -LiteralPath $dir -Destination $asideDir -ErrorAction Stop | ||
| $moved = $true |
There was a problem hiding this comment.
Move this mutation behind the installer and runtime locks
In install.ps1, this preflight runs at line 3116, before the install mutex is acquired at line 3394 and the runtime locks at lines 3421-3431, so those concurrency guards do not protect the new Move-Item. If two recovery runs both observe Denied, one can move the directory while the other subsequently reports access denied for a path that is now absent; similarly, the cache can be relocated before the installer discovers that another managed operation is active and aborts as busy. Acquire the relevant locks before renaming the cache, or at minimum re-probe after a failed move.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Took the re-probe, not the lock move, in f581996.
The reachable half of this is real: with two runs in flight the second one's Move-Item fails because the source is already gone, and it then printed an access-denied message for a path that no longer exists and stopped an install that could have continued. A failed move now re-runs Get-LlamaCppInstallReadState and returns null when the tree is no longer denied.
I did not move the preflight under the locks. The install mutex is taken at install.ps1:3825, after winget, Python and uv, and the whole point of running the preflight at 3469 is to stop before any of that is downloaded. Acquiring the mutex early enough to cover the rename would hold it across those phases and change the concurrency behaviour of every install, which is a much larger change than the window it closes.
| $suppliedDir = if ($WithLlamaCppDir) { $WithLlamaCppDir } else { $env:UNSLOTH_LOCAL_LLAMA_CPP_DIR } | ||
| $userSupplied = (-not [string]::IsNullOrWhiteSpace($suppliedDir)) -and | ||
| ((Get-CanonicalDir -Path $suppliedDir) -eq (Get-CanonicalDir -Path $dir)) |
There was a problem hiding this comment.
Preserve supplied builds nested under the managed directory
If --with-llama-cpp-dir or UNSLOTH_LOCAL_LLAMA_CPP_DIR points to a build beneath the managed directory, such as %USERPROFILE%\.unsloth\llama.cpp\custom, this equality check is false and the recovery branch moves the parent containing that user-supplied build. The later validation at install.ps1:6655-6659 then checks the original path, reports that it no longer exists, and aborts after altering a directory the comments promise not to touch. Treat the supplied path as user-owned when it equals or is contained by the directory being moved.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Real, and confirmed by reading the abort path: install.ps1:7085-7088 rejects --with-llama-cpp-dir with "path does not exist" for a directory the preflight had just renamed. Fixed in f581996.
$userSupplied now walks the override's ancestors and matches when any of them is the managed directory, so a build under it is treated as user-owned. That blocks the move and keeps the user-supplied wording, which matters just as much here: the default wording tells the user to delete the folder, and their build is inside it.
The walk compares canonical forms level by level rather than testing a string prefix. An override that does not exist yet cannot be resolved, so a prefix test would compare an unresolved path against a resolved managed directory and miss. tests/studio/test_path_probe_access_denied.ps1 gained a "nested" mode that asserts the tree is left where it is.
…de cache The first version changed only install.ps1, and the two Windows entrypoints carry byte-identical copies of these helpers: the parity suite failed on both edited functions, and `unsloth studio setup` and `update` kept the old dead end. scripts/sync_shared_ps1_helpers.py copies the shared block now, so the two cannot drift by hand again, and the parity failure names it. Three changes on top of that, each from a real report. - The guidance named Controlled folder access but never checked it, and never looked at anything else. It now reads the Defender mode, and when Defender is not the cause it names whichever antivirus is registered in SecurityCenter2. A user whose Bitdefender is holding the folder cannot act on advice that only says antivirus can do this, and takeown and icacls will not clear it. - A denied cache is only moved aside when it is ours to move. A link there is something the user arranged, so moving it would change which tree they run without touching the one they were protecting, and unreadable attributes are treated as a link rather than guessed at. - The same denial reaches the Node cache, where install_node_prebuilt.py called it an unexpected error and setup.ps1 followed with install Node yourself or check your network. Neither is the fix. It exits 4 now and setup.ps1 gives it the same guidance the llama.cpp cache gets. The behaviour suite gained the cases this needs: a cache that can be renamed is recovered, one that cannot still reports, and a link is never moved. The entrypoint fixtures block the rename so they keep exercising the guidance path.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5d1cf9a623
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
| if ($mode -eq 1) { | ||
| return "Controlled folder access is ON, and it denies this path whatever your privileges are, so takeown and icacls will not help: allow Unsloth under Virus & threat protection > Ransomware protection > Allow an app, or exclude this folder" |
There was a problem hiding this comment.
Keep security-software status from overriding ACL guidance
When Controlled Folder Access is enabled, every denial is now reported as being caused by CFA and the user is told that takeown/icacls cannot help, even though this branch does not correlate the failure with a protected path or a Defender block event; the preflight can simply be observing an ordinary read/list ACL denial. The later SecurityCenter branch makes the same inference from antivirus registration alone while discarding productState. On affected Windows machines this definitive note can steer users away from the actual ACL repair, so report these products only as possibilities unless the specific denial can be attributed to them.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Agreed on both halves, fixed in f581996.
Controlled folder access is a write gate. It governs create, modify, delete and rename by untrusted apps and does not block reads (https://learn.microsoft.com/en-us/defender-endpoint/controlled-folder-access-overview), so for the llama.cpp preflight, which fails on a read, it was the least likely explanation and was still stated as the cause. Both branches now describe a possibility and point at Windows Defender Operational events 1123 and 1124, which is the only thing here that can actually tie a block to this path. Neither says takeown and icacls will not help any more.
The SecurityCenter2 branch also filters on productState now: the 0xF000 nibble is 0x1000 on, 0x2000 snoozed, 0 off, so a registered but not running product no longer gets named. A state that cannot be read is kept, since that proves nothing either way.
| Write-StudioLine $nodeOut -ForegroundColor DarkGray | ||
| Write-StudioLine "" | ||
| Exit-PathAccessDenied -Path $NodeDir -Label "Node install" |
There was a problem hiding this comment.
Diagnose the path the Node installer could not write
When Python returns 4 because it cannot create the install lock or .staging directory under $NodeParent, $NodeDir may not exist and is not the denied object. This branch nevertheless says that $NodeDir cannot be read and advises deleting or renaming it, which cannot fix a non-writable parent directory. Preserve the failing filename from the Python error or diagnose $NodeParent for these creation failures instead of unconditionally routing them through the cache-directory message.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Right, fixed in f581996. install_node_prebuilt.py puts the install lock at install_dir.parent (line 497) and the .staging root at install_dir.parent / ".staging" (line 844), so a denial on either is on $NodeParent and $NodeDir may not exist.
Rather than re-derive that from a path string in PowerShell, the Python side classifies it where install_dir is known and logs both "denied-path: " and "denied-scope: install-dir|parent". setup.ps1 routes the parent case to Exit-PathAccessDenied -Path $NodeParent -OwnershipUnverified, so the guidance names the directory whose ACL has to change and never offers to delete the Unsloth home, which holds more than Node. tests/studio/install/test_install_node_prebuilt_logic.py covers a denial inside the cache, one on the lock in the parent, and one with no filename at all.
| if text[index] == "{": | ||
| depth += 1 | ||
| elif text[index] == "}": | ||
| depth -= 1 | ||
| if depth == 0: |
There was a problem hiding this comment.
Parse braces outside PowerShell strings and comments
When a shared helper contains a literal brace in a quoted string, regex, or comment, this character loop treats it as PowerShell block syntax. For example, a string containing only "{" makes the script exit with an unbalanced-braces error, while a } in a comment can terminate the span early and cause the default write mode to replace the setup helper with a truncated function. Since ordinary helper edits can contain such text, use PowerShell's parser or otherwise skip quoted/comment tokens before changing studio/setup.ps1.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Leaving this one. The failure needs an unbalanced brace inside a string, regex or comment in one of the ten shared helpers, and there is none today; the closest thing in the block is a Defender settings path with no braces in it.
If one did arrive, a truncated write cannot reach a commit. tests/studio/install/test_denied_llama_cpp_preflight.py compares the two copies with the same brace counter over both files, so it fails on the next run, and several suites parse install.ps1 and studio/setup.ps1 with [System.Management.Automation.Language.Parser]::ParseFile, which a half-copied function does not survive.
Using the PowerShell parser instead would mean requiring pwsh to run a script whose whole job is to avoid hand-copying, on machines that may not have it. Worth revisiting if a helper ever does need a brace in a literal.
|
Confirmed the old Get-PathDenialDetail bailed out on Get-Item exactly when the directory is unreadable, so the reason was suppressed in the case it was written for, and the preflight now moves the managed cache aside only when it is not user supplied and not a link. Will get this reviewed. |
|
@codex review |
|
@codex security review |
|
Codex Review: Something went wrong. Try again later by commenting “@codex review”. ℹ️ 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". |
|
@codex review |
1 similar comment
|
@codex review |
🛡️ Codex Security ReviewSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
|
Codex Review: Didn't find any major issues. Another round soon, please! 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". |
Both sides appended tests at the same point in tests/studio/install/test_install_node_prebuilt_logic.py: this branch's access-denied reporting cases and main's recorded-runtime cases. Kept both.
…tted (#11207) #11025, #10533 and #11067 each landed today with a blank line the ruff-format-with-kwargs hook removes or adds, so `pre-commit run --all-files` is red on main. Every open PR inherits that: pre-commit.ci evaluates the PR merged with main, finds files to rewrite that the PR never touched, and pushes them onto the PR branch, which is how unrelated files end up in a diff. On a branch too far behind main to apply, it fails outright instead. Output of the repo's own hook, with the pinned ruff 0.6.9. Blank lines only. Co-authored-by: danielhanchen <[email protected]>
* Repair the three checks that went red on main today All three reproduce on a clean origin/main (1d5210d) and none needs a product behaviour change, but they do not share a cause, so each is attributed here. install.ps1, studio/setup.ps1: unslothai#10533 added a comment naming an antivirus vendor to Get-SecuritySoftwareNote. The ban on vendor names in shipped scripts landed two days earlier in unslothai#10978, and it is not a style rule: PowerShell hands the entire top-level script block to the scanner at compile time, so comments are classifier input, and VirusTotal's analysis of install.ps1 quoted one of our own comments back as grounds for suspicion. The knowledge is moved rather than deleted, into AV_SHAPES_RECORD, which is where the guard's failure message says it belongs and which now records what each suite calls its protected-folders feature. The function never hard-coded a product name; it reads what SecurityCenter2 registered, and that is now said where the list used to be. tests/test_apply_qkv_fallback.py, tests/test_lora_dropout_patch_summary.py: unslothai#11038 added two skip guards reading torch.cuda.is_available(), which tests/_zoo_aggressive_cuda_spoof.py patches True process-wide and never puts back. A skipif is evaluated at import, so either file sharing a session with tests/version_compat or tests/vllm_compat un-skips on a CPU-only box and dies inside torch. They go through tests/_shared/real_accelerator.py instead, which records the answer before any spoof can run. test_apply_qkv_fallback_end_to_end allocates on "cuda" by name, so it takes has_real_cuda rather than the broad probe, which is also true on an XPU-only or Ascend NPU-only host. tests/python/test_docker_hub_readme.py: here the test was wrong, not the README. It took the first "#### Docker" heading and read to the next "####". The README grew a second Docker heading above the one carrying the run command, so the pins read a one-line pointer that was never meant to hold a docker run. It now picks the section by content and requires exactly one section to carry a run command, in both directions: zero is the regression it was written for, and more than one means two places tell the user how to start the image while only one is pinned. The stale-token check widened from that one section to every Docker section. * Let the save-signature probe resolve the import unslothai#11067 deferred Fourth check red on main today, in the (CPU, rest) shard: five failures in tests/test_st_save_merged_signature.py, all KeyError: "'__name__' not in globals". unslothai#11067 put `from ..save import _is_adapter_save_method` inside _save_pretrained_merged, deferred on purpose because a module-scope bind out of unsloth.save closes an import cycle. This file reads the two closures out of the source and execs them so the assertions run without importing unsloth, and a bare globals dict has no __name__ or __package__ for a relative import to resolve against, so every test that calls the body died on the import rather than on what it was checking. Satisfying it by importing unsloth would give up what the file is for, so the harness now stands up a package of its own holding the REAL helper, pulled from unsloth/save.py by source the way _normalize_save_method already is. The import executes and binds the shipped function, so its spelling rules still reach these tests; neutering that function fails three of them, which is how I checked the resolution is not cosmetic. That unmasked a second mismatch the import error was hiding. test_the_forwarding_path_still_accepts_lora asserted that "lora" is accepted when modules.json is present. unslothai#11067 deliberately retired that premise: save_pretrained_merged writes a loadable SentenceTransformer and an adapter-only save has no base weights for one, where previously "lora" matched no branch in merge_and_overwrite_lora and fell through to a 16bit merge that happened to write something loadable for a request that asked for adapters. Taking the product as correct, the test now pins the new refusal. The invariant it was really protecting survives and is what is checked: the no_modules refusal must not leak into the branch that has modules.json. Both paths raise now, so a bare pytest.raises would no longer notice one borrowing the other's reason; the messages are pinned apart, and a second test holds the pair distinct, which neither can see on its own. * Drop the torch import the skip-guard fix left unused Source lint caught it: tests/test_lora_dropout_patch_summary.py imported torch only for the torch.cuda.is_available() in the guard this PR replaced, so the import was left bound and unused. The sibling file still uses torch eleven times and keeps its import. * Let the rope carry drift tests run on a transformers that has no rope_parameters Fifth check red on main, in Core (HF=4.57.6 + TRL<1). Both tests from unslothai#11192 assume transformers 5's config.rope_parameters and fail on the 4.x job: test_rope_carry_keeps_every_nested_base_on_every_real_config AssertionError: no config with a nested rope dict was found to check test_rope_carry_leaves_the_zoo_gemma_local_base_alone_on_a_real_config AttributeError: 'Gemma2Config' object has no attribute 'rope_parameters' Both reproduce locally on transformers 4.57.6, the same pin that job resolves. The second is a one word fix. It already treats rope_parameters as optional, via an isinstance check, but read it with attribute access, and 4.x raises rather than returning None, so the tolerance was unreachable. getattr with a default. The first swept for nested rope dicts and asserted it found at least one. On 4.x there is no rope_parameters at all, so the sweep is empty and the assert fires. The two cases are now told apart: no rope_parameters anywhere is 4.x, where this carry does not exist and there is nothing to damage, and skips with that reason; the attribute present but no nested config is still drift and still fails. Collapsing them would either red the 4.x job forever or silently stop testing 5.x. Checked in both directions rather than assumed. On 4.57.6 the skip fires and the Gemma test passes. On 5.17.0 the skip does not fire and the sweep finds 16 nested configs, including the four the docstring names: deepseek_v4, laguna, mellum and zaya. Also stopped the sweep being ended by an unrelated optional dependency. CONFIG_MAPPING is lazy, so .items() imports every config module to hand back the classes, and one model whose module needs something missing takes the whole sweep down before the loop body runs. Seen with transformers.models.gemma3n, which imports timm.data.ImageNetInfo and raises on a timm that does not export it. Iterating keys and resolving inside the existing try skips that model, which is right: a config that cannot be built here cannot be the one that regressed. * Stop one test's account fence deciding another test's assertions tests/multi_account/test_routing_invariance.py::test_owner_routing_facts_and_shared_queue failed in Repo tests (CPU, rest) on assert active_generations._FENCED == set() carrying an account id it never created. It passed when run alone, passed on some pull requests and failed on others, which is the shape that eventually gets a real test deleted for being flaky. state.active_generations keeps _ACTIVE and _FENCED on the module, so they are process-global and outlive the test that wrote them. Retiring or deactivating an account fences it, and staying fenced is the CORRECT end state for those tests, so none of them is at fault. What was missing is isolation, the same way a tmp dir is isolated rather than every test being asked to clean up after itself. Measured rather than guessed: a report-only probe over the backend suite names 15 leakers, in test_job_accounts.py, test_account_storage.py, test_account_integration_wiring.py and test_account_retired_workspace_recreated.py. Whichever of them landed in an xdist worker ahead of the routing test decided its assertion. So the reset goes in conftest as an autouse fixture, before and after each test, using the reset_for_tests() the module already ships for exactly this. Before AND after: clearing only on the way in leaves the last test of a worker holding a fence, and clearing only on the way out trusts every other plugin to have left it alone. The files that already reset around themselves keep doing so; resetting twice costs nothing and the local call documents the intent at its own site. Reproduced before fixing, and confirmed by differential. Running the four leaker files together with the routing test: pristine main 3 failed, incl. test_owner_routing_facts_and_shared_queue with this fix 2 failed, that one gone The remaining two are an unrelated rag_db pair that fails identically on main in this environment. test_generation_state_isolation.py guards the repair. The structural check reads conftest rather than exercising ordering, because observing a leak functionally would require assuming test ORDER and this suite runs under pytest-randomly, where a test may not assume it. Dropping autouse from the fixture fails that check, which is how I confirmed it is not decorative.
…Windows (unslothai#10533) * Installer: recover from and explain an unreadable llama.cpp cache on Windows * Mirror the preflight into setup.ps1, name the antivirus, cover the Node cache The first version changed only install.ps1, and the two Windows entrypoints carry byte-identical copies of these helpers: the parity suite failed on both edited functions, and `unsloth studio setup` and `update` kept the old dead end. scripts/sync_shared_ps1_helpers.py copies the shared block now, so the two cannot drift by hand again, and the parity failure names it. Three changes on top of that, each from a real report. - The guidance named Controlled folder access but never checked it, and never looked at anything else. It now reads the Defender mode, and when Defender is not the cause it names whichever antivirus is registered in SecurityCenter2. A user whose Bitdefender is holding the folder cannot act on advice that only says antivirus can do this, and takeown and icacls will not clear it. - A denied cache is only moved aside when it is ours to move. A link there is something the user arranged, so moving it would change which tree they run without touching the one they were protecting, and unreadable attributes are treated as a link rather than guessed at. - The same denial reaches the Node cache, where install_node_prebuilt.py called it an unexpected error and setup.ps1 followed with install Node yourself or check your network. Neither is the fix. It exits 4 now and setup.ps1 gives it the same guidance the llama.cpp cache gets. The behaviour suite gained the cases this needs: a cache that can be renamed is recovered, one that cannot still reports, and a link is never moved. The entrypoint fixtures block the rename so they keep exercising the guidance path. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Tighten the denied-path diagnostics and what the recovery may touch --------- Co-authored-by: danielhanchen <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: oobabooga <[email protected]>
…tted (unslothai#11207) unslothai#11025, unslothai#10533 and unslothai#11067 each landed today with a blank line the ruff-format-with-kwargs hook removes or adds, so `pre-commit run --all-files` is red on main. Every open PR inherits that: pre-commit.ci evaluates the PR merged with main, finds files to rewrite that the PR never touched, and pushes them onto the PR branch, which is how unrelated files end up in a diff. On a branch too far behind main to apply, it fails outright instead. Output of the repo's own hook, with the pinned ruff 0.6.9. Blank lines only. Co-authored-by: danielhanchen <[email protected]>
* Repair the three checks that went red on main today All three reproduce on a clean origin/main (1d5210d) and none needs a product behaviour change, but they do not share a cause, so each is attributed here. install.ps1, studio/setup.ps1: unslothai#10533 added a comment naming an antivirus vendor to Get-SecuritySoftwareNote. The ban on vendor names in shipped scripts landed two days earlier in unslothai#10978, and it is not a style rule: PowerShell hands the entire top-level script block to the scanner at compile time, so comments are classifier input, and VirusTotal's analysis of install.ps1 quoted one of our own comments back as grounds for suspicion. The knowledge is moved rather than deleted, into AV_SHAPES_RECORD, which is where the guard's failure message says it belongs and which now records what each suite calls its protected-folders feature. The function never hard-coded a product name; it reads what SecurityCenter2 registered, and that is now said where the list used to be. tests/test_apply_qkv_fallback.py, tests/test_lora_dropout_patch_summary.py: unslothai#11038 added two skip guards reading torch.cuda.is_available(), which tests/_zoo_aggressive_cuda_spoof.py patches True process-wide and never puts back. A skipif is evaluated at import, so either file sharing a session with tests/version_compat or tests/vllm_compat un-skips on a CPU-only box and dies inside torch. They go through tests/_shared/real_accelerator.py instead, which records the answer before any spoof can run. test_apply_qkv_fallback_end_to_end allocates on "cuda" by name, so it takes has_real_cuda rather than the broad probe, which is also true on an XPU-only or Ascend NPU-only host. tests/python/test_docker_hub_readme.py: here the test was wrong, not the README. It took the first "#### Docker" heading and read to the next "####". The README grew a second Docker heading above the one carrying the run command, so the pins read a one-line pointer that was never meant to hold a docker run. It now picks the section by content and requires exactly one section to carry a run command, in both directions: zero is the regression it was written for, and more than one means two places tell the user how to start the image while only one is pinned. The stale-token check widened from that one section to every Docker section. * Let the save-signature probe resolve the import unslothai#11067 deferred Fourth check red on main today, in the (CPU, rest) shard: five failures in tests/test_st_save_merged_signature.py, all KeyError: "'__name__' not in globals". unslothai#11067 put `from ..save import _is_adapter_save_method` inside _save_pretrained_merged, deferred on purpose because a module-scope bind out of unsloth.save closes an import cycle. This file reads the two closures out of the source and execs them so the assertions run without importing unsloth, and a bare globals dict has no __name__ or __package__ for a relative import to resolve against, so every test that calls the body died on the import rather than on what it was checking. Satisfying it by importing unsloth would give up what the file is for, so the harness now stands up a package of its own holding the REAL helper, pulled from unsloth/save.py by source the way _normalize_save_method already is. The import executes and binds the shipped function, so its spelling rules still reach these tests; neutering that function fails three of them, which is how I checked the resolution is not cosmetic. That unmasked a second mismatch the import error was hiding. test_the_forwarding_path_still_accepts_lora asserted that "lora" is accepted when modules.json is present. unslothai#11067 deliberately retired that premise: save_pretrained_merged writes a loadable SentenceTransformer and an adapter-only save has no base weights for one, where previously "lora" matched no branch in merge_and_overwrite_lora and fell through to a 16bit merge that happened to write something loadable for a request that asked for adapters. Taking the product as correct, the test now pins the new refusal. The invariant it was really protecting survives and is what is checked: the no_modules refusal must not leak into the branch that has modules.json. Both paths raise now, so a bare pytest.raises would no longer notice one borrowing the other's reason; the messages are pinned apart, and a second test holds the pair distinct, which neither can see on its own. * Drop the torch import the skip-guard fix left unused Source lint caught it: tests/test_lora_dropout_patch_summary.py imported torch only for the torch.cuda.is_available() in the guard this PR replaced, so the import was left bound and unused. The sibling file still uses torch eleven times and keeps its import. * Let the rope carry drift tests run on a transformers that has no rope_parameters Fifth check red on main, in Core (HF=4.57.6 + TRL<1). Both tests from unslothai#11192 assume transformers 5's config.rope_parameters and fail on the 4.x job: test_rope_carry_keeps_every_nested_base_on_every_real_config AssertionError: no config with a nested rope dict was found to check test_rope_carry_leaves_the_zoo_gemma_local_base_alone_on_a_real_config AttributeError: 'Gemma2Config' object has no attribute 'rope_parameters' Both reproduce locally on transformers 4.57.6, the same pin that job resolves. The second is a one word fix. It already treats rope_parameters as optional, via an isinstance check, but read it with attribute access, and 4.x raises rather than returning None, so the tolerance was unreachable. getattr with a default. The first swept for nested rope dicts and asserted it found at least one. On 4.x there is no rope_parameters at all, so the sweep is empty and the assert fires. The two cases are now told apart: no rope_parameters anywhere is 4.x, where this carry does not exist and there is nothing to damage, and skips with that reason; the attribute present but no nested config is still drift and still fails. Collapsing them would either red the 4.x job forever or silently stop testing 5.x. Checked in both directions rather than assumed. On 4.57.6 the skip fires and the Gemma test passes. On 5.17.0 the skip does not fire and the sweep finds 16 nested configs, including the four the docstring names: deepseek_v4, laguna, mellum and zaya. Also stopped the sweep being ended by an unrelated optional dependency. CONFIG_MAPPING is lazy, so .items() imports every config module to hand back the classes, and one model whose module needs something missing takes the whole sweep down before the loop body runs. Seen with transformers.models.gemma3n, which imports timm.data.ImageNetInfo and raises on a timm that does not export it. Iterating keys and resolving inside the existing try skips that model, which is right: a config that cannot be built here cannot be the one that regressed. * Stop one test's account fence deciding another test's assertions tests/multi_account/test_routing_invariance.py::test_owner_routing_facts_and_shared_queue failed in Repo tests (CPU, rest) on assert active_generations._FENCED == set() carrying an account id it never created. It passed when run alone, passed on some pull requests and failed on others, which is the shape that eventually gets a real test deleted for being flaky. state.active_generations keeps _ACTIVE and _FENCED on the module, so they are process-global and outlive the test that wrote them. Retiring or deactivating an account fences it, and staying fenced is the CORRECT end state for those tests, so none of them is at fault. What was missing is isolation, the same way a tmp dir is isolated rather than every test being asked to clean up after itself. Measured rather than guessed: a report-only probe over the backend suite names 15 leakers, in test_job_accounts.py, test_account_storage.py, test_account_integration_wiring.py and test_account_retired_workspace_recreated.py. Whichever of them landed in an xdist worker ahead of the routing test decided its assertion. So the reset goes in conftest as an autouse fixture, before and after each test, using the reset_for_tests() the module already ships for exactly this. Before AND after: clearing only on the way in leaves the last test of a worker holding a fence, and clearing only on the way out trusts every other plugin to have left it alone. The files that already reset around themselves keep doing so; resetting twice costs nothing and the local call documents the intent at its own site. Reproduced before fixing, and confirmed by differential. Running the four leaker files together with the routing test: pristine main 3 failed, incl. test_owner_routing_facts_and_shared_queue with this fix 2 failed, that one gone The remaining two are an unrelated rag_db pair that fails identically on main in this environment. test_generation_state_isolation.py guards the repair. The structural check reads conftest rather than exercising ordering, because observing a leak functionally would require assuming test ORDER and this suite runs under pytest-randomly, where a test may not assume it. Dropping autouse from the fixture fails that check, which is how I confirmed it is not decorative.
Since unslothai#10533, a denied swap that cannot keep the existing Node reaches main() as a PermissionError and exits 4, and setup.ps1 answers exit 4 with Exit-PathAccessDenied: its own elevated takeown/icacls for the refused path and a note that antivirus can deny it too. _replace_with_retry had already printed ours, so that path showed two sets of repair commands for the same folder, with different icacls flags, around unslothai#10533's advice that elevation may not clear a security-software block. The lines now ride on the error and install_prebuilt logs them only in the branch that keeps a Node that still runs. That is exit 0, where setup.ps1 and setup.sh relay them on `takeown /F` and nothing else names a repair. "rename still blocked (5) after N attempts" still prints at the retry, so the exit-4 output keeps the rename's own record. Measured through main() with the real swap and a refused rename: exit 4 printed our four repair commands ahead of unslothai#10533's message, and now prints none, with the denied-path and denied-scope markers unchanged. A kept Node prints the same lines as before, ahead of "existing Node could not be replaced". test_a_denial_that_cannot_keep_node_leaves_the_repair_to_setup fails without this change; test_a_kept_node_prints_the_repair_setup_relays is a parity guard for the kept path. Four tests that read the lines from the log or checked the old flag, and the swap stand-in that set it, now use the error. One consequence worth naming: when the rollback of a failed forward rename is denied too, the repair lines naming the backup no longer print. The line "could not restore the previous Node install from <backup>" still names it, and the run exits 4.
…unslothai#10075) * studio: report a denied Node rename as a possible ACL fault, not a scanner _replace_with_retry retries `os.replace` on WinError 5, 32 and 145 and logs one message for all three: "a scanner is likely still holding the extracted files". WinError 5 is not only a scanner. It is equally what a tree with unreadable ACLs looks like, and that is a permission fault no backoff can clear. It matters most because `_swap_into_place` also uses this helper to move the EXISTING install aside, the tree a user is likeliest to have broken permissions on. In unslothai#9928 the same rename in the llama.cpp installer failed with (5) on every attempt and reported a scanner. The reporter's cause was corrupt ACLs -- icacls and Get-Acl both returned access-denied for the directory -- and `takeown /F ... /R /D Y` followed by `icacls ... /reset /T /C` fixed it. The Node helper carries the same three codes and the same message. 5 stays in the retry set: a scanner does raise it right after extraction. Only the reporting changes: the per-retry line offers both causes, and the takeown/icacls recovery prints once, when the budget is exhausted rather than on every attempt. WinError 32 and 145 keep their wording. The two commands go on separate lines for the reason tests/studio/install/test_setup_denied_install_tree.py pins -- on one line takeown swallows icacls as an argument. The constant and the recovery lines live in this module because it imports nothing outside the stdlib on purpose. Three tests extend the suite that already covers the helper. Two fail without the change: test_replace_names_acl_recovery_when_access_denied_persists and test_replace_does_not_blame_a_scanner_for_access_denied. test_replace_keeps_the_scanner_message_for_a_sharing_violation is a parity guard: 32 keeps its wording and prints no ACL guidance. One consequence worth naming: a 5 that really was a scanner now prints ACL guidance that does not apply to it, at the point the rename has already failed. Refs unslothai#9928. * studio: make ACL rename recovery actionable * studio: address ACL recovery review feedback * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * studio: stop reporting every blocked llama.cpp install as an active process setup.ps1 exits 3 when the existing llama.cpp install could not be replaced, and both sites that report it asserted an active llama.cpp process as the cause. Windows raises WinError 5 for a file another process holds open and for a tree whose ACLs are unreadable alike; is_busy_lock_error in studio/prebuilt_core.py classifies 5 as busy for exactly that reason, and _access_denied_recovery_lines prints takeown/icacls guidance for the ACL case. Write-LlamaFailureLog relays that guidance into the same block, so an ACL-denied user read repair commands bracketed by a headline and a retry hint that both named a process instead. Two sites, not one. The prebuilt exit-3 branch is the reported one; the local-directory link path carries the same three lines and says in its own comment that it mirrors the prebuilt handling, and that "Denied counts as surviving: unreadable is not gone" -- so it reaches the message by the same route and had to move with it. The classification is unchanged: exit 3 still means blocked, is_busy_lock_error still treats WinError 5 as busy, and the user is still told to close other llama.cpp users. Only the claim about which cause it was is dropped, in favour of naming both recoveries. whisper.cpp's exit-3 branch already reads "install busy; keeping existing runtime" and is the cause-neutral precedent followed here. Studio.Setup.BlockedInstallCause.Tests.ps1 pins it: 15 tests, 5 of which fail without this change, including a file-wide guard that neither phrase reappears at a third site and that every blocked-install site offers ACL repair. One consequence worth naming: the local-link path names the directory but cannot print the takeown/icacls lines, because it has no installer output to relay. It points at the ACLs on that path and leaves the commands to Write-PathAccessDenied, which already prints them wherever setup detects a denial up front. * studio: gate ACL retry guidance on helper output * studio: keep a running Node when its replacement stays denied The re-raise of a reported access denial sat ahead of install_prebuilt's keep-existing check, so a WinError 5 rename that outlasted the retries failed setup even when the Node already on disk still ran: exit 1, which setup.ps1 and setup.sh turn into "Could not install an isolated Node runtime". The re-raise was there for a real reason -- both scripts show the installer's output only on a non-zero exit, so a plain keep-existing return would have swallowed the takeown/icacls lines -- but the two goals conflicted only because exit 0 was silent. It no longer is. install_llama_prebuilt.py already exits 0 when it keeps the tree on disk after a transient failure, and setup.ps1 and setup.sh match its "keeping the existing complete install" line to warn "update unavailable, existing prebuilt kept". Node now takes the same shape: the reported denial reaches the keep-existing check like any other failure, a Node that still runs is kept with exit 0 on a line ending "keeping existing isolated Node", as the download-failure case already logs, and both scripts match that line, warn "update not applied, existing isolated Node kept", and relay the installer output when it carries takeown lines. The line names the rename instead of "Node download failed" when that is what failed. The warning is not llama.cpp's text, which test_pr10648_offline_and_status.py holds to exactly two keep arms. No new exit code, and nothing else moves: a Node that does not run, a forced reinstall, and a same-version install whose digest is not the pin still raise, exactly as they do for a failed download. setup.sh gets the arm for parity; its takeown branch can only fire on Windows output. test_install_prebuilt_keeps_existing_when_a_reported_denial_blocks_the_swap replaces test_install_prebuilt_does_not_hide_reported_acl_denial and fails without this change, when the swap's OSError escapes. The three cases of test_install_prebuilt_reraises_a_reported_denial_it_cannot_keep_existing_through are parity guards. Studio.Setup.BlockedInstallCause.Tests.ps1 gains a block on the setup.ps1 arm, four of its five tests failing without it, and tests/sh/test_setup_node_kept_existing.sh runs the real setup.sh block against a stand-in installer, three of its thirteen checks failing without it. One consequence worth naming: setup now carries on with a Node it could not replace, so a user can stay on an older runtime while setup succeeds, and the warning prints once per run. Refs unslothai#9928. * studio: offer the Node ACL repair only where the caller names the paths _replace_with_retry printed takeown/icacls for its source whenever a WinError 5 outlasted the retries, and flagged the exception as a reported denial, whoever called it. Since unslothai#10648 that includes atomic_replace_from_tempfile, which renames a temp file onto the downloaded archive and onto the install marker. A denial there named a temp file that is removed moments later, and the flag made the keep-existing line say the existing Node "could not be replaced" when the swap had never run. The repair lines and the flag now need access_denied_paths, which only _swap_into_place passes, for its three renames. A temp-file rename still retries the same budget and still raises; it only stops naming a path that will not exist, and a Node kept after it is logged as "Node download failed", as before. test_a_denied_marker_write_offers_no_repair_for_its_temp_file drives atomic_replace_from_tempfile into an exhausted 5 and fails without this change. test_replace_names_acl_recovery_when_access_denied_persists now passes its paths, as the callers that get the lines do. Refs unslothai#9928. * studio: describe the llama.cpp exit-3 repair gate by what it checks The comment above setup.ps1's llama.cpp exit-3 branch said "The helper prints takeown guidance only when access was denied", and the header of Studio.Setup.BlockedInstallCause.Tests.ps1 named _access_denied_recovery_lines as the source of llama.cpp's repair commands. Both described the installer half this PR carried before the llama.cpp message was left to unslothai#10182. On main no installer prints those lines: install_llama_prebuilt.py and prebuilt_core.py contain no takeown at all, and _access_denied_recovery_lines exists only in install_node_prebuilt.py. So the branch's `-match 'takeown /F'` arm is correct but cannot fire until unslothai#10182 lands, and both comments said it could. The gate stays, because it is what unslothai#10182's output needs, and without it the ACL repair hint would be offered to every busy install. Only the text changes: both comments now describe the check rather than a producer. Comments only, no assertion changes. Refs unslothai#9928 * tests: anchor the Node exit-chain Pester block on the chain itself Get-BlockSource took the Node exit handling from the first `$nodeExit = $LASTEXITCODE` to the next closing brace at that indent. unslothai#11786 put the mirror retry between the two, `if ($nodeExit -notin 0, 3, 4 -and (Use-MirrorSpare node)) { ... }`, so the slice ended at the retry's own brace. Merged with main, four of the five tests on a kept Node failed against a setup.ps1 that still has the branch they look for. The marker is now `$nodeExit -eq 3`, the chain's first line, once in setup.ps1. Against main's setup.ps1 the file still fails 11 of 22 (4, 3, 1, 3 and 0 by block), as it did at a09f376; with this branch's it passes 22. * studio: print the Node ACL repair only when the existing Node is kept Since unslothai#10533, a denied swap that cannot keep the existing Node reaches main() as a PermissionError and exits 4, and setup.ps1 answers exit 4 with Exit-PathAccessDenied: its own elevated takeown/icacls for the refused path and a note that antivirus can deny it too. _replace_with_retry had already printed ours, so that path showed two sets of repair commands for the same folder, with different icacls flags, around unslothai#10533's advice that elevation may not clear a security-software block. The lines now ride on the error and install_prebuilt logs them only in the branch that keeps a Node that still runs. That is exit 0, where setup.ps1 and setup.sh relay them on `takeown /F` and nothing else names a repair. "rename still blocked (5) after N attempts" still prints at the retry, so the exit-4 output keeps the rename's own record. Measured through main() with the real swap and a refused rename: exit 4 printed our four repair commands ahead of unslothai#10533's message, and now prints none, with the denied-path and denied-scope markers unchanged. A kept Node prints the same lines as before, ahead of "existing Node could not be replaced". test_a_denial_that_cannot_keep_node_leaves_the_repair_to_setup fails without this change; test_a_kept_node_prints_the_repair_setup_relays is a parity guard for the kept path. Four tests that read the lines from the log or checked the old flag, and the swap stand-in that set it, now use the error. One consequence worth naming: when the rollback of a failed forward rename is denied too, the repair lines naming the backup no longer print. The line "could not restore the previous Node install from <backup>" still names it, and the run exits 4. * Trim comments in the denied-rename reporting --------- Co-authored-by: Etherll <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Daniel Han <[email protected]>
A Windows 11 user on 0.1.807-beta hit a dead end: the managed llama.cpp cache at
%USERPROFILE%\.unsloth\llama.cppcould not be read, so setup stopped before phase 1 and nothing installed. The app had fallen back to the bundled installer after the managed CLI failed to start, so the installer was the only thing left that could repair the install, and it refused.The guidance we print did not help them. It says to delete or rename the folder, and offers
takeownplusicaclsif deleting is denied. They ran it elevated and still could not get access.Two problems, fixed here.
The folder is not moved even though we say we reinstall it
The message tells the user the folder is a managed cache that setup reinstalls, then asks them to move it by hand. When the denial is an ACL, we can usually do that ourselves: renaming a directory needs DELETE on it plus write on the parent, and neither is read access, so a rename can succeed where reading fails.
Invoke-ManagedLlamaCppPreflightnow tries to rename the folder tollama.cpp.denied-<timestamp>and continues the install when that works. If the rename is also denied we fall through to the existing message unchanged.This is scoped to the one case that already tells the user to delete the folder. A user-supplied build (
--with-llama-cpp-dir,UNSLOTH_LOCAL_LLAMA_CPP_DIR) is not ours to move, and an unreadable customUNSLOTH_STUDIO_HOMEcannot be confirmed to be a managed cache, so both keep the current behaviour of refusing to touch anything.We cannot say why access was denied, in the case where it matters
Get-PathDenialDetailexists to add a reason to the message, but it starts withGet-Item -LiteralPath $Path -Force -ErrorAction SilentlyContinueand returns an empty string when that yields nothing. Reading a directory whose ACL denies read is exactly whenGet-Itemyields nothing, so the detail is suppressed in the case it was written for. It also only ever reported reparse points.It now reads attributes with
[System.IO.File]::GetAttributes, which needs onlyFILE_READ_ATTRIBUTESand so survives denials that stopGet-Item, and it names the three causes that elevation cannot fix:Ordinary ACL denials are unchanged and still fall through to the
takeownandicaclsguidance, which is correct for them.RECALL_ON_OPENandRECALL_ON_DATA_ACCESSare missing from theFileAttributesenum on Windows PowerShell 5.1, so those two are tested as raw bits.Notes
Windows only.
install.shhas no equivalent preflight, so nothing there to mirror.Verified
install.ps1parses cleanly, and checked the attribute reads against a real directory: normal folders report no detail, and a missing path throws into the catch that returns an empty string.For the reported user specifically there is also an existing way out that needs no permission fix at all. Setting
UNSLOTH_STUDIO_HOMEmoves the managed cache to<StudioHome>\llama.cppviaGet-ManagedLlamaCppDir, so the unreadable folder stops being consulted.Update
The first version changed only
install.ps1. The two Windows entrypoints carry byte-identical copies of these helpers, enforced bytests/studio/install/test_denied_llama_cpp_preflight.py, so that failed on both edited functions andunsloth studio setup/updatekept the old dead end.scripts/sync_shared_ps1_helpers.pycopies the shared block now, and the parity failure names it.Three further changes, each from a real report on the same machine.
The guidance never checked what it was blaming. It mentioned Controlled folder access without reading it, and looked at nothing else.
Get-SecuritySoftwareNotenow reads the Defender mode (onlyEnabledblocks file access;BlockDiskModificationOnlyandAuditDiskModificationOnlyare disk-sector writes and cannot explain a denied folder), and when Defender is not the cause it names whichever antivirus is registered inroot/SecurityCenter2. The reporter that prompted this was running Bitdefender, whose Safe Files and Ransomware Remediation deny regardless of privilege, sotakeownandicaclscannot clear them.A denied cache is only moved aside when it is ours to move. Setup never makes that path a link, so a link there is something the user arranged, and moving it would change which tree they run without touching the one they were protecting. Attributes that cannot be read are treated as a link rather than guessed at.
The same denial reaches the Node cache. With the llama.cpp folder cleared, the identical
WinError 5appeared at~\.unsloth\node\UNSLOTH_NODE_PREBUILT_INFO.json;install_node_prebuilt.pycalled it an unexpected error and setup followed with "install Node yourself, or check your network". It exits4now, andsetup.ps1gives it the same guidance the llama.cpp cache gets.Testing
tests/studio/test_path_probe_access_denied.ps1gained the cases this needs: a cache that can be renamed is recovered, one that cannot still reports, and a link is never moved. The whole-entrypoint fixtures block the rename so they keep exercising the guidance path. All checks pass on Linux underpwsh;pytest tests/studio/installplus the installer suites is 4498 passed, 0 failed; both scripts parse.Not covered here
This makes the denial survivable and explains it. It does not stop the antivirus from objecting in the first place: the same machine shows Bitdefender blocking the DLL that
Add-Typecompiles throughcsc.exeat installer start. That is a separate change and is tracked on its own.