Skip to content

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.

perf(ROCm): optimize chunked CE loss num_warps for RDNA GPUs (#4123)

金黄色葡萄球君君721bf4852a80
diff --git a/unsloth/kernels/cross_entropy_loss.py b/unsloth/kernels/cross_entropy_loss.py
index d92229314fa..1bb1691776d 100644
--- a/unsloth/kernels/cross_entropy_loss.py
+++ b/unsloth/kernels/cross_entropy_loss.py
@@ -22,6 +22,7 @@ from .utils import (
triton_cast,
torch_gpu_device,
is_cdna,
+ is_rdna,
)
from transformers.models.llama.modeling_llama import logger
from unsloth_zoo.utils import Version
@@ -364,7 +365,7 @@ class Fast_CrossEntropyLoss(torch.autograd.Function):
SOFTCAP = logit_softcapping,
DO_LOGIT_SCALING = DO_LOGIT_SCALING,
LOGIT_SCALE = logit_scaling,
- num_warps = 32 if not is_cdna() else 16,
+ num_warps = 16 if is_cdna() or is_rdna() else 32,
)
# logsumexp(chunked_logsumexp) - x
# Do the -x separately