Skip to content

A bug for reduction='none' in LigerFusedLinearCrossEntropyLoss #872

@yshenaw

Description

@yshenaw

🐛 Describe the bug

I noticed that the fused_linear_cross_entropy function has support for reduction='none', but in the LigerFusedLinearCrossEntropyLoss, there is currently an assertion that restricts reduction to only 'mean' or 'sum'. The current code looks like this:

assert reduction in {
    "mean",
    "sum",
}, f"reduction must be 'mean' or 'sum'. Got: {reduction}"

Here is the proposed change:

assert reduction in {
    "mean",
    "sum",
    "none",
}, f"reduction must be 'mean', 'sum', or 'none'. Got: {reduction}"

I hope this bug can be fixed soon.

Reproduce

No response

Versions

Environment Report:

Operating System: Linux-6.8.0-1031-azure-x86_64-with-glibc2.35
Python version: 3.10.18
Liger Kernel version: 0.6.2
PyTorch version: 2.8.0+cu128
CUDA version: 12.8
HIP(ROCm) version: Not available
Triton version: 3.4.0
Transformers version: 4.56.0
XPU version: XPU Not Available

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions