| Crates.io | diffai-core |
| lib.rs | diffai-core |
| version | 0.4.1 |
| created_at | 2025-07-06 03:13:41.322558+00 |
| updated_at | 2025-12-19 04:46:43.801479+00 |
| description | Core library for AI/ML diff analysis - PyTorch, Safetensors, tensor statistics |
| homepage | https://github.com/kako-jun/diffai |
| repository | https://github.com/kako-jun/diffai |
| max_upload_size | |
| id | 1739698 |
| size | 402,354 |
Semantic diff tool for AI/ML models (PyTorch, Safetensors, NumPy, MATLAB). Provides tensor statistics, parameter comparisons, and automatic ML analysis.
Traditional diff doesn't understand binary ML files:
$ diff model_v1.pt model_v2.pt
Binary files model_v1.pt and model_v2.pt differ
diffai shows meaningful analysis:
$ diffai model_v1.safetensors model_v2.safetensors
learning_rate_analysis: old=0.001, new=0.0015, change=+50.0%
gradient_analysis: flow_health=healthy, norm=0.021
~ fc1.weight: mean=-0.0002->-0.0001, std=0.0514->0.0716
~ fc2.weight: mean=-0.0008->-0.0018, std=0.0719->0.0883
# As CLI tool
cargo install diffai
# As library (Cargo.toml)
[dependencies]
diffai-core = "0.4"
# Basic
diffai model1.pt model2.pt
# JSON output for automation
diffai model1.safetensors model2.safetensors --output json
# With numerical tolerance
diffai weights1.npy weights2.npy --epsilon 0.001
--format <FORMAT> # Force input format (pytorch, safetensors, numpy, matlab)
--output <FORMAT> # Output format: json, yaml, text (default: text)
--epsilon <N> # Float comparison tolerance
--ignore-keys-regex RE # Ignore keys matching regex
--quiet # Return only exit code (0: same, 1: diff found)
--verbose # Show detailed analysis
+ Added tensor/parameter- Removed tensor/parameter~ Modified tensor/parameterWhen comparing PyTorch/Safetensors files, diffai automatically runs 11 specialized analyses:
# Detect model changes
if ! diffai production.pt candidate.pt --quiet; then
echo "Model has changed"
diffai production.pt candidate.pt --output json > changes.json
fi
See diffai-cli/tests/cmd/ for executable examples:
MIT