Skip to content
Open
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
44 changes: 44 additions & 0 deletions swe-paddle/tasks/PaddlePaddle__Paddle-79197/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# PaddlePaddle__Paddle-79197

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

## Source

| Field | Value |
| --- | --- |
| Repo | `PaddlePaddle/Paddle` |
| PR | [79197](https://github.com/PaddlePaddle/Paddle/pull/79197) |
| PR title | `[API Compatibility] Support param optimizer for lr_scheduler` |
| Base commit | `06d8af53d39ef6622689bab27e1cd03a2ffab0f3` |
| Merged at | `2026-06-08T06:44:24Z` |
| Task type | `feature_enhancement` |
| Resource | CPU |

## Summary

Allow commonly used learning-rate schedulers to accept an existing optimizer directly and automatically associate themselves with that optimizer, while preserving the existing `learning_rate` calling convention.

## Why This Is A Good SWE-Paddle Candidate

* The issue reflects a common scheduler API mismatch encountered when migrating training code, with clear trigger conditions and expected behavior.
* The change covers shared argument-handling logic used by multiple schedulers and cannot be solved through a one-off special case.
* The source PR provides real tests covering positional and keyword arguments, learning-rate updates, and the association between schedulers and optimizers.
* The tests run on CPU without external datasets, network access, or distributed devices.

## Files

- `proposal.md`: candidate proposal for maintainer triage.
- `instruction.md`: self-contained problem statement for the coding agent.
- `solution/code.patch`: production-only gold patch from the merged PR.
- `tests/test.patch`: exact upstream diff for `test/legacy_test/test_lr_scheduler.py`.
- `tests/test.sh`: minimal target test command.
- `environment/README.md`: environment notes for reproduction.
- `README.md`: task overview and verification entrypoint.

## Verification

```bash
bash tests/test.sh
```

Expected behavior: applying `tests/test.patch` to `base_commit` should fail when schedulers receive an optimizer; applying both `tests/test.patch` and `solution/code.patch` should pass the complete upstream test file.
27 changes: 27 additions & 0 deletions swe-paddle/tasks/PaddlePaddle__Paddle-79197/environment/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Environment Notes

This candidate is part of the SWE-Paddle community task set.

## Expected Environment

- Repository: `PaddlePaddle/Paddle`
- Base commit: `06d8af53d39ef6622689bab27e1cd03a2ffab0f3`
- Resource: CPU
- GPU required: no
- Build path: Python-only runtime overlay; no Paddle source build is required when a compatible Paddle wheel is available.

## Run Order

1. Check out `PaddlePaddle/Paddle` at the base commit.
2. Apply `tests/test.patch`.
3. Run `bash tests/test.sh`; the target behavior should fail before the fix.
4. Apply `solution/code.patch`.
5. Run `bash tests/test.sh` again; the target behavior should pass after the gold patch.

## Minimal Test Command

```bash
bash tests/test.sh
```

The verifier is responsible for deriving stable F2P and P2P node IDs from repeated runs.
22 changes: 22 additions & 0 deletions swe-paddle/tasks/PaddlePaddle__Paddle-79197/instruction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# 让 learning-rate scheduler 可以直接接收 optimizer

## 详细描述

很多训练代码会先创建 optimizer,再把这个 optimizer 传给 learning-rate scheduler。这样 scheduler 可以直接使用 optimizer 当前的学习率,并在后续训练中负责更新它。

目前 Paddle 的常用 scheduler 只接受一个数值形式的 `learning_rate`。开发者把 optimizer 作为位置参数或使用 `optimizer=` 传入时,会收到参数类型错误或不支持该参数的报错。即使手动取出学习率创建 scheduler,还需要额外处理 optimizer 和 scheduler 的关联,迁移代码比较麻烦。

需要让常用 scheduler 同时支持两种写法:继续接受原来的数值学习率,也可以直接接受已经创建好的 optimizer。使用 optimizer 创建 scheduler 后,scheduler 应从 optimizer 取得初始学习率,并由 optimizer 在训练过程中使用。

## 验收说明

- 常用 scheduler 可以通过位置参数或 `optimizer=` 接收已有 optimizer,并使用它当前的学习率。
- 创建完成后,optimizer 应使用这个 scheduler;调用 `step()` 时,学习率仍按各 scheduler 原有规则变化。
- 原有的 `learning_rate` 数值调用方式和计算结果保持不变。
- 同时传入 `learning_rate` 和 `optimizer` 时,应给出清楚的参数冲突错误。

## 技术要求

- 熟悉 PaddlePaddle optimizer 和 learning-rate scheduler 的使用方式。
- 熟悉 Python 函数的位置参数、关键字参数和参数校验。
- 能够验证 scheduler 与 optimizer 的关联以及学习率变化结果。
56 changes: 56 additions & 0 deletions swe-paddle/tasks/PaddlePaddle__Paddle-79197/proposal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Task Proposal: PaddlePaddle__Paddle-79197

## 1. 来源信息

- Instance ID:`PaddlePaddle__Paddle-79197`
- PR 链接:https://github.com/PaddlePaddle/Paddle/pull/79197
- PR 标题:`[API Compatibility] Support param optimizer for lr_scheduler`
- `base_commit`:`06d8af53d39ef6622689bab27e1cd03a2ffab0f3`
- merged 时间:`2026-06-08T06:44:24Z`
- 你的身份:熟悉该模块的 contributor
- 后续联系人:TBD

## 2. 问题一句话

常用 learning-rate scheduler 只能接收数值学习率,不能直接接收已经创建好的 optimizer,导致兼容写法报错且无法自动关联二者。

## 3. 为什么适合作为 SWE-Paddle 样本

- **真实性**:训练代码迁移时,先创建 optimizer、再把 optimizer 交给 scheduler 是常见写法。
- **代表性**:任务涉及多个 scheduler 的一致参数行为,以及 scheduler 与 optimizer 的状态关联。
- **边界清楚**:只调整 learning-rate scheduler 的初始化兼容性,不修改优化算法、算子或训练结果计算。
- **非平凡性**:需要同时支持位置参数和关键字参数,处理冲突输入,并确保各 scheduler 的学习率曲线不变。
- **环境友好性**:来源 PR 单测使用小型 CPU 网络和本地随机输入,不依赖 GPU、外部数据或网络。

## 4. 任务类型和标签

- 任务类型:`feature_enhancement`
- 执行后端:`cpu`
- 设备范围:`cpu_only`
- 模块标签:`[optimizer, lr-scheduler, api-compatibility]`

## 5. 验证思路

- 目标测试命令:`bash tests/test.sh`
- 目标测试文件:`test/legacy_test/test_lr_scheduler.py`
- 修复前预期:新增的 optimizer 参数测试失败;已有 `learning_rate` 调用测试通过。
- 修复后预期:optimizer 可通过位置参数或关键字参数传入,scheduler 使用 optimizer 当前学习率并被 optimizer 持有,PR 新增的六个目标用例与已有 regression case 全部通过。
- P2P 候选:`TestCosineAnnealingWarmRestarts::test_CosineRestartsLR`
- F2P 候选:`test_exponential_decay`、`test_cosine_annealing_decay`、`test_cosine_annealing_warm_restarts`、`test_multi_step_decay`、`test_reduce_on_plateau`、`test_step_decay`

## 6. 环境与资源

- 资源需求:CPU
- Paddle 来源:`PaddlePaddle/Paddle` source checkout at `base_commit`
- 是否能提供 Docker:暂无
- patch 类型:Python-only
- 环境建议:使用兼容的已安装 Paddle wheel 承载运行时,由 verifier 覆盖 checkout 中两个精确 Python production files。
- 最小测试命令:`bash tests/test.sh`
- 是否有 oracle 日志:由 SWE-Paddle verifier 结果另行维护

## 7. 风险自查

- 泄露风险:instruction 只描述开发者遇到的调用问题和期望行为,不说明 Gold patch 的具体实现方式。
- 环境风险:测试会进行小规模 CPU 前向、反向和 optimizer step,需要已安装 Paddle,但无需源码编译。
- flaky 风险:上游测试不使用网络、并发、外部数据集或随机时序,只验证确定的学习率序列和对象关联。
- 拆分风险:所有变更共同解决 scheduler 接收 optimizer 的兼容调用问题,没有混入其他功能。
Loading