https://github.com/kako-jun/diffai

https://github.com/kako-jun/diffai

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (10.7%) to scientific vocabulary
Last synced: 11 months ago · JSON representation

Repository

Basic Info
  • Host: GitHub
  • Owner: kako-jun
  • License: mit
  • Language: Rust
  • Default Branch: main
  • Size: 15.6 MB
Statistics
  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • Open Issues: 0
  • Releases: 11
Created about 1 year ago · Last pushed 11 months ago
Metadata Files
Readme Changelog Contributing License

README.md

diffai

AI/ML specialized diff tool for PyTorch, Safetensors, NumPy, and MATLAB files

CI Crates.io CLI npm PyPI

🤔 The Problem

Traditional diff tools fail completely with AI/ML workflows:

mermaid graph LR A[ML Engineer] --> B[Compare Models] B --> C{Traditional Tools} C --> D["❌ Binary files differ"] C --> E["❌ No semantic understanding"] C --> F["❌ Memory issues with GB+ files"] D --> G[😞 No actionable insights] E --> G F --> G

Reality Check: When you need to compare two PyTorch models, git diff and standard tools give you nothing useful.

✨ The Solution

diffai automatically analyzes AI/ML files and provides 11 specialized ML analysis functions without any configuration:

mermaid graph LR A[ML Engineer] --> B[diffai model1.pt model2.pt] B --> C[🎯 11 Auto ML Analyses] C --> D[📊 Learning Rate Changes] C --> E[🔍 Gradient Health] C --> F[⚡ Quantization Effects] C --> G[📈 Convergence Patterns] D --> H[✅ Actionable Insights] E --> H F --> H G --> H

Convention over Configuration: No setup required - diffai detects AI/ML files and runs comprehensive analysis automatically.

🆚 vs Traditional Tools

| Challenge | Traditional Tools | diffai | |-----------|------------------|---------| | Binary model files | "Binary files differ" | 11 specialized ML analyses + tensor statistics | | Large files (GB+) | Memory issues or failures | Efficient streaming with lawkit patterns | | ML semantics | No understanding | Learning rate, gradients, quantization detection | | Automation | Manual inspection required | JSON output for MLOps integration | | Scientific data | Text-only comparison | NumPy/MATLAB statistical analysis |

🚀 Quick Demo

```bash

Traditional diff: Useless for ML files

$ diff modelv1.safetensors modelv2.safetensors Binary files modelv1.safetensors and modelv2.safetensors differ

diffai: Comprehensive ML analysis automatically

$ diffai modelv1.safetensors modelv2.safetensors learningrateanalysis: old=0.001, new=0.0015, change=+50.0%, trend=increasing optimizercomparison: type=Adam, momentumchange=+2.1%, stateevolution=stable gradientanalysis: flowhealth=healthy, norm=0.021069, variancechange=+15.3% quantizationanalysis: mixedprecision=FP16+FP32, compression=12.5%, precisionloss=1.2% convergenceanalysis: status=converging, stability=0.92, plateau_detected=false

... + 6 more analyses automatically

~ fc1.weight: mean=-0.0002->-0.0001, std=0.0514->0.0716 ~ fc2.weight: mean=-0.0008->-0.0018, std=0.0719->0.0883 ```

✅ What diffai CAN do today

  • PyTorch/Safetensors files: 11 automatic ML analysis functions
  • NumPy/MATLAB files: Comprehensive tensor statistics (shape, mean, std, dtype)
  • Multiple output formats: Human-readable CLI, JSON for automation, YAML for reports
  • Memory efficient: Handles GB+ model files with streaming processing
  • Zero configuration: Automatic analysis based on file format detection
  • MLOps integration: JSON output for CI/CD pipelines and automation

❌ What diffai CANNOT do (be realistic)

  • TensorFlow formats (.pb, .h5, SavedModel) - Use TensorBoard for these
  • ONNX models - Consider netron for visualization
  • Live training monitoring - Use wandb/tensorboard for real-time tracking
  • Model performance prediction - Shows changes, not absolute performance
  • Automatic hyperparameter tuning - Analysis only, no recommendations yet
  • General text/code files - Use diffx for JSON/YAML/CSV

