Skip to content

cuda: decline unsupported indexer top_k cache types in supports_op#2118

Closed
joelfarthing wants to merge 1 commit into
ikawrakow:mainfrom
joelfarthing:filament/indexer-topk-supports-op
Closed

cuda: decline unsupported indexer top_k cache types in supports_op#2118
joelfarthing wants to merge 1 commit into
ikawrakow:mainfrom
joelfarthing:filament/indexer-topk-supports-op

Conversation

@joelfarthing

Copy link
Copy Markdown
Contributor

-fidx -ictk f32 on a CUDA build aborts at eval: the indexer top_k kernel asserts k->type == F16 || ggml_is_quantized(k->type) (indexer_topk.cu:72) while supports_op returns true unconditionally, so the scheduler keeps the op on CUDA. Because the op only engages once n_kv exceeds top_k, the server loads clean and serves short requests, then aborts on the first one past 2048 tokens. On main at 8e2d83cfe:

./llama-server -m openPangu-2.0-Flash-Q4_K_M.gguf -c 8192 -fa off -ngl 999 -ot exps=CPU -ctk q8_0 -fidx -ictk f32
# first request > 2048 tokens:
ggml/src/ggml-cuda/indexer_topk.cu:72: GGML_ASSERT(k->type == GGML_TYPE_F16 || ggml_is_quantized(k->type)) failed

This patch makes supports_op mirror what the kernel can execute: f16 k (the cuBLAS path), or quantized k that has an MMQ kernel for the type on the device (ggml_cuda_should_use_mmq), plus the operand types the kernel asserts. Everything else falls back through the scheduler to the CPU op, which handles all four openPangu -ictk types on AVX2 and ARM-dotprod builds (its existing platform contract from #2111). Checking ggml_is_quantized alone would over-accept: quantized types with no MMQ case would still hit the dispatch abort, and the GLM -ictk path does not restrict cache types.

With the fix, the same f32 configuration answers a 6.5K-token needle correctly with every INDEXER_TOPK node on CPU (GGML_SCHED_DEBUG); -ictk q8_0 and the default f16 keep their main placement (identical scheduler split before and after the fix). bf16, which the kernel also cannot execute, did not abort on main because the scheduler happened to route it to CPU already; it now lands there by explicit decline, with the same needle result.

@ikawrakow

Copy link
Copy Markdown
Owner

I was actually thinking to remove the -ictk option. As some experiments have shown, quantizing the indexer cache can be futile. Using f32 is overkill. Hence, just leave it at f16.

@joelfarthing

Copy link
Copy Markdown
Contributor Author

I was actually thinking to remove the -ictk option. As some experiments have shown, quantizing the indexer cache can be futile. Using f32 is overkill. Hence, just leave it at f16.

Even better. I'll close this one out.

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