Repository navigation
fix(desktop): keep a verified CUDA torch, and repair a missing torchvision - #895
Merged
Merged
Conversation
…ision A torch swap commit deleted the backup tree with the manifest still in it, so a delete that stopped part way (a file held open) left a backup that the next launch restored over the verified CUDA install. The manifest is now removed first, and the next snapshot clears a manifest-less leftover before moving anything into it. owned_entries and restore kept RECORD and manifest names that exist() accepts but that are not entries: on Windows "C:" joins to a drive's current directory and "..." or ". " are trimmed to site-packages itself, which discard_installed or restore would then delete. Names are now matched against read_dir instead. The launch check reported a missing torchvision beside +cpu torch as healthy, so a pip run that stopped between uninstall and install left the karaoke split broken for good. An absent version.py now gets the CPU torchvision install; an unreadable one is still left alone.
This was referenced Nov 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three small repairs to how the desktop shell swaps torch for a CUDA build and checks torchvision on launch. Builds on #891.
What changes for the user
manifest.txt, so the next launch treated it as an interrupted swap and restored half a CPU torch over the working CUDA one. The commit now removesmanifest.txtfirst, so a delete that stops part way leaves nothing that counts as a backup. The next snapshot clears that manifest-less leftover before it moves anything, so a stale entry cannot block the move or be restored later.owned_entriestakes the first path segment of each line in torch'sRECORDand kept it ifsite.join(name).exists(). On Windows that is true for names that are not entries at all:C:(from a line such asC:\x,,) joins to that drive's current directory, and...or.are trimmed to site-packages itself.discard_installedwould then delete them. A name is now kept only ifread_dir(site)lists it, which never returns any of those.restoreuses the same rule for the names inmanifest.txt, matched againstread_dirof the backup, because a manifest written by an older build from such a RECORD could hold them.torchvision/version.pybeside+cputorch now gets the same CPU torchvision install. Aversion.pythat exists but cannot be read is still left alone, so a healthy offline machine is not sent to the network on every launch. A CUDA torch is not touched.How it was verified
cargo test:torchswap::tests::a_commit_that_stops_part_way_leaves_no_backup_to_restore(Windows only: it holds a backup file open withshare_mode(0)). Before:assertion failed: !has_backup(&site). With only the commit change, the secondsnapshotfailed on the leftover. After: passes.torchswap::tests::a_record_line_naming_no_entry_in_site_is_not_owned. Before: owned entries included"C:","...",". "and".. ". After: passes. The test only reads, so running it against the old code was safe.torchswap::tests::a_manifest_line_that_names_no_entry_is_ignored(manifest lines...and.). Before:restoreremoved the test's site-packages and then failed. After: passes, CPU torch and the neighbour package are intact. It works in a temp dir, so the red run could only delete that.tests::a_missing_torchvision_beside_cpu_torch_is_repairedand the extendedtests::the_repair_decision_reads_the_installed_tree. The helper's signature changed to takeOption<&str>, so the old code cannot compile these; the old behaviour is visible in the removedlet (Some(torch), Some(vision)) = ... else { return "ok" }.C:line on purpose: against the old code it would makerestoredelete from the drive's current directory, so a red run is not safe on any machine. The sameread_dirrule covers it.cargo test: 209 passed, 0 failed, 2 ignored.cargo fmt --checkandcargo clippy --tests -- -D warningsclean.Update path
uv.lockis unchanged, so theruntimeIdgate is not affected and existing installs receive it through the in-app update.What I have to check by hand
On a Windows machine with an NVIDIA GPU, using a throwaway install of the desktop build:
setup.logsaysverifiedand that.stemdeck-torch-backupnext tosite-packagesis gone.site-packages/torchvisionandtorchvision-*.dist-info, then launch. Confirmsetup.logsaystorchvision is missing beside torch ...; installing torchvision==...+cpu, and that the karaoke split works afterwards.