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 Hana4471de988bd
diff --git a/unsloth/kernels/cross_entropy_loss.py b/unsloth/kernels/cross_entropy_loss.py
index efe18f5c14b..17168b230af 100644
--- a/unsloth/kernels/cross_entropy_loss.py
+++ b/unsloth/kernels/cross_entropy_loss.py
@@ -32,16 +32,16 @@ from unsloth_zoo.loss_utils import (
@triton.jit
def _cross_entropy_forward(
logits_ptr ,
- logits_row_stride : tl.constexpr(tl.int64),
+ logits_row_stride : tl.constexpr,
loss_ptr ,
logsumexp_ptr ,
labels_ptr ,
- VOCAB_SIZE : tl.constexpr(tl.int32),
- BLOCK_SIZE : tl.constexpr(tl.int32),
+ VOCAB_SIZE : tl.constexpr,
+ BLOCK_SIZE : tl.constexpr,
DO_SOFTCAPPING ,
- SOFTCAP : tl.constexpr(tl.float32),
+ SOFTCAP : tl.constexpr,
DO_LOGIT_SCALING ,
- LOGIT_SCALE : tl.constexpr(tl.float32),
+ LOGIT_SCALE : tl.constexpr,
):
"""
Cross Entropy Loss = 1/n sum [ -yi log(Pi) ]
@@ -105,17 +105,17 @@ pass
@triton.jit
def _chunked_cross_entropy_forward(
logits_ptr ,
- logits_row_stride : tl.constexpr(tl.int64),
+ logits_row_stride : tl.constexpr,
loss_ptr ,
logsumexp_ptr ,
labels_ptr ,
- VOCAB_SIZE : tl.constexpr(tl.int32),
- N_CHUNKS : tl.constexpr(tl.int32),
- BLOCK_SIZE : tl.constexpr(tl.int32),
+ VOCAB_SIZE : tl.constexpr,
+ N_CHUNKS : tl.constexpr,
+ BLOCK_SIZE : tl.constexpr,
DO_SOFTCAPPING ,
- SOFTCAP : tl.constexpr(tl.float32),
+ SOFTCAP : tl.constexpr,
DO_LOGIT_SCALING ,
- LOGIT_SCALE : tl.constexpr(tl.float32),
+ LOGIT_SCALE : tl.constexpr,
):
"""
256K vocab divided in 4 chunks
@@ -188,17 +188,17 @@ pass
@triton.jit
def _cross_entropy_backward(
logits_ptr ,
- logits_row_stride : tl.constexpr(tl.int64),
+ logits_row_stride : tl.constexpr,
dloss_ptr ,
dloss_row_stride ,
logsumexp_ptr ,
labels_ptr ,
- VOCAB_SIZE : tl.constexpr(tl.int32),
- BLOCK_SIZE : tl.constexpr(tl.int32),
+ VOCAB_SIZE : tl.constexpr,
+ BLOCK_SIZE : tl.constexpr,
DO_SOFTCAPPING ,
- SOFTCAP : tl.constexpr(tl.float32),
+ SOFTCAP : tl.constexpr,
DO_LOGIT_SCALING ,
- LOGIT_SCALE : tl.constexpr(tl.float32),
+ LOGIT_SCALE : tl.constexpr,
):
"""
CE_i = -y log(P) = y * (log[sum(exp(x))] - x)