fix: two x86_64 Linux inference crashes (sched_reserve assert + CUDA concat dispatch)#7
Open
randomsamples wants to merge 2 commits into
Open
Conversation
Patch 1 (src/llama-context.cpp): when n_ctx <= n_batch, sched_reserve() set reserve_pos0 = n_tokens, placing the dry-run batch outside the KV cache window. This caused: GGML_ASSERT(n_comp_visible <= n_comp_cache) failed common_params_fit_impl() probes n_ctx=n_batch first, so this fires on every Linux run. Fix: use 0 as fallback (prefill-from-zero is the only valid graph shape when n_ctx == n_batch). Patch 2 (ggml/src/ggml-cuda/ggml-cuda.cu): supports_op() reported GGML_OP_CONCAT as OK for any non-I32/I16 type, but the kernel asserts src0->type == F32. DeepSeek V4 attention state tensors are non-F32, so the scheduler dispatched them to CUDA and the kernel aborted with: GGML_ASSERT(src0->type == GGML_TYPE_F32) failed Fix: restrict supports_op for CONCAT to F32 only, matching the kernel. Verified on Ubuntu 24.04 x86_64, CUDA 12.1, RTX 3090 with DeepSeek-V4-Flash-IQ2XXS GGUF. Both bugs reproduced 100% before fix.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two one-line fixes that make the server actually run on x86_64 Linux. Before these patches the server aborts on every run — the model was completely unusable on Linux.
Tested on: Ubuntu 24.04, x86_64, GCC 13.3, CUDA 12.1, RTX 3090,
DeepSeek-V4-Flash-IQ2XXS-w2Q2K-AProjQ8-SExpQ8-OutQ8-chat-v2.gguf.Bug 1 —
sched_reserveassert whenn_ctx <= n_batchFile:
src/llama-context.cppsched_reserve()picks a synthetic start positionreserve_pos0to size the "resumed decode" graph. Whenn_ctx <= n_tokensthe fallback wasn_tokens, placing the dry-run batch at positions[n_tokens .. 2*n_tokens-1]— entirely outside the KV cache[0 .. n_ctx-1].Inside
llm_build_deepseek4the decode path then computedn_comp_visible = 2*n_ctx/ratiovsn_comp_cache = n_ctx/ratio, triggering:common_params_fit_impl()probesn_ctx = n_batchas its first candidate, so this assertion fires unconditionally before inference ever starts.Fix: use
0as the fallback. Whenn_ctx == n_batcha "resumed" full-batch decode is impossible anyway — prefill-from-zero is the only valid graph shape.Bug 2 — CUDA
GGML_OP_CONCATdispatch mismatchFile:
ggml/src/ggml-cuda/ggml-cuda.cuggml_backend_cuda_device_supports_op()returnedtrueforGGML_OP_CONCATwith any type except I32/I16. Butggml_cuda_op_concat()assertssrc0->type == GGML_TYPE_F32. DeepSeek V4 attention state tensors are non-F32, so the backend scheduler dispatched them to CUDA and the kernel aborted on the first decode step:Fix: restrict
supports_opforGGML_OP_CONCATtoF32only, matching what the kernel actually implements.