Skip to content

Installer: restore interrupted updates and clean stale rollback environments - #7342

Merged
danielhanchen merged 2 commits into
unslothai:mainfrom
oobabooga:fix/installer-orphaned-rollbacks
Jul 23, 2026
Merged

danielhanchen merged 2 commits into
unslothai:mainfrom
oobabooga:fix/installer-orphaned-rollbacks

Conversation

@oobabooga

Copy link
Copy Markdown
Member

Every Studio reinstall moves the existing Python environment to unsloth_studio.rollback.<timestamp>.<pid> before building its replacement. Once PyTorch is installed, each rollback can take several gigabytes.

On Debian and Ubuntu, curl ... | sh runs under dash, which does not execute the existing EXIT trap for INT, TERM, or HUP. Interrupting or closing an update could therefore leave the old environment under its rollback name and the live environment incomplete. Windows had the same unguarded replacement window, while locked-file cleanup failures were ignored.

Fix

Handle HUP, INT, and TERM explicitly in install.sh, and protect the Windows replacement with try/finally. When an update is interrupted or fails, the incomplete environment is removed and the previous one is restored.

After a replacement succeeds, remove older rollback directories whose owner process is no longer running. Rollbacks belonging to active installers are preserved, as are symlinks, Windows reparse points, and names outside the installer's generated format. Windows cleanup retries temporarily locked files and reports the retained path if deletion still fails.

Rollback state is recorded before the old environment is renamed and cleared before a committed backup is deleted. This covers interruptions at both transition boundaries without risking replacement of a healthy new environment with a partially deleted backup.

Verification

  • Shell lifecycle tests run the real helpers under dash and cover SIGINT, SIGTERM, SIGHUP, restoration, transition boundaries, and stale cleanup: 19 checks passed.
  • PowerShell lifecycle tests cover restoration after failure, stale and active rollbacks, and locked-file retries: 8 checks passed.
  • The existing installer test runner and workspace guard suite pass, along with shell syntax and whitespace checks.

@oobabooga
oobabooga requested a review from danielhanchen as a code owner July 22, 2026 20:03
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@oobabooga

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 35d19c5e59

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread tests/run_all.sh Resolved
@oobabooga

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: 37d5f6dd7b

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@danielhanchen
danielhanchen merged commit 88583dd into unslothai:main Jul 23, 2026
50 of 53 checks passed
danielhanchen pushed a commit that referenced this pull request Jul 24, 2026
Reconcile PR #7256 (Windows torch 2.11 + release preservation, installer
comment reduction, torch 2.11 default line) with 77 commits of main install
rewrites. Base is main's newer install semantics; this branch's still-novel
contributions are layered on top.

Key decisions:
- install.ps1: kept main's rollback lifecycle (try/finally Restore-StudioVenvRollback,
  #7342) and the installed-version report (#7265); layered this branch's torch-2.11
  allowance (torch<2.12.0 on the Windows CUDA fresh-install, CPU fallback and flavor
  repairs), the release-preservation port (Get-InstalledTorchVersionRaw / kept-release
  installs / UNSLOTH_KEPT_TORCH handoff / torch-overrides freeze) and the Exit-InstallFailure
  UNSLOTH_KEPT_TORCH clear.
- install.sh: took main's newer AMD/Strix routing (per-arch index reroute #7264/#7300,
  runtime-less gfx inference #7305, KFD detection fix #7314, Radeon 8065S regex #7290,
  signal-restore trap #7342) and the #7365 unsloth pin bump; kept this branch's
  _TORCH_CEILING/_TORCHVISION_CEILING/_TORCHAUDIO_CEILING refactor widening the default
  ceiling to torch<2.12.0.
- studio/install_python_stack.py: deferred all five code conflicts to main's Strix
  inference logic (result is AST-identical to main; only comment reductions remain).
- studio/setup.ps1: took main's comment covering the whisper.cpp dictation markers
  (#7095); the UNSLOTH_KEPT_TORCH consumption handoff auto-merged intact.

Dropped as superseded by main: this branch's stale unsloth>=2026.7.4 pins (main #7365),
the older rocm7.1->rocm7.2 Strix reroute (main #7264/#7300), the narrow Radeon 80[0-9]0S
regex (main #7290), and the pre-inference has_hip_torch gate (main's rocm_torch_ready gate,
Codex P1 #7305). The two review-item fixes (grep -E in test_torch_constraint.sh,
UNSLOTH_KEPT_TORCH clear in Exit-InstallFailure) survive.
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.

2 participants