Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions swe-paddle/tasks/PaddlePaddle__Paddle-77064/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# PaddlePaddle__Paddle-77064

This directory converts Paddle PR #77064 into a SWE-Paddle community task candidate.

## Source

| Field | Value |
| --- | --- |
| Repository | `PaddlePaddle/Paddle` |
| PR | [77064](https://github.com/PaddlePaddle/Paddle/pull/77064) |
| PR title | `[API Compatibility] Sink paddle.allclose to cpp -part` |
| Base commit | `1a6a9ab02e12fd792d036dc78b94f46a1371e6fa` |
| Squash commit | `407e3b6931a282a78653d559e675a598153ae977` |
| Merged at | `2025-12-25T11:41:33Z` |
| Task type | `feature_enhancement` |
| Resource | CPU (source build required) |

## Summary

Improve `allclose` API compatibility while preserving its numerical semantics. The public function accepts both its established argument names and the `input`/`other` aliases, the Tensor method accepts `other`, and a compatibility entrypoint returns a Python `bool` rather than a Tensor.

## Why This Task

- It comes from a merged API-compatibility change with deterministic, user-visible behavior.
- It spans a generated public binding, function and Tensor-method aliases, static-graph validation, and a compatibility API.
- It requires preserving two distinct return contracts: a scalar boolean Tensor for the primary API and Python `bool` for the compatibility API.
- The target behavior and regressions are verifiable on CPU with fixed inputs.

## Files

- `proposal.md`: candidate proposal and maintainer review context.
- `instruction.md`: self-contained problem statement for the coding agent.
- `solution/code.patch`: gold patch for six non-test source files.
- `tests/test.patch`: test changes from the merged fix in two test files.
- `tests/test.sh`: F2P tests plus existing allclose regression coverage.
- `environment/README.md`: base revision, source-build path, run order, and risks.

## Verification

From a Paddle source checkout at the base commit, apply `tests/test.patch`, then run the task script while keeping the Paddle checkout as the working directory:

```bash
TASK_DIR=/path/to/community/swe-paddle/tasks/PaddlePaddle__Paddle-77064
bash "$TASK_DIR/tests/test.sh"
```

The alias and compatibility cases should fail before `solution/code.patch` is applied and pass after applying it and rebuilding Paddle. The remaining allclose module provides P2P regression coverage for numerical, input-dtype, tolerance, NaN, dynamic-graph, and static-graph behavior; the merged change intentionally removes obsolete Python-wrapper attribute-type assertions.
52 changes: 52 additions & 0 deletions swe-paddle/tasks/PaddlePaddle__Paddle-77064/environment/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Environment Notes

SWE-Paddle task candidate for PaddlePaddle/Paddle PR #77064.

## Expected Environment

- Repository: `PaddlePaddle/Paddle`
- Base commit: `1a6a9ab02e12fd792d036dc78b94f46a1371e6fa` (first parent of squash commit `407e3b6931a282a78653d559e675a598153ae977`)
- Resource: CPU; CUDA is optional and not required for acceptance.
- Platform: Linux x86_64 with a Python version supported by this revision, CMake, a compatible C++ compiler, NumPy, and pytest.
- Build path: **source build required**. The solution modifies C++ pybind argument preprocessing and API-generation metadata, so a prebuilt wheel or Python-only overlay cannot expose the fixed binding. Rebuild Paddle after applying the solution patch so code generation and C++ compilation run again.

## Verified Author Environment

The original change was built and tested on:

- OS: Windows 11 Home
- CPU/GPU: AMD 9800X3D + NVIDIA RTX 5070 Ti
- Python: 3.12
- CMake: 3.18.6
- Toolchain: Visual Studio 2022
- CUDA / cuDNN: 12.9 / 9.12.0

The target tests require CPU only. On CUDA-enabled builds, the upstream compatibility test also repeats its assertions when CUDA is available, but GPU execution is not an acceptance requirement.

## Run / Test / Fix Order

1. Check out `PaddlePaddle/Paddle` at the base commit.
2. Build Paddle from source and make the built package importable.
3. Apply `tests/test.patch` from this task package (for example, set `TASK_DIR` to this directory).
4. From the Paddle source root, run `bash "$TASK_DIR/tests/test.sh"`. The new function aliases, Tensor-method alias, and compatibility entrypoint should fail or error before the fix; existing regression cases should remain passing.
5. Apply `solution/code.patch`.
6. Rebuild Paddle from source to regenerate and compile the public binding.
7. From the Paddle source root, run `bash "$TASK_DIR/tests/test.sh"` again. All target and regression tests should pass.

## Minimal F2P Command

```bash
python -m pytest \
test/legacy_test/test_allclose_op.py::TestAllcloseAlias \
test/legacy_test/test_compat_allclose.py \
-q
```

`tests/test.sh` intentionally runs the complete existing allclose module as a P2P regression guard in addition to the new compatibility test file.

## Known Risks

- A rebuild is mandatory after the solution patch; otherwise the generated C++ binding remains stale and alias tests can still fail.
- There is no fixed Docker image verified against this historical revision, so maintainers must use an era-compatible source-build toolchain.
- The target tests use fixed small tensors and no external data or network access. CUDA branches are conditional and are not part of the pass requirement.
- The package records the merged fix and its test updates as-is. Verifiers should preserve the Run/Test/Fix order and must not test against an unrelated installed Paddle wheel.
33 changes: 33 additions & 0 deletions swe-paddle/tasks/PaddlePaddle__Paddle-77064/instruction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# 增强 allclose 的 API 兼容性

## 详细描述

完善 Paddle 的 `allclose` 公开接口兼容性,同时保持其现有数值语义和返回类型不变。

需要达成的目标:

- `paddle.allclose` 继续支持位置参数及关键字参数 `x`、`y`,并为第一个和第二个输入分别支持 `input`、`other` 参数别名。
- 原参数名与别名可以混合使用,例如 `input`/`y`、`x`/`other`,结果应与普通位置参数调用一致。
- `paddle.Tensor.allclose` 支持使用 `other` 指定待比较的 Tensor。
- 新增 `paddle.compat.allclose` 兼容入口,其输入参数名为 `input` 和 `other`,并支持 `rtol`、`atol`、`equal_nan` 与 `name`。
- `paddle.allclose` 和 Tensor 方法仍返回标量布尔 Tensor;`paddle.compat.allclose` 返回 Python `bool`。
- 保留现有的容差计算、NaN 处理、支持的数据类型、动态图和静态图行为。

## 验收说明

- 所有参数别名及其混合调用形式结果一致。
- `equal_nan=True` 和 `equal_nan=False` 保持正确语义。
- 接近与不接近的输入均能产生正确结果,且两个公开入口各自满足上述返回类型契约。
- 已有 allclose 数值、输入 Tensor 数据类型和执行模式行为不得回归。
- 不允许通过删除与目标行为无关的测试、弱化相关断言或大范围绕过校验来完成任务。

## 技术要求

- 熟悉 Python 与 C++。
- 了解 Paddle 公开 API、Tensor 方法和静态图执行机制。

## Acceptance Criteria

- The observable behavior described above is implemented.
- Existing valid allclose behavior remains unchanged.
- Do not satisfy the task by deleting unrelated tests, weakening relevant assertions, or broadly bypassing validation.
8 changes: 4 additions & 4 deletions swe-paddle/tasks/PaddlePaddle__Paddle-77064/proposal.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

- **真实性**:问题来自真实的 Paddle API Compatibility 工作,目标是统一 Python/C++ API 行为并提供 PyTorch 风格兼容入口,且 PR 已在 Paddle 主仓库合并。
- **代表性**:样本覆盖 Python API C++ sink、YAML/codegen 参数别名、PIR 静态参数预处理、Tensor method、compat 适配层及返回类型差异,代表 Paddle API 兼容改造的典型链路。
- **边界清楚**:`paddle.allclose` 应继续返回单元素 Tensor,并同时接受 `x`/`y`、`input`/`other` 及测试中的混合关键字组合;Tensor 方法应接受 `other`。`paddle.compat.allclose` 应使用 `input`、`other` 参数并返回 Python `bool`。两者都需要保留 `rtol`、`atol`、`equal_nan`、CPU/可选 CUDA 和原有 dtype 校验语义,普通位置参数调用不得回归。
- **边界清楚**:`paddle.allclose` 应继续返回单元素 Tensor,并同时接受 `x`/`y`、`input`/`other` 及测试中的混合关键字组合;Tensor 方法应接受 `other`。`paddle.compat.allclose` 应使用 `input`、`other` 参数并返回 Python `bool`。两者都需要保留 `rtol`、`atol`、`equal_nan`、CPU/可选 CUDA 和输入 Tensor 的原有 dtype 校验语义,普通位置参数调用不得回归。C++ sink 后不再保留旧 Python wrapper 对布尔容差属性的 TypeError 断言
- **非平凡性**:任务不是简单增加一个 Python 别名。正确修复需要把现有 wrapper 切换到生成的 C++ 绑定,在 API 元数据中建立函数与 Tensor method 的别名映射,在静态路径补齐输入和容差 dtype 预处理,并保证 compat wrapper 的 Python `bool` 契约不改变底层 `paddle.allclose` 的 Tensor 返回契约。

## 4. 任务类型和标签
Expand All @@ -44,7 +44,7 @@

- 修复前预期:在 `base_commit + test_patch` 下,`paddle.allclose(input=..., other=...)` 及混合别名调用会因旧 Python 签名不接受这些关键字而报错,Tensor method 的 `other` 别名也不可用;`paddle.compat` 尚未导出 `allclose`,新增 compat 测试在导入或调用阶段失败。
- 修复后预期:在 `base_commit + test_patch + code_patch` 下,函数 API 的四种别名/原名组合结果一致,Tensor method 可使用 `other`,`equal_nan=True` 保持正确行为;compat API 在 CPU 上对接近和不接近的输入分别返回 Python `True`/`False`,而底层 `paddle.allclose` 继续返回 Tensor,全部目标测试通过。
- P2P 候选:`test/legacy_test/test_allclose_op.py` 中现有 allclose operator、静态/动态图、dtype、FP16、容差和 NaN 测试可作为主要回归护栏,确认 C++ sink 后数值与类型检查没有变化;同模块既有 `isclose` 测试可辅助保护共享 close-family 预处理逻辑。
- P2P 候选:`test/legacy_test/test_allclose_op.py` 中保留的 allclose operator、静态/动态图、输入 dtype、FP16、容差和 NaN 测试可作为主要回归护栏,确认 C++ sink 后数值与输入类型检查没有变化;同模块既有 `isclose` 测试可辅助保护共享 close-family 预处理逻辑。合并补丁删除了仅适用于旧 Python wrapper 的布尔容差属性 TypeError 断言,该断言不属于 P2P

## 6. 环境与资源

Expand All @@ -57,12 +57,12 @@
- 硬件:目标 verifier 使用 CPU 即可;原 PR 验证机器为 9800X3D + RTX 5070Ti,GPU 不是本任务要求
- patch 类型:含 C++ pybind 参数预处理、YAML/codegen 和 Python API/compat wrapper,需要重新编译 Paddle
- 最小测试命令:`python -m pytest test/legacy_test/test_allclose_op.py::TestAllcloseAlias test/legacy_test/test_compat_allclose.py -q`
- 是否有 oracle 日志:无固定 oracle 日志;以既有 allclose 结果、Tensor/Python bool 类型断言、别名一致性和 NaN 行为作为验收依据
- 是否有 oracle 日志:有本地 Run/Test/Fix 实测结果;`base_commit + test_patch` 下 alias 两个用例及 compat 两个测试失败,应用 `code.patch`、重编并重装后,`test_allclose_op.py` 的 21 个测试和 `test_compat_allclose.py` 的 2 个测试均通过

## 7. 风险自查

- 泄露风险:后续 `instruction.md` 只描述公开 API 的可观察签名、返回类型和兼容行为,不包含 source PR、具体文件、内部预处理函数、YAML 映射、diff 结构或实现顺序;proposal 中的实现范围仅供维护组审核
- 环境风险:任务必须在历史 `base_commit` 上完成 Paddle 源码构建,并触发 YAML/codegen 和 pybind C++ 编译,无法通过修改普通已安装 wheel 完成;维护组 verifier 需要固定源码构建配方
- flaky 风险:新增测试使用固定小张量,只断言确定性的 allclose 结果、别名一致性、返回类型和 `equal_nan` 行为,不依赖随机 seed、外部数据、网络服务或多卡同步,预期无明显 flaky 风险
- 拆分风险:PR 同时包含 C++ sink/参数别名和 `paddle.compat.allclose`,但两者共同定义同一 allclose 兼容边界,且 compat 层直接复用下沉后的公开 API。拆分会使一个子任务只验证内部迁移、另一个子任务依赖未纳入范围的别名与底层契约,因此保留为一个样本
- 其他不确定点:当前环境未完成该历史 commit 的 Paddle 源码构建,最终 build flags、生成代码步骤和测试启动方式需由维护组 verifier 确认;CPU 是主验收后端,CUDA 条件分支不作为通过条件
- 其他不确定点:已在 Linux CUDA 构建上完成 Run/Test/Fix 实测,修复前目标 alias/compat 测试失败,应用 code patch 并重编重装后完整目标模块通过;CPU 是主验收后端,CUDA 条件分支不作为通过条件
Loading