Skip to content

Community GGUF dialect compat for ds4f-mxfp4: dense BF16/F32/Q6_K load-time conversion - #664

Open
nexus-cw wants to merge 8 commits into
antirez:ds4f-mxfp4from
nexus-cw:dialect-compat-dense-types
Open

Community GGUF dialect compat for ds4f-mxfp4: dense BF16/F32/Q6_K load-time conversion#664
nexus-cw wants to merge 8 commits into
antirez:ds4f-mxfp4from
nexus-cw:dialect-compat-dense-types

Conversation

@nexus-cw

@nexus-cw nexus-cw commented Aug 3, 2026

Copy link
Copy Markdown

Summary

Addresses #663 (part 2 of 2). Depends on #662 and is stacked on its
branch; the first three commits here are #662. Adds the dense tensor type
side of community GGUF dialect compat: with both PRs, llama.cpp-dialect
GGUFs like bullerwins/DeepSeek-V4-Flash-0731-MXFP4_MOE-Q8_0 load and run
on ds4f-mxfp4.

Changes

Three commits on top of #662, ds4.c plus a small ds4_cuda.cu change:

  1. BF16/Q6_K to F16 load-time conversion. Adds DS4_TENSOR_BF16 = 30
    to the type table and converts dense BF16 and Q6_K tensors to F16 at
    load, growing the mmap allocation as needed. Native GGUFs never enter
    the conversion path.
  2. F32 to F16 conversion and cuda_model_range fixes. Extends the
    conversion to F32 dense tensors and fixes cuda_model_range bookkeeping
    so SSD streaming addresses converted tensors at their post-conversion
    size and offset.
  3. Q6_K row-dequantizer per-block offset fix. dequantize_row_q6_K
    wrote every block of a multi-block row to the first 256 output slots;
    only the last block survived. The single-block expert caller never hits
    this, but whole-tensor conversion does, and it zeroed most of the
    attention LoRA weights. The decode-graph qkv type guard this fix
    originally shipped with is already present on the current branch tip,
    so only the dequantizer fix is carried.

Testing

make cpu at the branch tip: clean build, no new warnings beyond the two
pre-existing rax.c ones.

In production this stack serves the bullerwins GGUF on a GB10 CUDA node
with --ssd-streaming, several weeks of runtime, 12/12 on our eval
battery.

Community llama.cpp-dialect GGUFs of DeepSeek V4 Flash omit eight
deepseek4.* keys the loader hard-requires. Derive the hc, lora and
hash-layer values from keys the community dialect does carry, keeping
native GGUFs on the exact required path.
Community GGUF exports use llama.cpp tensor naming that differs from
ds4 canonical names in about twenty places, including missing suffixes
and renamed attention and expert tensors. Add an alias table consulted
only when the canonical lookup misses, so native GGUFs are unaffected.
Some community GGUFs omit deepseek4.vocab_size. When the key is
missing, derive vocab size from the length of tokenizer.ggml.tokens
instead of failing the load.
Community GGUFs carry dense deepseek4 tensors as BF16 or Q6_K, types
the runtime kernels do not accept for the dense path. Add a load-time
conversion to F16, growing the mmap allocation as needed, and add the
BF16 tensor type to the type table.
…ed tensors

Extend the load-time dense conversion to F32 inputs and fix the
cuda_model_range bookkeeping so SSD streaming addresses converted
tensors at their post-conversion size and offset.
dequantize_row_q6_K wrote every block of a multi-block row to the
first 256 output slots, so only the last block survived. The original
routed-expert caller always passed a single block and never saw this,
but the load-time dense conversion dequantizes whole tensors and lost
all but the final block, zeroing most of the attention LoRA weights.
Apply the per-block output offset.

The decode-graph type guard this fix originally shipped with is
already present on this branch, so only the dequantizer fix is
carried here.
test22345 and others added 2 commits August 3, 2026 00:56
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@nexus-cw

nexus-cw commented Aug 3, 2026

Copy link
Copy Markdown
Author

Added two README lines to the Community GGUF dialects subsection covering this PR: dense BF16/F32/Q6_K tensors are accepted and converted to F16 at load time. Docs only, no code change (the subsection itself flows in from #662, on which this PR is stacked).

🤖 Generated with Claude Code

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