Skip to content

fix(adopt): guard GPU installs with CPU-only Torch - #1287

Open
Kosinkadink wants to merge 3 commits into
mainfrom
fix/adopted-gpu-torch-mismatch
Open

fix(adopt): guard GPU installs with CPU-only Torch#1287
Kosinkadink wants to merge 3 commits into
mainfrom
fix/adopted-gpu-torch-mismatch

Conversation

@Kosinkadink

@Kosinkadink Kosinkadink commented Jul 21, 2026

Copy link
Copy Markdown
Member

Summary

  • detect definite mismatches between an adopted install's selected GPU backend and its existing PyTorch build metadata
  • ask before falling back to CPU and never download, replace, or repair PyTorch in an adopted environment
  • preserve the selected-device and CPU-fallback metadata through migration, launch, and copy paths
  • block unconfirmed direct launches that would otherwise fail with an incompatible Torch build
  • leave explicit legacy CPU configurations unchanged and avoid offering CPU fallback when Torch cannot import

Incident evidence

The supplied Legacy Desktop files showed NVIDIA selected and empty ComfyUI launch arguments. The linked log then failed with AssertionError: Torch not compiled with CUDA enabled.

This means the incident was not caused by restoring a legacy --cpu launch argument. Instead, adoption accepted an environment where import torch succeeded even though the existing Torch build was CPU-only. This PR tightens that validation without mutating user environments.

Safety

Mismatch detection uses Torch build metadata and only acts on definite mismatches. Existing explicit CPU configurations are left unchanged. Adopted environments are never auto-repaired; users can consent to an in-memory CPU fallback or cancel and create a managed installation.

Validation

  • pnpm run typecheck
  • pnpm run lint
  • pnpm run build
  • pnpm run test (191 files, 2,859 tests)
  • pnpm run test:integration (4 files, 28 tests)
  • git diff --check

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@Kosinkadink, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 46 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 9f59ecea-df09-4b80-a361-e8af95531918

📥 Commits

Reviewing files that changed from the base of the PR and between 197b199 and a994f2d.

📒 Files selected for processing (1)
  • src/main/lib/ipc/sessionActions/launch.test.ts
📝 Walkthrough

Walkthrough

Legacy Desktop adoption now detects incompatible Torch/GPU combinations, offers CPU fallback, persists that choice, and enforces it during standalone launches. Launch action data and adopted installation metadata are preserved through IPC and copy operations.

Changes

Adopted Torch CPU fallback

Layer / File(s) Summary
Torch mismatch detection
src/main/sources/standalone/torchRepair.ts, src/main/sources/standalone/torchRepair.test.ts
Torch accelerator evidence and mismatch detection are centralized, with helpers for detecting and forcing CPU launch arguments.
Adoption mismatch prompt
src/main/lib/desktopAdopt.ts, src/main/lib/ipc/sessionActions/migrate.ts, locales/*.json, src/main/lib/desktopAdopt.test.ts
Adoption detects Torch mismatches, prompts for CPU mode or cancellation, and records adoptedCpuFallback.
Standalone launch enforcement
src/main/lib/ipc/sessionActions/launch.ts, src/main/lib/ipc/sessionActions/launch.test.ts
Adopted Torch mismatches block unconfirmed launches or add --cpu when fallback is enabled.
Standalone action and IPC payload wiring
src/main/sources/standalone/*, src/renderer/src/composables/useListAction.*, src/types/ipc.ts
Standalone launch actions request fallback consent, and structured action data is forwarded through IPC.
Adopted metadata preservation
src/main/lib/ipc/shared.ts, src/main/lib/ipc/sessionActions/copy.integration.test.ts
Copied adopted installations retain selected-device and CPU-fallback metadata.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant StandaloneActions
  participant useListAction
  participant handleLaunch
  participant TorchRepair
  User->>StandaloneActions: select Launch
  StandaloneActions->>TorchRepair: check adopted Torch mismatch
  TorchRepair-->>StandaloneActions: return mismatch details
  StandaloneActions->>User: request CPU fallback confirmation
  User-->>StandaloneActions: confirm CPU mode
  StandaloneActions->>useListAction: provide action data
  useListAction->>handleLaunch: run launch with fallback data
  handleLaunch->>TorchRepair: validate launch environment
  TorchRepair-->>handleLaunch: return mismatch status
  handleLaunch-->>User: launch with --cpu
Loading

Suggested reviewers: deepme987, maanilverma

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/adopted-gpu-torch-mismatch
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch fix/adopted-gpu-torch-mismatch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai
coderabbitai Bot requested review from MaanilVerma and deepme987 July 21, 2026 23:09
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.

1 participant