/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-composable-kernel/checkouts/develop/include/ck_tile/ops/fmha/kernel/fmha_batch_prefill_kernel.hpp Source File#
fmha_batch_prefill_kernel.hpp
Go to the documentation of this file.
Definition: cluster_descriptor.hpp:13
constexpr CK_TILE_DEVICE auto make_null_tile_window(const WindowLengths &window_lengths)
Definition: null_tile_window.hpp:66
constexpr CK_TILE_HOST_DEVICE auto integer_divide_ceil(X x, Y y)
Definition: math.hpp:145
__device__ uint32_t amd_wave_read_first_lane(uint16_t v)
Definition: amd_buffer_addressing.hpp:36
@ ELEMENTWISE_BIAS
CK_TILE_HOST_DEVICE_EXTERN composes(Ts &&...) -> composes< remove_cvref_t< Ts >... >
constexpr CK_TILE_HOST_DEVICE auto transform_tensor_view(const OldTensorView &old_tensor_view, const NewTransforms &new_transforms, NewLowerDimensionOldVisibleIdss, NewUpperDimensionNewVisibleIdss)
Definition: tensor_view.hpp:526
@ VECTORIZED_LAYOUT
constexpr CK_TILE_HOST_DEVICE auto make_merge_transform(const LowLengths &low_lengths)
Definition: coordinate_transform.hpp:1690
constexpr CK_TILE_HOST_DEVICE auto pad_tensor_view(const TensorView &tensor_view, const TileLengths &tile_lengths, DoPads)
Definition: tensor_view.hpp:545
constexpr CK_TILE_HOST_DEVICE auto make_pass_through_transform(const LowLength &low_length)
Definition: coordinate_transform.hpp:1633
remove_cv_t< std::remove_reference_t< T > > remove_cvref_t
Definition: type_traits.hpp:21
constexpr CK_TILE_DEVICE auto make_tile_window(null_tensor_view, const WindowLengths &window_lengths, const multi_index< WindowLengths::size()> &, Ts &&...)
Definition: null_tile_window.hpp:75
@ SGLANG_PAGE_TABLE_1D
constexpr CK_TILE_HOST_DEVICE auto make_tuple(Xs &&... xs)
Definition: tuple.hpp:360
@ MASK_FROM_TOP_LEFT
@ FROM_BOTTOM_RIGHT
typename conditional< predicate, X, Y >::type conditional_t
Definition: functional.hpp:115
Definition: block_position_encoding.hpp:48
Definition: block_dropout.hpp:53
Definition: block_position_encoding.hpp:137
Definition: fmha_batch_prefill_kernel.hpp:292
ck_tile::index_t kv_head_idx
Definition: fmha_batch_prefill_kernel.hpp:295
ck_tile::index_t qo_head_idx
Definition: fmha_batch_prefill_kernel.hpp:294
ck_tile::index_t batch_idx
Definition: fmha_batch_prefill_kernel.hpp:293
Definition: fmha_batch_prefill_kernel.hpp:167
ck_tile::index_t alibi_slope_stride
Definition: fmha_batch_prefill_kernel.hpp:170
const void * alibi_slope_ptr
Definition: fmha_batch_prefill_kernel.hpp:169
Definition: fmha_batch_prefill_kernel.hpp:162
ck_tile::index_t batch_stride_bias
Definition: fmha_batch_prefill_kernel.hpp:163
Definition: fmha_batch_prefill_kernel.hpp:244
ck_tile::index_t batch_stride_randval
Definition: fmha_batch_prefill_kernel.hpp:245
Definition: fmha_batch_prefill_kernel.hpp:262
ck_tile::index_t batch_stride_o
Definition: fmha_batch_prefill_kernel.hpp:266
ck_tile::index_t batch_stride_v
Definition: fmha_batch_prefill_kernel.hpp:265
ck_tile::index_t batch_stride_q
Definition: fmha_batch_prefill_kernel.hpp:263
ck_tile::index_t batch_stride_k
Definition: fmha_batch_prefill_kernel.hpp:264
Definition: fmha_batch_prefill_kernel.hpp:155
ck_tile::index_t nhead_stride_bias
Definition: fmha_batch_prefill_kernel.hpp:158
ck_tile::index_t stride_bias
Definition: fmha_batch_prefill_kernel.hpp:157
const void * bias_ptr
Definition: fmha_batch_prefill_kernel.hpp:156
Definition: fmha_batch_prefill_kernel.hpp:209
ck_tile::index_t stride_randval
Definition: fmha_batch_prefill_kernel.hpp:239
void init_dropout(float p_drop, const uint64_t *seed_ptr, const uint64_t *offset_ptr)
Definition: fmha_batch_prefill_kernel.hpp:222
ck_tile::index_t nhead_stride_randval
Definition: fmha_batch_prefill_kernel.hpp:240
void init_dropout(float p_drop, uint64_t seed, uint64_t offset)
Definition: fmha_batch_prefill_kernel.hpp:210
void * rand_val_ptr
Definition: fmha_batch_prefill_kernel.hpp:237
float rp_undrop
Definition: fmha_batch_prefill_kernel.hpp:234
bool is_store_randval
Definition: fmha_batch_prefill_kernel.hpp:236
uint8_t p_undrop_in_uint8_t
Definition: fmha_batch_prefill_kernel.hpp:235
Definition: fmha_batch_prefill_kernel.hpp:99
ck_tile::index_t page_block_size
Definition: fmha_batch_prefill_kernel.hpp:116
ck_tile::index_t stride_q
Definition: fmha_batch_prefill_kernel.hpp:121
ck_tile::index_t stride_v
Definition: fmha_batch_prefill_kernel.hpp:123
int32_t num_total_pages
Definition: fmha_batch_prefill_kernel.hpp:115
float scale_s
Definition: fmha_batch_prefill_kernel.hpp:119
PageBlockTableKargs page_table
Definition: fmha_batch_prefill_kernel.hpp:117
ck_tile::index_t seqlen_q
Definition: fmha_batch_prefill_kernel.hpp:105
ck_tile::index_t stride_k
Definition: fmha_batch_prefill_kernel.hpp:122
ck_tile::index_t nhead_stride_o
Definition: fmha_batch_prefill_kernel.hpp:129
ck_tile::index_t nhead_stride_k
Definition: fmha_batch_prefill_kernel.hpp:127
ck_tile::index_t nhead_ratio_qk
Definition: fmha_batch_prefill_kernel.hpp:113
ck_tile::index_t nhead_stride_v
Definition: fmha_batch_prefill_kernel.hpp:128
ck_tile::index_t nhead_stride_q
Definition: fmha_batch_prefill_kernel.hpp:126
const void * v_ptr
Definition: fmha_batch_prefill_kernel.hpp:102
void * o_ptr
Definition: fmha_batch_prefill_kernel.hpp:103
ck_tile::index_t seqlen_k
Definition: fmha_batch_prefill_kernel.hpp:106
ck_tile::index_t stride_o
Definition: fmha_batch_prefill_kernel.hpp:124
ck_tile::index_t hdim_v
Definition: fmha_batch_prefill_kernel.hpp:108
ck_tile::index_t num_head_q
Definition: fmha_batch_prefill_kernel.hpp:110
const void * k_ptr
Definition: fmha_batch_prefill_kernel.hpp:101
ck_tile::index_t hdim_q
Definition: fmha_batch_prefill_kernel.hpp:107
const void * q_ptr
Definition: fmha_batch_prefill_kernel.hpp:100
Definition: fmha_batch_prefill_kernel.hpp:181
ck_tile::index_t batch_stride_lse
Definition: fmha_batch_prefill_kernel.hpp:184
ck_tile::index_t nhead_stride_lse
Definition: fmha_batch_prefill_kernel.hpp:183
void * lse_ptr
Definition: fmha_batch_prefill_kernel.hpp:182
Definition: fmha_batch_prefill_kernel.hpp:188
const void * v_descale_ptr
Definition: fmha_batch_prefill_kernel.hpp:191
const void * k_descale_ptr
Definition: fmha_batch_prefill_kernel.hpp:190
const void * q_descale_ptr
Definition: fmha_batch_prefill_kernel.hpp:189
Definition: fmha_batch_prefill_kernel.hpp:195
bool is_drop_seed_offset_from_host
Definition: fmha_batch_prefill_kernel.hpp:205
ValueOrPointer< uint64_t > drop_seed
Definition: fmha_batch_prefill_kernel.hpp:203
ValueOrPointer< uint64_t > drop_offset
Definition: fmha_batch_prefill_kernel.hpp:204
Definition: fmha_batch_prefill_kernel.hpp:72
Definition: fmha_batch_prefill_kernel.hpp:283
ck_tile::index_t batch_stride_v
Definition: fmha_batch_prefill_kernel.hpp:286
ck_tile::index_t batch_stride_k
Definition: fmha_batch_prefill_kernel.hpp:285
const int32_t * seqstart_q_ptr
Definition: fmha_batch_prefill_kernel.hpp:284
Definition: fmha_batch_prefill_kernel.hpp:133
float logits_soft_cap_rcp
Definition: fmha_batch_prefill_kernel.hpp:151
void init_logits_soft_cap(float logits_soft_cap_)
Definition: fmha_batch_prefill_kernel.hpp:136
FmhaFwdLogitsSoftCapKargs()=default
float logits_soft_cap
Definition: fmha_batch_prefill_kernel.hpp:150
Definition: fmha_batch_prefill_kernel.hpp:174
ck_tile::index_t sink_size
Definition: fmha_batch_prefill_kernel.hpp:176
ck_tile::index_t window_size_right
Definition: fmha_batch_prefill_kernel.hpp:176
ck_tile::index_t window_size_left
Definition: fmha_batch_prefill_kernel.hpp:176
ck_tile::GenericAttentionMaskEnum mask_type
Definition: fmha_batch_prefill_kernel.hpp:177
Definition: fmha_batch_prefill_kernel.hpp:79
const int32_t * kv_page_indices
Definition: fmha_batch_prefill_kernel.hpp:81
const int32_t * kv_indptr
Definition: fmha_batch_prefill_kernel.hpp:80
const int32_t * kv_last_page_lens
Definition: fmha_batch_prefill_kernel.hpp:82
Definition: fmha_batch_prefill_kernel.hpp:86
const int32_t * block_table_ptr
Definition: fmha_batch_prefill_kernel.hpp:87
const int32_t * seqlen_k_ptr
Definition: fmha_batch_prefill_kernel.hpp:89
ck_tile::index_t batch_stride_block_table
Definition: fmha_batch_prefill_kernel.hpp:88
Definition: fmha_batch_prefill_kernel.hpp:28
static constexpr CK_TILE_DEVICE auto GetTileIndex(const Kargs &kargs)
Definition: fmha_batch_prefill_kernel.hpp:612
static constexpr bool kIsGroupMode
Definition: fmha_batch_prefill_kernel.hpp:50
static constexpr ck_tile::index_t kBlockPerCu
Definition: fmha_batch_prefill_kernel.hpp:33
ck_tile::remove_cvref_t< typename FmhaPipeline::VDataType > VDataType
Definition: fmha_batch_prefill_kernel.hpp:39
static constexpr CK_TILE_HOST std::enable_if_t< Cond, Kargs > MakeKargs(const void *q_ptr, const void *k_ptr, const void *v_ptr, const void *bias_ptr, const void *q_descale_ptr, const void *k_descale_ptr, const void *v_descale_ptr, void *rand_val_ptr, void *lse_ptr, void *o_ptr, const void *seqstart_q_ptr, ck_tile::index_t hdim_q, ck_tile::index_t hdim_v, ck_tile::index_t num_head_q, ck_tile::index_t nhead_ratio_qk, int32_t num_total_pages, ck_tile::index_t page_block_size, const PageBlockTableKargs &page_table, float scale_s, [[maybe_unused]] float scale_p, [[maybe_unused]] float scale_o, float logits_soft_cap, ck_tile::index_t stride_q, ck_tile::index_t stride_k, ck_tile::index_t stride_v, ck_tile::index_t stride_bias, ck_tile::index_t stride_randval, ck_tile::index_t stride_o, ck_tile::index_t nhead_stride_q, ck_tile::index_t nhead_stride_k, ck_tile::index_t nhead_stride_v, ck_tile::index_t nhead_stride_bias, ck_tile::index_t nhead_stride_randval, ck_tile::index_t nhead_stride_lse, ck_tile::index_t nhead_stride_o, ck_tile::index_t batch_stride_k, ck_tile::index_t batch_stride_v, ck_tile::index_t window_size_left, ck_tile::index_t window_size_right, ck_tile::index_t sink_size, ck_tile::index_t mask_type, float p_drop, bool s_randval, std::variant< std::pair< uint64_t, uint64_t >, std::pair< const void *, const void * >> drop_seed_offset)
Definition: fmha_batch_prefill_kernel.hpp:450
ck_tile::remove_cvref_t< FmhaPipeline_ > FmhaPipeline
Definition: fmha_batch_prefill_kernel.hpp:29
ck_tile::remove_cvref_t< typename FmhaPipeline::KDataType > KDataType
Definition: fmha_batch_prefill_kernel.hpp:38
static constexpr bool kPadSeqLenQ
Definition: fmha_batch_prefill_kernel.hpp:51
ck_tile::remove_cvref_t< typename FmhaPipeline::RandValOutputDataType > RandValOutputDataType
Definition: fmha_batch_prefill_kernel.hpp:43
static constexpr bool kPadHeadDimV
Definition: fmha_batch_prefill_kernel.hpp:54
ck_tile::remove_cvref_t< typename FmhaPipeline::LSEDataType > LSEDataType
Definition: fmha_batch_prefill_kernel.hpp:44
ck_tile::remove_cvref_t< typename FmhaPipeline::QDataType > QDataType
Definition: fmha_batch_prefill_kernel.hpp:37
static constexpr auto kKVMemoryLayout
Definition: fmha_batch_prefill_kernel.hpp:60
static constexpr bool kHasMask
Definition: fmha_batch_prefill_kernel.hpp:66
ck_tile::remove_cvref_t< typename FmhaPipeline::BiasDataType > BiasDataType
Definition: fmha_batch_prefill_kernel.hpp:41
ck_tile::remove_cvref_t< typename FmhaPipeline::FmhaMask > FmhaMask
Definition: fmha_batch_prefill_kernel.hpp:65
static CK_TILE_HOST dim3 BlockSize()
Definition: fmha_batch_prefill_kernel.hpp:671
static constexpr bool kPadSeqLenK
Definition: fmha_batch_prefill_kernel.hpp:52
static constexpr auto QScaleEnum
Definition: fmha_batch_prefill_kernel.hpp:59
static constexpr bool kHasLogitsSoftCap
Definition: fmha_batch_prefill_kernel.hpp:55
static constexpr bool kHasDropout
Definition: fmha_batch_prefill_kernel.hpp:58
static constexpr bool kStoreLSE
Definition: fmha_batch_prefill_kernel.hpp:57
static constexpr auto kKVLookupTable
Definition: fmha_batch_prefill_kernel.hpp:61
ck_tile::remove_cvref_t< typename FmhaPipeline::SaccDataType > SaccDataType
Definition: fmha_batch_prefill_kernel.hpp:46
static constexpr index_t kPageBlockSize
Definition: fmha_batch_prefill_kernel.hpp:62
ck_tile::remove_cvref_t< typename FmhaPipeline::PDataType > PDataType
Definition: fmha_batch_prefill_kernel.hpp:40
static constexpr CK_TILE_HOST_DEVICE ck_tile::index_t GetSmemSize()
Definition: fmha_batch_prefill_kernel.hpp:683
std::conditional_t< kKVLookupTable==BlockAttentionKVCacheLookupTableEnum::SGLANG_PAGE_TABLE_1D, SglangPageTableKargs, VllmPageTableKargs > PageBlockTableKargs
Definition: fmha_batch_prefill_kernel.hpp:96
static constexpr ck_tile::index_t kBlockSize
Definition: fmha_batch_prefill_kernel.hpp:31
static constexpr auto BiasEnum
Definition: fmha_batch_prefill_kernel.hpp:56
ck_tile::remove_cvref_t< typename FmhaPipeline::VLayout > VLayout
Definition: fmha_batch_prefill_kernel.hpp:48
ck_tile::remove_cvref_t< typename FmhaPipeline::ODataType > ODataType
Definition: fmha_batch_prefill_kernel.hpp:45
ck_tile::remove_cvref_t< typename FmhaPipeline::AttentionVariant > AttentionVariant
Definition: fmha_batch_prefill_kernel.hpp:64
static constexpr index_t kVectorSize
Definition: fmha_batch_prefill_kernel.hpp:63
static constexpr bool kUseAsyncCopy
Definition: fmha_batch_prefill_kernel.hpp:68
static constexpr ck_tile::index_t kBlockPerCuInput
Definition: fmha_batch_prefill_kernel.hpp:35
static constexpr CK_TILE_HOST auto GridSize(ck_tile::index_t batch_size_, ck_tile::index_t nhead_, ck_tile::index_t seqlen_q_, ck_tile::index_t hdim_v_)
Definition: fmha_batch_prefill_kernel.hpp:589
static constexpr bool kPadHeadDimQ
Definition: fmha_batch_prefill_kernel.hpp:53
CK_TILE_DEVICE void operator()(Kargs kargs) const
Definition: fmha_batch_prefill_kernel.hpp:688
std::conditional_t< kIsGroupMode, FmhaFwdGroupModeKargs, FmhaFwdBatchModeKargs > Kargs
Definition: fmha_batch_prefill_kernel.hpp:289
ck_tile::remove_cvref_t< EpiloguePipeline_ > EpiloguePipeline
Definition: fmha_batch_prefill_kernel.hpp:30
static constexpr CK_TILE_HOST std::enable_if_t< Cond, Kargs > MakeKargs(const void *q_ptr, const void *k_ptr, const void *v_ptr, const void *bias_ptr, const void *q_descale_ptr, const void *k_descale_ptr, const void *v_descale_ptr, void *rand_val_ptr, void *lse_ptr, void *o_ptr, ck_tile::index_t seqlen_q, ck_tile::index_t hdim_q, ck_tile::index_t hdim_v, ck_tile::index_t num_head_q, ck_tile::index_t nhead_ratio_qk, int32_t num_total_pages, ck_tile::index_t page_block_size, const PageBlockTableKargs &page_table, float scale_s, [[maybe_unused]] float scale_p, [[maybe_unused]] float scale_o, float logits_soft_cap, ck_tile::index_t stride_q, ck_tile::index_t stride_k, ck_tile::index_t stride_v, ck_tile::index_t stride_bias, ck_tile::index_t stride_randval, ck_tile::index_t stride_o, ck_tile::index_t nhead_stride_q, ck_tile::index_t nhead_stride_k, ck_tile::index_t nhead_stride_v, ck_tile::index_t nhead_stride_bias, ck_tile::index_t nhead_stride_randval, ck_tile::index_t nhead_stride_lse, ck_tile::index_t nhead_stride_o, ck_tile::index_t batch_stride_q, ck_tile::index_t batch_stride_k, ck_tile::index_t batch_stride_v, ck_tile::index_t batch_stride_bias, ck_tile::index_t batch_stride_randval, ck_tile::index_t batch_stride_lse, ck_tile::index_t batch_stride_o, ck_tile::index_t window_size_left, ck_tile::index_t window_size_right, ck_tile::index_t sink_size, ck_tile::index_t mask_type, float p_drop, bool s_randval, std::variant< std::pair< uint64_t, uint64_t >, std::pair< const void *, const void * >> drop_seed_offset)
Definition: fmha_batch_prefill_kernel.hpp:300
Definition: variants.hpp:63
Definition: block_dropout.hpp:39
Definition: variants.hpp:51
Definition: integral_constant.hpp:13
Definition: functional.hpp:114
Definition: numeric.hpp:18
Definition: coordinate_transform.hpp:1392
Definition: unary_element_function.hpp:55
Definition: math.hpp:28
Definition: sequence.hpp:49
Definition: fmha_batch_prefill_kernel.hpp:198
T val
Definition: fmha_batch_prefill_kernel.hpp:199
const T * ptr
Definition: fmha_batch_prefill_kernel.hpp:200