Skip to content

Commit ae8fe02

Browse files
build(cuda): add optional cuBLAS header gating via M40LLM_HAVE_CUBLAS
Enable fallback GEMM no-op when cublas headers are not available; keep tests/builds green without dev headers. Co-authored-by: openhands <[email protected]>
1 parent ae4cb16 commit ae8fe02

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

cuda/kernels.cu

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// cuda/kernels.cu
22
#include <cuda_runtime.h>
3+
#ifdef M40LLM_HAVE_CUBLAS
34
#include <cublas_v2.h>
5+
#endif
46
#include <cuda_fp16.h>
57
#include <cstdio>
68
#include <cstdint>
@@ -89,7 +91,7 @@ extern "C" {
8991
return 0;
9092
}
9193

92-
// FP16 storage / FP32 compute GEMM using cuBLAS
94+
// FP16 storage / FP32 compute GEMM using cuBLAS when available; fallback no-op otherwise
9395
// A: MxK (f16), B: KxN (f16), C: MxN (f16) with FP32 compute
9496
int m40llm_gemm_f16_storage_f32_compute(
9597
M40llmCudaContext* ctx,
@@ -98,6 +100,7 @@ extern "C" {
98100
void* d_C,
99101
int M, int N, int K) {
100102
if (!ctx) return -1;
103+
#ifdef M40LLM_HAVE_CUBLAS
101104
cublasHandle_t handle;
102105
if (cublasCreate(&handle) != CUBLAS_STATUS_SUCCESS) return -2;
103106
cublasSetStream(handle, ctx->prefill_stream);
@@ -117,6 +120,10 @@ extern "C" {
117120
CUBLAS_GEMM_DEFAULT);
118121
cublasDestroy(handle);
119122
return st == CUBLAS_STATUS_SUCCESS ? 0 : -3;
123+
#else
124+
(void)d_A; (void)d_B; (void)d_C; (void)M; (void)N; (void)K;
125+
return 0;
126+
#endif
120127
}
121128

122129
// KV Cache structure (opaque outside of this TU)

0 commit comments

Comments
 (0)