trajectory_group_batches leaves started rollouts running after close, error or cancellation
维护者通常 1 天内回复
评估
调研方向
Read src/art/batches.py and the assumptions in test_batches_completion_bursts.py. Reproduce the iterator-close case with the supplied asyncio example, then examine cleanup when the generator exits, including error and cancellation paths. Done means started tasks are cancelled and awaited, completed task exceptions are retrieved, and batching, ordering, exception-budget behavior, and ownership of unstarted coroutines remain as described; an open linked pull request already addresses this issue.
由索引模型根据 Issue 内容生成。
描述
art.trajectory_group_batches starts rollouts as asyncio tasks, but it never cancels or awaits them when it stops early. Three ordinary exits leave started rollouts running with no owner:
- the training loop closes the iterator (
breakout ofasync for, oraclose()), - a rollout raises past
max_batch_exceptions, - the task consuming the iterator is cancelled.
The orphaned rollouts keep calling the inference server and stepping environments after the training loop has stopped. In a long-lived event loop (a notebook or a server), nothing cleans them up until they finish on their own.
Reproduced on main at 5f0c1fb, Python 3.12. No model or service needed:
import asyncio
import art
async def main():
entered, release = asyncio.Event(), asyncio.Event()
effects = []
async def slow_rollout():
entered.set()
await release.wait()
effects.append("finished after iterator close")
return art.TrajectoryGroup([art.Trajectory(reward=1)])
async def first_rollout():
await entered.wait()
return art.TrajectoryGroup([art.Trajectory(reward=0)])
batches = art.trajectory_group_batches(
[first_rollout(), slow_rollout()],
batch_size=1, max_concurrent_batches=2, pbar_desc=None,
)
await anext(batches)
await batches.aclose()
release.set()
await asyncio.sleep(0.1)
print(effects)
asyncio.run(main())
Output: ['finished after iterator close']. Expected: []. After aclose() returns, the second rollout should already be cancelled.
There is a related leak on the error path. When several tasks finish in the same asyncio.wait, task.result() raises on the first failure. The other failed tasks in done are never read, so asyncio logs Task exception was never retrieved for each.
Cause: src/art/batches.py keeps the started tasks in pending and has no try/finally around the loop.
Expected fix: on any exit, cancel and await the tasks the generator started, and retrieve the exceptions of tasks that already finished. Coroutines that were never started stay owned by the caller, as test_batches_completion_bursts.py already assumes. Batching, ordering and exception-budget semantics stay the same. #969 changes the exception budget, not cleanup, so it doesn't overlap.
- 主要语言
- Python
- 星标
- 10.8k
- 派生
- 1k
- 平均合并
- 12 小时 33 分钟
- 30 天内合并 PR
- 126
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
OpenPipe/ART 的其他 Issue
-
gather_trajectory_groups / gather_trajectories leave sibling rollouts running after a failure可能已有人在做 @salma2vec 于 1 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
Distributed group_mean casts group ids to float32, losing precision vs non-distributed path可能已有人在做 @OnePunchMonk 于 20 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
Add from_entity parameter to _experimental_fork_checkpoint可能重新可做 关联的 PR 已关闭且未合并。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
ruler_score_group drops group exceptions, metadata and metrics, and trajectory policy versions可能已有人在做 @salma2vec 于 1 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 35/100
维护者通常 1 天内回复
-
LocalBackend/Unsloth: gradient_accumulation_steps > 1 hangs the trainer (producer waits for one result per sequence)可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 4/5 3-5 天 新手友好度 15/100
维护者通常 1 天内回复
相似的 Issue
-
tests: pin that the atomic writers in utils/paths.py stage the temporary file in the target's directory可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭difficulty:2 enhancement good first issue
难度 1/5 1-3 小时 新手友好度 92/100
MakazhanAlpamys/Soup#2178 ·
维护者通常 1 天内回复
-
Slang input: int8_t4_packed and uint8_t4_packed are copied into CrossGL可能已有人在做 @ninglinLiu 今天认领。 未关闭area:frontend backend:slang bug direction:input
难度 2/5 1-3 小时 新手友好度 70/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 85/100
维护者通常 13 天内回复
-
难度 2/5 1-3 小时 新手友好度 85/100
维护者通常 1 天内回复
-
bug ci good first issue
难度 2/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复