Skip to content

feat(st): COLI_MODEL_DIRS ΓÇö split model shards across N drives, no duplication (capacity aggregation; composable with #421 mirror) - #469

Merged
JustVugg merged 1 commit into
JustVugg:devfrom
mohamedmastouri2000-boop:feat/model-dirs-split
Jul 20, 2026
Merged

feat(st): COLI_MODEL_DIRS ΓÇö split model shards across N drives, no duplication (capacity aggregation; composable with #421 mirror)#469
JustVugg merged 1 commit into
JustVugg:devfrom
mohamedmastouri2000-boop:feat/model-dirs-split

Conversation

@mohamedmastouri2000-boop

Copy link
Copy Markdown
Contributor

What

Per the green light in #467 (finding 4): COLI_MODEL_DIRS=<dir>[;<dir>...] — split the model's .safetensors shards across N drives with no duplication. Complementary to #421's mirror, not a competitor.

Why

The mirror gives 2× read bandwidth at 2× disk cost. The split gives capacity aggregation, which the mirror fundamentally can't: a 400 GB container fits across two smaller drives that individually can't hold it (or three, or N — ST_MAX_SHARDS is the only bound). Demand preads hit whichever drive holds the shard, so concurrent expert loads still parallelise across spindles when routing spreads.

Design

  • The dir list acts as a search path with dedup by basename: a shard present in two dirs is taken from the first-listed one (primary COLI_MODEL first). No layout convention imposed — any partition of the shards works; users move files between drives freely.
  • Each shard opens its own fd from its own path, exactly as today — the split needs no read-path changes at all: st_open_fd/pread/O_DIRECT twins/PIPE workers all work per-fd already. The whole feature is in indexing.
  • Composable with COLI_MODEL_MIRROR (the init-order ask from [Performance]: RTX 5080 / 128 GB resource matrix (drive x compute x RAM) ΓÇö RAM dominates; COLI_CUDA=0 Windows quirk; PR-ready N-drive shard split #467): st_mirror_init runs after indexing and matches per-shard by basename against the merged index, so a mirror dir may hold a copy of any subset of the split's shards — partial mirrors of a split are valid, divergent files are rejected per-file exactly as on a single-dir model. They cannot fight at init: split resolves which file is primary, mirror only ever adds a replica fd to an already-indexed shard.
  • Metadata (config.json, tokenizer, .coli_usage, .coli_kv) stays in the primary COLI_MODEL dir only — extra dirs are weights-only, never written.
  • st_init(S, dir) remains as a one-line back-compat wrapper over the new st_init_multi(S, dir, extra); every existing call site and test is untouched.
  • Startup logs the layout: [SPLIT] +C:\glm_split_b -> 70 shard(s) / [SPLIT] model across 2 dir(s): 142 shard(s) total (primary ... -> 72 shard(s)), no duplication.

Verification (RTX 5080 / Windows 11, g64 container, 142 shards, 399.8 GB)

Scope

+61/−10 over c/st.h (scan/dedup/init-multi), one call site in c/colibri.c (env read at model_init), docs/ENVIRONMENT.md row. No kernel, no read-path, no format changes. Happy to add a test_st_split.c sibling of test_st_mirror.c (dedup priority, partial-dir, missing-dir error) if you want one in-tree — say the word and I'll push it to this branch.

…plication

Each extra directory holds a DISTINCT subset of the .safetensors shards (search path, dedup by basename; first-listed dir wins). Demand preads hit whichever drive holds the shard, so concurrent expert loads parallelise across drives and combined capacity is used - a 400 GB container fits across two smaller drives that individually cannot hold it, which COLI_MODEL_MIRROR (a full second copy) cannot do. Composable with the mirror: st_mirror_init matches per-shard by basename against the merged index. st_init stays as a back-compat wrapper over st_init_multi. Verified on RTX 5080 / Windows: 72+70 shards across two NVMes, coherent output, [SPLIT] startup log, decode parity with single-drive at full RAM (0.92 vs 0.89-0.90).
@JustVugg
JustVugg merged commit e16ec68 into JustVugg:dev Jul 20, 2026
8 checks passed
BColsey added a commit to BColsey/colibri that referenced this pull request Jul 21, 2026
Retarget PR JustVugg#377 onto current dev (origin/dev @ 4aca059) after JustVugg#391 split
glm.c into colibri.c + quant.h/sample.h/kv_persist.h/telemetry.h. Reconciles
four collisions:

- JustVugg#391 split: all glm.c hunks resited -- prof_*/g_prof_io/ProfBase live in
  colibri.c (NOT telemetry.h); tiers_emit/emap_emit -> telemetry.h (with a
  rammap_slot forward-decl); st_fd_is_tmpfs/st_fd_fs_magic -> st.h; .coli_kv
  state-dir -> serve_ctx_init/run_serve/run_serve_mux + main.
- DISK-CLASS (1f00142): prof_physical_read_bytes/ProfPhysicalWire merged ON
  TOP of dev's dc_* fields; PROF protocol line extended 9->17 fields
  additively; expert_load_impl 6-arg `demand` signature preserved; g_prof_io
  routed through prof_ssd_tensor_bytes (tmpfs-excluded).
- DUAL-SSD mirror (JustVugg#298/JustVugg#469): ESlot.backing hand-merged with dev's
  aslab/afslab; map_of_fd exact-length + MADV_HUGEPAGE composes with rep_bfd.
- int3 fmt=5 (JustVugg#168): rammap_bind_one reuses dev's qt_resolve_fmt/detect_group_size
  (inline fmt-detection dropped; duplicate detect_group_size not re-added).

Verified: make colibri 0 warnings; make check 187 tests pass (test_uring skips
in sandboxes via the PR's helpers; test_rammap builds against colibri.c and
passes). Default path byte-identical -- oracle-safe by construction.

Co-Authored-By: Claude <noreply@anthropic.com>
BColsey added a commit to BColsey/colibri that referenced this pull request Jul 24, 2026
Retarget PR JustVugg#377 onto current dev (origin/dev @ 4aca059) after JustVugg#391 split
glm.c into colibri.c + quant.h/sample.h/kv_persist.h/telemetry.h. Reconciles
four collisions:

- JustVugg#391 split: all glm.c hunks resited -- prof_*/g_prof_io/ProfBase live in
  colibri.c (NOT telemetry.h); tiers_emit/emap_emit -> telemetry.h (with a
  rammap_slot forward-decl); st_fd_is_tmpfs/st_fd_fs_magic -> st.h; .coli_kv
  state-dir -> serve_ctx_init/run_serve/run_serve_mux + main.
- DISK-CLASS (1f00142): prof_physical_read_bytes/ProfPhysicalWire merged ON
  TOP of dev's dc_* fields; PROF protocol line extended 9->17 fields
  additively; expert_load_impl 6-arg `demand` signature preserved; g_prof_io
  routed through prof_ssd_tensor_bytes (tmpfs-excluded).
- DUAL-SSD mirror (JustVugg#298/JustVugg#469): ESlot.backing hand-merged with dev's
  aslab/afslab; map_of_fd exact-length + MADV_HUGEPAGE composes with rep_bfd.
- int3 fmt=5 (JustVugg#168): rammap_bind_one reuses dev's qt_resolve_fmt/detect_group_size
  (inline fmt-detection dropped; duplicate detect_group_size not re-added).

Verified: make colibri 0 warnings; make check 187 tests pass (test_uring skips
in sandboxes via the PR's helpers; test_rammap builds against colibri.c and
passes). Default path byte-identical -- oracle-safe by construction.

Co-Authored-By: Claude <noreply@anthropic.com>
ebby-s added a commit to ebby-s/colibri that referenced this pull request Jul 29, 2026
…m upstream JustVugg/colibri

JustVugg#469 COLI_MODEL_DIRS: st_init -> st_init_multi(snap, extra_dirs); st_scan_dir
dedups shards by basename (first-listed dir wins), so a model split across N
drives is indexed as one set with no duplication — concurrent expert loads
parallelise across drives and combined capacity is used (a 400 GB container
fits across two 250 GB drives). st_init kept as a back-compat 1-dir wrapper.

JustVugg#421 COLI_MODEL_MIRROR: st_mirror_init registers a second read-only copy as a
per-shard replica, accepted only if size + safetensors header are byte-identical
to the primary (partial mirrors OK; never written). st_fd_rep/st_direct_fd_rep/
st_prefetch_rep/st_read_raw_rep expose replica routing with primary fallback +
per-replica byte counters (st_mirror_stats). glm.c call site upgraded to
st_init_multi(COLI_MODEL_DIRS).

tests/test_st_multi.c: shard split + dedup, mirror acceptance, routed-read
equality, and the size-mismatch rejection path.

dsv4 read routing + glm mirror wiring land with the dsv4 integration commit.
ebby-s added a commit to ebby-s/colibri that referenced this pull request Jul 29, 2026
…4 from upstream JustVugg/colibri

JustVugg#403 measured-RSS guard: at the decode safe point (no moe in flight), every ~16
tokens, if measured RSS (/proc/self/status VmRSS — not ru_maxrss, so it reflects
frees) exceeds the budget (RSS_GUARD_GB | RAM_GB | 0.88*MemAvailable), evict the
coldest LRU expert slots per layer: free the six FP4 buffers (g4/u4/d4 + gs/us/ds),
eid=-1, clk=0 (no compaction — PIPE workers hold pointers across preads), and lower
ecap[L] so the cache cannot regrow. slot_load's realloc re-allocates a freed slot
on next miss, so pages (>128 KB) return to the kernel and RSS actually drops.
Pinned slots are never touched. Victim selection/free under g_pp.mx when PIPE runs.

JustVugg#421 mirror routing wired into the disk-bound path: mirror_route(L,e) deterministically
assigns all six reads of one expert to the same drive (readahead-coherent, no double
cache), weighted by COLI_DISK_WEIGHTS=p,m (default 1:1). slot_load/mtp_slot_load read
via st_read_raw_rep; expert_prefetch via st_prefetch_rep; [MIRROR] I/O split logged at
shutdown. Dense FP8/FP4 loads stay on the primary (one-shot at startup).

JustVugg#469: dsv4 load_model calls st_init_multi(COLI_MODEL_DIRS).

All byte-identical (only residency/IO change, never compute); guarded no-op when the
budget is unset, not streaming, or RSS within tolerance.
BColsey added a commit to BColsey/colibri that referenced this pull request Aug 1, 2026
Retarget PR JustVugg#377 onto current dev (origin/dev @ 4aca059) after JustVugg#391 split
glm.c into colibri.c + quant.h/sample.h/kv_persist.h/telemetry.h. Reconciles
four collisions:

- JustVugg#391 split: all glm.c hunks resited -- prof_*/g_prof_io/ProfBase live in
  colibri.c (NOT telemetry.h); tiers_emit/emap_emit -> telemetry.h (with a
  rammap_slot forward-decl); st_fd_is_tmpfs/st_fd_fs_magic -> st.h; .coli_kv
  state-dir -> serve_ctx_init/run_serve/run_serve_mux + main.
- DISK-CLASS (1f00142): prof_physical_read_bytes/ProfPhysicalWire merged ON
  TOP of dev's dc_* fields; PROF protocol line extended 9->17 fields
  additively; expert_load_impl 6-arg `demand` signature preserved; g_prof_io
  routed through prof_ssd_tensor_bytes (tmpfs-excluded).
- DUAL-SSD mirror (JustVugg#298/JustVugg#469): ESlot.backing hand-merged with dev's
  aslab/afslab; map_of_fd exact-length + MADV_HUGEPAGE composes with rep_bfd.
- int3 fmt=5 (JustVugg#168): rammap_bind_one reuses dev's qt_resolve_fmt/detect_group_size
  (inline fmt-detection dropped; duplicate detect_group_size not re-added).

Verified: make colibri 0 warnings; make check 187 tests pass (test_uring skips
in sandboxes via the PR's helpers; test_rammap builds against colibri.c and
passes). Default path byte-identical -- oracle-safe by construction.

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants