Sinir ağı ağırlıkları için veritabanıThe database for neural network weights

WeightLake

Model checkpoint'lerini dosya yığını olarak değil, sorgulanabilir veri olarak sakla. Her sürüm Git gibi kayıtlı, her bayt bir kez yazılı, her ağırlık SQL'in bir satır uzağında. Keep model checkpoints as queryable data, not a pile of files. Every version recorded like Git, every byte written once, every weight one SQL line away.

$git clone https://github.com/PoyrazAlkan65/weightlake
Gölün içine kaydırScroll into the lake
01 / 04 · chunk

Her matris satır bloklarına ayrılırEvery matrix splits into blocks of rows

Bir tensör ~4 MiB'lık chunk'lara, her zaman satır sınırından bölünür. Her chunk'ın kimliği BLAKE3 hash'idir. Aynı baytlar hangi modelde ya da sürümde olursa olsun diske bir kez yazılır.A tensor is cut into ~4 MiB chunks, always on row boundaries. Each chunk's identity is its BLAKE3 hash, so the same bytes are written to disk once, whatever model or version they belong to.

[768, 2304]h.0.attn.c_attn.weight
2chunk, tam satırlarchunks, whole rows
02 / 04 · delta

Yeni sürüm sadece değişeni yazarA new version writes only what changed

Değişmeyen chunk'lar paylaşılır. Değişenler önceki sürümdeki karşılığıyla XOR'lanır ve zstd ile sıkıştırılır. GPT-2 üzerinde, 28 tensörü değişen bir fine-tune diske sadece 41,5 MiB ekledi.Unchanged chunks are shared. Changed ones are XOR'ed with their counterpart in the previous version and compressed with zstd. On GPT-2, a fine-tune that changed 28 tensors added only 41.5 MiB to disk.

88%yeniden kullanıldıreused
62 → 41.5 MiBXOR deltaXOR delta
03 / 04 · SQL

Modeli yüklemeden sorgulaQuery the model without loading it

Her chunk istatistik taşır: min, max, L2, sıfır, NaN. "En büyük normlu attention matrisleri" sorusu tek bir ağırlık okunmadan cevaplanır. Yükselen sütunlar GPT-2'deki gerçek ilk beş.Every chunk carries statistics: min, max, L2, zeros, NaN. "Largest-norm attention matrices" is answered without reading a single weight. The rising columns are GPT-2's real top five.

SELECT name, l2 FROM tensors
WHERE commit_id = rev('main')
  AND role = 'attention' AND ndim = 2
ORDER BY l2 DESC LIMIT 5;
04 / 04 · round trip

Ve her şey bayt bayt geri dönerAnd everything comes back byte for byte

Export ettiğin .safetensors dosyası orijinaliyle birebir aynı. PyTorch tarafında save_pretrained ve from_pretrained ağırlıkları dosyasız taşır. Göl sakin, veri yerinde.The .safetensors file you export is identical to the original. On the PyTorch side, save_pretrained and from_pretrained move weights with no files at all. The lake is calm, the data is in place.

0 Bexport sonrası farkdiff after export
+1 080 Bdeğişmemiş modeli tekrar kaydetmekre-saving an unchanged model
AvantajlarAdvantages

Checkpoint dosyalarının yapamadıklarıWhat checkpoint files can't do

7B'lik bir modelin on fine-tune'u, katmanların çoğu aynı kalsa bile ~14 GB'lık on kopya demek. "Hangi katman ne kadar değişti?" sorusu için de hepsini bir framework'e yüklemen gerekir.Ten fine-tunes of a 7B model are ten ~14 GB copies, even when most layers stay the same. And asking "which layer moved, and how far?" means loading all of them into a framework.

DepolamaStorage

Her bayt bir kezEvery byte once

İçerik-adresli chunk'lar. 50 sürümde değişmeyen bir katman diskte tek kopya. Bağlı ağırlıklar (lm_head = wte) ek yer kaplamaz.Content-addressed chunks. A layer unchanged across 50 versions is one copy on disk. Tied weights (lm_head = wte) take no extra space.

SıkıştırmaCompression

