---
myst:
  html_meta:
    description: "Per-engine compile-artifact manifest for vLLM Neuron"
    content_type: "conceptual-deep-dive"
    date-modified: "2026-08-07"
---

# Compile-Artifact Manifest

## Overview

Each engine emits one `manifest.json` that lists every graph it compiled
(HLO / NEFF) alongside the config that produced them, so a reader consumes one
file instead of crawling the raw compile-cache directories.

- **Per engine** — one manifest per engine, named by the engine's core window,
  so a data-parallel or co-located deployment produces one file each.
- **Self-describing** — each graph entry carries its cache paths, shapes,
  compiler flags, and the ranks that traced it; `config` records the model,
  parallelism, and resolved Neuron / vLLM settings.
- **Best-effort and off by default** — gated by `VLLM_NEURON_MANIFEST_DIR`; it
  never affects compilation, warmup, or serving.

The feature is enabled by setting **`VLLM_NEURON_MANIFEST_DIR`** to a directory.
Unset or empty, nothing is recorded and no manifest is written — there is no
default location.

### Why a Manifest?

A deployment's compiled artifacts are otherwise discoverable only by walking the
compile cache: a content-addressed tree of `native_neff_cache/<aa>/<bb>/<md5>.neff`
files with no record of which engine produced them, which config they came from, or
— under data and expert parallelism — which shard each graph belongs to. The manifest turns that into a
single per-engine file that:

- names the graphs an engine actually compiled this run, with their config;
- attributes each graph to the ranks that traced it, so a consumer can tell a
  complete deployment from a partial one;
- is cheap to collect and diff across runs.

## Architecture

The manifest is assembled in two phases from a compile-time **ledger**: every
worker records the graphs it traces during compilation, and one process per
engine reads that ledger after warmup and writes the manifest.

### Directory Layout

```text
$VLLM_NEURON_MANIFEST_DIR/
├── ledger/
│   ├── dev0_7/                  # engine 0 (cores 0-7): compile-time ledger
│   │   ├── 41234.jsonl          #   one JSONL file per writer process
│   │   └── 41240.jsonl
│   └── dev8_15/                 # engine 1 (cores 8-15)
│       └── …
├── dev0_7/
│   └── manifest.json            # emitted by local_rank 0 of engine 0
└── dev8_15/
    └── manifest.json
```

`<engine-id>` is `get_server_prefix()` — `dev{first}_{last}` over
`NEURON_VISIBLE_DEVICES`, or `nodev` when no device is visible (CPU-compile).
The manifest filename is fixed and written atomically (temp file + `os.replace`),
so relaunching an engine overwrites its manifest and nothing accumulates.

### Record — Compile Time, Every Rank

