> 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.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.shared.torch_patches

Torch compatibility patches.

These patches are intentionally NOT applied at `import nemo_automodel` time to keep
tokenizer-only imports lightweight. Call `apply_torch_patches()` from code paths
that already depend on torch (training / distributed / dataloading).

## Module Contents

### Functions

| Name                                                                              | Description                                                   |
| --------------------------------------------------------------------------------- | ------------------------------------------------------------- |
| [`apply_torch_patches`](#nemo_automodel-shared-torch_patches-apply_torch_patches) | Apply small, version/packaging-specific torch monkey patches. |

### Data

[`_TORCH_PATCHES_APPLIED`](#nemo_automodel-shared-torch_patches-_TORCH_PATCHES_APPLIED)

[`_logger`](#nemo_automodel-shared-torch_patches-_logger)

### API

```python
nemo_automodel.shared.torch_patches.apply_torch_patches() -> None
```

Apply small, version/packaging-specific torch monkey patches.

This function is idempotent and safe to call multiple times.

```python
nemo_automodel.shared.torch_patches._TORCH_PATCHES_APPLIED = False
```

```python
nemo_automodel.shared.torch_patches._logger = logging.getLogger(__name__)
```