feat: make DEVICE_BATCH_SIZE configurable via env var#138
Open
0xmichalis wants to merge 1 commit intokarpathy:masterfrom
Open
feat: make DEVICE_BATCH_SIZE configurable via env var#1380xmichalis wants to merge 1 commit intokarpathy:masterfrom
0xmichalis wants to merge 1 commit intokarpathy:masterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR makes DEVICE_BATCH_SIZE configurable via an environment variable (DEVICE_BATCH_SIZE), allowing users with smaller GPUs to reduce the per-device batch size without editing source code. Gradient accumulation steps automatically adjust to preserve TOTAL_BATCH_SIZE, as they are computed from DEVICE_BATCH_SIZE at line 496.
Changes:
DEVICE_BATCH_SIZEis now read from the environment usingos.environ.get, falling back to128if unset.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Allow overriding DEVICE_BATCH_SIZE with an environment variable so users with smaller GPUs can reduce it without editing source code, e.g.: DEVICE_BATCH_SIZE=16 uv run train.py grad_accum_steps auto-adjusts to preserve TOTAL_BATCH_SIZE. Co-Authored-By: Claude Opus 4.6 <[email protected]>
cf4fd31 to
5f1a1d6
Compare
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.
Allow overriding DEVICE_BATCH_SIZE with an environment variable so users with smaller GPUs can reduce it without editing source code, e.g.:
grad_accum_steps auto-adjusts to preserve TOTAL_BATCH_SIZE.