-
Notifications
You must be signed in to change notification settings - Fork 336
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[JAX] Added prepare phase for the FusedAttnForwardFFI (#1313)
* added prepare phase for the FusedAttnForwardFFI * enabled FusedAttnForwardFFI by default * moved prepare phase into pybind --------- Signed-off-by: Phuong Nguyen <[email protected]>
- Loading branch information
Showing
8 changed files
with
82 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/************************************************************************* | ||
* Copyright (c) 2022-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
* | ||
* See LICENSE for license information. | ||
************************************************************************/ | ||
|
||
#include "../fused_attn/utils.h" | ||
#include "transformer_engine/cudnn.h" | ||
|
||
namespace transformer_engine { | ||
|
||
void nvte_cudnn_handle_init() { | ||
auto handle = cudnnExecutionPlanManager::Instance().GetCudnnHandle(); | ||
} | ||
|
||
} // namespace transformer_engine |
29 changes: 29 additions & 0 deletions
29
transformer_engine/common/include/transformer_engine/cudnn.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/************************************************************************* | ||
* Copyright (c) 2022-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
* | ||
* See LICENSE for license information. | ||
************************************************************************/ | ||
|
||
/*! \file cudnn.h | ||
* \brief Helper for cuDNN initialization | ||
*/ | ||
|
||
#ifndef TRANSFORMER_ENGINE_CUDNN_H_ | ||
#define TRANSFORMER_ENGINE_CUDNN_H_ | ||
|
||
#include "transformer_engine.h" | ||
|
||
/*! \namespace transformer_engine | ||
*/ | ||
namespace transformer_engine { | ||
|
||
/*! \brief TE/JAX cudaGraph requires the cuDNN initialization to happen outside of the capturing | ||
* region. This function is a helper to call cudnnCreate() which allocate memory for the handle. | ||
* The function will be called in the initialize() phase of the related XLA custom calls. | ||
*/ | ||
|
||
void nvte_cudnn_handle_init(); | ||
|
||
} // namespace transformer_engine | ||
|
||
#endif // TRANSFORMER_ENGINE_CUDNN_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/************************************************************************* | ||
* Copyright (c) 2022-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
* | ||
* See LICENSE for license information. | ||
************************************************************************/ | ||
|
||
#include "transformer_engine/cudnn.h" | ||
|
||
#include "extensions.h" | ||
#include "xla/ffi/api/c_api.h" | ||
|
||
namespace transformer_engine { | ||
namespace jax { | ||
|
||
Error_Type CudnnHandleInitFFI(Variadic_Buffer_Type args, Variadic_Result_Type rets, | ||
Dictionary attrs) { | ||
nvte_cudnn_handle_init(); | ||
return ffi_with_cuda_error_check(); | ||
} | ||
|
||
XLA_FFI_DEFINE_HANDLER_SYMBOL(CudnnHandleInitHandler, CudnnHandleInitFFI, | ||
FFI::Bind<FFI_Prepare>().RemainingArgs().RemainingRets().Attrs()); | ||
} // namespace jax | ||
} // namespace transformer_engine |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters