> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/nemo/automodel/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/nemo/automodel/_mcp/server.

# nemo_automodel.components.loss.linear_ce

## Module Contents

### Classes

| Name                                                                                           | Description                                            |
| ---------------------------------------------------------------------------------------------- | ------------------------------------------------------ |
| [`FusedLinearCrossEntropy`](#nemo_automodel-components-loss-linear_ce-FusedLinearCrossEntropy) | Fused linear-projection and cross-entropy loss module. |

### Functions

| Name                                                                                                                     | Description                                                                        |
| ------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------- |
| [`new_is_triton_greater_or_equal`](#nemo_automodel-components-loss-linear_ce-new_is_triton_greater_or_equal)             | Check if pytorch-triton version is greater than or equal to the specified version. |
| [`new_is_triton_greater_or_equal_3_2_0`](#nemo_automodel-components-loss-linear_ce-new_is_triton_greater_or_equal_3_2_0) | Check if pytorch-triton version is greater than or equal to 3.1.0.                 |

### Data

[`HAVE_CUT_CROSS_ENTROPY`](#nemo_automodel-components-loss-linear_ce-HAVE_CUT_CROSS_ENTROPY)

### API

```python
class nemo_automodel.components.loss.linear_ce.FusedLinearCrossEntropy(
    ignore_index: int = -100,
    logit_softcapping: float = 0,
    reduction: str = 'sum'
)
```

**Bases:** `Module`

Fused linear-projection and cross-entropy loss module.

```python
nemo_automodel.components.loss.linear_ce.FusedLinearCrossEntropy.forward(
    hidden_states: torch.Tensor,
    labels: torch.Tensor,
    lm_weight: torch.Tensor,
    num_label_tokens: typing.Optional[int] = None
) -> torch.Tensor
```

Compute fused linear cross entropy loss that matches PyTorch's cross\_entropy behavior.

**Parameters:**

Input hidden states

Target labels

Weight matrix for linear transformation

Number of non-padding tokens.

```python
nemo_automodel.components.loss.linear_ce.new_is_triton_greater_or_equal(
    version_str
)
```

Check if pytorch-triton version is greater than or equal to the specified version.

**Parameters:**

Version string to check

**Returns:**

True if pytorch-triton version >= specified version

```python
nemo_automodel.components.loss.linear_ce.new_is_triton_greater_or_equal_3_2_0()
```

Check if pytorch-triton version is greater than or equal to 3.1.0.

**Returns:**

True if pytorch-triton version >= 3.1.0

```python
nemo_automodel.components.loss.linear_ce.HAVE_CUT_CROSS_ENTROPY = True
```