Download scripts/train.py from luyingxi35/RoboFAPE: direct link, hf CLI and curl.
- Browser
- Download file 2.88 kB
-
https://huggingface.co/datasets/luyingxi35/RoboFAPE/resolve/main/scripts/train.py
- Command line
-
hf download hf://datasets/luyingxi35/RoboFAPE/scripts/train.py
-
curl -L -o train.py https://huggingface.co/datasets/luyingxi35/RoboFAPE/resolve/main/scripts/train.py
2.88 kB
| """Portable launcher for the frozen Setting A smoke/pilot configuration.""" | |
| import argparse,os,shlex,subprocess,sys | |
| from pathlib import Path | |
| import yaml | |
| def main(): | |
| p=argparse.ArgumentParser() | |
| p.add_argument('--root',type=Path,default=Path(__file__).resolve().parents[1]) | |
| p.add_argument('--robometer-repo',type=Path,required=True) | |
| p.add_argument('--init-checkpoint',type=Path,required=True) | |
| p.add_argument('--output',type=Path,required=True) | |
| p.add_argument('--mode',choices=['smoke','pilot'],default='smoke') | |
| p.add_argument('--num-gpus',type=int,default=4) | |
| p.add_argument('--port',type=int,default=29543) | |
| p.add_argument('--dry-run',action='store_true') | |
| a=p.parse_args();root=a.root.resolve();repo=a.robometer_repo.resolve();output=a.output.resolve() | |
| if output.is_relative_to(root) or root.is_relative_to(output): | |
| p.error('--output must be separate from the release directory') | |
| if a.num_gpus < 1: | |
| p.error('--num-gpus must be positive') | |
| assert (repo/'train.py').is_file(),'Pass the Robometer repository, not its parent repository' | |
| assert (root/'repro/processed/local_RoboFAPE_train/processed_dataset').is_dir() | |
| checkpoint=a.init_checkpoint.resolve() | |
| config=next((p for p in (checkpoint/'config.yaml',checkpoint.parent/'config.yaml') if p.is_file()),None) | |
| if config is None: | |
| p.error('The initialization checkpoint needs its recorded config.yaml') | |
| base_model=yaml.safe_load(config.read_text())['model']['base_model_id'] | |
| if base_model.startswith('/') and not Path(base_model).is_dir(): | |
| p.error('The checkpoint config references an unavailable backbone; prepare a portable checkpoint copy first') | |
| env=dict(os.environ,ROBOMETER_PROCESSED_DATASETS_PATH=str(root/'repro/processed'), | |
| ROBOFAPE_BASE_MODEL=base_model,ROBOFAPE_INIT_CHECKPOINT=str(checkpoint), | |
| ROBOFAPE_TRAIN_OUTPUT=str(output),PYTHONPATH=str(repo),WANDB_MODE='disabled') | |
| steps,save,limit=(10,10,1) if a.mode=='smoke' else (500,50,11) | |
| cmd=[sys.executable,'-m','accelerate.commands.launch','--config_file',str(repo/'robometer/configs/distributed/fsdp.yaml'), | |
| '--num_processes',str(a.num_gpus),'--main_process_port',str(a.port),'train.py', | |
| '--config-path',str(root/'configs'),'--config-name','setting_a_train', | |
| f'training.exp_name=RoboFAPE_train_fsdp_{a.mode}',f'training.max_steps={steps}', | |
| f'training.num_gpus={a.num_gpus}','training.overwrite_output_dir=false', | |
| f'training.save_steps={save}',f'training.save_total_limit={limit}', | |
| 'training.save_only_model='+('false' if a.mode=='smoke' else 'true'),f'logging.save_best.save_every={save}', | |
| 'hydra.run.dir='+str(output/'hydra')] | |
| print(shlex.join(cmd),flush=True) | |
| if not a.dry_run:subprocess.run(cmd,cwd=repo,env=env,check=True) | |
| if __name__=='__main__':main() | |