Skip to content

fix(CI-MAIN-CTEST-RESIDUE): deepseek-v4 keep-quant slices consume repacked stacked-expert weights - #3610

Open
lu-zero wants to merge 1 commit into
localai-org:mainfrom
lu-zero:row/CI-MAIN-CTEST-RESIDUE-deepseek-repack-slice
Open

lu-zero wants to merge 1 commit into
localai-org:mainfrom
lu-zero:row/CI-MAIN-CTEST-RESIDUE-deepseek-repack-slice

Conversation

@lu-zero

@lu-zero lu-zero commented Dec 5, 2026

Copy link
Copy Markdown
Collaborator

fix(CI-MAIN-CTEST-RESIDUE): deepseek-v4 keep-quant slices consume repacked stacked-expert weights

On i8mm aarch64 hosts the auto repack lever packs deepseek-v4's
stacked-expert Q8_0 weights at load, and the keep-quant expert/group
slice GEMM refused them (deepseek_v4.cpp:631) - breaking
deepseek-v4 k-quant on every i8mm ARM box and failing
test_deepseek_v4_gguf_load + test_deepseek_v4_mm_reach on the
scheduled arm64-full lane since Nov 22. Two defects, both fixed:

  1. GemmRowSlice now accepts repacked weights for group-aligned
    slices (row_off/N multiples of the 4-row block_q8_0x4 interleave -
    size-neutral, byte offset unchanged), carries wt.repacked, and still
    refuses group-crossing slices and device queues loudly.
  2. OwnedTensor::View() was dropping the layout markers, so the
    full-tensor GEMMs decoded interleaved bytes as plain q8_0 (all-NaN
    logits once the refusal was unblocked). They now carry
    repacked/q8_0_aligned back, matching qwen3_5.cpp's tower handling.

Reproduced locally on this i8mm aarch64 host before any fix (the CI
failure verbatim; mm_reach 8/20 cases failing); after the fix both
tests run 100% with the repack lever ON (default) and with
VT_CPU_QUANT_REPACK=0. New hermetic case enters at
ModelRegistry::Forward (finite, deterministic logits over repacked
bytes); two mutations (marker-carry deleted; wt.repacked stripped)
each red the new tests. Repacked weights never exist on a device
queue, so device arms are untouched. Slice widths must be multiples
of 4 (true for every real DeepSeek-V4 shape); violations throw with
a message naming the constraint.

Closes ISSUE-LOCAL-01M93Y397CF1KRTRW8SFCNAMF1

FOLLOWING_AGENTS_PROTOCOL

Following-Agents-Protocol: true
AI-Assisted: true
Assisted-by: AGENT:zai/glm-5.3-flash [maki]

… i8mm arm64

The arm64-full CI has red test_deepseek_v4_gguf_load and eight
test_deepseek_v4_mm_reach sub-cases since Nov 22: on an i8mm host the auto
repack lever (QuantRepackActive() default auto) interleaves the
stacked-expert Q8_0 weights into block_q8_0x4 at load, and GemmRowSlice
refused them outright. The refusal also masked a silent second defect: the
forward's full-tensor GEMMs consume weights through OwnedTensor::View(),
whose ViewOn deliberately drops the LAYOUT markers, so a repacked weight
decodes as plain q8_0 and yields NaN logits with no refusal (the localai-org#2031
failure mode).

Option (a), the real fix; no option-(b) disable gate is needed:

- GemmRowSlice accepts a repacked stacked weight when the slice is
  GROUP-ALIGNED (row_off and N multiples of kQ8_0xNrowsInterleaved = 4).
  The interleave is size-neutral (block_q8_0x4 == 4 * block_q8_0), so a
  group-aligned slice maps to the same byte offset and stays a valid
  QuantRepackMatmul operand; the slice carries wt.repacked. Group-crossing
  slices and device queues are refused loudly. The tiny test geometry
  (mi = olr = 32) and the real arch are always group-aligned.
- GemmGroupedExpertsKq accepts repacked with N % 4 == 0; the CPU grouped
  provider already carries repacked onto its per-expert slices.
- Gemm, GemmGroupedExpertsKq and GemmIntoKq carry repacked/q8_0_aligned
  back onto the View() operand, exactly as qwen3_5.cpp does for its tower.
  A repacked weight never exists on a device queue
  (QuantRepackForDevice), so the device arms are unaffected.

Local i8mm aarch64 host reproduced the CI failure verbatim before the fix.
After: both CI tests 100% with the lever ON (default) and with
VT_CPU_QUANT_REPACK=0; test_deepseek_v4_forward/scaffold/moe and
test_ops_quant_dot pass. Two mutations (delete the Gemm marker carry;
strip wt.repacked in GemmRowSlice) each red the suite and were restored
byte-for-byte. New hermetic case "CIQ G7: the repacked stacked-expert
weights serve the forward (arm64 i8mm)" enters at ModelRegistry::Forward
and reds under both mutants.

Fixes ISSUE-LOCAL-01M93Y397CF1KRTRW8SFCNAMF1 (row CI-MAIN-CTEST-RESIDUE).

FOLLOWING_AGENTS_PROTOCOL

Following-Agents-Protocol: true
AI-Assisted: true
Assisted-by: AGENT:zai/glm-5.3-flash [task]

This branch has not been deployed

No deployments
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.

1 participant