| 651 | |
| 652 | |
| 653 | def validate_args(train: TrainArgs, eval: EvalArgs) -> None: |
| 654 | issues = [] |
| 655 | unsupported = [(train, ['max_tokens', 'max_norm', 'tie_embeddings'])] |
| 656 | for args, names in unsupported: |
| 657 | for name in names: |
| 658 | if getattr(args, name) is not None: |
| 659 | issues.append( |
| 660 | f"{__file__} doesn't support the {name!r} argument. This is set in {args}" |
| 661 | ) |
| 662 | required = [(train, ['epochs']), (eval, ['max_new_tokens'])] |
| 663 | for args, names in required: |
| 664 | for name in names: |
| 665 | if getattr(args, name) is None: |
| 666 | issues.append( |
| 667 | f'{__file__} requires the {name!r} argument. This is set in {args}' |
| 668 | ) |
| 669 | if not train.epochs and not train.max_steps: |
| 670 | issues.append( |
| 671 | f'{__file__} requires either epochs or max_steps to be set. This is set in {train}' |
| 672 | ) |
| 673 | if issues: |
| 674 | raise ValueError('\n'.join(issues)) |
| 675 | |
| 676 | |
| 677 | if __name__ == '__main__': |