feat: add tinker API support - #1
Open
GavinZhu-GMI wants to merge 10 commits into
Open
Conversation
Signed-off-by: Gavin.Zhu <gavin.z@gmicloud.ai>
Signed-off-by: Gavin.Zhu <gavin.z@gmicloud.ai>
Signed-off-by: Gavin.Zhu <gavin.z@gmicloud.ai>
Signed-off-by: Gavin.Zhu <gavin.z@gmicloud.ai>
Signed-off-by: Gavin.Zhu <gavin.z@gmicloud.ai>
Signed-off-by: Gavin.Zhu <gavin.z@gmicloud.ai>
Signed-off-by: Gavin.Zhu <gavin.z@gmicloud.ai>
Add dynamic batch size handling to support variable-sized training requests
from external services (e.g., tinker-cookbook) while preserving gradient
accumulation semantics.
**Problem:**
Slime was designed for standalone training with fixed batch sizes configured
at initialization. When used as a backend service, clients send variable
batch sizes per request, causing mismatches between configured and actual
batch sizes.
**Solution:**
1. data.py (lines 181-198):
- Detect when actual batch size differs from configured global_batch_size
- Small batches (≤ target): Process in 1 step without gradient accumulation
- Large batches (> target): Enable multi-step gradient accumulation
- Pass _actual_global_batch_size to loss.py for correct loss scaling
2. loss.py (lines 524-529):
- Use actual batch size for loss scaling instead of configured value
- Prevents incorrect gradient magnitudes when batch sizes vary
Signed-off-by: Gavin.Zhu <gavin.z@gmicloud.ai>
Signed-off-by: Gavin.Zhu <gavin.z@gmicloud.ai>
…ients and returning logprobs per sample Signed-off-by: Gavin.Zhu <gavin.z@gmicloud.ai>
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.
No description provided.