Disable brittle torch.compile in multi-GPU DDP to prevent Dynamo AOTAutograd graph breaks
Browse files1176 unmodified lines1177117811791180118111801181118211831184118511863 unmodified lines119011911192119311941195119611971176 unmodified lines gc.collect() if torch.cuda.is_available(): torch.cuda.empty_cache() # Optional torch.compile for maximum speed (compiled BEFORE DDP wrapping as per PyTorch best practices) if args.compile and hasattr(torch, "compile"): # Optional torch.compile for maximum speed # Note: Under multi-GPU DDP, PyTorch's native eager mode with FlashAttention SDPA # delivers full Tensor Core performance without brittle AOTAutograd / Dynamo DDP backend graph-breaks. if args.compile and hasattr(torch, "compile") and not IS_DDP: if IS_MAIN: print("⚡ Compiling model with torch.compile(dynamic=True)...") try:3 unmodified lines except Exception as e: if IS_MAIN: print(f"⚠️ Could not compile model: {e}") elif args.compile and IS_DDP and IS_MAIN: print("ℹ️ Multi-GPU DDP Active: Utilizing native Blackwell FlashAttention & cuBLAS Tensor Cores for maximum stability!")
if IS_DDP: model = DDP(code/train_sft.py+6-2