> 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.speculative.eagle.remote.wire

Compact binary tensor serialization for the remote target data plane.

This is the fallback path used when NCCL GPU-to-GPU transfer is unavailable:
tensors are encoded as dtype + shape + raw contiguous bytes and shipped inside
the HTTP body. The format is little-endian and self-delimiting.

Format::

\[4B]  magic         0x4E4D4554  ("NMET")
per entry:
\[4B]  key\_len      (uint32)
\[key\_len B] key     UTF-8
\[1B]  flags        bit0 = is\_none
if not none:
\[1B]  dtype\_code (see \_DTYPE\_TABLE)
\[1B]  ndim
\[ndim x 8B] shape (int64)
\[8B]  nbytes     (uint64)
\[nbytes B] data   raw contiguous tensor bytes

## Module Contents

### Functions

| Name                                                                                          | Description                                                              |
| --------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------ |
| [`decode`](#nemo_automodel-components-speculative-eagle-remote-wire-decode)                   | Decode a wire-format blob back into a dict of tensors on `map_location`. |
| [`encode`](#nemo_automodel-components-speculative-eagle-remote-wire-encode)                   | Encode a dict of CPU tensors into the wire format.                       |
| [`encode_to_bytes`](#nemo_automodel-components-speculative-eagle-remote-wire-encode_to_bytes) | Encode and return immutable `bytes` (HTTP body).                         |

### Data

[`MAGIC`](#nemo_automodel-components-speculative-eagle-remote-wire-MAGIC)

[`_DTYPE_FMT`](#nemo_automodel-components-speculative-eagle-remote-wire-_DTYPE_FMT)

[`_DTYPE_TABLE`](#nemo_automodel-components-speculative-eagle-remote-wire-_DTYPE_TABLE)

[`_DTYPE_TO_CODE`](#nemo_automodel-components-speculative-eagle-remote-wire-_DTYPE_TO_CODE)

[`_FLAG_FMT`](#nemo_automodel-components-speculative-eagle-remote-wire-_FLAG_FMT)

[`_FLAG_NONE`](#nemo_automodel-components-speculative-eagle-remote-wire-_FLAG_NONE)

[`_HEADER_FMT`](#nemo_automodel-components-speculative-eagle-remote-wire-_HEADER_FMT)

[`_KEYLEN_FMT`](#nemo_automodel-components-speculative-eagle-remote-wire-_KEYLEN_FMT)

[`_NBYTES_FMT`](#nemo_automodel-components-speculative-eagle-remote-wire-_NBYTES_FMT)

[`_NDIM_FMT`](#nemo_automodel-components-speculative-eagle-remote-wire-_NDIM_FMT)

[`_SHAPE_FMT`](#nemo_automodel-components-speculative-eagle-remote-wire-_SHAPE_FMT)

### API

```python
nemo_automodel.components.speculative.eagle.remote.wire.decode(
    raw: bytes,
    map_location: str = 'cpu'
) -> dict[str, typing.Optional[torch.Tensor]]
```

Decode a wire-format blob back into a dict of tensors on `map_location`.

```python
nemo_automodel.components.speculative.eagle.remote.wire.encode(
    tensor_dict: dict[str, typing.Optional[torch.Tensor]]
) -> bytearray
```

Encode a dict of CPU tensors into the wire format.

`None` values are preserved. The caller is responsible for moving tensors
to CPU first; CUDA tensors are rejected to keep the data path explicit.

```python
nemo_automodel.components.speculative.eagle.remote.wire.encode_to_bytes(
    tensor_dict: dict[str, typing.Optional[torch.Tensor]]
) -> bytes
```

Encode and return immutable `bytes` (HTTP body).

```python
nemo_automodel.components.speculative.eagle.remote.wire.MAGIC = 1313686868
```

```python
nemo_automodel.components.speculative.eagle.remote.wire._DTYPE_FMT = struct.Struct('<B')
```

```python
nemo_automodel.components.speculative.eagle.remote.wire._DTYPE_TABLE: dict[int, dtype] = {0: torch.float32, 1: torch.float64, 2: torch.float16, 3: torch.bfloat16, 4: tor...
```

```python
nemo_automodel.components.speculative.eagle.remote.wire._DTYPE_TO_CODE: dict[dtype, int] = {dt: c for c, dt in (_DTYPE_TABLE.items())}
```

```python
nemo_automodel.components.speculative.eagle.remote.wire._FLAG_FMT = struct.Struct('<B')
```

```python
nemo_automodel.components.speculative.eagle.remote.wire._FLAG_NONE = 1
```

```python
nemo_automodel.components.speculative.eagle.remote.wire._HEADER_FMT = struct.Struct('<I')
```

```python
nemo_automodel.components.speculative.eagle.remote.wire._KEYLEN_FMT = struct.Struct('<I')
```

```python
nemo_automodel.components.speculative.eagle.remote.wire._NBYTES_FMT = struct.Struct('<Q')
```

```python
nemo_automodel.components.speculative.eagle.remote.wire._NDIM_FMT = struct.Struct('<B')
```

```python
nemo_automodel.components.speculative.eagle.remote.wire._SHAPE_FMT = struct.Struct('<q')
```