Repository navigation
Enable CUDA graphs on Volta+Turing - #25749
Conversation
JohannesGaessler
left a comment
There was a problem hiding this comment.
The reason CUDA graphs were disabled for architectures older than Ampere was that at the time the decision was made the ggml-side logic surrounding them was a lot more primitive. So especially on older GPUs enabling them was actually detrimental. Since then simply no one has re-checked the performance difference for older hardware. So, thank you for doing that.
Appreciate the explanation, and glad this could get this merged so quickly, thanks |
|
I’m suddenly getting CUDA OOM errors after rebuilding with this. Not sure if it’s from another recent change but should this be using more VRAM (I’m very tight)? |
|
@roger- Try with GGML_CUDA_DISABLE_GRAPHS=1 env var, I think that should force disable cuda graphs which should make it behave the same as pre-PR (assuming you are on Volta/Turing) |
Roughly 128 byte / node in the graph / graph. For 1.5k node graph like qwen3.6, that's 180 kB per graph. |
|
@heislera763 There is another report that the change causes issues on Volta: #26119 (comment) |
|
@ggerganov I'll see if I can reproduce what they see. Anecdotally, I haven't seen this crash or any stability issues since merging, but I also don't use mmproj |
…v100 Ports only the CUDA/Volta-specific changes of the llamacpp-v100 fork (C:/Users/confu/llama/llamacpp-v100 @ 15e91bbbb, merge-base 6d5a910) on top of the existing turboquant + adaptive-KV-streaming integration. The fork's remaining features (SSD streaming, RPC 4.2/distributed, the ggml-backend-meta tensor-split rewrite, the fleet web UI and the backend-agnostic perf work) are deliberately NOT ported. Taken: - One-shot P2P NVLink AllReduce for 2-GPU tensor mode (allreduce.cu/.cuh verbatim from the fork; allreduce was untouched by both upstream since the merge base and by the integration branch, so the patch applies without adaptation). Wired into upstream's existing AllReduce chain as a fourth variant: GGML_CUDA_ALLREDUCE=p2p -> comm_init_p2p(), chained on top of nccl/internal via a new `fallback_allreduce` so large (bandwidth-bound) and unsupported reductions still go to NCCL/internal. Cap: GGML_CUDA_AR_P2P_MAX_BYTES (default 4 MiB). - MMVQ sm70 parameter table (mmvq.cu). Upstream refactored calc_nwarps() since the merge base (+307/-45: added small_k/halve_iters, renamed the parameter, added MMVQ_PARAMETERS_GB10), so the fork's hunk could not be applied verbatim and was rewritten into the current scheme: new MMVQ_PARAMETERS_VOLTA enum value, the __CUDA_ARCH__ >= VOLTA && < TURING and host-side highest_compiled_arch branches, the batch-1 K-quant nwarps=2 case, and the calc_rows_per_block() guard (GB10 included, which the fork's base did not have yet). Fork measurement: +1.8% tg on Qwen 27B Q4_K, perplexity-identical. Deliberately excluded (reviewed hunk by hunk): - FA MMA shared-memory-failure fallback (fattn*.cuh/.cu, vendors/hip.h). Does not affect V100: the fork measured baseline / GGML_CUDA_FA_NO_MMA / injected failure as identical output at identical speed (~260 t/s) on V100, i.e. the fallback never fires there. Its target device is GTX 16xx (TU116/117, cc 7.5 without tensor cores). Its one genuinely V100-touching sub-fix (wmma returning true for NVIDIA Volta -> NO_DEVICE_CODE) existed only because that feature introduced the MMA-disable knob, and upstream has since deleted fattn-wmma-f16.cuh entirely. Upstream has no such fix; upstream discussion ggml-org#5329 holds that tensor-core availability is not queryable via the CUDA API. - CUDA-graph arch-gate removal in ggml-cuda.cu. The deleted assignment lives in the `cc < GGML_CUDA_CC_VOLTA` branch, which V100 (cc 7.0) never enters, so it has zero effect on V100; its actual effect is to enable CUDA graphs below Volta. Upstream deliberately set that boundary in PR ggml-org#25749 ("Enable CUDA graphs on volta+turing", 2026-07-16), which moved the threshold from AMPERE down to VOLTA and kept everything below off. The fork documents a GGML_CUDA_FORCE_GRAPHS knob for this that was never implemented anywhere in its source tree, and records "no gain". - CUDA worker error containment (GGML_CUDA_ERROR_CONTAIN) and compute-fault injection (GGML_CUDA_INJECT_COMPUTE_FAIL): both serve the excluded RPC worker path. - SSD GPU-landing offload hook (ggml_ssd_stream_*): excluded SSD streaming. Included-with-delta: the two comments in ggml_backend_cuda_comm_context and above ggml_backend_cuda_comm_init() were updated to mention the new fourth path, since we are changing exactly the mechanism they describe. Verified by set difference against the fork's own diff (normalised added lines): mmvq.cu 31 vs 31 with the single explainable guard-line delta; ggml-cuda.cu's residuals are exactly the three excluded features plus the comment updates. Allreduce files are byte-identical to the fork's.
Overview
This PR expands the check for whether or not CUDA graphs are enabled so that it includes Volta and Turing archs.
I haven't been able to find a reason for this to not be enabled, there's no perplexity difference and performance seems equal or better across the board (mostly the same in -sm layer case, with some major gains in -sm tensor).
Outputs are coherent but I haven't tested any conversations past a few turns. I also have not tested Turing as I don't have access to any hardware, but I would presume that if it works good on Volta it will probably be fine on Turing as well?
Additional information
For context I'm running Debian 13 on a dual socket E5-2696 v4 system, 8 x V100 32GB cards with 8x Gen3 PCIE each (4 cards per NUMA node), nvidia driver 580.105.08, and llama.cpp built w/ CUDA 12.9
I did some llama-perplexity runs on wikitext-2 and for performance I ran llama-bench on a bunch of currently popular models using -sm layer, as well as -sm tensor when possible:
Master Performance
Master Perplexity
PR Performance
PR Perplexity
The -sm layer tests seem to have had a few decent improvements, but mostly insignificant up/down fluctuations, while the -sm tensor cases definitely had the more interesting highlights. Most notable for me would probably be qwen3.6 27b going from 20tps to 41tps, and gemma 4 31b going from 24tps to 36tps. qwen3.5 122b is also an interesting case with a huge jump from 17tps to 58tps, but the pp is still quite bad with tensor split on this model.
As an aside, I seem to remember getting better -sm tensor performance before I upgraded from 6 to 8 GPUs, I would guess because that forced me to bifurcate two of my 16x lanes into 8x ones? Unsure if this is at all relevant to this PR but I thought it was at least worth mentioning in case these numbers look off from other V100 + sm tensor test results that may be out there.
Requirements