Değişiklikler delta olarakChanges as deltas

XOR + bayt düzlemleri + zstd. Küçük güncellemelerde XOR sonucu neredeyse tamamen sıfır.XOR + byte planes + zstd. For small updates the XOR is almost all zeros.

SorguQuery

Yüklemeden SQLSQL without loading

Normlar, seyreklik, NaN sayıları indeksten. Sürümler arası kosinüs ve L2 sapması SQL fonksiyonu.Norms, sparsity and NaN counts from the index. Cosine and L2 drift between versions are SQL functions.

OkumaReads

Sadece gerekeni okuRead only what you need

Tek bir tensör ya da tek bir ağırlık. Yalnızca onu içeren chunk çözülür, mmap'ten sıfır kopyayla.One tensor or one weight. Only the chunk that holds it is decoded, from a memory map with zero copies.

SürümlemeVersioning

Model için GitGit for models

Commit, branch, main~1, log, yapısal ve sayısal diff, gc. Yarıda kesilen import yarım sürüm bırakmaz.Commit, branch, main~1, log, structural and numeric diff, gc. An interrupted import leaves no half-written version.

PyTorch

Doğrudan transformersStraight from transformers

save_pretrained / from_pretrained ağırlıkları RAM ile veritabanı arasında taşır. Logitler birebir aynı.save_pretrained / from_pretrained move weights between RAM and the database. Logits are identical.

KavramlarConcepts

MongoDB'yi biliyorsan bunu da biliyorsunIf you know MongoDB, you know this

Database →Repo

Bir modelin bütün sürümleriEvery version of a model

Collection →Tensor

Bir ağırlık matrisiOne weight matrix

Document →Chunk

~4 MiB tam satır, BLAKE3~4 MiB of rows, BLAKE3

Field →Weight

weight(rev, tensor, i)

Index →Chunk stats

min, max, L2, sıfır, NaNmin, max, L2, zeros, NaN

Git commit →Commit

Model sürümüModel version

Bit düzeyinde · XOR deltaAt the bit level · XOR delta

Fine-tune bitlerin çoğuna dokunmazA fine-tune leaves most bits alone

Bu çift gerçek: GPT-2'nin h.11.mlp.c_fc.weight[0] ağırlığı, base ve fine-tune sürümünde. İşaret ve üs bitleri değişmiyor. XOR'un sıfır bitleri zstd için neredeyse bedava.This pair is real: GPT-2's h.11.mlp.c_fc.weight[0] in the base and fine-tuned versions. The sign and exponent bits don't change. The zero bits of the XOR cost zstd almost nothing.

/ 32 bit sıfır/ 32 bits are zero
baştaki ortak bitleading bits shared

WeightLake bunu 4 MiB'lık chunk'lara uygular: her elemanın k. baytı k. düzleme toplanır, sonra zstd çalışır. Sıfırlarla dolu üst baytlar uzun sıfır dizilerine dönüşür.WeightLake applies this to 4 MiB chunks: byte k of every element goes into plane k, then zstd runs. The mostly-zero high bytes turn into long runs of zeros.

Ölçülmüş · GPT-2 small, 124M parametre, F32Measured · GPT-2 small, 124M parameters, F32

İki sürüm, bir modelin yerindeTwo versions in the space of one

0.8 s525 MiB'lık modeli import etmeto import the 525 MiB model
88%fine-tune'da yeniden kullanılan chunkof chunks reused by the fine-tune
41.5 MiB62 MiB değişikliğin diske yazılan haliwritten to disk for 62 MiB of changes
523 MiBiki sürümün toplamı (1,02 GiB yerine)for both versions (instead of 1.02 GiB)

Dizüstü bir SSD'de CLI ile ölçüldü. İkinci sürüm, 160 tensörden 28'ini değiştiren sentetik bir fine-tune. Gerçek eğitim checkpoint'leri genelde daha küçük güncellemeler içerir, delta oranı veriye göre değişir. Bu bir benchmark değil, hızlı bir doğrulama.Measured with the CLI on a laptop SSD. The second version is a synthetic fine-tune that changes 28 of 160 tensors. Real training checkpoints usually differ by smaller updates, and the delta ratio depends on your data. This is a smoke test, not a benchmark.

