CUBLAS_STATUS_INTERNAL_ERROR when seq_len bigger than 384.

Author: SefaZengCreated May 18, 2023Updated Sep 22, 2025

I am using an old version of faster-transformer which limit the max_seq_len for using FusedAttentionLayer is 384(512 now in the main branch). I found when the model is using fp16 and the sequence length exceeds 384, the Bert.cc go to call UnfusedAttentionLayer and raise this error:

[FT][ERROR] CUDA runtime error: CUBLAS_STATUS_INTERNAL_ERROR /home/faster-transformer/src/fastertransformer/utils/cublasMMWrapper.cc:460

And this function is called by UnfusedAttentionLayer. It looks :

void cublasMMWrapper::stridedBatchedGemm(cublasOperation_t transa,
                                         cublasOperation_t transb,
                                         const int m,
                                         const int n,
                                         const int k,
                                         const void* A,
                                         const int lda,
                                         const int64_t strideA,
                                         const void* B,
                                         const int ldb,
                                         const int64_t strideB,
                                         void* C,
                                         const int ldc,
                                         const int64_t strideC,
                                         const int batch_count,
                                         const float f_alpha,
                                         const float f_beta)
{
    half h_alpha = (half)f_alpha;
    half h_beta = (half)f_beta;

    mu_->lock();
    int is_fp16_computeType = computeType_ == CUDA_R_16F ? 1 : 0;
    const void* alpha =
        is_fp16_computeType ? reinterpret_cast<void*>(&h_alpha) : reinterpret_cast<const void*>(&f_alpha);
    const void* beta = is_fp16_computeType ? reinterpret_cast<void*>(&h_beta) : reinterpret_cast<const void*>(&f_beta);
    cublasLtMatmulAlgo_info info = cublas_algo_map_->getAlgo(batch_count, m, n, k, getCublasDataType(Atype_));
    check_cuda_error(cublasGemmStridedBatchedEx(cublas_handle_,
                                                transa,
                                                transb,
                                                m,  
                                                n,  
                                                k,  
                                                alpha,
                                                A,  
                                                Atype_,
                                                lda,
                                                strideA,
                                                B,  
                                                Btype_,
                                                ldb,
                                                strideB,
                                                beta,
                                                C,  
                                                Ctype_,
                                                ldc,
                                                strideC,
                                                batch_count,
                                                computeType_,
                                                static_cast<cublasGemmAlgo_t>(info.algoId)));

I did not change the code for UnfusedAttentionLayer.* and still digging into it. Could you give some advice about which part may cause this? Any reply is appreciated! Thx!

Source: NVIDIA/FasterTransformer