🔄 When to use diffai vs alternatives

| Your Goal | Use This Instead | Why | |-----------|------------------|-----| | Live training monitoring | TensorBoard, wandb | Real-time visualization during training | | Model architecture visualization | netron, torchviz | Interactive network diagrams | | Experiment tracking | MLflow, Neptune | Full experiment lifecycle management | | Performance benchmarking | MLPerf, custom scripts | Focused on inference/training speed | | General file comparison | diffx, git diff | Text-based structured data |

diffai is best for: Post-training model comparison, checkpoint analysis, and MLOps automation.

📥 Installation

```bash

From crates.io (recommended)

cargo install diffai

From source

git clone https://github.com/kako-jun/diffai.git cd diffai && cargo build --release ```

🎯 Common Use Cases

Research & Development

```bash

Compare before/after fine-tuning

diffai pretrainedmodel.pt finetunedmodel.pt

Auto-detects: parameter changes, convergence patterns, gradient health

```

MLOps & CI/CD

```bash

Automated model validation in pipelines

diffai productionmodel.safetensors candidatemodel.safetensors --output json

Pipe to automated decision making based on analysis results

```

Model Optimization

```bash

Analyze quantization effects

diffai full_precision.pt quantized.pt

Auto-detects: compression ratios, precision loss, performance impact

```

📚 Documentation

🔧 Technical Details

Supported Formats

  • PyTorch (.pt, .pth) - Full ML analysis + tensor statistics
  • Safetensors (.safetensors) - Full ML analysis + tensor statistics
  • NumPy (.npy, .npz) - Tensor statistics only
  • MATLAB (.mat) - Tensor statistics only

The 11 Automatic ML Analysis Functions

  1. Learning Rate Analysis - Training dynamics tracking
  2. Optimizer Comparison - Adam/SGD state analysis
  3. Loss Tracking - Convergence pattern detection
  4. Accuracy Tracking - Performance metric evolution
  5. Model Version Analysis - Checkpoint progression
  6. Gradient Analysis - Flow health, vanishing/exploding detection
  7. Quantization Analysis - Mixed precision (FP32/FP16/INT8/INT4) detection
  8. Convergence Analysis - Learning curves, plateau detection
  9. Activation Analysis - ReLU/GELU/Tanh distribution
  10. Attention Analysis - Transformer mechanism detection
  11. Ensemble Analysis - Multi-model structure detection

Output Formats

```bash

Human-readable (default)

diffai model1.pt model2.pt

JSON for automation

diffai model1.pt model2.pt --output json

YAML for reports

diffai model1.pt model2.pt --output yaml

Verbose diagnostics

diffai model1.pt model2.pt --verbose ```

🏗️ Built With

  • Rust - Performance and memory safety
  • diffx-core - Proven diff engine foundation
  • lawkit patterns - Memory-efficient incremental statistics
  • Convention over Configuration - Zero-setup philosophy

🤝 Contributing

We welcome contributions! See CONTRIBUTING.md for guidelines.

bash git clone https://github.com/kako-jun/diffai.git cd diffai cargo build && cargo test

📄 License

MIT License - see LICENSE file for details.

🔗 Related Projects

  • diffx - General-purpose structured data diff (JSON, YAML, CSV, XML)
  • lawkit - Memory-efficient data processing patterns
  • safetensors - Safe tensor storage format

Bottom line: diffai gives you actionable insights from AI/ML model comparisons that traditional tools simply cannot provide. No setup required - just point it at your models and get comprehensive analysis automatically.

Owner

  • Name: kako-jun
  • Login: kako-jun
  • Kind: user
  • Location: Kanazawa, Japan
  • Company: a taxpayer

too low visual acuity :eyeglasses: + too slow moving speed :ant: + too happy with coding :cake: === 42

