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.

Update cross_entropy_loss.py

Daniel Han8942b2fc76c5
diff --git a/unsloth/kernels/cross_entropy_loss.py b/unsloth/kernels/cross_entropy_loss.py
index 8cbdbf2a2c4..a13475e227c 100644
--- a/unsloth/kernels/cross_entropy_loss.py
+++ b/unsloth/kernels/cross_entropy_loss.py
@@ -92,10 +92,10 @@ def _cross_entropy_forward(
pass
-# @triton.heuristics({
-# "DO_SOFTCAPPING": lambda args: args["DO_SOFTCAPPING" ],
-# "DO_LOGIT_SCALING": lambda args: args["DO_LOGIT_SCALING"],
-# })
+ "DO_SOFTCAPPING": lambda args: args["DO_SOFTCAPPING" ],
+ "DO_LOGIT_SCALING": lambda args: args["DO_LOGIT_SCALING"],
+})
@triton.jit
def _chunked_cross_entropy_forward(
logits_ptr ,
@@ -106,9 +106,9 @@ def _chunked_cross_entropy_forward(
VOCAB_SIZE ,
N_CHUNKS ,
BLOCK_SIZE : tl.constexpr,
- DO_SOFTCAPPING ,
+ DO_SOFTCAPPING : tl.constexpr(tl.int1),
SOFTCAP ,
- DO_LOGIT_SCALING ,
+ DO_LOGIT_SCALING : tl.constexpr(tl.int1),
LOGIT_SCALE ,
):
"""
@@ -189,9 +189,9 @@ def _cross_entropy_backward(
labels_ptr ,
VOCAB_SIZE ,
BLOCK_SIZE : tl.constexpr,
- DO_SOFTCAPPING ,
+ DO_SOFTCAPPING : tl.constexpr(tl.int1),
SOFTCAP ,
- DO_LOGIT_SCALING ,
+ DO_LOGIT_SCALING : tl.constexpr(tl.int1),
LOGIT_SCALE ,
):
"""
@@ -347,7 +347,7 @@ class Fast_CrossEntropyLoss(torch.autograd.Function):
SOFTCAP = ctx.logit_softcapping,
DO_LOGIT_SCALING = ctx.DO_LOGIT_SCALING,
LOGIT_SCALE = ctx.logit_scaling,
- num_warps = 8,
+ num_warps = 8,
)
return logits, None, None, None,
pass