Repository navigation
Critic FP32 masters: one gather buffer per leaf; single-rank DP gathers on the CPU (CompactionRL G3 OOM) - #226
Merged
Conversation
…gathers on the CPU s19-compaction-g3-20261010a (CompactionRL, two islands, strict-avg): after round 0 the actor was still resident on the GPU (16k-token segments) when the critic woke for export_critic_tensors; full_masters built a FP32 copy per parameter on the GPU and then a second torch.cat copy (2 x 3.25 GiB) -> CUDA OOM with 1.46 GiB free, CrossChannelCommitError, island 0 exited. * full_masters: one flat FP32 buffer per optimizer leaf, each master a view of it (no concatenated copy); optional device for the buffers. * _critic_masters: when torch.distributed is up and every DP group has one rank (no collective needed), gather on the CPU: export/import no longer need a full FP32 critic copy on the GPU. Multi-rank groups keep the GPU buffer + all-reduce; a CPU buffer with a multi-rank group is refused. * _write_critic_masters: targets stay on their device (copy_ moves them); the stale-parameter check casts each master to the parameter's device. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
s19-compaction-g3-20261010a(CompactionRL G3,两岛 strict-avg,Qwen3.5-0.8B,16k 序列)失败:export_critic_tensors → _critic_masters → full_masters中 CUDA OOM:要分配 3.25 GiB,整卡只剩 1.46 GiB。根因
full_masters先为每个参数在 GPU 上建一份 fp32 全量张量,再用torch.cat拼出第二份,峰值约 2×3.25 GiB。为什么之前没出问题:
改动
full_masters:每个优化器叶子只分配一个扁平 fp32 缓冲区,各主权重是它的视图,不再有拼接副本;新增可选参数device。_critic_masters:torch.distributed 已初始化且每个 DP 组只有 1 个 rank 时,在 CPU 上拼,不做集合通信。多 rank 组保持 GPU 缓冲区 + all-reduce;CPU 缓冲区遇到多 rank 组时拒绝执行。_write_critic_masters:targets 不再整体搬上 GPU,由 copy_ 逐个搬。stale 检查改为先把主权重转到参数所在设备再比较。子 agent 代拍板 + 理由:只改 yeto 插件,不改 Miles 的 sleep 顺序。理由是最少改动,且对 DP>1 的行为不变。
测试
test_single_rank_dp_gathers_on_cpu_in_one_buffer,检查三点:一个缓冲区、不调用集合通信、CPU 上 export/import 往返哈希一致。test_delta_protocol的 12 个报错在 main 上同样存在,与本改动无关。scripts/precommit_check.pyrc=0。🤖 Generated with Claude Code