> This page is for version 0.5.0 · 26.06.
> 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.7.0 · 26.10: https://docs.nvidia.com/nemo/automodel/v0.7/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.

# nemo_automodel.components.speculative.eagle.parallel_reconsideration

Native EAGLE-3.1 Parallel Reconsideration training (arXiv:2611.05724v1).

## Module Contents

### Classes

| Name                                                                                                                                                     | Description                                                                  |
| -------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- |
| [`LlamaParallelReconsiderationDraftModel`](#nemo_automodel-components-speculative-eagle-parallel_reconsideration-LlamaParallelReconsiderationDraftModel) | The EAGLE-3.1 layer and LM head with a feature query and a shared halt gate. |
| [`ParallelReconsiderationConfig`](#nemo_automodel-components-speculative-eagle-parallel_reconsideration-ParallelReconsiderationConfig)                   | Training options for the paper's Eq. (6).                                    |
| [`ParallelReconsiderationTrainerModule`](#nemo_automodel-components-speculative-eagle-parallel_reconsideration-ParallelReconsiderationTrainerModule)     | Train two feature rollouts over the same recorded token sequence.            |
| [`ReconsiderationKV`](#nemo_automodel-components-speculative-eagle-parallel_reconsideration-ReconsiderationKV)                                           | Rotated keys and values of shape \[batch, heads, origin, head_dim].          |
| [`ReconsiderationStep`](#nemo_automodel-components-speculative-eagle-parallel_reconsideration-ReconsiderationStep)                                       | One pass's features \[batch, origin, hidden] and uncommitted KV.             |

### Functions

| Name                                                                                                                             | Description                                                      |
| -------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------- |
| [`_ce`](#nemo_automodel-components-speculative-eagle-parallel_reconsideration-_ce)                                               | Compute the hard target loss for each origin.                    |
| [`_select_halt`](#nemo_automodel-components-speculative-eagle-parallel_reconsideration-_select_halt)                             | Select the same depth for the feature and its cache.             |
| [`halt_probabilities`](#nemo_automodel-components-speculative-eagle-parallel_reconsideration-halt_probabilities)                 | Apply the shared gate's stick-breaking distribution.             |
| [`reconsideration_token_loss`](#nemo_automodel-components-speculative-eagle-parallel_reconsideration-reconsideration_token_loss) | Apply Eq. (6)'s token terms with separate gate and CE gradients. |

### API

```python
class nemo_automodel.components.speculative.eagle.parallel_reconsideration.LlamaParallelReconsiderationDraftModel(
    config: transformers.PretrainedConfig
)
```

**Bases:** [LlamaEagle3DraftModel](/nemo/automodel/v0.5/nemo-automodel/nemo_automodel/components/speculative/eagle/draft_llama#nemo_automodel-components-speculative-eagle-draft_llama-LlamaEagle3DraftModel)

The EAGLE-3.1 layer and LM head with a feature query and a shared halt gate.

**`halt_gate`** `= nn.Linear(config.hidden_size, 1)`

---

**`self_query`** `= nn.Linear(config.hidden_size, config.hidden_size)`

---

```python
nemo_automodel.components.speculative.eagle.parallel_reconsideration.LlamaParallelReconsiderationDraftModel.draft_step(
    input_embeds: torch.Tensor,
    hidden: torch.Tensor,
    mask: torch.Tensor,
    positions: torch.Tensor,
    prefix: tuple[nemo_automodel.components.speculative.eagle.parallel_reconsideration.ReconsiderationKV, ...] = ()
) -> nemo_automodel.components.speculative.eagle.parallel_reconsideration.ReconsiderationStep
```

Run the shared M with explicit positions and a branch-owned cache.

**Parameters:**

**`input_embeds`** `Tensor`

Token embeddings or self-queries of shape \[batch, origin, hidden].

---

**`hidden`** `Tensor`

Features of shape \[batch, origin, hidden].

---

**`mask`** `Tensor`

Additive base attention mask of shape \[batch, 1, origin, origin].

---

**`positions`** `Tensor`

Absolute RoPE indices of shape \[batch, origin].

---

**`prefix`** `tuple[ReconsiderationKV, ...]` — default: ()

Base keys/values followed by one diagonal block per prior
speculative position. Blocks have shape \[batch, heads, origin, head_dim].

---

**Returns:** `ReconsiderationStep`

Updated features \[batch, origin, hidden] and this pass's key/value

```python
class nemo_automodel.components.speculative.eagle.parallel_reconsideration.ParallelReconsiderationConfig(
    max_reconsiderations: int = 2,
    balance_beta: float = 0.01
)
```

Dataclass

Training options for the paper's Eq. (6).

**`balance_beta`** `float = 0.01`

Coefficient for entropy of the minibatch halt marginal.

---

**`max_reconsiderations`** `int = 2`

Positive cap on additional passes at a position.

---

```python
nemo_automodel.components.speculative.eagle.parallel_reconsideration.ParallelReconsiderationConfig.__post_init__() -> None
```

```python
nemo_automodel.components.speculative.eagle.parallel_reconsideration.ParallelReconsiderationConfig.build(
    draft_model: nemo_automodel.components.speculative.eagle.parallel_reconsideration.LlamaParallelReconsiderationDraftModel,
    selected_token_ids: torch.Tensor,
    selected_token_mask: torch.Tensor,
    ttt_steps: int
) -> nemo_automodel.components.speculative.eagle.parallel_reconsideration.ParallelReconsiderationTrainerModule
```

Build the trainer with the configured reconsideration loss.

**Parameters:**

**`draft_model`** `LlamaParallelReconsiderationDraftModel`

Draft that owns the shared decoder, query, and gate.

---

**`selected_token_ids`** `Tensor`

Target token IDs of shape \[draft_vocab] in draft order.

---

**`selected_token_mask`** `Tensor`

Eligibility mask of shape \[target_vocab].

---

**`ttt_steps`** `int`

Maximum rollout length in positions.

---

**Returns:** `ParallelReconsiderationTrainerModule`

The trainer with its own target-vocabulary mapping buffers.

```python
class nemo_automodel.components.speculative.eagle.parallel_reconsideration.ParallelReconsiderationTrainerModule(
    draft_model: nemo_automodel.components.speculative.eagle.parallel_reconsideration.LlamaParallelReconsiderationDraftModel,
    settings: nemo_automodel.components.speculative.eagle.parallel_reconsideration.ParallelReconsiderationConfig,
    selected_token_ids: torch.Tensor,
    selected_token_mask: torch.Tensor,
    ttt_steps: int
)
```

**Bases:** `Module`

Train two feature rollouts over the same recorded token sequence.

```python
nemo_automodel.components.speculative.eagle.parallel_reconsideration.ParallelReconsiderationTrainerModule._teacher_labels(
    loss_mask: torch.Tensor,
    target_logits: torch.Tensor | None,
    target_probs: torch.Tensor | None,
    position_mask: torch.Tensor | None
) -> tuple[torch.Tensor, torch.Tensor]
```

Resolve hard teacher labels in the aligned EAGLE frame.

**Parameters:**

**`loss_mask`** `Tensor`

Eligible teacher rows of shape \[batch, origin].

---

**`target_logits`** `Tensor | None`

Live logits of shape \[batch, origin, target_vocab].

---

**`target_probs`** `Tensor | None`

Cached probabilities of shape \[batch, origin, draft_vocab].

---

**`position_mask`** `Tensor | None`

Cache eligibility of shape \[batch, origin, 1].

---

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

Draft IDs and a boolean eligibility mask, each of shape \[batch, origin].

```python
nemo_automodel.components.speculative.eagle.parallel_reconsideration.ParallelReconsiderationTrainerModule.forward(
    input_ids: torch.Tensor,
    attention_mask: torch.Tensor,
    loss_mask: torch.Tensor,
    aux_hidden_states: torch.Tensor,
    target_logits: torch.Tensor | None = None,
    target_probs: torch.Tensor | None = None,
    position_mask: torch.Tensor | None = None,
    position_ids: torch.Tensor | None = None,
    seq_lens: torch.Tensor | None = None,
    doc_remaining: torch.Tensor | None = None
) -> nemo_automodel.components.speculative.eagle.core.Eagle3StepMetrics
```

Compute the native trainer's loss and one-pass metrics.

**Parameters:**

**`input_ids`** `Tensor`

EAGLE-shifted recorded token IDs \[batch, origin], shared by both rollouts.

---

**`attention_mask`** `Tensor`

Original real-token mask \[batch, origin].

---

**`loss_mask`** `Tensor`

Aligned teacher supervision mask \[batch, origin].

---

**`aux_hidden_states`** `Tensor`

Target taps \[batch, origin, concatenated_hidden].

---

**`target_logits`** `Tensor | None` — default: None

Aligned live teacher logits \[batch, origin, target_vocab].

---

**`target_probs`** `Tensor | None` — default: None

Aligned cached probabilities \[batch, origin, draft_vocab].

---

**`position_mask`** `Tensor | None` — default: None

Cached supervision eligibility \[batch, origin, 1].

---

**`position_ids`** `Tensor | None` — default: None

Optional original RoPE indices \[batch, origin].

---

**`seq_lens`** `Tensor | None` — default: None

Packed document lengths \[num_documents]. Must be absent.

---

**`doc_remaining`** `Tensor | None` — default: None

Packed positions remaining \[batch, origin]. Must be absent.

---

**Returns:** `Eagle3StepMetrics`

Scalar loss, accuracy and supervised-token count in the recipe's metric record.

```python
class nemo_automodel.components.speculative.eagle.parallel_reconsideration.ReconsiderationKV(
    key: torch.Tensor,
    value: torch.Tensor
)
```

Dataclass

Rotated keys and values of shape \[batch, heads, origin, head_dim].

**`key`** `Tensor`

---

**`value`** `Tensor`

---

```python
class nemo_automodel.components.speculative.eagle.parallel_reconsideration.ReconsiderationStep(
    hidden: torch.Tensor,
    kv: nemo_automodel.components.speculative.eagle.parallel_reconsideration.ReconsiderationKV
)
```

Dataclass

One pass's features \[batch, origin, hidden] and uncommitted KV.

**`hidden`** `Tensor`

---

**`kv`** `ReconsiderationKV`

---

```python
nemo_automodel.components.speculative.eagle.parallel_reconsideration._ce(
    logits: torch.Tensor,
    labels: torch.Tensor
) -> torch.Tensor
```

Compute the hard target loss for each origin.

**Parameters:**

**`logits`** `Tensor`

Tensor of shape \[batch, origin, draft_vocab].

---

**`labels`** `Tensor`

Integer draft IDs of shape \[batch, origin].

---

**Returns:** `Tensor`

FP32 cross entropy of shape \[batch, origin].

```python
nemo_automodel.components.speculative.eagle.parallel_reconsideration._select_halt(
    levels: list[nemo_automodel.components.speculative.eagle.parallel_reconsideration.ReconsiderationStep],
    depth: torch.Tensor
) -> nemo_automodel.components.speculative.eagle.parallel_reconsideration.ReconsiderationStep
```

Select the same depth for the feature and its cache.

**Parameters:**

**`levels`** `list[ReconsiderationStep]`

Candidate features \[batch, origin, hidden] with projected keys
and values \[batch, heads, origin, head_dim], ordered by depth.

---

**`depth`** `Tensor`

Sampled depth indices of shape \[batch, origin].

---

**Returns:** `ReconsiderationStep`

A gathered feature and KV block with the same layouts as a single level.

```python
nemo_automodel.components.speculative.eagle.parallel_reconsideration.halt_probabilities(
    logits: torch.Tensor
) -> torch.Tensor
```

Apply the shared gate's stick-breaking distribution.

**Parameters:**

**`logits`** `Tensor`

Tensor of shape \[..., depth_cap] with one logit per optional halt.

---

**Returns:** `Tensor`

FP32 halt masses of shape \[..., depth_cap + 1], including forced halt.

```python
nemo_automodel.components.speculative.eagle.parallel_reconsideration.reconsideration_token_loss(
    ce: torch.Tensor,
    mass: torch.Tensor
) -> torch.Tensor
```

Apply Eq. (6)'s token terms with separate gate and CE gradients.

**Parameters:**

**`ce`** `Tensor`

Cross entropy of shape \[..., depth], with depth zero first.

---

**`mass`** `Tensor`

Halt probabilities of shape \[..., depth].

---

**Returns:** `Tensor`

Combined loss of shape \[...] before the marginal entropy term.