[InferMeta] Add input validation for FusedRopeInferMeta#78333
Closed
wanghuancoder wants to merge 5 commits intoPaddlePaddle:developfrom
Closed
[InferMeta] Add input validation for FusedRopeInferMeta#78333wanghuancoder wants to merge 5 commits intoPaddlePaddle:developfrom
wanghuancoder wants to merge 5 commits intoPaddlePaddle:developfrom
Conversation
…kernels When processing tensors with zero dimensions (e.g., shape (0, 10) or (16, 0)), the cross_entropy kernels encounter invalid configuration arguments because: 1. std::log2(0) is undefined behavior, resulting in -inf 2. The computed block/grid dimensions become invalid This fix adds zero-dimension checks at the entry of affected kernel functions to avoid launching kernels with invalid configurations. Files modified: - paddle/phi/kernels/funcs/cross_entropy.cu - paddle/phi/kernels/gpu/cross_entropy_kernel.cu - paddle/phi/kernels/gpu/cross_entropy_grad_kernel.cu - paddle/phi/kernels/gpu/cross_entropy_bwd_w_downcast.cu
When calling paddle.full_like with int64 max value (9223372036854775807), the value was incorrectly converted to -9223372036854775808 due to: 1. Converting the value to double (which has only 53 bits of precision) 2. Converting back to int64 (causing overflow) This fix directly converts the value to the target type without going through double for integer types, while still using double for inf/nan checking in floating-point types.
Add comprehensive input validation for FusedRopeInferMeta: - Validate head_dim is a multiple of 2 - Validate batch_size, seq_len, num_heads, head_dim are greater than 0 - Validate optional inputs k, v have same dims as q - Validate optional inputs sin, cos have correct shape [seq_len, head_dim] or [1, seq_len, 1, head_dim] - Validate sin and cos must be both provided or both absent - Validate position_ids has shape [batch_size, seq_len]
|
你的PR提交成功,感谢你对开源项目的贡献! |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
PR Category
Operator Mechanism
PR Types
Improvements
Description
为
FusedRopeInferMeta添加全面的输入参数验证:基础参数校验:
head_dim必须是 2 的倍数batch_size,seq_len,num_heads,head_dim必须大于 0可选输入 k, v 校验:
可选输入 sin, cos 校验:
position_ids 校验:
这些验证可以提前捕获潜在的输入错误,提供更友好的错误信息。
是否引起精度变化
否