/* SPDX-License-Identifier: Apache-2.0 * SPDX-FileCopyrightText: Copyright 2025 SGLang Team. All Rights Reserved. * * Vendored from sgl-kernel/include/sgl_flash_kernel_ops.h (commit bcf72ccc). * Declares the mha_fwd() C++ function signature for CUTLASS FA3 kernels. * NO MODIFICATIONS from the original (except removing unused macros). */ #pragma once #include #include #include #include #include #include "sgl_kernel_torch_shim.h" /* * From flash-attention (sgl-attn fork) */ std::tuple mha_fwd( at::Tensor q, // (b, s_q, h, d) or (total_q, h, d) if there is cu_seqlens_q at::Tensor k, // (b_k, s_k, h_k, d) or (total_k, h_k, d) or paged at::Tensor v, // (b_k, s_k, h_k, dv) or (total_k, h_k, dv) or paged std::optional k_new_, std::optional v_new_, std::optional q_v_, // MLA value projection query std::optional out_, std::optional cu_seqlens_q_, std::optional cu_seqlens_k_, std::optional cu_seqlens_k_new_, std::optional seqused_q_, std::optional seqused_k_, std::optional max_seqlen_q_, std::optional max_seqlen_k_, std::optional page_table_, std::optional kv_batch_idx_, std::optional leftpad_k_, std::optional rotary_cos_, std::optional rotary_sin_, std::optional seqlens_rotary_, std::optional q_descale_, std::optional k_descale_, std::optional v_descale_, std::optional softmax_scale_, bool is_causal, int64_t window_size_left, int64_t window_size_right, int64_t attention_chunk, double softcap, bool is_rotary_interleaved, std::optional scheduler_metadata_, int64_t num_splits, std::optional pack_gqa_, int64_t sm_margin, std::optional& sinks_);