Skip to content

Add sidecar for speed up ssd streaming#514

Open
GiorgioOppo wants to merge 6 commits into
antirez:mainfrom
GiorgioOppo:Sidecar
Open

Add sidecar for speed up ssd streaming#514
GiorgioOppo wants to merge 6 commits into
antirez:mainfrom
GiorgioOppo:Sidecar

Conversation

@GiorgioOppo

Copy link
Copy Markdown

This sidecar could be speed up the ssd streaming by 20%
#491

claude and others added 6 commits July 5, 2026 21:10
…BUNDLE=1)

Serve streaming expert-cache misses from a sidecar file where each routed
expert's gate|up|down slabs are contiguous, so a miss becomes one sequential
burst instead of three reads scattered across the GGUF. Same bytes, same
numerics; built one-time next to the model (or in $DS4_BUNDLE_DIR),
fingerprinted against the model and rebuilt when the GGUF changes.

- ds4_ssd.c/.h: DSEB v1 sidecar format (build/validate/open), byte-compatible
  with the DwarfStar Swift port so one bundle serves both implementations
- ds4_metal.m: remap exact expert-slab preads to the sidecar record at the
  lowest read level; every miss/seed path benefits, plain GGUF fallback
- ds4.c: engine wiring (contiguous uniform routed-layer range only;
  mixed-precision boosted models are skipped)
- ds4_cuda.cu, rocm: no-op stubs (Metal-only for now)
- tests/expert_bundle_test.c: build/reuse/tamper/DS4_BUNDLE_DIR coverage

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AoyYYU8BwNXeJpt2WRsmXL
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AoyYYU8BwNXeJpt2WRsmXL
- Metal: a failed sidecar read now retries the same slab from the model
  file (the sidecar can never break inference), logging the first fallback
- Metal: F_RDADVISE readahead hints follow the remap to the bundle fd
  instead of prefetching GGUF ranges that are never read
- API: ds4_gpu_set_streaming_expert_bundle takes the validated
  ds4_expert_bundle + layer table, returns acceptance so the engine only
  logs 'active' (and keeps the fd) when the backend really serves reads;
  the Metal remap reuses ds4_expert_bundle_record_offset for the layout math
- build: per-process .tmp name (concurrent builders can no longer
  interleave writes), stale incompatible bundles are removed before the
  space check, statvfs failure is treated as unknown instead of full disk
- open: overflow guards on the size arithmetic before trusting the file

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AoyYYU8BwNXeJpt2WRsmXL
…mparison-0vj3ah

Claude/swift main c sidecar comparison 0vj3ah
…mparison-0vj3ah

docs(bundle): measured +9% decode with the sidecar on M1 Pro 16GB
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