Skip to content

Add max batch size check #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 11, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 17 additions & 13 deletions src/together/finetune.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,25 +63,29 @@ def create(
n_checkpoints = n_epochs
adjusted_inputs = True

# batch_size used to be 144 for 70b models
if (
model
in [
"togethercomputer/llama-2-70b",
"togethercomputer/llama-2-70b-chat",
]
# and batch_size != 144
):
# batch_size = 144
batch_size = round_to_closest_multiple_of_32(batch_size)
adjusted_inputs = True

# TODO: Replace with mongodb retrieval for max, min, and default batch size
if batch_size is None:
batch_size = 32
elif batch_size < 4:
batch_size = 4
adjusted_inputs = True

max_batch_size = 128
if model.startswith("togethercomputer/llama-2-70b"):
max_batch_size = 64
batch_size = round_to_closest_multiple_of_32(batch_size)
adjusted_inputs = True
elif model.startswith("togethercomputer/CodeLlama-7b"):
max_batch_size = 16
elif model.startswith("togethercomputer/CodeLlama-13b"):
max_batch_size = 8

if batch_size > max_batch_size:
raise ValueError(
f"The max batch size for model {model} is {max_batch_size}. Received batch size {batch_size}."
)
Comment on lines +84 to +86
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@clam004 put in some changes that allow the user to confirm changes to the input. I think for max batch size we can clamp it and set adjusted_inputs = True as we did with other parameters.



# TODO: REMOVE THIS CHECK WHEN WE HAVE CHECKPOINTING WORKING FOR 70B models
if n_checkpoints > 1 and model in [
"togethercomputer/llama-2-70b",
Expand Down