SQL · Apache DataFusion

Modeline soru sorAsk your model questions

Tablolar: commits, refs, tensors, chunks, tensor_chunks. Çıktılar GPT-2 deposunda çalıştırılan gerçek sorgulardan.Tables: commits, refs, tensors, chunks, tensor_chunks. The outputs come from real queries on the GPT-2 repo.

Tek çekirdek, altı arayüzOne core, six interfaces

Kullandığın dildeIn the language you use

Hepsi aynı Rust crate'i üzerinde. Python numpy, torch ve pandas döndürür. Node TypedArray ve TypeScript tipleriyle gelir.All on the same Rust crate. Python returns numpy, torch and pandas. Node comes with TypedArrays and TypeScript types.

Depolama motoruStorage engine

Bir import'ta ne olurWhat happens on import

  1. Satırlara bölSplit into rows

    Her tensör ~4 MiB'lık chunk'lara, satır sınırından.Each tensor into ~4 MiB chunks, on row boundaries.

  2. Hash ve istatistikHash and stats

    BLAKE3 ve chunk istatistikleri tüm çekirdeklerde paralel.BLAKE3 and chunk statistics, in parallel on all cores.

  3. TekilleştirDeduplicate

    Hash'i katalogda olan chunk'lar atlanır.Chunks whose hash is already in the catalog are skipped.

  4. Kodla ve yazEncode and write

    raw, zstd ya da XOR-zstd olarak yeni, değişmez bir pack dosyasına.As raw, zstd or XOR-zstd into a fresh, immutable pack file.

  5. Commit

    Manifest ve commit tek bir ACID transaction'la kataloğa girer.Manifest and commit enter the catalog in one ACID transaction.

codecne zamanwhenkodlamaencoding
rawyeni chunknew chunkOlduğu gibi, sıfır kopyalı okumaAs is, zero-copy reads
zstdcompress=trueBayt düzlemleri + zstdByte planes + zstd
xor-zstdbase'i olan değişmiş chunkchanged chunk with a baseBase ile XOR + bayt düzlemleri + zstdXOR with base + byte planes + zstd
repo/
  catalog.redb        # chunks, manifests, commits, refs
  packs/000001.pack   # immutable, 64-byte aligned, mmap
  packs/000002.pack
Yol haritasıRoadmap

Nerede olduğumuzWhere it stands

bittidoneDepolama çekirdeği: chunk'lama, tekilleştirme, istatistik, safetensors import/exportStorage core: chunking, dedup, statistics, safetensors import/export
bittidoneSürümleme: commit, branch, log, diff, XOR delta + zstd, gcVersioning: commit, branch, log, diff, XOR delta + zstd, gc
bittidoneSQL (DataFusion) ve ağırlık seviyesinde fonksiyonlarSQL (DataFusion) and weight-level functions
bittidoneRust, C/C++, Python, JavaScript API'leri ve Hugging Face transformersRust, C/C++, Python and JavaScript APIs, and Hugging Face transformers
sıradanextGGUF desteği, PyPI ve npm paketleriGGUF support, PyPI and npm packages
planlıplannedSunucu: gRPC + Arrow Flight, repolar arası push / pull, uzaktan SQLServer: gRPC + Arrow Flight, push / pull between repos, remote SQL
  • Bir repo aynı anda tek bir process tarafından açılır.A repo is opened by one process at a time.
  • Şimdilik sadece safetensors. GGUF, .bin ve ONNX için önce dönüştürme gerekir.safetensors only for now. GGUF, .bin and ONNX need converting first.
  • Windows'ta geliştirildi. Linux ve macOS henüz test edilmedi.Developed on Windows. Linux and macOS are not tested yet.
weightlake.com

Ağırlıklarını göle bırak.Let your weights into the lake.

Açık kaynak, MIT veya Apache-2.0. Rust ile derle, Python'dan ya da terminalden kullan.Open source, MIT or Apache-2.0. Build it with Rust, use it from Python or the terminal.