yuuu94's picture
Standardize Stack Bowls V7 10000 inference release with exact training statistics
0250497 verified
Raw History Blame Contribute Delete
2.62 kB
"""Resolved real-world hyperparameters, shared by model and diagnostic runtime."""
from pathlib import Path
from omegaconf import OmegaConf
R=Path(__file__).resolve().parent
DEFAULT_CONFIG=R/'train_realworld.yaml'
def load_training_config(path=None):
cfg=OmegaConf.load(path or DEFAULT_CONFIG)
a=cfg.framework.action_model;t=cfg.trainer;d=cfg.datasets.vla_data;g=cfg.framework.graph
if cfg.execution.mode!='test_only' or cfg.execution.allow_full_training or not 1<=cfg.execution.max_test_steps<=3:
raise ValueError('Current authorization is parameter testing only, at most three updates')
if (a.action_dim,a.state_dim,a.action_horizon,a.future_action_window_size,a.past_action_window_size)!=(14,14,16,15,0):
raise ValueError('Stack joint14/horizon16 action contract mismatch')
if g.bptt!=1 or g.geometry_input_dim!=4 or g.edge_status_input:raise ValueError('Wrong graph/memory contract')
if t.optimizer.fused or t.optimizer.foreach:raise ValueError('Use the validated non-fused AdamW backend')
if not d.include_state or d.normalization!='train_split_mean_std':raise ValueError('Stack state/normalization contract changed')
if not 0<t.num_warmup_steps<t.max_train_steps:raise ValueError('Invalid training schedule')
batch=int(d.per_device_batch_size)*int(t.gradient_accumulation_steps)*int(cfg.distributed.reference_world_size)
if batch!=int(cfg.distributed.reference_global_batch_size):raise ValueError('Inconsistent global batch')
return cfg
def zero2_config(cfg,world_size=None,per_device_batch_size=None):
world=int(world_size or cfg.distributed.reference_world_size)
batch=int(per_device_batch_size or cfg.datasets.vla_data.per_device_batch_size)
accum=int(cfg.trainer.gradient_accumulation_steps)
if min(world,batch,accum)<1:raise ValueError('Invalid runtime batch')
return dict(train_micro_batch_size_per_gpu=batch,train_batch_size=world*batch*accum,
gradient_accumulation_steps=accum,fp16=dict(enabled=False),bf16=dict(enabled=True),
zero_optimization=dict(stage=2,allgather_partitions=True,allgather_bucket_size=50000000,
reduce_scatter=True,reduce_bucket_size=50000000,overlap_comm=False,contiguous_gradients=True),
gradient_clipping=float(cfg.trainer.gradient_clipping),steps_per_print=50)
if __name__=='__main__':
import argparse,json
p=argparse.ArgumentParser();p.add_argument('--config');p.add_argument('--write-zero2',action='store_true');args=p.parse_args()
cfg=load_training_config(args.config);ds=zero2_config(cfg)
if args.write_zero2:(R/'zero2_realworld.json').write_text(json.dumps(ds,indent=2)+'\n')
print(OmegaConf.to_yaml(cfg));print(json.dumps(ds,indent=2))