Skip to content

[API Compatibility] Add param alias for paddle.set_rng_state#79161

Open
algorithm1832 wants to merge 2 commits into
PaddlePaddle:developfrom
algorithm1832:improvement_set_rng_state
Open

[API Compatibility] Add param alias for paddle.set_rng_state#79161
algorithm1832 wants to merge 2 commits into
PaddlePaddle:developfrom
algorithm1832:improvement_set_rng_state

Conversation

@algorithm1832
Copy link
Copy Markdown
Contributor

PR Category

User Experience

PR Types

Improvements

Description

  • Add alias new_state for arg state_list in paddle.set_rng_state
  • Add compatibility test

Used AI Studio

是否引起精度变化

@paddle-bot
Copy link
Copy Markdown

paddle-bot Bot commented May 27, 2026

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@paddle-bot paddle-bot Bot added the contributor External developers label May 27, 2026
Copy link
Copy Markdown

@PaddlePaddle-bot PaddlePaddle-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Paddle-CI-Agent | pr_review | 2026-05-27 10:30:00

📋 Review 摘要

PR 概述:为 paddle.set_rng_statestate_list 参数添加 new_state 别名,以提升与 PyTorch 风格 API 的兼容性。
变更范围python/paddle/framework/random.pytest/legacy_test/test_api_compatibility_part1.py
影响面 Tag[User Experience]

问题

级别 文件 概述
🟡 建议 test/legacy_test/test_api_compatibility_part1.py:2173 测试仅覆盖 happy path,缺少同时传入 state_listnew_state 时应抛出 ValueError 的错误路径验证
📝 PR 规范 标题 Tag [API Compatibility] 不在官方枚举中

📝 PR 规范检查

PR 描述结构(4 个必填 section)完整合规;但标题使用的 [API Compatibility] 不在官方 Tag 枚举中。

标题建议(可直接复制):

  • [User Experience] Add param alias new_state for paddle.set_rng_state

总体评价

实现思路正确,param_one_alias 装饰器正确处理了别名替换和冲突检测,向后兼容。建议补充错误路径测试以增强健壮性,并修正 PR 标题 Tag。

Copy link
Copy Markdown

@PaddlePaddle-bot PaddlePaddle-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Paddle-CI-Agent | pr_review | 2026-05-27 10:30:00

📋 Review 摘要

PR 概述:为 paddle.set_rng_statestate_list 参数添加 new_state 别名,以提升与 PyTorch 风格 API 的兼容性。
变更范围python/paddle/framework/random.pytest/legacy_test/test_api_compatibility_part1.py
影响面 Tag[User Experience]

问题

级别 文件 概述
🟡 建议 test/legacy_test/test_api_compatibility_part1.py:2173 测试仅覆盖 happy path,缺少同时传入 state_listnew_state 时应抛出 ValueError 的错误路径验证
📝 PR 规范 标题 Tag [API Compatibility] 不在官方枚举中

📝 PR 规范检查

PR 描述结构(4 个必填 section)完整合规;但标题使用的 [API Compatibility] 不在官方 Tag 枚举中。

标题建议(可直接复制):

  • [User Experience] Add param alias new_state for paddle.set_rng_state

总体评价

实现思路正确,param_one_alias 装饰器正确处理了别名替换和冲突检测,向后兼容。建议补充错误路径测试以增强健壮性,并修正 PR 标题 Tag。

# 2. paddle-style keyword argument
paddle.set_rng_state(state_list=states)
# 3. torch-style keyword argument
paddle.set_rng_state(new_state=states)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 建议 测试仅覆盖 happy path,缺少对冲突入参场景的错误路径验证。

当用户同时传入 state_listnew_state 时,param_one_alias 装饰器会抛出 ValueError,建议补充测试:

# 4. conflict: both state_list and new_state → should raise ValueError
with self.assertRaises(ValueError):
    paddle.set_rng_state(state_list=states, new_state=states)

Copy link
Copy Markdown

@risemeup1111 risemeup1111 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已完成初始代码审查,未发现需要阻塞合入的问题。当前仍有部分 CI 任务在运行,建议以最终 CI 结果为准。

Powered by Nyanpasu with gpt-5.5 xhigh, please check the suggestions carefully.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor External developers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants