Skip to content

cli: tensorfold rm removes a cached checkpoint, or one snapshot with the refs naming it and the blobs only it links to - #3525

Merged
ashhart merged 4 commits into
mainfrom
lead/cli-rm
Nov 17, 2026
Merged

ashhart merged 4 commits into
mainfrom
lead/cli-rm

Conversation

@ashhart

@ashhart ashhart commented Nov 16, 2026

Copy link
Copy Markdown
Owner

Today the only way to free a checkpoint tensorfold pull cached is to delete folders under the Hugging Face cache by hand. tensorfold rm REPO[@REVISION] [--yes] [--dry-run] does it safely.

What this changes

  • tensorfold rm REPO: removes every snapshot, blob and ref of REPO, then its models--ORG--NAME folder.

  • tensorfold rm REPO@REVISION: removes one snapshot.

    • The revision is a ref (main, pr/1) or a 40-hex commit, looked up in the cache only, never on the hub.
    • It also removes the refs naming that snapshot, the blobs no other snapshot still links to, and huggingface_hub's .no_exist/<commit> notes.
    • Emptied folders go, and the repo folder goes when nothing is left.
  • The printout before deleting: each snapshot with its refs, any link pointing outside the folder, the counts, and the bytes freed.

    • A file counts once, by inode, and only when every name it has is going.
    • That keeps the number right for symlinked blobs, for hard links (pull's Windows fallback), and for copies.
  • Confirmation: on a terminal it asks Remove? [y/N] on stderr, so a redirected stdout can't hide the question. --yes skips the question and --dry-run only prints. With stdin not a terminal and no --yes, it refuses and names --yes.

  • Safety:

    • Deletion never follows a link: every folder is opened without following links, and a link's own entry goes, never its target.
    • A repo folder that is itself a link is refused.
    • Paths, .., absolute paths and anything that isn't a repo id are refused (exit 2).
    • An uncached repo or revision is refused by name (exit 1), pointing at tensorfold models or listing the snapshots and refs held.
  • Order: refs first, then the snapshot's entries, then unshared blobs, then empty folders. An interrupted run never leaves a ref pointing at a half-removed snapshot, and running it again finishes.

  • What stays: TensorFold's own files inside a snapshot (.tensorfold-original, rollback files, .tensorfold/) go with it. Nothing outside the repo folder is touched:

    • Flash Next packs in ~/.cache/tensorfold/packs, which are keyed by content and rebuild on demand;
    • the other caches;
    • benchmark receipts;
    • huggingface_hub's .locks.

    The README says so.

  • Issue: n/a. This came from the 16 Nov check of competitor gap docs against main: five tools ship a remove command, and zig/src/cli/cli.zig had none.

  • Stacked on: main. It merges cleanly with pull: gated and private repos come down with a Hugging Face token, sent only to the hub's own host #3524 except for the usual CHANGELOG line (trial merge, 16 Nov).

  • atc overlap --json: to run after review.

  • Follow-up: refuse while a running server has the snapshot open. Servers already take a shared lock on the snapshot folder, but that code sits in a module the CLI doesn't import. On macOS and Linux, a served model keeps running from the unlinked files; the docs say to stop the server first.

Checks on this head

  • Head commit: bad0ff6 on main e7e2424.
  • Lean checker: 337 on base and head, 0 new (tools/pr_check.py: 0 errors, 1 advisory warning).
  • Tests:
    • zig build test-rm-host (new step on macOS, Linux and Windows): 13/13.
    • zig build test-cli: 48/63 (15 existing info and plan tests skip as before).
    • zig build test-pull-host test-pull-security: 43/43. pull's revision check moved into hub.zig unchanged, so rm accepts the same names.
    • zig build test-golden: 322/335 equal, 0 unexpected differences.
    • zig build test-cuda-host: 6777/6817 (40 skipped).
    • zig build check-native-cuda-host: passes, and it failed on a type error planted in the rm branch.
    • zig build native -Dcpu=apple_m1, zig fmt --check, git diff --check: clean.
  • Nine planted faults each failed at least one test, one at a time:
    • deleting shared blobs;
    • following links while deleting;
    • keeping refs;
    • deleting on a dry run;
    • ignoring a file's other names;
    • skipping the terminal check;
    • accepting ..;
    • accepting a linked repo folder;
    • leaving .no_exist.
  • End to end on a synthetic cache with the built binary: help, models before and after, a dry run, the piped-stdin refusal, the path refusal, @main --yes, and a pseudo-terminal answering the prompt.
  • CI: pending.
  • Not run: Windows and Linux runs (the rm files were cross-compiled for both; Windows CI runs test-rm-host, and its link tests skip there if the runner can't create symlinks), and a real multi-GB cache.

Receipt

n/a: a CLI cache command that can't reach inference. Host checks are above.

Checklist

  • The title and description match the head commit.

  • New tests fail before the change, pass after it, and skip cleanly without their dependency.

  • Comments and docstrings are one line. No measurements or history in the source.

  • No personal data, machine names, internal hosts or local paths in the diff or its commits. No AI attribution lines.

  • Synthena (Ash's Agent)

ashhart added a commit that referenced this pull request Nov 16, 2026
ashhart added a commit that referenced this pull request Nov 17, 2026
ashhart added a commit that referenced this pull request Nov 17, 2026
ashhart added a commit that referenced this pull request Nov 17, 2026
# Conflicts:
#	CHANGELOG.md
@ashhart
ashhart force-pushed the lead/cli-rm branch 2 times, most recently from d905486 to 4b471f8 Compare November 17, 2026 14:35
…the refs naming it and the blobs only it links to

It lists each snapshot and the bytes freed, then asks on a terminal; --yes skips the question, --dry-run only lists,
and without a terminal it refuses unless --yes. It takes only a cached repo id, deletes only inside that repo's cache
folder, never follows a link out of it, and refuses a repo folder that is itself a link. Hard links and copies count
once per file, so a Windows cache without symlinks frees what it reports. pull's revision check moves to hub.zig so
rm accepts the same refs and commits.
@ashhart
ashhart merged commit eaf4fe4 into main Nov 17, 2026
2 of 15 checks passed
@ashhart
ashhart deleted the lead/cli-rm branch November 17, 2026 17:59
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