Skip to content

Commit 5ec8dd5

Browse files
robyngrafggerganov
andauthored
#1869 Fix null reference errors when training from scratch with CUDA (#1907)
* #1869 Fix null reference errors when training from scratch with CUDA build Calling ggml_compute_forward when node->src0 was null was causing train-text-from-scratch.exe to terminate unexpectedly. * ggml : do not dereference src0 if NULL --------- Co-authored-by: Georgi Gerganov <[email protected]>
1 parent 65bdd52 commit 5ec8dd5

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

ggml-cuda.cu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2635,7 +2635,7 @@ void ggml_cuda_free_scratch() {
26352635
bool ggml_cuda_compute_forward(struct ggml_compute_params * params, struct ggml_tensor * tensor){
26362636
ggml_cuda_func_t func;
26372637
const bool any_on_device = tensor->backend == GGML_BACKEND_GPU
2638-
|| tensor->src0->backend == GGML_BACKEND_GPU || tensor->src0->backend == GGML_BACKEND_GPU_SPLIT
2638+
|| (tensor->src0 != nullptr && (tensor->src0->backend == GGML_BACKEND_GPU || tensor->src0->backend == GGML_BACKEND_GPU_SPLIT))
26392639
|| (tensor->src1 != nullptr && tensor->src1->backend == GGML_BACKEND_GPU);
26402640

26412641
switch (tensor->op) {

ggml.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14911,7 +14911,7 @@ static void ggml_compute_forward(struct ggml_compute_params * params, struct ggm
1491114911
if (skip_cpu) {
1491214912
return;
1491314913
}
14914-
GGML_ASSERT(tensor->src0->backend == GGML_BACKEND_CPU);
14914+
GGML_ASSERT(tensor->src0 == NULL || tensor->src0->backend == GGML_BACKEND_CPU);
1491514915
GGML_ASSERT(tensor->src1 == NULL || tensor->src1->backend == GGML_BACKEND_CPU);
1491614916
#endif // GGML_USE_CUBLAS
1491714917

0 commit comments

Comments
 (0)