While a graph is captured (Lite's `capture()` backend), the process appends one
line to its own ledger file `ledger/<engine-id>/<pid>.jsonl`:

```json
{"key": "<graph_hash>", "rank": 3, "input_shapes": ["4,", "..."], "compiler_flags": "--framework XLA --target trn2 ..."}
```

- `key` — the graph's content hash (its compile-cache directory name).
- `rank` — the writer's TP-group-relative rank (`get_tp_group().rank_in_group`);
  the emitter maps this to the writer's global rank for the manifest's `ranks`.
- `input_shapes` / `compiler_flags` — captured inline from the traced inputs and
  the resolved compile options; no artifact files are read.

Writes are raw `os.write` so a line survives the trace fork children's
`os._exit()` (which skips buffered flushes), and each process writes its own file
so concurrent lanes never contend. The first write of a run truncates the file —
discarding any stale same-pid file left by a prior run — and later writes append.
When the feature is off, nothing is computed or written.

On the native route, a second record type goes to the same directory. Lite
maps each cache key to the persistent key that names its NEFF when the graph
first runs. `ManifestWriter.arm_ledger` applies a patch that wraps that Lite recorder
(`vllm_neuron/vllm/patches/persistent_key_recorder_patch.py`), so each first
run also appends one line to `ledger/<engine-id>/<pid>.persistent_keys.jsonl`:

```json
{"key": "<graph_hash>", "backend": "native", "persistent_key": "<pk>"}
```

The emitter groups this line with the compile record that has the same `key`,
and uses `persistent_key` to name the NEFF. Lite's own index entry is named by
a digest of the compiler environment of the process, so a reader in another
process can miss it. The recorded key does not depend on the process. The
wrapper is installed once per process, only on the native route, and it never
raises.

### Emit — After Warmup, `local_rank == 0`

One process per engine reads its own engine's ledger and writes
`<engine-id>/manifest.json`:

1. **Group** the ledger lines by `key`, accumulating the ranks that traced each
   graph and mapping each writer's TP-local rank to its global rank (via the
   engine's TP group).
2. **Enrich** each graph from the NEFF the compiler wrote for it —
   `neff_path`, `neff_size`, and `created_timestamp` come from one `stat` of that
   file.
3. **Join** the live `VllmConfig` (`config`) and a package-version snapshot
   (`environment`).
4. **Write** the file atomically.

The manifest is written **whenever the feature is on**, even if the ledger is
empty (→ `"graphs": []`). Because the filename is fixed.

### Cleanup

After emitting, `local_rank == 0` removes its engine's `ledger/<engine-id>`
subdirectory. Other ranks remove nothing, and the shared `ledger/` root is left
in place — engines clean up independently.

The emit deletes every warmup line, so any line that is in the ledger later
was written during serving. Example: a graph with no warmup, such as an
encoder, compiles on the first request. Its record goes to a new
`ledger/<engine-id>/` directory, and `manifest.json` does not list it. The
profile tests read these records to find the late NEFFs, and they assert on
them (`test/utils/neuron_explorer.py`: `find_late_graphs`). A record whose
`key` is also in `manifest.json` is not counted. This holds only for a cold
start: a warm start from a precompile package does not trace, so it writes no
records.

These records stay after the server stops. The next run on the same devices
uses the same `ledger/<engine-id>/` directory. So `arm_ledger` first removes
each ledger file that is older than its writer, and the emit reads only the
records of its own run. The writer gets its creation time from the mtime of a
temporary marker file in `ledger/`. The filesystem also sets the mtime of each
ledger file, so clock skew between a host and a shared file server has no
effect.

Every step above is **best-effort**: a ledger-write, enrichment, or emit failure
is logged and swallowed, so the manifest can never break compilation, warmup, or
a request.

## Manifest Schema

The schema is versioned (`manifest_version`, currently `"1"`) and defined in
`vllm_neuron/manifest/schema.py`.

Top level:

| Field | Contents |
| ---- | ---- |
| `manifest_version` | Schema version (`"1"`) |
| `config` | How the run was compiled/served (below) |
| `graphs` | One entry per compiled graph (below) |
| `environment` | Installed package versions + Python (a pip-freeze snapshot) |

`config`:

| Field | Contents |
| ---- | ---- |
| `model`, `target`, `dtype` | Model path, compiler target (e.g. `trn2`), dtype |
| `max_num_seqs`, `max_model_len` | Max concurrent sequences, max sequence length |
| `topology` | `world_size`, `tensor_parallel_size`, `pipeline_parallel_size`, `data_parallel_size`, `attention_dp_size`, `ep_degree` (resolved), `decode_context_parallel_size`, `has_collectives` |
| `neuron_config` | Full resolved Neuron config |
| `vllm_config` | Full resolved vLLM `VllmConfig` — every sub-config (model / cache / parallel / scheduler / compilation / …), JSON-coerced |

`graphs[]`:

| Field | Contents |
| ---- | ---- |
| `graph_hash` | The graph's content hash. It is NOT a directory name: a NEFF is addressed by its own MD5 |
| `neff_path` | Path relative to `native_neff_cache`, as `<aa>/<bb>/<md5>.neff` |
| `hlo_path` | Relative path of a `graph.hlo`, or `null`. Not currently supported with the PyTorch Native backend. |
| `neff_size`, `created_timestamp` | NEFF size in bytes and compile time (ISO 8601 — the NEFF mtime) |
| `input_shapes`, `output_shapes` | Ordered shape strings (`""` for a scalar) |
| `compiler_flags` | `neuronx-cc` flags, machine-specific paths removed |
| `ranks` | Global ranks (`0..world_size-1`) that traced this graph |
| `input_snapshot_paths`, `output_snapshot_paths` | Reserved; a graph maps to 0..N snapshots, so each is a list (currently empty) |

Example (TP=2 dense model, trimmed):

```json
{
  "manifest_version": "1",
  "config": {
    "model": "TinyLlama/TinyLlama-1.1B-Chat-v1.0",
    "target": "trn2",
    "dtype": "torch.bfloat16",
    "max_num_seqs": 4,
    "max_model_len": 256,
    "topology": {"world_size": 2, "tensor_parallel_size": 2, "data_parallel_size": 1,
                 "ep_degree": 1, "has_collectives": true},
    "neuron_config": {"...": "..."},
    "vllm_config": {"...": "..."}
  },
  "graphs": [
    {
      "graph_hash": "fc5c06b7...",
      "hlo_path": null,
      "neff_path": "a4/3b/a43b08b578346c9318026903c55e043f.neff",
      "neff_size": 949498,
      "created_timestamp": "2026-08-06T20:37:11.818072+00:00",
      "input_shapes": ["4,", "4,", "..."],
      "output_shapes": ["4", "4, 49152", "..."],
      "compiler_flags": "--framework XLA --target trn2 --auto-cast=none ...",
      "ranks": [0, 1],
      "input_snapshot_paths": [],
      "output_snapshot_paths": []
    }
  ],
  "environment": {"python": "3.13.7", "torch": "2.11.0", "vllm": "0.24.0"}
}
```

## Engine Identity

`<engine-id>` is the engine's physical core window, from `get_server_prefix()`.
On Neuron, whenever `data_parallel_size > 1` each engine is assigned a disjoint
physical device slice and narrows `NEURON_VISIBLE_DEVICES` to it, so two engines
on one host never resolve to the same window. It is the same value the compile
cache uses to scope its per-rank subdirectories, so a manifest correlates
directly with the cache it describes.

The prefix is per-engine only *after* that narrowing, which happens in
`init_device`. Every manifest and ledger path is resolved later, during warmup,
so the value is always per-engine by the time it is used.

## Environment Variables

| Variable | Default | Description |
| ---- | ---- | ---- |
| `VLLM_NEURON_MANIFEST_DIR` | (unset) | Directory that ledgers and manifests are written under. A path enables the feature; unset or empty disables it. There is no default location. |
