-
Notifications
You must be signed in to change notification settings - Fork 88
Fix validate consistency #803
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Update torch.nn.MultiheadAttention mapping to use ChangeAPIMatcher with paddle.compat.nn.MultiheadAttention - Update torch.nn.functional.scaled_dot_product_attention mapping to use ChangeAPIMatcher with paddle.compat.nn.functional.scaled_dot_product_attention - Add torch.Tensor.shape to global variable manager - Add test case for torch.Tensor.shape with empty tensor - Remove unsupport flags from MultiheadAttention tests and add parameter initialization - Simplify API mapping configurations by removing detailed argument specifications
Changed the tolerance parameter from `rtol` (relative tolerance) to `atol` (absolute tolerance) in all test cases within `test_nn_MultiheadAttention.py`. This adjustment ensures more consistent and reliable test comparisons, particularly for values near zero where relative tolerance can be overly strict.
… attention tests - Changed tolerance parameter from `rtol` to `atol` in all test cases for more consistent numerical comparisons - Added new test cases (10-13) for GQA (Grouped Query Attention) and different sequence length scenarios - Maintains same tolerance values but uses absolute tolerance instead of relative tolerance
|
Thanks for your contribution! |
| "inplace" | ||
| ] | ||
| }, | ||
| "torch.nn.Module": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这些配置先不用删,no_need_convert会覆盖api_mapping.json。后面会将no_need_convert列表统一迁移到api_mapping.json中来配置。no_need_convert名单里不用动。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Restored
paconvert/api_matcher.py
Outdated
| return code | ||
|
|
||
|
|
||
| class CompositeMatcher(BaseMatcher): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个的功能是啥,和BaseMatcher一致?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
|
|
||
|
|
||
| def test_case_8(): | ||
| # PaConvert can't tell if args in **kawrgs are supported by paddle or not. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个功能退化了?之前是可以加未转换标记的
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个应该是符合预期的,这个类的init 参数里只有**kwargs,不需要看用户到底传入了些啥参数,PaConvert把它原封不动传进去就行
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个应该是符合预期的,这个类的init 参数里只有**kwargs,不需要看用户到底传入了些啥参数,PaConvert把它原封不动传进去就行
这个case之前是可以跑通的,针对torchvision.models.inception_v3的转换做了修改吗
| "torch.nn", | ||
| "torch.double", | ||
| "torch.cfloat", | ||
| "transformers.PreTrainedTokenizer", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个名单里可能还得加几个,baddbmm、round这些
| "Matcher": "GenericMatcher", | ||
| "paddle_api": "paddle.newaxis" | ||
| }, | ||
| "torch.nn": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这些留着吧,非必要不删,有用户报过这种case:
if hasattr(torch.nn, 'xxx')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Restored
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
目前NO_NEED_CONVERT这一套还是在globar_var里维护的,如果在api_mapping.json里配置。需要保证globar_var配置好,因为官网脚本目前还是会从globar_var里抓数据。
后面再开展:全量NO_NEED_CONVERT迁移到api_mapping.json+更新官网脚本。
paconvert/api_mapping.json
Outdated
| "Matcher": "GenericMatcher", | ||
| "paddle_api": "paddle.Tensor.log_normal_", | ||
| "kwargs_change": { | ||
| "generator": "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NoNeedConvertMatcher会处理generator、memory_format,可以计作NoNeedConvertMatcher
|
|
||
|
|
||
| def test_case_8(): | ||
| # PaConvert can't tell if args in **kawrgs are supported by paddle or not. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个应该是符合预期的,这个类的init 参数里只有**kwargs,不需要看用户到底传入了些啥参数,PaConvert把它原封不动传进去就行
这个case之前是可以跑通的,针对torchvision.models.inception_v3的转换做了修改吗
这个 case 测试的是当存在不支持的参数时 PaConvert 提示不能转换。torchvision.models.inception_v3 的转换规则做了修改,把 **kargs 直接转给 paddle 对应的类,所以没办法识别出不支持的转换,符合预期,不影响对于参数都支持的情况的转换 |
| "torchvision.models.inception_v3": { | ||
| "Matcher": "WeightsMatcher", | ||
| "paddle_api": "paddle.vision.models.inception_v3", | ||
| "args_list": [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个 API 后面改文档吧?pretrained 参数是弃用的用法,把 weights 放前面更合适
zhwesky2010
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
后面看下这一系列API的重载形式,确定docs和paconvert的最终版本。
| "Matcher": "WeightsMatcher", | ||
| "paddle_api": "paddle.vision.models.inception_v3", | ||
| "args_list": [ | ||
| "weights", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
现在看起来不是前后问题,是overload的问题,可以按torch.std_mean的文档形式来,两个签名要二选一的话,优先适配其中公开推荐的用法。


PR Docs
本 PR 修复差异文档与 PaConvert 中映射规则不一致的问题,具体描述见:PaddlePaddle/docs#7679
PR APIs
Fix validate consistency