LocalBackend/Unsloth: gradient_accumulation_steps > 1 hangs the trainer (producer waits for one result per sequence)
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 15/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- python
- Lĩnh vực
- machine-learning
Hướng nghiên cứu
The hang is in the producer loop of run_unsloth_rl_training in art/unsloth/train.py, which pairs each inputs_queue put with a results_queue get, and in _async_prepare_inputs. Read how gradient_accumulation_steps reaches the trainer through TrainerArgs, then reproduce with gradient_accumulation_steps=2 to confirm the deadlock. Done means either the step runs to completion or a clear error is raised up front, and the loss weighting question in loss.py has a maintainer decision.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Versions: openpipe-art 0.5.20 (LocalBackend, Unsloth service), unsloth 2026.3.3, ART's managed vLLM runtime 0.25.1, one GPU.
What happens: with trainer_args=art.dev.TrainerArgs(per_device_train_batch_size=1, gradient_accumulation_steps=2) the first backend.train(...) call never returns. The GPU is idle; py-spy shows the trainer thread waiting for its next input in _async_prepare_inputs (inputs_queue.get()), while run_unsloth_rl_training waits for a result.
Why (as far as I can tell from art/unsloth/train.py): run_unsloth_rl_training puts one packed sequence into inputs_queue and then awaits one item from results_queue before it puts the next sequence. A result is only produced after an optimizer step. With gradient_accumulation_steps=k > 1 the Hugging Face trainer needs k inputs before it steps, so after the first input both sides wait for each other.
So gradient_accumulation_steps is accepted through TrainerArgs but cannot work with this producer loop. If it is not meant to be supported, a clear error would help.
Why it matters for long rollouts: with agent rollouts of 10-25K tokens, every trajectory fills its own packed row, and with per_device_train_batch_size=1 (memory) every trajectory becomes its own optimizer step: 32 Adam updates per train() call for 4 groups x 8 rollouts, each seeing a single trajectory with a positive or negative advantage, instead of one update over the group.
A possible fix: in run_unsloth_rl_training, put gradient_accumulation_steps sequences into the queue before awaiting one result, and pad the last batch of a step with zero-weight rows (or raise if the row count is not a multiple).
Related observation: the loss multiplies each token by weights = 1 / (trained tokens of its trajectory) and then divides by assistant_mask.sum() of the row (loss.py, policy_loss * weights * assistant_mask, then / denominator). With several trajectories per row this gives every trajectory equal weight, but with one trajectory per row its loss is effectively divided by its length twice, so long trajectories get smaller gradients than short ones. Not necessarily a bug, but it surprised me.
Happy to send a PR for the producer loop if that is the direction you prefer.
- Ngôn ngữ chính
- Python
- Star
- 10.8k
- Fork
- 1k
- Merge trung bình
- 16 giờ 14 phút
- Pull request đã merge (30 ngày)
- 148
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của OpenPipe/ART
-
Distributed group_mean casts group ids to float32, losing precision vs non-distributed pathCó thể đã có người làm @OnePunchMonk đã nhận 16 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Add from_entity parameter to _experimental_fork_checkpointCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Tracking: numerical issues found in an audit of ART main after #1105Có thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 15/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Nonfused column LoRA misses input-gradient SUM when TP>1 and sequence parallelism is disabledCó thể đã có người làm @bradhilton đã nhận 17 ngày trước. Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 54/100
OpenPipe/ART#961 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Issue tương tự
-
wr.dynamodb.read_items returns [{}] for a single partition value that does not existCó thể đã có người làm @auraseb đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
aws/aws-sdk-pandas#3520 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
requires triage typing
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
sqlalchemy/sqlalchemy#13704 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Edit tool converts CRLF files to LFCó thể đã có người làm @RaphaelFakhri đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
huggingface/tau#774 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
show ignores the row limit when a column or table name contains "limit"Có thể đã có người làm @RaphaelFakhri đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
What happened to `check.py`?Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
linebender/resvg#1179 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày