Skip to content

Feature Request: support DeepSeek V4.1 Flash with bounded SSD expert caching #48

Description

@ajaxdude

Prerequisites

  • I am running the latest repository base used for this work: 0007bc6d3536bcd8c98c4e3eb18c5751b6822267.
  • I carefully followed the repository README and the Strix-specific contribution requirements.
  • I searched halo-box/strix-llama.cpp, halo-box/llama.cpp, and ggml-org/llama.cpp for DeepSeek V4.1, expert-cache, lazy-MoE, and SSD-streaming issues and pull requests; no matching work was found.
  • I reviewed the available repository documentation and existing DeepSeek V4, lazy tensor, and disk-backed n-gram implementations.

Feature Description

Support the published calibrated DeepSeek V4.1 Flash Q2 GGUF directly on a headless 128 GB Strix Halo without rewriting or requantizing the artifact.

Target artifact:

  • Path on the validation host: /mnt/models/deepseek-v41/DeepSeek-V4.1-Flash-Q2.gguf
  • Size: 365713686528 bytes
  • SHA-256: 1ce6a8f8806205c13330d7ca287bd198331dc5ca35ccc5d8a9a92a188a6f6f42
  • general.architecture=deepseek41
  • Source revision: df42c109f1defefcbfcedbe7d905718a12266e40
  • Quantization: IQ2_XXS gate/up, Q2_K down, Q8_0 attention/shared/head

The implementation must cover:

  • V4.1 metadata, tensor mapping, graph semantics, source-layer sharing, and output handling
  • Two disk-backed Engram tables with 264-byte rows: 256 native E4M3 values plus 8 E8M0 scales
  • Bounded SSD-backed routed-expert caching and native-quantized ROCm staging
  • Bounded prefill and decode execution using the existing IQ2_XXS, Q2_K, and MoE kernels
  • Runtime host-memory admission plus an independent watchdog
  • 32,768 context validation first, progressing to 131,072 only after correctness and memory stability

The published GGUF must remain unchanged if technically possible. Engram and expert payloads must stay on NVMe when not resident. The implementation must not silently degrade quantization.

Motivation

The published Q2 GGUF is about 365.7 GB and its ordinary main weights are about 151.77 GiB, so conventional full loading cannot fit within the target host's 124 GiB usable RAM. Strix Halo uses unified CPU/GPU memory, which means model weights, ROCm buffers, graph scratch, context state, the OS, and filesystem cache all compete for the same physical memory.

The target acceptance policy is:

  • total host RAM below 120 GiB at all times
  • automatic cache sizing and graceful stop at a 116 GiB soft threshold
  • zero configured or used swap during validation
  • no evaluation I/O on rotational /mnt/bigspace
  • no host ROCm package changes

The existing TENSOR_READ_LAZY path is not sufficient: it keeps marked tensors CPU-mapped, relies on page faults/page-cache behavior, and cannot provide useful-speed ROCm execution with an explicitly bounded expert residency set.

Possible Implementation

Use a dependent, one-concern-per-PR stack:

  1. DeepSeek V4.1 architecture and Engram

    • Register deepseek41 separately from deepseek4.
    • Add V4.1 metadata for compressor/indexer source-layer arrays and Engram layout.
    • Reuse current DeepSeek V4 graph code only where semantics are identical.
    • Add V4.1 source-layer indirection and output behavior.
    • Decode Engram rows directly from the unchanged GGUF using bounded reads and reference-compatible BF16 rounding.
    • Add synthetic/model-free architecture, hash, decode, malformed-row, and graph tests.
  2. Bounded routed-expert store and cache core

    • Exclude routed expert extents from ordinary model mapping/allocation.
    • Read contiguous native-quantized expert slices with aligned direct I/O.
    • Bound cache slots/bytes, bounce buffers, and in-flight entries.
    • Add deterministic eviction, statistics, and explicit I/O errors.
  3. Runtime memory admission and watchdog

    • Account for non-routed weights, expert cache, Engram staging, ROCm upload buffers, graph/scheduler scratch, KV/recurrent state, and context.
    • Auto-fit the expert cache to a projected total host use no higher than 116 GiB.
    • Refuse startup if mandatory allocations exceed the budget or swap is enabled.
    • Add an independent watchdog that measures host-wide use as MemTotal - MemAvailable and terminates below the 120 GiB hard ceiling.
  4. ROCm cached-expert decode

    • Split routing/selection from expert execution where needed.
    • Load and upload only selected expert slices.
    • Reuse existing gfx1151 quantized kernels without requantization.
    • Prevent eviction while ROCm work is in flight.
  5. Bounded prefill and final validation

    • Chunk prefill so selected expert working sets cannot exceed the cache/staging budget.
    • Add conservative measured prefetch and cache telemetry.
    • Validate against /home/papa/src/ds4-v41 at bd66c402070042bf0a79ad6ece8242de4c93680c using exact token IDs, Engram row IDs, expert routing IDs, complete logits, top-1 results, and deterministic multi-step decode over all four repository correctness corpora.
    • Build and run the merge-base and candidate separately in the same hardware session before performance claims.

No full-model load will be attempted while another user is active on the validation host.

AI usage disclosure: AGENT-AUTHORED. GitHub Copilot inspected the repository and reference implementation, drafted this issue, and will implement the proposed stack. All real-hardware verification and any unverified areas will be reported explicitly.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions