Skip to main content

ckptkit

CI Python 3.9+ License: Apache 2.0

The missing Swiss Army knife for model checkpoints.

ckptkit inspects, diffs, validates, and merges model checkpoints without loading them into GPU memory. Parse SafeTensors headers in milliseconds, compare checkpoints after fine-tuning, merge LoRA adapters, and validate file integrity — all from the command line or Python.

Inspect

Why ckptkit?

Working with model weights means dealing with:

  • "What layers are in this checkpoint?" → ckptkit info
  • "What changed after fine-tuning?" → ckptkit diff
  • "Is this download corrupt?" → ckptkit validate
  • "Merge this LoRA adapter into the base" → merge_lora_state_dicts()
  • "Show me parameter counts per layer" → ckptkit stats

mergekit handles model merging (TIES, DARE, SLERP), but nobody built the everyday checkpoint utility. ckptkit is that tool.

Install

pip install ckptkit

With SafeTensors support (recommended):

pip install ckptkit[safetensors]

With PyTorch support:

pip install ckptkit[torch]

Everything:

pip install ckptkit[all]

CLI

Inspect

# See what's inside a checkpoint
ckptkit info model.safetensors

# JSON output for scripts
ckptkit info model.safetensors --json | jq '.n_parameters'

Diff

Compare two checkpoints — see what changed during fine-tuning:

Diff

ckptkit diff base_model.safetensors finetuned_model.safetensors

Validate

Check for corruption before a long training run:

ckptkit validate model.safetensors
# ✓ model.safetensors: valid (safetensors)

Stats

ckptkit stats model.safetensors

Python API

Inspect

from ckptkit import inspect

info = inspect("model.safetensors")
print(f"Parameters: {info.n_parameters:,}")
print(f"Tensors: {info.n_tensors}")
print(f"Format: {info.format.value}")

for t in info.tensors[:5]:
    print(f"  {t.name}: {t.shape} {t.dtype.value} ({t.numel:,} params)")

Diff

from ckptkit import diff, format_diff

result = diff("base.safetensors", "finetuned.safetensors")
print(f"Changes: {result.n_changes}")
print(f"Identical: {result.n_identical} / {result.n_shared}")

for entry in result.entries:
    print(f"  {entry.change_type}: {entry.tensor_name} — {entry.details}")

Merge LoRA

import torch
from ckptkit import merge_lora_state_dicts

base = torch.load("base_model.bin", map_location="cpu")
adapter = torch.load("adapter_model.bin", map_location="cpu")

merged = merge_lora_state_dicts(base, adapter, alpha=1.0)
torch.save(merged, "merged_model.bin")

Validate

from ckptkit import validate

result = validate("model.safetensors")
if not result.valid:
    for issue in result.issues:
        print(f"  {issue.severity}: {issue.message}")

Stats

from ckptkit import inspect, stats_from_info

info = inspect("model.safetensors")
stats = stats_from_info(info)

print(f"Total size: {stats.total_size_human}")
for dtype, count in stats.dtype_counts.items():
    print(f"  {dtype}: {count:,} parameters")

Format support

Format Inspect Diff Validate Merge
SafeTensors ✓ (header-only, fast) ✓ ✓ (full integrity) ✓
PyTorch (.bin/.pt) ✓ (requires torch) ✓ basic ✓

How it works

SafeTensors inspection is fast because the format puts all tensor metadata (names, shapes, dtypes, offsets) in a JSON header at the start of the file. ckptkit reads only the first few KB, never loading the actual weight data.

LoRA merging performs base_weight += alpha * (lora_B @ lora_A) for each matched layer pair, with automatic key resolution for common adapter formats (PEFT, HuggingFace).

See Also

Part of the stef41 LLM toolkit — open-source tools for every stage of the LLM lifecycle:

Project What it does
tokonomics Token counting & cost management for LLM APIs
datacrux Training data quality — dedup, PII, contamination
castwright Synthetic instruction data generation
datamix Dataset mixing & curriculum optimization
toksight Tokenizer analysis & comparison
trainpulse Training health monitoring
quantbench Quantization quality analysis
infermark Inference benchmarking
modeldiff Behavioral regression testing
vibesafe AI-generated code safety scanner
injectionguard Prompt injection detection

License

Apache-2.0

Metadata

Release files for ckptkit 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ckptkit 0.3.0
File Size Uploaded Provenance
ckptkit-0.3.0.tar.gz 44.1 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for ckptkit 0.3.0
File Interpreter ABI Platform
ckptkit-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 74.8 kB

Release files / ckptkit-0.3.0.tar.gz

Download URL ckptkit-0.3.0.tar.gz
Size 44.1 kB
Tags Source
SHA-256 checksum
How to use checksums
d67df27288b7d4f3e193cdc0634f2f05e12f67ef6bab8b2c44ecc466fcddbcc4
BLAKE2b-256 checksum
How to use checksums
2ee5aac6341db4b5001c407f64636631f0a85178fa71256f4860586112e728ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Release files / ckptkit-0.3.0-py3-none-any.whl

Download URL ckptkit-0.3.0-py3-none-any.whl
Size 30.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
15f28b9ac4ad6d21679e5dcea32bcb3eeccebaa95e923c1a2d58887057f97ff5
BLAKE2b-256 checksum
How to use checksums
4230d7fde04bba6cdcba42db9efa0d3add5a5da39ff2cb408a0c1e9e9fff1160
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Security for ckptkit 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page