> This page is for version Latest.
> For other versions, use one of these documentation indexes:
> - Nightly (default): https://docs.nvidia.com/nemo/automodel/nightly/llms.txt
> - Latest: https://docs.nvidia.com/nemo/automodel/latest/llms.txt
> - 0.5.0 · 26.06: https://docs.nvidia.com/nemo/automodel/v0.5/llms.txt
> - 0.4.0 · 26.04: https://docs.nvidia.com/nemo/automodel/v0.4/llms.txt

> 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.step5.rope

Half-split RoPE with the checkpoint's explicit BF16 table boundary.

## Module Contents

### Classes

| Name                                                                                        | Description                                                            |
| ------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------- |
| [`Step5RotaryEmbedding`](#nemo_automodel-components-models-step5-rope-Step5RotaryEmbedding) | Recompute FP32 frequencies from config; never cast a frequency buffer. |

### Functions

| Name                                                                                                                    | Description                                                    |
| ----------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------- |
| [`_apply_full_rotary_compiled`](#nemo_automodel-components-models-step5-rope-_apply_full_rotary_compiled)               | -                                                              |
| [`_apply_partial_rotary_compiled`](#nemo_automodel-components-models-step5-rope-_apply_partial_rotary_compiled)         | -                                                              |
| [`_apply_rotary`](#nemo_automodel-components-models-step5-rope-_apply_rotary)                                           | Apply already-rounded tables using FP32 half-split arithmetic. |
| [`_apply_rotary_compiled`](#nemo_automodel-components-models-step5-rope-_apply_rotary_compiled)                         | -                                                              |
| [`_apply_single_head_rotary_compiled`](#nemo_automodel-components-models-step5-rope-_apply_single_head_rotary_compiled) | -                                                              |

### API

```python
class nemo_automodel.components.models.step5.rope.Step5RotaryEmbedding(
    config: nemo_automodel.components.models.step5.configuration.Step5Config,
    layer_idx: int,
    span: int
)
```

**Bases:** `Module`

Recompute FP32 frequencies from config; never cast a frequency buffer.

**`scaling`**

---

**`theta`**

---

```python
nemo_automodel.components.models.step5.rope.Step5RotaryEmbedding._tables(
    x: torch.Tensor,
    positions: torch.Tensor
) -> tuple[torch.Tensor, torch.Tensor]
```

Build tables once per call; preserve eager frequency/trig rounding.

```python
nemo_automodel.components.models.step5.rope.Step5RotaryEmbedding.forward(
    x: torch.Tensor,
    positions: torch.Tensor
) -> torch.Tensor
```

Rotate the leading half-split subspace.

**Parameters:**

**`x`** `torch.Tensor`

Tensor of shape \[batch, sequence, heads, head_dim].

---

**`positions`** `torch.Tensor`

Tensor of shape \[batch, sequence] with document-local positions.

---

**Returns:** `torch.Tensor`

Tensor of shape \[batch, sequence, heads, head_dim] in the input dtype.

```python
nemo_automodel.components.models.step5.rope.Step5RotaryEmbedding.forward_pair(
    query: torch.Tensor,
    key: torch.Tensor,
    positions: torch.Tensor
) -> tuple[torch.Tensor, torch.Tensor]
```

Rotate local Q/K with one shared, identically rounded table pair.

**Parameters:**

**`query`** `torch.Tensor`

Query tensor \[batch, sequence, query_heads, head_dim].

---

**`key`** `torch.Tensor`

Key tensor \[batch, sequence, key_heads, head_dim], sharing
query's dtype and device. Noncontiguous key views are supported.

---

**`positions`** `torch.Tensor`

Document-local positions \[batch, sequence].

---

**Returns:** `tuple[torch.Tensor, torch.Tensor]`

Rotated query and key tensors, preserving their respective shapes.

**Raises:**

* `ValueError`: Q/K have different batch/sequence extents, dtype or device.

```python
nemo_automodel.components.models.step5.rope._apply_full_rotary_compiled(
    x: torch.Tensor,
    cos: torch.Tensor,
    sin: torch.Tensor
) -> torch.Tensor
```

```python
nemo_automodel.components.models.step5.rope._apply_partial_rotary_compiled(
    x: torch.Tensor,
    cos: torch.Tensor,
    sin: torch.Tensor,
    span: int
) -> torch.Tensor
```

```python
nemo_automodel.components.models.step5.rope._apply_rotary(
    x: torch.Tensor,
    cos: torch.Tensor,
    sin: torch.Tensor,
    span: int
) -> torch.Tensor
```

Apply already-rounded tables using FP32 half-split arithmetic.

```python
nemo_automodel.components.models.step5.rope._apply_rotary_compiled(
    x: torch.Tensor,
    cos: torch.Tensor,
    sin: torch.Tensor,
    span: int
) -> torch.Tensor
```

```python
nemo_automodel.components.models.step5.rope._apply_single_head_rotary_compiled(
    x: torch.Tensor,
    cos: torch.Tensor,
    sin: torch.Tensor,
    span: int
) -> torch.Tensor
```