> 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.gpt_oss.layers

## Module Contents

### Classes

| Name                                                                                  | Description |
| ------------------------------------------------------------------------------------- | ----------- |
| [`GptOssAttention`](#nemo_automodel-components-models-gpt_oss-layers-GptOssAttention) | -           |

### Functions

| Name                                                                                      | Description |
| ----------------------------------------------------------------------------------------- | ----------- |
| [`_has_thd_metadata`](#nemo_automodel-components-models-gpt_oss-layers-_has_thd_metadata) | -           |

### API

```python
class nemo_automodel.components.models.gpt_oss.layers.GptOssAttention(
    config: transformers.models.gpt_oss.configuration_gpt_oss.GptOssConfig,
    backend: nemo_automodel.components.models.common.BackendConfig,
    use_sliding_attention: bool = False
)
```

**Bases:** `Module`

**`head_dim`** `= config.head_dim`

---

**`hidden_size`** `= config.hidden_size`

---

**`k_proj`**

---

**`num_attention_heads`** `= config.num_attention_heads`

---

**`num_key_value_heads`** `= config.num_key_value_heads`

---

**`o_proj`**

---

**`q_proj`**

---

**`sinks`**

---

**`sliding_window`**

---

**`softmax_scale`** `= self.head_dim ** -0.5`

---

**`v_proj`**

---

**`yarn_concentration`** `= yarn_get_mscale(config.rope_scaling['factor'])`

---

```python
nemo_automodel.components.models.gpt_oss.layers.GptOssAttention.forward(
    x: torch.Tensor,
    freqs_cis: torch.Tensor,
    attention_mask: torch.Tensor | None = None,
    attn_kwargs: typing.Any = {}
) -> torch.Tensor
```

```python
nemo_automodel.components.models.gpt_oss.layers.GptOssAttention.init_weights(
    buffer_device: torch.device,
    init_std: float = 0.02
)
```

```python
nemo_automodel.components.models.gpt_oss.layers._has_thd_metadata(
    attn_kwargs: dict[str, typing.Any]
) -> bool
```