已开启
[Refactor] npu.random APIs do not use upstream's '_accelerator_getDefaultGenerator' #4148
dwoai22创建于 25 天前
25 天前 关联了看板:FrameworkPTAdapter 版本issue看板
25 天前 添加了label:triage-review
TorchNPU-Bot
25 天前 评论:
25 天前 评论:
issue待分派,添加triage-review标签


25 天前 关联了pull request:refactor(npu): route RNG generator lookup through the accelerator entry point as upstream does
25 天前 关联了pull request:refactor(npu): route RNG generator lookup through the accelerator entry point as upstream does
25 天前 issue状态由 TODO 改变为 WIP
25 天前 添加了label:bot-triaged;删除了label:triage-review
TorchNPU-Bot
25 天前 评论:
25 天前 评论:
检测到当前 issue 已关联 PR !44830,自动添加标签:bot-triaged


14 天前 关闭了 issue
14 天前 添加了label:resolved
2 天前 issue状态由 WIP 改变为 ACCEPTED
2 天前 重新打开了 issue
2 天前 关联了pull request:fix: add set_rng_state,get_rng_state to transfer_to_npu to solve downstream error
2 天前 关联了pull request:fix: add set_rng_state,get_rng_state to transfer_to_npu to solve downstream error
ascend-robot
2 天前 评论:
2 天前 评论:
您好,当前Issue标记为resolved且有一段时间未进一步更新,因此我们将其标记为'stale'(闲置)状态。若您认为这是误操作,可通过添加任意评论来去除'stale'标签。标记为stale的Issue在4天内无更新活动将自动关闭。


2 天前 添加了label:stale
【背景】
torch_npu目前通过 NPU 专属的torch.npu.default_generators元组管理随机数Generator,该实现是
torch/cuda/random.py的 1:1 移植。上游已通过torch._C._accelerator_getDefaultGenerator提供跨后端统一的 Generator 获取入口,NPU 的 Generator 也已经由
NPUHooksInterface注册进 accelerator 框架,只是 Python侧尚未使用该入口。
两套机制并存导致:上游 random 逻辑变更时 NPU 侧需同步跟进,且自建的
default_generators与 accelerator 的统一管理机制重复。【目标】
与上游对齐,将
torch_npu内部获取 Generator 的路径收敛到 accelerator 统一入口。本 issue 覆盖 Phase 1,仅切换内部实现,对外 API 的签名与行为均不变化。完整的分阶段
方案见 random_patch_reduction_rfc.md`,Phase 2、Phase 3 另行提单跟踪。
【依赖】
#44025(已合入)修复了
NPUHooksInterface::getDefaultGenerator未覆写基类虚函数的问题;在其之前
_accelerator_getDefaultGenerator在 NPU 上不可用(见 #3809)。