Add flash params to csrc #5
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request introduces a new header file,
flash.h
, which defines the core structures and functions for a CUDA-based multi-head attention mechanism. The changes include the addition of parameter structures for forward and backward passes, utility constants, and function templates for executing the attention mechanism.Core functionality for multi-head attention:
Definition of parameter structures:
QKV_params
to encapsulate query, key, and value tensor pointers, strides, and head-related dimensions.ZeroHold_params
to manage zero-hold states, causal masks, and associated strides for attention mechanisms.Flash_fwd_params
andFlash_bwd_params
to extend the above structures for forward and backward pass parameters, including dropout, scaling factors, and random state handling.Function templates for execution:
run_mha_fwd_
,run_mha_fwd_splitkv_dispatch
, andrun_mha_bwd_
for executing forward and backward multi-head attention operations with CUDA streams.Namespace organization:
FLASH_NAMESPACE
for modularity and clarity.