fix(install,studio): address review round 5 (3 real of 10; 5 PS-5.1 claims disproven on hardware)

Real fixes:

- uninstall.ps1: scope the WSL process kill to argv referencing
  /root/.unsloth/ (the fallback's install dir, which its Studio server,
  llama-server, and build runner all reference) instead of the bare
  '[l]lama-server' / '[u]nsloth_studio' name patterns -- uninstalling the
  Windows shim must not kill a user's own unrelated llama.cpp server or a
  /home Studio in a probed distro. Proven live: the path pattern matched
  exactly the three fallback processes while a planted /tmp/llama-server
  decoy matched the old pattern and not the new one. The backslash in
  '/root/\.unslot[h]/' keeps the pattern from matching the cleanup
  command's own argv.

- install.ps1: bridge UNSLOTH_LLAMA_TAG / UNSLOTH_LLAMA_PR into the
  background CUDA-build runner -- the provisioner honors both pins, but
  Windows env vars don't cross into WSL on their own, so a user's pin was
  silently ignored by the deferred build. (Deliberately NOT forwarded into
  the inner install.sh env: setup.sh skips its deferral when a PR pin is
  visible there, which would CPU-build the pin in the foreground.)

- kernels/flex_attention.py: make _flex_is_dgx_spark() CUDA-free
  (nvidia-smi device names, mirroring _is_dgx_spark_no_cuda_init) -- it
  runs at module import and called torch.cuda.get_device_name(), which
  initializes the CUDA allocator before patch_dgx_spark_memory_config()
  can set PYTORCH_CUDA_ALLOC_CONF on exactly the Spark hosts it targets
  (reachable via vision.py importing ..kernels before ._utils). Verified
  on the N1X: detects the machine with torch.cuda.is_initialized() still
  False.

- _utils.py: the TrainingArguments __post_init__ wrapper now forwards
  *args/**kwargs (robustness against future InitVar signatures).

Disproven on hardware (no change): the five "high" PS-5.1 claims --
String.TrimEnd('\', '/') with multiple char args binds fine to
params char[] (verified on PS 5.1.28000.1737, and the uninstaller's PATH
cleanup using exactly that code ran successfully this same day), and
[Text.Encoding] resolves via the System namespace prefix (the background
build dispatch using it has run in every install this week). The worker
"_sp possibly undefined" claim is false: `import subprocess as _sp` is at
worker.py line 25.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Daniel Han 2026-06-09 23:56:31 -07:00
commit 5c2aefc6d1
4 changed files with 32 additions and 14 deletions

View file

@ -390,13 +390,17 @@ function Uninstall-UnslothStudio {
# /root/.local/bin/unsloth symlink (its target under /root/.unsloth is gone but the link still
# resolves on PATH). Scope STRICTLY to /root: the WoA fallback installs there (wsl -u root), so
# touching /home/*/.unsloth would erase an unrelated WSL user's own Unsloth/cache that this
# installer never created. pkill patterns use the [x]-regex self-exclusion trick: '[u]nsloth_studio'
# keeps the shell's own argv from matching while real processes still match. Same for '[l]lama-server'.
# installer never created.
# The port-8888 kill is gated on an Unsloth install actually existing in the
# distro (checked BEFORE the rm deletes the marker): a probed distro with an
# unrelated listener on 8888 (Jupyter etc.) must not lose it. The pkills are
# already Unsloth-specific, so they stay unconditional.
$_clean = '_had=0; if [ -d /root/.unsloth ] || [ -L /root/.local/bin/unsloth ]; then _had=1; fi; rm -rf /root/.unsloth /root/llama-cuda /root/provision_llama_cuda.sh /root/llama_cuda_build.log 2>/dev/null; rm -f /root/.local/bin/unsloth 2>/dev/null; if [ $_had -eq 1 ]; then fuser -k 8888/tcp 2>/dev/null; fi; pkill -9 -f ''[u]nsloth_studio'' 2>/dev/null; pkill -9 -f ''[l]lama-server'' 2>/dev/null; true'
# unrelated listener on 8888 (Jupyter etc.) must not lose it. The process kill is
# scoped to argv referencing /root/.unsloth/ -- the fallback's install dir, which
# its Studio server, llama-server, and build runner all reference -- instead of
# bare name patterns that would also kill a user's own unrelated llama-server or
# a /home Studio in that distro. The backslash in '/root/\.unslot[h]/' keeps the
# pattern from matching this command's own argv (whose literal text contains the
# escaped form, not the resolved path) -- same idea as the [x]-bracket trick.
$_clean = '_had=0; if [ -d /root/.unsloth ] || [ -L /root/.local/bin/unsloth ]; then _had=1; fi; rm -rf /root/.unsloth /root/llama-cuda /root/provision_llama_cuda.sh /root/llama_cuda_build.log 2>/dev/null; rm -f /root/.local/bin/unsloth 2>/dev/null; if [ $_had -eq 1 ]; then fuser -k 8888/tcp 2>/dev/null; fi; pkill -9 -f ''/root/\.unslot[h]/'' 2>/dev/null; true'
$_cands = @('', 'Ubuntu', 'Ubuntu-24.04', 'Ubuntu-22.04', 'Debian')
if ($_recordedDistro) { $_cands = @($_recordedDistro) + $_cands }
if ($env:UNSLOTH_WSL_DISTRO) { $_cands = @($env:UNSLOTH_WSL_DISTRO) + $_cands }