Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
device
Daniel Han37541f149a84
diff --git a/unsloth/kernels/geglu.py b/unsloth/kernels/geglu.pyindex d5a69aa67fa..1ece87c0801 100644--- a/unsloth/kernels/geglu.py+++ b/unsloth/kernels/geglu.py@@ -45,9 +45,10 @@ passdef geglu_exact_forward_kernel(gate, up):batch, seq_len, hd = gate.shapen_elements = gate.numel()- out = torch.empty((batch, seq_len, hd), dtype = gate.dtype, device = "cuda:0")+ device = gate.device+ out = torch.empty((batch, seq_len, hd), dtype = gate.dtype, device = device)grid = lambda meta: (triton.cdiv(n_elements, meta['BLOCK_SIZE']),)- with torch_cuda_device(gate.device):+ with torch_cuda_device(device):_exact_forward_kernel[grid](gate, up, out, n_elements, BLOCK_SIZE = 1024,)return outpass@@ -139,9 +140,10 @@ passdef geglu_approx_forward_kernel(gate, up):batch, seq_len, hd = gate.shapen_elements = gate.numel()- out = torch.empty((batch, seq_len, hd), dtype = gate.dtype, device = "cuda:0")+ device = gate.device+ out = torch.empty((batch, seq_len, hd), dtype = gate.dtype, device = device)grid = lambda meta: (triton.cdiv(n_elements, meta['BLOCK_SIZE']),)- with torch_cuda_device(gate.device):+ with torch_cuda_device(device):_approx_forward_kernel[grid](gate, up, out, n_elements, BLOCK_SIZE = 1024,)return outpassdiff --git a/unsloth/kernels/utils.py b/unsloth/kernels/utils.pyindex eb3a2e38cc1..2c4edf334bf 100644--- a/unsloth/kernels/utils.py+++ b/unsloth/kernels/utils.py@@ -460,7 +460,9 @@ def matmul_lora(X, W, W_quant, A, B, s, out = None):else:reshape = Falsepass-++ if X.device != W.device:+ print(X.device, W.device, torch.cuda.current_device())out = torch_matmul(X, W, out = out)if W_quant is not None: del Wdiff --git a/unsloth/models/llama.py b/unsloth/models/llama.pyindex fe0627f8d7e..7f475869c8b 100644--- a/unsloth/models/llama.py+++ b/unsloth/models/llama.py@@ -385,6 +385,7 @@ def LlamaAttention_fast_forward(head_dim = self.head_dimassert(n_kv_heads * n_groups == n_heads)+ print(hidden_states.device, torch.cuda.current_device())Q, K, V = self.apply_qkv(self, hidden_states)Q = Q.view(bsz, q_len, n_heads, head_dim).transpose(1, 2)K = K.view(bsz, q_len, n_kv_heads, head_dim).transpose(1, 2)