SPB Git

spb/forge Public MIT

Forge — LLM training from scratch in pure C++20 + Metal on Apple Silicon.

C++ 61.2% C 23% Python 7.6% TeX 7.2% CMake 1.1%

History of src/core/fmodel.h · clear filter

  1. Add .forge — Apple-native, git-style weight format with zero-copy loading
    A .forge is a model repository: tiny JSON manifests (one commit per save,
    with parent links) over content-addressed shards. Tensors are 16KB-page-
    aligned inside shards padded to page multiples, so loading is mmap +
    newBuffer(bytesNoCopy) — on unified memory the file-cache pages ARE the
    GPU memory. Saves are deltas: only tensors whose FNV-1a hash changed since
    the parent manifest are written. Shards cap at 95MB (GitHub-pushable).
    Store f32 (zero-copy alias at load) or f16/bf16 (half size).
    
    - src/core/fmodel.{h,cpp}: save() + Snapshot zero-copy reader
    - Tensor::from_buffer: views over externally-owned MTLBuffers
    - forge export CLI; generate/eval accept .forge repos directly
    - trainer commits weights natively to <out>/model.forge at each checkpoint
      (forge_save/forge_dtype config keys); .bin keeps optimizer state for resume
    - tools/fmodel.py: inspect, log (history), to-safetensors (pure numpy)
    
    Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
    simon-pierre boucher committed 5 days ago (Aug 5, 2026) · 1 file changed +80