| 55 | |
| 56 | template<typename T1, typename T2> |
| 57 | int bertExample(size_t max_batch_size, |
| 58 | size_t num_layers, |
| 59 | size_t head_num, |
| 60 | size_t size_per_head, |
| 61 | bool is_remove_padding, |
| 62 | bool allow_gemm_test) |
| 63 | { |
| 64 | const int fp8_mode = 2; |
| 65 | FT_LOG_INFO("fp8_mode: %d", fp8_mode); |
| 66 | FT_LOG_INFO("Device: %s \n", getDeviceName().c_str()); |
| 67 | |
| 68 | const size_t hidden_units = head_num * size_per_head; |
| 69 | const size_t inter_size = 4 * hidden_units; |
| 70 | const size_t vocab_size = 30522; // Fixed by bert model config |
| 71 | const size_t max_position_embeddings = 512; // Fixed by bert model config |
| 72 | const size_t token_type_vocab_size = 2; // Fixed by bert model config |
| 73 | |
| 74 | cudaStream_t stream; |
| 75 | cublasHandle_t cublas_handle; |
| 76 | cublasLtHandle_t cublaslt_handle; |
| 77 | cudaStreamCreate(&stream); |
| 78 | cublasCreate(&cublas_handle); |
| 79 | cublasLtCreate(&cublaslt_handle); |
| 80 | #ifdef SPARSITY_ENABLED |
| 81 | cusparseLtHandle_t cusparselt_handle; |
| 82 | CHECK_CUSPARSE(cusparseLtInit(&cusparselt_handle)); |
| 83 | #endif |
| 84 | cublasSetStream(cublas_handle, stream); |
| 85 | cublasAlgoMap* cublas_algo_map = new cublasAlgoMap("gemm_config.in", ""); |
| 86 | |
| 87 | Allocator<AllocatorType::CUDA> allocator(getDevice()); |
| 88 | |
| 89 | std::mutex* cublas_wrapper_mutex = new std::mutex(); |
| 90 | #ifdef SPARSITY_ENABLED |
| 91 | // cublasFP8MMWrapper cublas_wrapper = cublasFP8MMWrapper( |
| 92 | // cublas_handle, cublaslt_handle, cusparselt_handle, stream, cublas_algo_map, cublas_wrapper_mutex, |
| 93 | // &allocator); |
| 94 | #else |
| 95 | cublasFP8MMWrapper cublas_wrapper = |
| 96 | cublasFP8MMWrapper(cublas_handle, cublaslt_handle, stream, cublas_algo_map, cublas_wrapper_mutex, &allocator); |
| 97 | #endif |
| 98 | |
| 99 | // Prepare FP8 bert model and weight |
| 100 | BertFP8Weight<T1, T2> bert_weights(hidden_units, |
| 101 | head_num, |
| 102 | size_per_head, |
| 103 | inter_size, |
| 104 | num_layers, |
| 105 | vocab_size, |
| 106 | max_position_embeddings, |
| 107 | token_type_vocab_size, |
| 108 | 1, |
| 109 | 1, |
| 110 | fp8_mode, |
| 111 | true, |
| 112 | true); |
| 113 | bert_weights.loadModel("/home/scratch.bhsueh_sw_1/FP8/mlperf/ft_fp8/"); |
| 114 | bert_weights.transposeWeight(); |
nothing calls this directly
no test coverage detected