You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, may I ask if Unsloth currently supports multi-GPU training? I tried running it with torchrun for multi-GPU training using my own setup, but it failed. Could you please advise me on how to do it correctly? Thank you!
Reacted by Ilya Chernikov, Honza-Hroch, Rahul S. Poudel, LIUKAI0815, Steve, Radim Tylecek, John Bean, Andrew Mendez, VORTEX, Dan Saattrup Smart and 12 more
It's coming, I'll update you guys once we release it.
Reacted by Kristjan Kongas, Ilya Chernikov, kakao-charlie-cs, Matthew E. Kieren, Sousi Omine, Pavel Dudkouski, Masashi Sorimachi, Zihan Luo, binarrii, lucas and 10 more
I don't want multi-GPU support to only work in FP8 or INT4. We can already perform full-finetuning of many models in fp8 format. I think it's very important that float16 support is coming along with multi-GPU support.
Reacted by user_in_github, Kevin Xiang Li and Niko Maroulis
@cwpeng-cn Did you complete your training? In my case, after all epochs are completed, the process get stuck in trainer.train(), never exit or execute next line. Unable to find out the cause of it.
I think this issue happens when I use load_best_model_at_end=True at SFTConfig and provide an evaluation dataset. When I try on very small dataset, such as 8 samples, for both train and eval dataset, this happens quite frequently. I suspect that the trainer hangs when loading best model at the end, if this best model is not the latest checkpoint. But I am not sure.
@cwpeng-cn Did you complete your training? In my case, after all epochs are completed, the process get stuck in trainer.train(), never exit or execute next line. Unable to find out the cause of it.
I think this issue happens when I use load_best_model_at_end=True at SFTConfig and provide an evaluation dataset. When I try on very small dataset, such as 8 samples, for both train and eval dataset, this happens quite frequently. I suspect that the trainer hangs when loading best model at the end, if this best model is not the latest checkpoint. But I am not sure.
I solved this by setting load_best_model_at_end=False, then used a callback to save the best model.
classSaveBestModelCallback(TrainerCallback):
"""Track the best model and save. Only used when in DDP with unsloth."""def__init__(self, trainer: SFTTrainer, rank: int=0):
self.trainer=trainerself.rank=rankself.best_eval_loss=float("inf")
self.best_epoch=0defon_evaluate(self, args, state, control, **kwargs):
logs=state.log_history[-1]
current_eval_loss=logs.get("eval_loss", float("inf"))
ifcurrent_eval_loss<self.best_eval_loss:
ifself.rank==0:
print(f"\n✓ Eval loss improved from {self.best_eval_loss:.4f} to {current_eval_loss:.4f}, will save the model\n")
self.best_eval_loss=current_eval_lossself.trainer.save_model(self.trainer.args.output_dir)
self.best_epoch=state.epochelse:
ifself.rank==0:
print(f"\nCurrent eval loss: {current_eval_loss:.4f} > best eval loss: {self.best_eval_loss:.4f}\n")
trainer=SFTTrainer(
model=model,
args=config.training_args,
train_dataset=train_dataset,
eval_dataset=eval_dataset,
tokenizer=tokenizer,
)
trainer.add_callback(SaveBestModelCallback(trainer, rank=rank))
trainer.train(resume_from_checkpoint=config.resume_from_checkpoint)
Able to run this with FastLanguageModel but when I try to use a Vision model using FastVisionModel, the code gets struck in FastVisionModel.from_pretrained. Multi-Gpu finetuning for vision models isn't supported yet ? This looks similar to an old issue #2280
Able to run this with FastLanguageModel but when I try to use a Vision model using FastVisionModel, the code gets struck in FastVisionModel.from_pretrained. Multi-Gpu finetuning for vision models isn't supported yet ? This looks similar to an old issue #2280
@timho1047 You right, Thanks! Runs with torchrun --nproc_per_node=4 train_ddp.py
Did you split the dataset manually based on local rank inside your train script? And do I have to initialize and distroy torch distributed environment just like the normal DDP training? (Really appreciate it if you can provide something like pseudocode)
Thank You all for the thread,
successfuly running unsloth fine-tuning using multi GPU, but when adding target module "embed_tokens","lm_head", the training crash with error ValueError: DistributedDataParallel's input module must be on the same type of devices, but input module parameters locate in {'cpu', 'cuda'}.
Its it because unsloth offload input_embeddings and output_embeddings to disk cause the device mixup?
if it the case, how to disable embedding oflload?
Has anyone run into this issue with Unsloth Studio multi-GPU training?
I can successfully train Qwen3.8-27B with QLoRA on 3× RTX 5060 Ti 16GB using a standalone Unsloth Python script with:
device_map="balanced"
custom max_memory for all 3 GPUs
QLoRA 4-bit
batch size 1
The standalone training works and completes normally.
However, when I try to train the same model on the same hardware in Unsloth Studio, GPU memory usage becomes very uneven and one GPU eventually hits CUDA OOM, even with batch size 1.
Does Unsloth Studio use a different multi-GPU/device placement strategy than standalone Unsloth training with device_map="balanced" and custom max_memory?
I also successfully completed the full workflow outside Studio:
LoRA training → merge with the base model → GGUF conversion → quantization.
The resulting quantized GGUF loads correctly in Unsloth Studio, but LM Studio refuses to load it.
If useful, I can post the working standalone training script, merge script, GGUF conversion steps, quantization command, and GPU memory usage.
Activity
lot-insts commentedon Apr 30, 2025
Same question. How to train GRPO in multi-GPU?
sangmandu commentedon Apr 30, 2025
I am sooooooo looking forward to 2.0.
They said it comes out on end of April.
shimmyshimmer commentedon Apr 30, 2025
Have you guys tried running it on multiGPUs?
It's coming, I'll update you guys once we release it.
tianlinzx commentedon May 2, 2025
@shimmyshimmer How is it going ?
haoyuhan1 commentedon May 8, 2025
Any update? It's too slow to finetune large models now.
Micropot commentedon May 9, 2025
@haoyuhan1 still in beta. I haven't found any bypass yet...
rolandtannous commentedon May 10, 2025
@ztmzzz @edhh-hh @YuLionel @Strong-Gavin @honza @1183011789 @ZHONGJIAFENG7 @youyc22 @AUTOMATIC2222 @GorgeousWang @patel-zeel @wektorz @Songjw133 @XYZliang @GianlucaDeStefano @Poneglyph795 @ladbyte @songkq @MohamedAliRashad @BleedingDev @woreom @HamidGadirov @thusinh1969
@irisma00 @xywen97 @flerka @abidikhairi @molbal @dipta007 @v1ckxy @chuangzhidan @ZanMax @baibizhe @alaap001 @pandayummy @CDog94 @DaddyCodesAlot @kadirnar @mahiatlinux @xudou3 @NiuBlibing @songkq @beginerJSM
Feel free to use this unified thread for all your queries , questions and follow-ups regarding multi-gpu support.
chuangzhidan commentedon May 10, 2025
support train GRPO in multi-GPU now?
kadirnar commentedon May 10, 2025
Please add full-finetuning support in float16 format.
rolandtannous commentedon May 10, 2025
@kadirnar is this related to multi-gpu support?
kadirnar commentedon May 10, 2025
I don't want multi-GPU support to only work in FP8 or INT4. We can already perform full-finetuning of many models in fp8 format. I think it's very important that float16 support is coming along with multi-GPU support.
lot-insts commentedon May 14, 2025
Hope for updating
neozhao98 commentedon May 20, 2025
I tried accelerate + unsloth, it works well
chuangzhidan commentedon May 20, 2025
supports multi gpu reinforce training ?
risqaliyevds commentedon May 20, 2025
Well done @neozhao98. Can you share your tuning scripts?
73 remaining items
Skyruller commentedon Oct 24, 2025
Yesterday I wrote out some incorrect code, but today I updated and tested it. There were problems saving LoRa adapters.
Run:
CUDA_VISIBLE_DEVICES=0,1
torchrun --nproc_per_node=2 train_fsdp_unsloth.py
--model "/home/skyruller/text-generation-webui/user_data/models/Qwen3-4B-Instruct-2507"
--data "/media/skyruller/NovyTom/dataset/opensloth_powermill_dataset/dataset.txt"
--out "./out_fsdp_lora"
--epochs 1 --microbatch 1 --grad_accum 1 --lr 2e-4
--max_seq_len 896 --log_every 10 --save_every 45
train_fsdp_unsloth.py
timho1047 commentedon Oct 24, 2025
I think this issue happens when I use
load_best_model_at_end=TrueatSFTConfigand provide an evaluation dataset. When I try on very small dataset, such as 8 samples, for both train and eval dataset, this happens quite frequently. I suspect that the trainer hangs when loading best model at the end, if this best model is not the latest checkpoint. But I am not sure.timho1047 commentedon Oct 26, 2025
I solved this by setting
load_best_model_at_end=False, then used a callback to save the best model.santoshkosgi commentedon Oct 29, 2025
Able to run this with FastLanguageModel but when I try to use a Vision model using FastVisionModel, the code gets struck in FastVisionModel.from_pretrained. Multi-Gpu finetuning for vision models isn't supported yet ? This looks similar to an old issue #2280
521bibi commentedon Nov 4, 2025
How to train GRPO in multi-GPU?
Only get how to train SFT in multi-GPU
minhtcai commentedon Nov 8, 2025
I modified @cwpeng-cn work and made it run on Qwen3-VL on 2x L4:
https://github.com/minhtcai/unsloth-multi-gpu-vision
jamesnulliu commentedon Nov 12, 2025
Did you split the dataset manually based on local rank inside your train script? And do I have to initialize and distroy torch distributed environment just like the normal DDP training? (Really appreciate it if you can provide something like pseudocode)
antonheryanto commentedon Dec 3, 2025
Thank You all for the thread,
successfuly running unsloth fine-tuning using multi GPU, but when adding target module "embed_tokens","lm_head", the training crash with error
ValueError: DistributedDataParallel's input module must be on the same type of devices, but input module parameters locate in {'cpu', 'cuda'}.Its it because unsloth offload
input_embeddingsandoutput_embeddingsto disk cause the device mixup?if it the case, how to disable embedding oflload?
Skyruller commentedon Dec 24, 2025
I checked, and it works on 3 graphics cards.
ProArt Z790-CREATOR WIFI, Intel® Core™ i7 processor 14700K, 2*48 RAM
train_fsdp_lora.py
r=512, lora_alpha=1024
target_modules=["q_proj","k_proj","v_proj","o_proj","gate_proj","up_proj","down_proj"]
CUDA_VISIBLE_DEVICES=0,1,2
torchrun --nproc_per_node=3 train_fsdp_lora.py
--model "/home/skyruller/text-generation-webui/user_data/models/Qwen3-4B-Instruct-2507"
--data "/home/skyruller/SSD/FSDP/dataset.txt"
--out "./out_fsdp_lora4"
--epochs 10 --microbatch 1 --grad_accum 1 --lr 2e-4
--max_seq_len 2048 --log_every 10 --save_every 45
Niklas-dev commentedon Mar 13, 2026
Is it possible now to use unsloth with fsdp?
And with how many devices if it works?
madmax0404 commentedon Mar 21, 2026
vllm + unsloth + deepspeed would be a monstrosity
Imagineer99 commentedon Jun 11, 2026
Added in #3917, #4602, #4063, #4143.
thad0ctor commentedon Jun 11, 2026
Is this really closed with comparable feature parity?
https://unsloth.ai/docs/basics/multi-gpu-training-with-unsloth still says this is a work-in-progress
Skyruller commentedon Aug 26, 2026
Has anyone run into this issue with Unsloth Studio multi-GPU training?
I can successfully train Qwen3.8-27B with QLoRA on 3× RTX 5060 Ti 16GB using a standalone Unsloth Python script with:
device_map="balanced"
custom max_memory for all 3 GPUs
QLoRA 4-bit
batch size 1
The standalone training works and completes normally.
However, when I try to train the same model on the same hardware in Unsloth Studio, GPU memory usage becomes very uneven and one GPU eventually hits CUDA OOM, even with batch size 1.
Does Unsloth Studio use a different multi-GPU/device placement strategy than standalone Unsloth training with device_map="balanced" and custom max_memory?
I also successfully completed the full workflow outside Studio:
LoRA training → merge with the base model → GGUF conversion → quantization.
The resulting quantized GGUF loads correctly in Unsloth Studio, but LM Studio refuses to load it.
If useful, I can post the working standalone training script, merge script, GGUF conversion steps, quantization command, and GPU memory usage.