Disable brittle torch.compile in multi-GPU DDP to prevent Dynamo AOTAutograd graph breaks
Browse files1176 unmodified lines117711781179118011811182118311843 unmodified lines1188118911901191119211931176 unmodified linesgc.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"):if IS_MAIN:print("⚡ Compiling model with torch.compile(dynamic=True)...")try:3 unmodified linesexcept Exception as e:if IS_MAIN:print(f"⚠️ Could not compile model: {e}")if IS_DDP:model = DDP(1176 unmodified lines11771178117911801181118211831184118511863 unmodified lines119011911192119311941195119611971176 unmodified linesgc.collect()if torch.cuda.is_available():torch.cuda.empty_cache()# 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 linesexcept 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