-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow parsing trainer options with additional gradient cuts (#23)
* Add options to cut bptt and diverted chain * Add test for parsing the new options
- Loading branch information
Showing
2 changed files
with
80 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import apebench | ||
|
||
|
||
def test_trainer_parsing(): | ||
advection_scenario = apebench.scenarios.difficulty.Advection() | ||
|
||
trainer = advection_scenario.get_trainer( | ||
train_config="one", | ||
) | ||
|
||
assert trainer.loss_configuration.num_rollout_steps == 1 | ||
del trainer | ||
|
||
trainer = advection_scenario.get_trainer(train_config="sup;3") | ||
|
||
assert trainer.loss_configuration.num_rollout_steps == 3 | ||
assert trainer.loss_configuration.cut_bptt is False | ||
del trainer | ||
|
||
trainer = advection_scenario.get_trainer(train_config="sup;3;True") | ||
|
||
assert trainer.loss_configuration.num_rollout_steps == 3 | ||
assert trainer.loss_configuration.cut_bptt is True | ||
del trainer | ||
|
||
trainer = advection_scenario.get_trainer(train_config="sup;3;False") | ||
|
||
assert trainer.loss_configuration.num_rollout_steps == 3 | ||
assert trainer.loss_configuration.cut_bptt is False | ||
del trainer | ||
|
||
trainer = advection_scenario.get_trainer(train_config="div;3") | ||
|
||
assert trainer.loss_configuration.num_rollout_steps == 3 | ||
assert trainer.loss_configuration.cut_bptt is False | ||
assert trainer.loss_configuration.cut_div_chain is False | ||
del trainer | ||
|
||
trainer = advection_scenario.get_trainer(train_config="div;3;True") | ||
|
||
assert trainer.loss_configuration.num_rollout_steps == 3 | ||
assert trainer.loss_configuration.cut_bptt is True | ||
assert trainer.loss_configuration.cut_div_chain is False | ||
del trainer | ||
|
||
trainer = advection_scenario.get_trainer(train_config="div;3;False") | ||
|
||
assert trainer.loss_configuration.num_rollout_steps == 3 | ||
assert trainer.loss_configuration.cut_bptt is False | ||
assert trainer.loss_configuration.cut_div_chain is False | ||
del trainer | ||
|
||
trainer = advection_scenario.get_trainer(train_config="div;3;True;True") | ||
|
||
assert trainer.loss_configuration.num_rollout_steps == 3 | ||
assert trainer.loss_configuration.cut_bptt is True | ||
assert trainer.loss_configuration.cut_div_chain is True | ||
del trainer | ||
|
||
trainer = advection_scenario.get_trainer(train_config="div;3;False;True") | ||
|
||
assert trainer.loss_configuration.num_rollout_steps == 3 | ||
assert trainer.loss_configuration.cut_bptt is False | ||
assert trainer.loss_configuration.cut_div_chain is True | ||
del trainer |