Fix: add **kwargs to _named_members for PyTorch 2.6+ compatibility #86
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.
Checklist / 检查清单
core_torch.py, no impact on TF / 修改仅涉及 PyTorch 后端,不影响 TF)Motivation and Context / 动机与背景
PyTorch 2.6+ introduces a new argument
remove_duplicateinnamed_parameters, which causes a crash in the current TLX implementation.PyTorch 2.6+ 在
named_parameters中引入了新参数remove_duplicate,导致当前 TLX 实现崩溃。TypeErrorcrash on PyTorch 2.6/2.7+.原因: 修复了 PyTorch 2.6/2.7+ 环境下的
TypeError报错。测试: 已在本地使用 PyTorch 2.7 和 GammaGL 训练脚本(Cora 数据集)验证通过。
Description / 描述
This PR adds
**kwargsto the_named_membersmethod intensorlayerx/nn/core/core_torch.py.本 PR 在
tensorlayerx/nn/core/core_torch.py的_named_members方法中添加了**kwargs。This allows the method to accept and ignore future arguments (like
remove_duplicate) gracefully, ensuring forward compatibility with newer PyTorch versions.这使得该方法能够优雅地接收并忽略未来的新参数(如
remove_duplicate),从而确保与新版 PyTorch 的向前兼容性。