| 23 | |
| 24 | template<typename T> |
| 25 | void BartEncoder<T>::initialize() |
| 26 | { |
| 27 | if ((attention_type_ == AttentionType::FUSED_MHA || attention_type_ == AttentionType::FUSED_PADDED_MHA) |
| 28 | && false // disable the fused mha |
| 29 | && std::is_same<T, half>::value == true && max_seq_len_ <= 384) { |
| 30 | FT_CHECK(false); // fused mha does not support relatvie attention bias now. |
| 31 | // attention_layer_ = new FusedAttentionLayer<T>(max_batch_size_, |
| 32 | // max_seq_len_, |
| 33 | // head_num_, |
| 34 | // size_per_head_, |
| 35 | // sm_, |
| 36 | // q_scaling_ * (1.0 / sqrtf(size_per_head_ * 1.0f)), |
| 37 | // stream_, |
| 38 | // cublas_wrapper_, |
| 39 | // allocator_, |
| 40 | // is_free_buffer_after_forward_, |
| 41 | // sparse_); |
| 42 | } |
| 43 | else if (attention_type_ == AttentionType::UNFUSED_MHA || attention_type_ == AttentionType::UNFUSED_PADDED_MHA) { |
| 44 | attention_layer_ = |
| 45 | new TensorParallelUnfusedAttentionLayer<T>(max_batch_size_, |
| 46 | max_seq_len_, |
| 47 | head_num_, |
| 48 | size_per_head_, |
| 49 | d_model_, |
| 50 | q_scaling_, // adjust according to checkpoint structure |
| 51 | tensor_para_, |
| 52 | stream_, |
| 53 | cublas_wrapper_, |
| 54 | allocator_, |
| 55 | is_free_buffer_after_forward_, |
| 56 | sparse_, |
| 57 | custom_all_reduce_comm_, |
| 58 | enable_custom_all_reduce_); |
| 59 | } |
| 60 | else { |
| 61 | throw std::runtime_error(std::string("[FT][ERROR] Invalid attention type \n")); |
| 62 | } |
| 63 | |
| 64 | bool use_gated_activation = activation_type_ == ActivationType::GeGLU || activation_type_ == ActivationType::ReGLU |
| 65 | || activation_type_ == ActivationType::SiGLU; |
| 66 | if (activation_type_ == ActivationType::Gelu || activation_type_ == ActivationType::GeGLU) { |
| 67 | ffn_layer_ = new TensorParallelGeluFfnLayer<T>(max_batch_size_, |
| 68 | max_seq_len_, |
| 69 | 1, |
| 70 | d_model_, |
| 71 | 0, |
| 72 | inter_size_, |
| 73 | tensor_para_, |
| 74 | stream_, |
| 75 | cublas_wrapper_, |
| 76 | allocator_, |
| 77 | true, |
| 78 | is_free_buffer_after_forward_, |
| 79 | sparse_, |
| 80 | 0, |
| 81 | use_gated_activation, // don't use GeGLU |
| 82 | custom_all_reduce_comm_, |
nothing calls this directly
no outgoing calls
no test coverage detected