Download code/refined_math/smoke.py from davidheineman/tiny-rl-refined-math-v1: direct link, hf CLI and curl.
- Browser
- Download file 1.59 kB
-
https://huggingface.co/datasets/davidheineman/tiny-rl-refined-math-v1/resolve/main/code/refined_math/smoke.py
- Command line
-
hf download hf://datasets/davidheineman/tiny-rl-refined-math-v1/code/refined_math/smoke.py
-
curl -L -o smoke.py https://huggingface.co/datasets/davidheineman/tiny-rl-refined-math-v1/resolve/main/code/refined_math/smoke.py
1.59 kB
| from dataclasses import dataclass | |
| import gc | |
| import os | |
| from pathlib import Path | |
| import subprocess | |
| from omegaconf import OmegaConf | |
| from rich import print | |
| import torch | |
| from refined_v4.train import Config as TrainConfig, run | |
| from refined_v4.study import model_inventory | |
| from .data import ROOT, TASKS | |
| class Config: | |
| root: str = str(ROOT / 'smoke') | |
| output: str = str(ROOT / 'smoke-flow') | |
| task: str = '' | |
| device: str = 'auto' | |
| def main(config: Config): | |
| base = next(row for row in model_inventory() if row['name'] == '8m') | |
| for task in TASKS: | |
| if config.task and config.task != task: | |
| continue | |
| settings = TrainConfig(task=task, model='8m', root=config.root, | |
| checkpoint=base['checkpoint'], output=str(Path(config.output) / task), | |
| sft_tokens=4096, rl_rollouts=128, samples=32, groups=4, | |
| eval_queries=16, eval_samples=2, interval=128, recovery_interval=128, | |
| workers=2, threads=2, wandb_mode='disabled', smoke=True, device=config.device) | |
| if not run(settings): | |
| if os.environ.get('SLURM_JOB_ID'): | |
| subprocess.run(['scontrol', 'requeue', os.environ['SLURM_JOB_ID']], check=True) | |
| return | |
| raise RuntimeError('Smoke training interrupted') | |
| print(f'[green]{task}: real SFT + RL smoke complete[/green]') | |
| gc.collect() | |
| if torch.cuda.is_available(): | |
| torch.cuda.empty_cache() | |
| if __name__ == '__main__': | |
| main(OmegaConf.to_object(OmegaConf.merge(OmegaConf.structured(Config), OmegaConf.from_cli()))) | |