Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

trajectory_group_batches leaves started rollouts running after close, error or cancellation

Đang mở
#1,140 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@salma2vec đang làm issue này rồi.

Từ ngày 22/10/2026.

  • #1141 của @salma2vec — đang mở

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
25/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
backend

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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 (break out of async for, or aclose()),
  • 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.

Ngôn ngữ chính
Python
Star
10.8k
Fork
1k
Merge trung bình
12 giờ 33 phút
Pull request đã merge (30 ngày)
126

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của OpenPipe/ART

Tất cả issue của OpenPipe/ART

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.