Co-authored-by: Jiayi_Meng<mengjiayi5@huawei.com> # message auto-generated for no-merge-commit merge: !46841 merge test/dtensor-179203-187933 into master [test] verify NPU DTensor fixes for #179203 and #187933 Created-by: Jiayi_Meng Commit-by: Jiayi_Meng Merged-by: ascend-robot Description: 关联 Issue:[Ascend/pytorch#3815](https://gitcode.com/Ascend/pytorch/issues/3815) # 【合入来源】 - [x] 需求 - 补充社区 PR #179203 和 #187933 对应的 NPU DTensor 回归测试。 - [x] 问题单 - 关联 Issue:[Ascend/pytorch#3815](https://gitcode.com/Ascend/pytorch/issues/3815) - [ ] 重构优化 - [ ] 资料更新 # 【修改方案】 - 在 `test/distributed/tensor/test_math_ops.py` 中: - 增加 `Partial` 和 `SupportedDevices` 导入。 - 增加 `test_nll_loss_weighted_mean_with_even_target_counts`,覆盖输入分片、target/weight 副本场景下的加权 mean NLLLoss。 - 增加 `test_foreach_max_sharded`,校验分片 DTensor 执行 `torch._foreach_max` 后的 `Partial("max")` placement 及完整结果。 - 在 `test/distributed/_tensor/test_init.py` 中: - 从 `torch.distributed.tensor` 导入 `linspace` 和 `logspace`。 - 增加 `test_linspace` 和 `test_logspace`,覆盖 `Replicate()` / `Shard(0)`、默认及显式 dtype、`steps=0/1`、逆序区间、DTensor 标量 start/end 及非法非标量输入。 - `linspace` 显式 dtype 保持 `torch.float64`。 - `logspace` 显式 dtype 使用 `torch.float32`,适配 `aclnnLogSpace` 不支持 `float64` 的限制。 # 【资料变更】 不涉及。 # 【接口变更】 不涉及。本 PR 仅补充测试用例。 # 【功能验证】       # 【CheckList】 > PR 提交人对以下 CheckList 自检项进行全量自检,自检通过或不涉及,均修改 `[ ]` 为 `[x]`。 - [x] 改动仅涉及两个目标测试文件,未引入构建产物或无关文件。 - [x] 新增多卡测试复用现有 NPU DTensor / HCCL 测试框架。 - [x] PR 标题使用 `test` 类型标签。 - [x] 已关联 Issue:[Ascend/pytorch#5037](https://gitcode.com/Ascend/pytorch/issues/5037)。 - [x] 本地差异检查和目标测试验证通过。 - [ ] PR 持续集成流水线执行通过。 See merge request: Ascend/pytorch!46841