from pathlib import Path import sys,os,torch import torch.distributed as dist from torch.nn.parallel import DistributedDataParallel as DDP ROOT=Path(__file__).resolve().parents[1];sys.path.insert(0,str(ROOT)) from model.sfno_bvmc import * c=load_config(ROOT);rank=int(os.environ.get("RANK",0));world=int(os.environ.get("WORLD_SIZE",1));distributed=world>1 if distributed:dist.init_process_group("gloo") torch.manual_seed(c["seed"]);torch.set_num_threads(2);base=CompactSFNO(**c["model"]);m=DDP(base) if distributed else base;opt=torch.optim.Adam(m.parameters(),lr=c["train"]["learning_rate"]);losses=[] indices=list(range(rank,len(c["data"]["tile_origins"]),world)) while len(indices)