> This page is for version 0.4.0 · 26.04.
> 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.optim.gradient_sketch.row_adam

Adam-style second moments shared across each sketch row; no first moment.

## Module Contents

### Functions

| Name                                                                                                 | Description                                                  |
| ---------------------------------------------------------------------------------------------------- | ------------------------------------------------------------ |
| [`row_adam_direction`](#nemo_automodel-components-optim-gradient_sketch-row_adam-row_adam_direction) | Normalize each sketch row by its bias-corrected running RMS. |

### API

```python
nemo_automodel.components.optim.gradient_sketch.row_adam.row_adam_direction(
    sketch: torch.Tensor,
    second_moment: torch.Tensor,
    step: int,
    beta2: float,
    epsilon: float,
    inplace: bool = False
) -> torch.Tensor
```

Normalize each sketch row by its bias-corrected running RMS.

The state is indexed by the original weight's output rows, not by the changing
projection coordinates. With `inplace` the sketch is overwritten with the
direction, avoiding a full-size temporary when the sketch is no longer needed.

**Parameters:**

**`sketch`** `Tensor`

`[rows, rank]` accumulated sketch.

---

**`second_moment`** `Tensor`

`[rows, 1]` running second moment, updated in place.

---

**`step`** `int`

1-based update count used for bias correction.

---

**`beta2`** `float`

Second-moment decay in `[0, 1)`.

---

**`epsilon`** `float`

Denominator floor.

---

**`inplace`** `bool` — default: False

Overwrite `sketch` with the direction.

---

**Returns:** `Tensor`

The normalized direction, same shape as `sketch`.