GitHub Events

Total
  • Create event: 23
  • Issues event: 4
  • Release event: 18
  • Watch event: 1
  • Delete event: 12
  • Push event: 83
  • Pull request event: 6
Last Year
  • Create event: 23
  • Issues event: 4
  • Release event: 18
  • Watch event: 1
  • Delete event: 12
  • Push event: 83
  • Pull request event: 6

Committers

Last synced: about 1 year ago

All Time
  • Total Commits: 80
  • Total Committers: 2
  • Avg Commits per committer: 40.0
  • Development Distribution Score (DDS): 0.012
Past Year
  • Commits: 80
  • Committers: 2
  • Avg Commits per committer: 40.0
  • Development Distribution Score (DDS): 0.012
Top Committers
Name Email Commits
kako-jun 3****n 79
github-actions[bot] g****] 1

Issues and Pull Requests

Last synced: 11 months ago

All Time
  • Total issues: 2
  • Total pull requests: 2
  • Average time to close issues: 1 day
  • Average time to close pull requests: 1 day
  • Total issue authors: 1
  • Total pull request authors: 1
  • Average comments per issue: 0.0
  • Average comments per pull request: 0.0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 2
  • Pull requests: 2
  • Average time to close issues: 1 day
  • Average time to close pull requests: 1 day
  • Issue authors: 1
  • Pull request authors: 1
  • Average comments per issue: 0.0
  • Average comments per pull request: 0.0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • kako-jun (3)
Pull Request Authors
  • kako-jun (5)
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 4
  • Total downloads:
    • cargo 9,893 total
    • pypi 87 last-month
    • npm 41 last-month
  • Total dependent packages: 0
    (may contain duplicates)
  • Total dependent repositories: 0
    (may contain duplicates)
  • Total versions: 61
  • Total maintainers: 2
pypi.org: diffai-python

AI/ML specialized diff tool for deep tensor comparison and analysis

  • Versions: 12
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 87 Last month
Rankings
Dependent packages count: 8.8%
Average: 29.3%
Dependent repos count: 49.8%
Maintainers (1)
Last synced: 11 months ago
npmjs.org: diffai-js

A Node.js wrapper for the diffai CLI tool - AI/ML specialized diff tool for PyTorch, Safetensors, NumPy, and MATLAB files with deep tensor analysis

  • Versions: 9
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 41 Last month
Rankings
Dependent repos count: 24.2%
Average: 29.6%
Dependent packages count: 34.9%
Maintainers (1)
Funding
  • type: github
  • url: https://github.com/sponsors/kako-jun
Last synced: 11 months ago
crates.io: diffai-core

Core library for AI/ML diff analysis - PyTorch, Safetensors, tensor statistics, structured data

  • Versions: 20
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 4,899 Total
Rankings
Dependent repos count: 21.0%
Dependent packages count: 27.8%
Average: 47.8%
Downloads: 94.7%
Maintainers (1)
Last synced: 11 months ago
crates.io: diffai

AI/ML specialized diff CLI - PyTorch, Safetensors model comparison, tensor analysis

  • Versions: 20
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 4,994 Total
Rankings
Dependent repos count: 21.0%
Dependent packages count: 27.8%
Average: 47.8%
Downloads: 94.7%
Maintainers (1)
Last synced: 11 months ago

Dependencies

Cargo.lock cargo
  • 129 dependencies
Cargo.toml cargo
diffai-cli/Cargo.toml cargo
diffai-core/Cargo.toml cargo
.github/workflows/benchmark.yml actions
.github/workflows/ci.yml actions
.github/workflows/release-act1.yml actions
.github/workflows/release-act2.yml actions
diffai-python/Cargo.toml cargo
diffai-npm/package.json npm
diffai-python/pyproject.toml pypi
test-models/pyproject.toml pypi
  • huggingface-hub >=0.20.0
  • requests >=2.31.0
  • urllib3 >=2.0.0