GpuTrainer に forward-only モードを追加し --eval-only の device memory を削減 - #408
Merged
Merged
Conversation
…mory を削減 forward + loss (validate) しか使わない --eval-only が学習構成と同じ optimizer state (m/v/slow)・全 *_grad・backward workspace を確保しており、 大 batch の評価が 12GB 級 GPU で out of memory になっていた。 - GpuTrainer::new_forward_only を追加: optimizer state / grad / backward 専用 workspace (activation-grad・inverse-index scratch・sorted-grad) を 0-byte で確保する (tf32 off の dcombined_from_l1_sorted と同じ手法) - forward-only では step / save_raw_checkpoint を明示エラーで拒否し、 load_layerstack_weights / load_raw_checkpoint は optimizer state の 確保・upload を行わない (weight のみ載せる) - --eval-only は forward-only trainer で構築する - テスト: 同一重み・同一 batch で学習 trainer の validate と bit 一致、 学習 trainer が書いた ckpt からの resume validate の bit 一致、 step / save_raw_checkpoint の拒否 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- 量子化 .bin を --init-from 相当で読み込んだ forward-only trainer の validate が 学習 trainer と bit 一致することを GPU テストで固定 (--eval-only --init-from の 本命経路。量子化往復を含む実 .bin を save_checkpoint で生成して使う) - step 拒否エラーメッセージ内の連続空白を除去 - new_forward_only の削減量コメントを正確化 (m/v/slow/grad の companion 4 本、 --fp16-opt-state 時は f32 換算 3 本分) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This was referenced Sep 5, 2026
Merged
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.
概要
GpuTrainerに forward-only モードを追加する。forward + loss (validate) しか使わない--eval-onlyが学習構成と同じ optimizer state (m/v/slow)・全*_grad・backward workspace を確保しており、大 batch の評価が 12GB 級 GPU で out of memory になっていた。GPU リスコア基盤 (PSV pool の 1-node 静的評価リラベル) の土台でもある。変更内容
GpuTrainer::new_forward_only: optimizer state / grad / backward 専用 workspace (activation-grad・inverse-index scratch・sorted-grad・f16 backward halves) を 0-byte で確保する (tf32 off のdcombined_from_l1_sortedと同じ dead-allocation 回避手法)。struct 形状と forward / loss 経路の数値は不変step/save_raw_checkpointを明示エラーで拒否load_layerstack_weights/load_raw_checkpointは forward-only 時に optimizer state の確保・upload を行わない (weight のみ載せる)。特に--init-fromが m/v/grad をフル長で再確保して省メモリを無効化する経路を塞いだ--eval-onlyは forward-only trainer で構築する実測 (RTX 3080 Ti, 12GB)
前回 OOM だった構成 (
--eval-only --batch-size 65536× LayerStack 3072x16x32 halfka-hm-merged) が完走:再現:
テスト
forward_only_validate_matches_training_trainer: 同一重み・同一 batch で学習 trainer のvalidateと bit 一致 (loss + net_output)、step/save_raw_checkpointの拒否forward_only_resumes_raw_checkpoint_for_validate: 学習 trainer が書いた.ckptからの resume validate が bit 一致 (--eval-only --resume経路)forward_only_init_from_quantised_bin_matches_training_trainer: 量子化.bin(量子化往復込み) を--init-from相当で読んだ validate が bit 一致 (--eval-only --init-from経路)既知の未カバー分岐: forward-only の bit 一致検証は FP32 / HalfKP / base 構成のみで、
--ft-fp16(-out)/ threat / FT factorizer / PSQT / stack-shared-delta との組合せは 0-byte 化の対象ではあるが GPU テスト未カバー (これらの構成を forward-only で使う場合は追加検証が要る)。検証記録
bash scripts/local-ci.shフル PASS ×2 回 (aa29b99 時点 / 470f8ad 時点、GPU テスト含む全 step)cargo fmt --check/cargo clippy --workspace --all-targets -- -D warnings/ CPU テスト green🤖 Generated with Claude Code