Skip to main content

pf_model/
lib.rs

1// SPDX-License-Identifier: MIT
2//! # `pf-model`
3//!
4//! Captures model-weight diffs (LoRA, IA³, full-finetune, in-place TTT)
5//! and implements the TIES + DARE task-vector merge from
6//! `agent_docs/model-layer.md`.
7//!
8//! ## What ships in Phase 5 (this commit)
9//!
10//! - [`diff::ModelDiff`] tagged enum + per-variant payloads.
11//! - [`serialize::store_diff`] / [`serialize::load_diff`]: round-trip every
12//!   variant through any [`pf_core::cas::BlobStore`].
13//! - [`merge::dare`] / [`merge::ties_merge`]: the two task-arithmetic
14//!   primitives, tested on small synthetic tensors.
15//!
16//! ## Wire format
17//!
18//! For Phase 5 we use a single JSON-typed wire format (`model.diff.v1`) for
19//! every variant. Parameter tensors are stored as `Vec<f32>` with shape
20//! metadata; safetensors interop lands in Phase 10's vLLM adapter where
21//! it's actually needed (no point pulling 50 kloc of safetensors deps now).
22
23#![deny(unsafe_code)]
24#![allow(missing_docs)] // documented per-symbol in submodules
25
26pub mod diff;
27pub mod merge;
28pub mod serialize;
29
30pub use diff::{
31    DiffKind, FullDelta, IA3Delta, InPlaceTttDelta, LoraAdapter, LoraDelta, ModelDiff, TttStep,
32};
33pub use merge::{TiesParams, dare, ties_merge};
34pub use serialize::{load_diff, store_diff};