[kernel] Recompilation optimization triggered by triton function parameter optimization (#7645)
<!-- Thanks for sending a pull request! BEFORE SUBMITTING, PLEASE READ https://docs.vllm.ai/en/latest/contributing/overview.html --> ### What this PR does / why we need it? - Please clarify why the changes are needed. For instance, the use case and bug description. Some parameters of Triton operators are unnecessarily modified with the "constexpr" modifier. When these parameters change, recompilation is triggered, which significantly affects the model performance. Therefore, these parameters need to be rectified. main branch:https://github.com/vllm-project/vllm-ascend/pull/7483 ### Does this PR introduce _any_ user-facing change? no ### How was this patch tested? <!-- CI passed with new added/existing test. If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future. If tests were not added, please describe why they were not added and/or why it was difficult to add. --> --------- Signed-off-by: cvSoldier <610496306@qq.com>
This commit is contained in:
@@ -156,7 +156,20 @@ def extract_last_width(x, start_loc, width):
|
||||
return x[:, indices].permute(1, 0, 2)
|
||||
|
||||
|
||||
@triton.jit
|
||||
@triton.jit(
|
||||
do_not_specialize=[
|
||||
"batch",
|
||||
"state_len",
|
||||
"num_cache_lines",
|
||||
"stride_x_seq",
|
||||
"stride_x_token",
|
||||
"stride_conv_state_seq",
|
||||
"stride_conv_state_tok",
|
||||
"stride_state_indices",
|
||||
"stride_o_seq",
|
||||
"stride_o_token",
|
||||
]
|
||||
)
|
||||
def _causal_conv1d_update_kernel_npu_tiled(
|
||||
# Pointers
|
||||
x_ptr, # (batch, dim, seqlen) OR (num_tokens, dim) for varlen
|
||||
@@ -172,21 +185,21 @@ def _causal_conv1d_update_kernel_npu_tiled(
|
||||
batch: tl.int32,
|
||||
dim: tl.constexpr,
|
||||
seqlen: tl.constexpr, # max seqlen for varlen, or exact seqlen
|
||||
state_len: tl.constexpr, # effective state_len computed in wrapper
|
||||
num_cache_lines: tl.constexpr,
|
||||
state_len, # effective state_len computed in wrapper
|
||||
num_cache_lines,
|
||||
# Strides
|
||||
stride_x_seq: tl.constexpr,
|
||||
stride_x_seq,
|
||||
stride_x_dim: tl.constexpr,
|
||||
stride_x_token: tl.constexpr,
|
||||
stride_x_token,
|
||||
stride_w_dim: tl.constexpr,
|
||||
stride_w_width: tl.constexpr,
|
||||
stride_conv_state_seq: tl.constexpr,
|
||||
stride_conv_state_seq,
|
||||
stride_conv_state_dim: tl.constexpr,
|
||||
stride_conv_state_tok: tl.constexpr,
|
||||
stride_state_indices: tl.constexpr,
|
||||
stride_o_seq: tl.constexpr,
|
||||
stride_conv_state_tok,
|
||||
stride_state_indices,
|
||||
stride_o_seq,
|
||||
stride_o_dim: tl.constexpr,
|
||||
stride_o_token: tl.constexpr,
|
||||
stride_o_token,
|
||||
# others
|
||||
pad_slot_id: tl.constexpr,
|
||||
# Meta
|
||||
|
||||
Reference in New Issue
Block a user