Commit a0c91e8
Improve CUDA graph capture (ggml-org#19754)
* Improve CUDA graph capture
Currently, CUDA graphs are eagerly enabled on the first call to ggml_backend_cuda_graph_compute. If the graph properties keep changing (4+ consecutive updates), the graph is permanently disabled. This is suboptimal because:
- The first call always incurs CUDA graph capture overhead even if the graph is unstable
- Once permanently disabled, CUDA graphs never re-enable even after the graph stabilizes (e.g., switching from prompt processing to decode)
The new approach delays CUDA graph activation until warmup completes: the same cgraph must be called at least twice with matching properties before CUDA graph capture begins. This avoids wasted capture overhead on volatile graphs and allows graphs to become eligible once they stabilize.
This also fixes issues such as ggml-org#19708
* Update ggml/src/ggml-cuda/ggml-cuda.cu
Co-authored-by: Johannes Gäßler <johannesg@5d6.de>
* Remove EM dashes
* Update ggml/src/ggml-cuda/ggml-cuda.cu
Co-authored-by: Aman Gupta <amangupta052@gmail.com>
---------
Co-authored-by: Johannes Gäßler <johannesg@5d6.de>
Co-authored-by: Aman Gupta <amangupta052@gmail.com>1 parent 07968d5 commit a0c91e8
2 files changed
+28
-24
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1149 | 1149 | | |
1150 | 1150 | | |
1151 | 1151 | | |
1152 | | - | |
1153 | | - | |
| 1152 | + | |
1154 | 1153 | | |
1155 | 1154 | | |
1156 | 1155 | | |
| |||
1159 | 1158 | | |
1160 | 1159 | | |
1161 | 1160 | | |
1162 | | - | |
1163 | | - | |
1164 | | - | |
1165 | | - | |
1166 | | - | |
1167 | | - | |
1168 | | - | |
1169 | | - | |
1170 | | - | |
1171 | | - | |
1172 | | - | |
1173 | | - | |
1174 | 1161 | | |
1175 | 1162 | | |
1176 | | - | |
| 1163 | + | |
1177 | 1164 | | |
1178 | 1165 | | |
1179 | 1166 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2979 | 2979 | | |
2980 | 2980 | | |
2981 | 2981 | | |
2982 | | - | |
2983 | | - | |
2984 | | - | |
2985 | | - | |
2986 | 2982 | | |
2987 | 2983 | | |
2988 | 2984 | | |
| |||
3931 | 3927 | | |
3932 | 3928 | | |
3933 | 3929 | | |
3934 | | - | |
| 3930 | + | |
3935 | 3931 | | |
3936 | 3932 | | |
3937 | 3933 | | |
3938 | | - | |
3939 | | - | |
3940 | | - | |
3941 | | - | |
| 3934 | + | |
| 3935 | + | |
| 3936 | + | |
| 3937 | + | |
| 3938 | + | |
| 3939 | + | |
| 3940 | + | |
| 3941 | + | |
| 3942 | + | |
| 3943 | + | |
| 3944 | + | |
| 3945 | + | |
| 3946 | + | |
| 3947 | + | |
| 3948 | + | |
| 3949 | + | |
| 3950 | + | |
| 3951 | + | |
| 3952 | + | |
| 3953 | + | |
| 3954 | + | |
| 3955 | + | |
| 3956 | + | |
| 3957 | + | |
| 3958 | + | |
3942 | 3959 | | |
3943 | 3960 | | |
3944 | 3961 | | |
| |||
0 commit comments