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

[tune] Update pbt_transformers example #40125

Closed
wants to merge 1 commit into from
Closed
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
13 changes: 5 additions & 8 deletions python/ray/tune/examples/pbt_transformers/pbt_transformers.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,17 @@ def get_model():
)

tune_config = {
"per_device_train_batch_size": 32,
"per_device_train_batch_size": tune.choice([16, 32, 64]),
"per_device_eval_batch_size": 32,
"num_train_epochs": tune.choice([2, 3, 4, 5]),
"max_steps": 1 if smoke_test else -1, # Used for smoke test.
"num_train_epochs": 2 if smoke_test else tune.choice([2, 3, 4, 5]),
}

scheduler = PopulationBasedTraining(
time_attr="training_iteration",
metric="eval_acc",
mode="max",
perturbation_interval=1,
synch=True,
Copy link
Contributor

Choose a reason for hiding this comment

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

We could also pass this as a **kwargs parameter so that the regular example has sync=False - happy either way

hyperparam_mutations={
"weight_decay": tune.uniform(0.0, 0.3),
"learning_rate": tune.uniform(1e-5, 5e-5),
Expand All @@ -137,14 +137,11 @@ def get_model():
resources_per_trial={"cpu": 1, "gpu": gpus_per_trial},
scheduler=scheduler,
checkpoint_config=CheckpointConfig(
num_to_keep=1,
num_to_keep=3,
checkpoint_score_attribute="training_iteration",
),
stop={"training_iteration": 1} if smoke_test else None,
progress_reporter=reporter,
local_dir="~/ray_results/",
name="tune_transformer_pbt",
log_to_file=True,
)


Expand All @@ -158,7 +155,7 @@ def get_model():
args, _ = parser.parse_known_args()

if args.smoke_test:
tune_transformer(num_samples=1, gpus_per_trial=0, smoke_test=True)
tune_transformer(num_samples=2, gpus_per_trial=0, smoke_test=True)
else:
# You can change the number of GPUs here:
tune_transformer(num_samples=8, gpus_per_trial=1)