MCPcopy Create free account
hub / github.com/NVIDIA/FasterTransformer / init_cublas_ctx

Function init_cublas_ctx

examples/cpp/multi_gpu_gpt/gpt_example_utils.cc:281–326  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

279 ftNcclInitialize(tensor_para, pipeline_para, model_config.tensor_para_size, model_config.pipeline_para_size);
280}
281cublasMMWrapper init_cublas_ctx(DataType data_type,
282 cudaStream_t& stream,
283 Allocator<AllocatorType::CUDA>& allocator,
284 cublasHandle_t& cublas_handle,
285 std::mutex& cublas_wrapper_mutex,
286 cublasLtHandle_t& cublaslt_handle,
287 cublasAlgoMap& cublas_algo_map
288#ifdef SPARSITY_ENABLED
289 ,
290 cusparseLtHandle_t& cusparselt_handle
291#endif
292)
293{
294 cudaStreamCreate(&stream);
295 cublasCreate(&cublas_handle);
296 cublasLtCreate(&cublaslt_handle);
297 cublasSetStream(cublas_handle, stream);
298#ifdef SPARSITY_ENABLED
299 CHECK_CUSPARSE(cusparseLtInit(&cusparselt_handle));
300 cublas_algo_map = cublasAlgoMap(GEMM_CONFIG, SPGEMM_CONFIG);
301#else
302 cublas_algo_map = cublasAlgoMap(GEMM_CONFIG);
303#endif
304
305#ifdef SPARSITY_ENABLED
306 cublasMMWrapper cublas_wrapper = cublasMMWrapper(
307 cublas_handle, cublaslt_handle, cusparselt_handle, stream, &cublas_algo_map, &cublas_wrapper_mutex, &allocator);
308#else
309 cublasMMWrapper cublas_wrapper =
310 cublasMMWrapper(cublas_handle, cublaslt_handle, stream, &cublas_algo_map, &cublas_wrapper_mutex, &allocator);
311#endif
312
313 if (data_type == DataType::TYPE_FP16) {
314 cublas_wrapper.setGemmConfig(CUDA_R_16F, CUDA_R_16F, CUDA_R_16F, CUDA_R_32F);
315 }
316#ifdef ENABLE_BF16
317 else if (data_type == DataType::TYPE_BF16) {
318 cublas_wrapper.setBF16GemmConfig();
319 }
320#endif
321 else if (data_type == DataType::TYPE_FP32) {
322 cublas_wrapper.setFP32GemmConfig();
323 }
324
325 return cublas_wrapper;
326}
327
328void populate_request(std::unordered_map<std::string, Tensor>& input_tensors,
329 std::unordered_map<std::string, Tensor>& output_tensors,

Callers 1

multi_gpu_gpt_exampleFunction · 0.85

Calls 5

cublasAlgoMapClass · 0.85
cublasMMWrapperClass · 0.85
setGemmConfigMethod · 0.80
setBF16GemmConfigMethod · 0.80
setFP32GemmConfigMethod · 0.80

Tested by

no test coverage detected