Repository navigation
model : DeepSeek-V4.1-Flash-1017 pin on upstream deepseek41 (MXFP8 Engram + extras) - #332
danielhanchen wants to merge 22 commits into
Conversation
Three sub-IQ1_S data types: IQ1_S's algorithm with the codebook the mapping step may choose from cut to a subset of iq1s_grid, and the index stored in fewer bits. IQ1_XS id 64 46 B / 256 1024-entry grid 10-bit index 1.4375 bpw IQ1_XXS id 65 42 B / 256 512-entry grid 9-bit index 1.3125 bpw IQ1_XXXS id 66 38 B / 256 256-entry grid 8-bit index 1.1875 bpw Dequantization is IQ1_S's rule throughout, y[j] = d*(2*ls + 1)*(grid[idx][j] + delta). GGML_TYPE_COUNT is 67; 42..63 are left for upstream, which already uses 42 for Q2_0, so a stock build rejects these files rather than misreading them. CPU, CUDA dequant, MMVQ and MMQ. The MMQ path targets the current ggml_cuda_mmq_util_funcs / ggml_cuda_mmq_config API and registers the types in every per-architecture config table; Blackwell falls through to Ampere and needs none. scripts/iqxs_gen_tables.py regenerates all six codebook tables in ggml-common.h byte-identically from the three committed .npy grids, so the tables are reproducible rather than pasted. Tested on B200, CUDA 13, sm_100. test-backend-ops -o MUL_MAT passes 2/2 backends both default and with GGML_CUDA_FORCE_MMQ=1, 11 cases per type matching IQ1_S. Note the default run never enters the new MMQ kernels, since small n routes to MMVQ.
# Conflicts: # ggml/src/ggml-common.h
# Conflicts: # ggml/src/ggml-cuda/mmq.cuh
ggml-org#30168 made the src1 precision an explicit template argument of mul_mat_q_case and removed its default.
…onverters Mirror the IQ1_S CASE rows (same QK_K block, QR 8, Q8_0 SRAM layout) for IQ1_XS, IQ1_XXS and IQ1_XXXS in mmq-config-gcn.cuh and mmq-config-pascal-older.cuh, so MMQ selection on those arches no longer finds zero configs and trips GGML_ASSERT(J_best > 0). Add the three dequantizers to ggml_get_to_bf16_cuda to match the FP16/FP32 tables (cuBLAS BF16 compute path for quantized src0). Map the three types in the loader's guessed-ftype switch.
…am deepseek41 Upstream deepseek41 (ggml-org ggml-org#31086 and ggml-org#31137) now carries the model, so this keeps only what it does not have: - ggml : MXFP8 (E4M3 + E8M0 scale) block type 43, gather-only (CPU and CUDA GET_ROWS, gguf-py constants and (de)quantize), used by the Engram table of the published UD-Q3_K_XL / UD-Q4_K_XL / UD-Q8_K_XL GGUFs; converter writes the Engram tables bit-exact as MXFP8 (DSV41_ENGRAM_TYPE=bf16 for BF16) - Engram table always in host memory; token and Engram rows gathered in set_input (LLAMA_DSV41_HOST_GATHER=0 for the in-graph CPU GET_ROWS) - output projection through build_lora_mm (output LoRA) - ggml-cpu AMX: 2D weights only, batched src1 folded into M - chat: V4.1 chat template file, namespaced tool names in DSML parsing - fit: draft measured with its backend samplers; llama_sched_reserve - mtmd: deepseek41v placeholder entries skip the bf16 rounding - tests: MXFP8 GET_ROWS, softplus range, V4.1 template cases
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 80f0f5a8e4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| llama_model_params * mparams; | ||
| llama_context_params * cparams; | ||
| bool shares_model; | ||
| bool backend_sampling = true; // the speculative decoder offloads draft sampling to the backend (its default) |
There was a problem hiding this comment.
Propagate the draft backend-sampling setting into fitting
For DFlash/DSpark runs with params.speculative.draft.backend_sampling set to false, the sole common_fit_extra_model initializer in common/common.cpp still supplies only the original four fields, leaving this field true. Consequently, common_fit_draft_target installs top-k samplers during measurement even though common_speculative_impl_draft_dflash skips them at runtime. Fitting therefore budgets for a different compute graph and can unnecessarily reduce context size or GPU offload under a tight memory budget. Pass the configured draft backend-sampling value into the extra initializer instead of always using this default.
Useful? React with 👍 / 👎.
| } break; | ||
| case GGML_TYPE_MXFP8: | ||
| { | ||
| VALIDATE_ROW_DATA_E_E8M0_IMPL(block_mxfp8, data, nb); |
There was a problem hiding this comment.
Reject NaN E4M3 payloads when validating MXFP8 blocks
When an MXFP8 tensor contains an E4M3 NaN code (0x7F or 0xFF) with a valid scale, this macro checks only the scale and incorrectly accepts the block. I reproduced this with a 33-byte block containing scale 127: ggml_validate_row_data returns true for both NaN codes, while dequantize_row_mxfp8 produces NaNs. Consequently, enabling check_tensors does not reject a corrupted Engram table, and gathering an affected row can propagate NaNs through inference. Validate the payload codes as well as the scale, matching the checks already present in the new conversion path.
Useful? React with 👍 / 👎.
…hen the size cannot tell - spans come from the sorted data offsets (file end for the last tensor), not the next header entry - a span that fits both types (small tensors at an alignment above 32) is decided by the rest of the file: another type-43 tensor that fits only one type, a type-63 tensor or general.file_type MOSTLY_F8_E4M3; with nothing to go on the file is refused instead of read as F8_E4M3 - gguf-py: general.alignment is a numpy uint32, use a Python int for the padding arithmetic (NumPy 2 raised OverflowError on any file with explicit alignment)
pr-set : repin unslothai#332 for b12228
pr-set : repin unslothai#251 and unslothai#332 for b12233 (ggml-org#31185)
Leaves the upstream LLM_ARCH_DEEPSEEK41 condition line untouched, so this pin no longer conflicts with architectures upstream adds to that same line (Inkling 2, ggml-org#32217). Same arithmetic for both arches.
…-b12347 pr-set : move to b12347 (repin ggml-org#32187 to 69437b7 with the Inkling 2 KV gather fix, unslothai#332 to 24a4976)
|
As of today (2026-11-22), his PR applied to the HEAD of unslothai/llama.cpp fails to build on the UI. One workaround seems to be: replace llama.cpp/ui with ggml-org/llama.cpp/ui and llama.cpp/scripts/ui-assets.cmake with ggml-org/llama.cpp/scripts/ui-assets.cmake. |
|
Repinned to Upstream ggml-org#15550 (b12669, automatic quant type choice for a size target) rewrote the type fallback table in The merge point is the oldest tag that has the break (b12669), not master. Against b12669 the pin's own diff is line for line the same as before: 63 files changed, 3476 insertions(+), 48 deletions(-). It also merges cleanly with b12679 (ggml-org#32902, which touches the same file). The PR base moves to The pin set with this commit merges, passes the contract and merge checks on b12670 and b12671, and passes |
Pin for DeepSeek-V4.1-Flash-1017 now that upstream carries the model: upstream
deepseek41(ggml-org#31086 and the follow-up ggml-org#31137) is kept verbatim, and this pin adds only what upstream does not have. It replaces the full-stack pin #298, which no longer merges once the base contains ggml-org#31137 (conflicts insrc/llama-kv-cache-dsv4.cpp,src/llama-model-saver.cpp,src/models/deepseek41.cpp,src/models/models.h).Base is
base/upstream-ee17f293b, upstream b12065, which is this pin's upstream merge base, so the diff is everything this pin adds over upstream. That includes #61's IQ1_XS..IQ1_XXXS types (43 of the 63 files, about 2400 of the lines): #61 adds fork-local types 64..66 and this pin adds MXFP8, both on theGGML_TYPE_COUNTline, so this pin is built on #61's pinned commit (722adcd) and carries the combined enum (MXFP8 = 43,IQ1_XS..IQ1_XXXS = 64..66,GGML_TYPE_COUNT = 67). It sits after #61 inpr-set.json, as #298 did, so the nightly merges #61 first and those lines are already in the tree when this pin is merged. Earlier bases weredsv41-pin-base61bto61e(#61's commit plus an upstream tag); those showed upstream changes as part of this PR once the pin itself merged a newer tag.Why MXFP8 is still needed
Upstream has no MXFP8 type (
GGML_TYPE_COUNT = 43), and a stock build rejects these files withtensor 'per_layer_token_embd.weight' has invalid ggml type 43. A header scan of every GGUF inunsloth/DeepSeek-V4.1-Flash-1017-GGUFfinds type 43 in exactly one tensor, the Engram tableper_layer_token_embd.weight, in:engram/DeepSeek-V4.1-Flash-1017-engram-MXFP8.gguf_fileUD-IQ1_S, UD-IQ1_M, UD-IQ2_XXS, UD-IQ3_XXS, UD-IQ3_S, UD-Q2_K_XL, the DSpark drafts, the mmproj files and the IQ4_NL / Q5_K / Q6_K swap-in Engram files have no type 43 and already load on upstream. MXFP8 stays at 43 because that is what the published files store.
What this pin keeps
GET_ROWS, gguf-py constants and (de)quantizeDSV41_ENGRAM_TYPE=bf16for BF16); the V4.1 chat template file is embeddedset_input(LLAMA_DSV41_HOST_GATHER=0restores the in-graph CPUGET_ROWS); output projection throughbuild_lora_mm-ngl/-ot; output LoRAns::f) in V4.1 DSML parsing; the shipped template plus tests next to the upstream onesllama_sched_reserveGET_ROWScases, softplus rangeEverything else from #298 is dropped in favour of the upstream code: Engram hash constants stay in
hparams.ple_*, the deterministic sort of the gathered top-k rows stays, and the per-device compressed-KV mirrors use upstream'scomp_read(theLLAMA_DSV41_KV_MIRRORknob is gone).Evidence
Simulated nightly merge (
pr-set.jsonwith #298 replaced by this head, all other pins unchanged):Pins refused in the same simulation for unrelated upstream changes: ggml-org#24423 and ggml-org#25731 (
src/llama-model-saver.cpp, upstream ggml-org#30880), #241 (src/llama-memory-hybrid-idx.cpp, upstream ggml-org#31141), and from b11930 #251 (common/common.cpp,common/fit.cpp, upstream ggml-org#21231). This pin does not touch them.Merged tree (all pins minus the refused ones above), CUDA sm_100 on B200:
Pin branch alone, CPU:
test-chatall passed,test-llama-archs142/142,test-backend-ops -o GET_ROWSincluding 9 MXFP8 cases.Tiny DeepSeek-V4.1 fixture (real dimensions, few layers, random weights),
llama-perplexity -c 128 --chunks 20scored against the current #298 build:Real models,
llama-perplexityon wikitext-2-c 512 --chunks 20, all GPU layers, scored with--kl-divergenceagainst the current #298 build (A); A again gives the run-to-run floor:invalid ggml type 43)Not covered here: ROCm, Vulkan, macOS, Windows and ARM legs (nightly only).