ACCC1380/molab-moss / Lora /scripts /run_training.py
ACCC1380's picture
download
raw
972 Bytes
import os,sys,json,math,time
from pathlib import Path
root=Path('/marimo/shuiwu')
os.environ['HF_HOME']=str(root/'.cache/huggingface')
os.environ['TORCHINDUCTOR_CACHE_DIR']=str(root/'.cache/torchinductor')
os.environ['TRITON_CACHE_DIR']=str(root/'.cache/triton')
os.environ['TOKENIZERS_PARALLELISM']='false'
sys.path.insert(0,str(root/'LoRA-Forge/lora_forge/trainers/moss_image'))
import torch
# The original DiT remains unquantized bf16; LoRA and optimizer state are fp32.
torch.set_num_threads(8)
from moss_train_network import Trainer,read_config
class RecordedTrainer(Trainer):
def step_logs(self,loss,average,scheduler):
if not math.isfinite(loss):raise RuntimeError('Non-finite training loss')
result=super().step_logs(loss,average,scheduler)
with (root/'logs/metrics.jsonl').open('a') as f:f.write(json.dumps({'time':time.time(),**result})+chr(10))
return result
config=read_config(['--config_file',str(root/'train.toml')])
RecordedTrainer(config).train()

Xet Storage Details

Size:
972 Bytes
·
Xet hash:
f666e3cf4f229b16e5156f1548861e85570ed97cc686b240970e34185ddc8bd9

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.