Module vcs

Module vcs 

Source
Expand description

Version Control System for Differentiable Storage

Provides Git-like version control for tensor models and gradients:

  • Commit tracking with parent links (DAG structure)
  • Branch and tag management
  • Checkout to specific commits
  • Merge support for collaborative training

This enables reproducible model states and collaborative training workflows.

§Example

use ipfrs_storage::{VersionControl, Author, SledBlockStore, BlockStoreConfig};
use ipfrs_core::Block;
use bytes::Bytes;
use std::sync::Arc;
use std::collections::HashMap;
use std::path::PathBuf;

// Create a block store
let config = BlockStoreConfig {
    path: PathBuf::from(".ipfrs/vcs"),
    cache_size: 100 * 1024 * 1024,
};
let store = Arc::new(SledBlockStore::new(config)?);

// Initialize version control
let vcs = VersionControl::new(store.clone());

// Store model v1 and create initial commit
let model_v1 = Block::new(Bytes::from("model weights v1"))?;
store.put(&model_v1).await?;

let author = Author {
    name: "AI Researcher".to_string(),
    email: "researcher@example.com".to_string(),
};

let commit1 = vcs.commit(
    *model_v1.cid(),
    "Initial model".to_string(),
    author.clone(),
    HashMap::new(),
).await?;

// Train model, create v2, and commit
let model_v2 = Block::new(Bytes::from("model weights v2"))?;
store.put(&model_v2).await?;

let commit2 = vcs.commit(
    *model_v2.cid(),
    "After 100 epochs".to_string(),
    author,
    HashMap::new(),
).await?;

// Checkout to previous version
let model_cid = vcs.checkout(&commit1).await?;
let previous_model = store.get(&model_cid).await?;

// View commit history
let history = vcs.log(&commit2, 10).await?;
for commit in history {
    println!("{}: {}", commit.timestamp, commit.message);
}

Structs§

Author
Author information for a commit
Commit
IPLD schema for a commit in the version control system
CommitBuilder
Commit builder for ergonomic commit creation
Ref
Reference to a commit (branch or tag)
VersionControl
Version Control System for managing commits, branches, and tags

Enums§

MergeResult
Result of a merge operation
MergeStrategy
Merge strategy for combining branches
RefType
Type of reference