> 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.models.glm_moe_dsa.kernels.sparse_mla

## Module Contents

### Classes

| Name                                                                                      | Description |
| ----------------------------------------------------------------------------------------- | ----------- |
| [`SparseMLA`](#nemo_automodel-components-models-glm_moe_dsa-kernels-sparse_mla-SparseMLA) | -           |

### API

```python
class nemo_automodel.components.models.glm_moe_dsa.kernels.sparse_mla.SparseMLA()
```

**Bases:** `Function`

```python
nemo_automodel.components.models.glm_moe_dsa.kernels.sparse_mla.SparseMLA.backward(
    ctx,
    grad_output,
    grad_lse
)
```

staticmethod

**Parameters:**

Gradient of the loss with respect to output

**Returns:**

Gradients for q, kv, and indices (None for indices)

```python
nemo_automodel.components.models.glm_moe_dsa.kernels.sparse_mla.SparseMLA.forward(
    ctx,
    q,
    kv,
    indices,
    scaling
)
```

staticmethod

**Parameters:**

Query tensor (seq\_len, heads, dim\_plus\_tail\_dim)

Key-Value tensor (seq\_len\_kv, kv\_group, dim\_plus\_tail\_dim)

Sparse indices tensor (seq\_len, kv\_group, topk)

**Returns:**

Output tensor (seq\_len, heads, dim)