Skip to content
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

Make sure do_eval works without do_train #100

Merged
merged 2 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion ultravox/training/configs/meta_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ max_audio_duration_secs: 16

val_num_samples: 64
val_steps: 1000
eval_num_samples: 1024
eval_num_samples: 2000
eval_max_new_tokens: 32
eval_num_procs: 16

Expand Down
25 changes: 13 additions & 12 deletions ultravox/training/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ def main() -> None:
local_rank = int(os.environ.get("LOCAL_RANK", 0))
is_master = local_rank == 0

if args.do_train:
train(args)
train(args)

if args.do_eval and is_master:
gc.collect()
Expand Down Expand Up @@ -296,22 +295,24 @@ def train(args: config_base.TrainConfig):
),
)

# Training loop
logging.info("Starting training...")
t_start = datetime.now()
logging.info(f"train start time: {t_start}")
if args.val_steps:
trainer.evaluate()
trainer.train()
if args.do_train:
# Training loop
logging.info("Starting training...")
t_start = datetime.now()
logging.info(f"train start time: {t_start}")
if args.val_steps:
trainer.evaluate()
trainer.train()
t_end = datetime.now()
logging.info(f"train end time: {t_end}")
logging.info(f"elapsed: {t_end - t_start}")

if is_master:
# Saving the model using pipeline to ensure its code is saved
pipeline = ultravox_pipeline.UltravoxPipeline(
model, tokenizer=text_tokenizer, device=device
)
pipeline.save_pretrained(args.output_dir)
t_end = datetime.now()
logging.info(f"train end time: {t_end}")
logging.info(f"elapsed: {t_end - t_start}")


def evaluate(args: config_base.TrainConfig):
Expand Down
Loading