Skip to main content

sft

The Swiss army knife for .safetensors files.

PyPI Python CI License

sft demo

sft is a single-binary CLI for inspecting, editing, and diffing .safetensors files — and an interactive terminal browser for poking around large checkpoints. Most commands read the file header only, so multi-gigabyte models open in milliseconds.

It also ships a skill that teaches AI coding agents (Claude Code, Cursor, Codex CLI) when to reach for it and how to parse the output.

Install

uv tool install sft-cli                 # recommended
pip install sft-cli                     # or pip
uv tool install 'sft-cli[torch]'        # + .pt/.pth conversion

🚀 Quick start

sft model.safetensors                   # open the interactive browser
sft info model.safetensors              # one-shot summary
sft info model.safetensors --json       # machine-readable

The bare sft <file> form is a shortcut for sft browse <file>. Inside the browser: ↑↓ to navigate, / to filter, L on a LoRA file for LoRA Mode, D to diff against another file, q to quit.

What it does

Inspect a file without loading it:

sft info  model.safetensors             # size, tensor count, dtypes, metadata
sft ls    model.safetensors             # flat list, sort/filter friendly
sft tree  model.safetensors --depth=2   # hierarchical view
sft stat  model.safetensors             # per-tensor mean/std/min/max/sparsity
sft check model.safetensors             # corruption + NaN/Inf scan

Compare two checkpoints:

sft diff base.safetensors finetuned.safetensors --delta \
    --include='**.self_attn.**'         # cosine, L2, max-abs per tensor

Edit without writing Python:

sft slice  big.safetensors --include='**.weight' -o weights-only.safetensors
sft strip  big.safetensors --exclude='*lora_*'
sft cast   model.safetensors --dtype fp16
sft cat    a.safetensors b.safetensors -o merged.safetensors
sft rename model.safetensors --sub 'model\.' 'backbone.'
sft split  model.safetensors --max-size 4GB
sft convert pytorch_model.bin           # → safetensors

Every write command supports --dry-run and never overwrites the input — outputs default to {stem}.{suffix}.safetensors.

Adapter workflows (PEFT and Kohya):

sft lora info    adapter.safetensors            # rank, alpha, target modules
sft lora svd     adapter.safetensors            # singular-value spectrum
sft lora compat  base.safetensors adapter.safetensors
sft lora extract base.safetensors ft.safetensors --rank 16
sft lora resize  adapter.safetensors --rank auto    # per-pair adaptive rank
sft lora stack   a.safetensors b.safetensors -a 0.7 -b 0.3
sft lora merge   base.safetensors adapter.safetensors
sft lora convert adapter.safetensors --to peft      # Kohya ↔ PEFT

--rank auto picks each pair's output rank from its singular-value spectrum (ceil(stable_rank) + 1), so over-parameterized pairs compress harder than rich ones. auto+N adds a safety margin.

The browser

Press a key, get a result.

Key Action
Navigate
Collapse / expand tree
Tab Switch between tree and table
/ Search / filter
s Cycle sort
Enter Tensor stats popup
m File metadata
c Cast file dtype
L LoRA Mode (per-pair stats, SVD, compress)
D Diff against another file
: Command palette
q Quit

🤖 AI agents

sft skill install                       # auto-detects Claude / Cursor / Codex
sft skill status
sft skill uninstall

The installer symlinks sft's skill into your agent's well-known skills directory (~/.claude/skills/sft, ~/.cursor/skills/sft, etc.), so it stays in sync when you uv tool upgrade sft-cli. Pass --mode copy for a frozen snapshot.

Every command supports --json for clean parsing:

sft info model.safetensors --json | jq '.tensors'
sft lora info adapter.safetensors --json | jq '.rank'
sft stat model.safetensors --json --include='**.q_proj.*'

License

MIT — see LICENSE.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sft_cli-0.2.2.tar.gz (195.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sft_cli-0.2.2-py3-none-any.whl (102.4 kB view details)

Uploaded Python 3

File details

Details for the file sft_cli-0.2.2.tar.gz.

File metadata

  • Download URL: sft_cli-0.2.2.tar.gz
  • Upload date:
  • Size: 195.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for sft_cli-0.2.2.tar.gz
Algorithm Hash digest
SHA256 a56fd13f887c99146cac85041b0d159b59e4769f236a0dd7136621d722d815e6
MD5 d5db968c37fe179aacf3ac194bcde998
BLAKE2b-256 b906dbeeb1eabaa3ea5acf7278d40b61e08143bf8085e68ad6577f55af2121f5

See more details on using hashes here.

Provenance

The following attestation bundles were made for sft_cli-0.2.2.tar.gz:

Publisher: publish.yml on matanby/sft-cli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sft_cli-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: sft_cli-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 102.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for sft_cli-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3a5a9d6648737bb98f1a2e3b4f4b82b8f74e7379dd574be9d04eacaae912cb0f
MD5 f76dbe784616a386eea48f782add4785
BLAKE2b-256 e64993d52842d11a39e1134dd9a477eef2fdfb9ed3ae1e3c0c2feb50dee1ce7e

See more details on using hashes here.

Provenance

The following attestation bundles were made for sft_cli-0.2.2-py3-none-any.whl:

Publisher: publish.yml on matanby/sft-cli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page