Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions GLOSSARY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Glossary

## Prefill (P)

The stage that consumes a request prompt and produces the key/value state and
final prompt hidden state needed by Decode.

## Decode (D)

The stage that owns coda execution, first-token sampling and subsequent token
generation after a transfer is received.

## Transfer Generation (`tid`)

A unique identity for one handoff of one request. It separates a current
handoff from an older handoff that used the same external request ID.

## Logical Payload

The key/value state and final prompt hidden state required by Decode. Protocol
metadata and transport framing are outside the logical payload.

## Received

A transfer state in which Decode has received every declared payload chunk and
the destination device writes are safe to read.

## Activated

A transfer state in which the received request has entered Decode scheduling.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ a fixed scale at startup. See the

| Checkpoint | Implementation | Platforms | Documented validation scope |
| --- | --- | --- | --- |
| Ouro-1.4B | Native Ouro | [CUDA](docs/launching.md)<br>[Ascend](docs/recipes/ouro_ascend.md) | Ascend BF16 full prefill with eager Python execution, paged KV and optional fixed-depth async scheduling. Arbitrary chunked prefill remains unresolved. |
| Ouro-1.4B | Native Ouro | [CUDA](docs/launching.md)<br>[Ascend](docs/recipes/ouro_ascend.md) | Ascend BF16 full prefill with eager Python execution, paged KV, optional fixed-depth async scheduling and experimental same-host 2P2D PD. Arbitrary chunked prefill remains unresolved. |
| Ouro-2.6B | Shared Ouro | [CUDA](docs/launching.md) | Shares the Ouro implementation. [Separate quality and performance qualification](docs/recipes/ouro_thinking.md#6-evidence-and-limitations) remains open. |
| [Ouro-1.4B-Thinking](docs/recipes/ouro_thinking.md) | Reuses Ouro | [CUDA](docs/launching.md) | Bounded BF16, fixed-four-loop synchronous basic integration |
| [Ouro-2.6B-Thinking](docs/recipes/ouro_thinking.md) | Reuses Ouro | [CUDA](docs/launching.md) | Bounded BF16, fixed-four-loop synchronous basic integration |
Expand Down
160 changes: 160 additions & 0 deletions benchmarks/ascend_pd_2p2d.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
"""Run a reproducible same-host Ascend 2P2D PD smoke and write JSON metrics."""

import argparse
import json
import os
import time
from pathlib import Path

from vllm_rlt import CacheConfig, ExecutionConfig, ExitConfig, SamplingParams, SchedulerConfig
from vllm_rlt.pd.config import PDConfig
from vllm_rlt.pd.engine import PDEngine

PROMPTS = {
"r0": [3, 7, 2, 11, 5, 17, 8],
"r1": [5, 9, 11, 13, 15, 19],
"r2": [2, 4, 6, 8, 10],
"r3": [1, 12, 14, 16, 18, 20, 22, 24],
}


def drain(engine, expected, timeout):
outputs = {}
deadline = time.monotonic() + timeout
while len(outputs) < expected:
for output in engine.step():
if output.finished:
outputs[output.request_id] = output
if time.monotonic() >= deadline:
if os.getenv("VLLM_RLT_PD_DEBUG"):
print(
"PD debug transfers="
+ repr(
{
tid: {
"phase": transfer.phase,
"cancelled": transfer.cancelled,
"p": transfer.p,
"d": transfer.d,
"timings": transfer.timings,
}
for tid, transfer in engine.transfers.items()
}
),
flush=True,
)
print(
"PD debug peers="
+ repr(
{
name: {
"role": peer.role,
"slots": peer.slots,
"reserved_blocks": peer.reserved_blocks,
"ready": peer.client.ready,
"connected": peer.client.connected,
"failure": peer.client.failure,
"alive": peer.client.process.is_alive(),
}
for name, peer in engine.peers.items()
}
),
flush=True,
)
raise TimeoutError(f"received {len(outputs)} of {expected} outputs")
return outputs


def run(args):
params = SamplingParams(
max_tokens=args.max_tokens,
min_loops=4,
max_loops=4,
temperature=0,
ignore_eos=True,
)
cache = CacheConfig(num_blocks=args.num_blocks, block_size=args.block_size)
engine = None
result = None
started = time.monotonic()
try:
engine = PDEngine(
args.model,
pd_config=PDConfig(
device_type="npu",
prefill_devices=tuple(args.prefill_devices),
decode_devices=tuple(args.decode_devices),
backend="HCCL",
transfer_chunk_bytes=args.transfer_chunk_bytes,
max_inflight_bytes=args.max_inflight_bytes,
startup_timeout=args.startup_timeout,
request_timeout=args.request_timeout,
shutdown_timeout=args.shutdown_timeout,
),
prefill_cache_config=cache,
decode_cache_config=cache,
prefill_scheduler_config=SchedulerConfig(
max_num_seqs=2,
max_num_batched_tokens=args.prefill_tokens,
prefill_chunk_size=args.prefill_tokens,
),
decode_scheduler_config=SchedulerConfig(max_num_seqs=2, max_num_batched_tokens=16),
execution_config=ExecutionConfig(async_scheduling=False),
exit_config=ExitConfig("ouro"),
attention_backend="ascend_eager",
dtype="bfloat16",
)
for request_id, prompt in PROMPTS.items():
engine.add_request(request_id, prompt, params)
outputs = drain(engine, len(PROMPTS), args.request_timeout)
result = {
"model": args.model,
"topology": {
"prefill_devices": args.prefill_devices,
"decode_devices": args.decode_devices,
},
"elapsed_seconds": time.monotonic() - started,
"outputs": {
request_id: {
"token_ids": output.token_ids,
"exit_depths": output.exit_depths,
"finish_reason": output.finish_reason,
}
for request_id, output in outputs.items()
},
"request_metrics": list(engine.metrics),
}
return result
finally:
if engine is not None:
engine.close()
if result is not None:
result["worker_metrics"] = engine.worker_metrics


def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--model", required=True)
parser.add_argument("--output", type=Path)
parser.add_argument("--prefill-devices", type=int, nargs="+", default=[0, 1])
parser.add_argument("--decode-devices", type=int, nargs="+", default=[2, 3])
parser.add_argument("--num-blocks", type=int, default=128)
parser.add_argument("--block-size", type=int, default=16)
parser.add_argument("--prefill-tokens", type=int, default=128)
parser.add_argument("--max-tokens", type=int, default=8)
parser.add_argument("--transfer-chunk-bytes", type=int, default=16 * 1024 * 1024)
parser.add_argument("--max-inflight-bytes", type=int, default=64 * 1024 * 1024)
parser.add_argument("--startup-timeout", type=float, default=300)
parser.add_argument("--shutdown-timeout", type=float, default=90)
parser.add_argument("--request-timeout", type=float, default=900)
args = parser.parse_args()
result = run(args)
encoded = json.dumps(result, indent=2)
if args.output is not None:
args.output.parent.mkdir(parents=True, exist_ok=True)
args.output.write_text(encoded + "\n")
print(encoded)


if __name__ == "__main__":
main()
40 changes: 40 additions & 0 deletions docs/adr/0001-ascend-pd-hccl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# ADR 0001: Use HCCL for Initial Ascend 2P2D PD

- Status: Accepted for the current Ascend PD implementation
- Date: 2026-11-23

## Context

PR #168 provides the Ascend eager execution path, paged KV and NPU stream and
event handling. The existing PD transport registers CUDA allocations through
NIXL. The target Ascend environment provides HCCL point-to-point communication
for NPU tensors.

The PD contract still requires destination reservation before Prefill work,
transfer generations, receipt after destination writes complete, and safe
retirement after all local and remote users release their allocations.

## Decision

Add an explicit Ascend `HCCL` transport for same-host 2P2D. Each worker joins
one HCCL process group. The transport packs descriptor ranges into NPU uint8
buffers, submits asynchronous point-to-point sends and receives, then copies
received buffers into the destination KV and hidden tensors. CUDA deployments
keep the existing NIXL transport.

Workers run a synchronized one-byte `batch_isend_irecv` warmup for every
Prefill/Decode pair before serving requests. HCCL creates pair subgroups for
the subsequent traffic, and the connector serializes transfers across tids so
each subgroup sees the same operation order on both ranks.

The qualified Ascend scope is Ouro-1.4B, BF16, fixed four loops, greedy full
prefill and `last_exited` KV. HCCL receive plans are created after D reserves
its destination and posted lazily after P starts its matching sends. The fixed
full-prefill geometry provides matching source and destination chunk boundaries.

## Consequences

The implementation can validate multi-worker output equality, transfer byte
accounting and resource retirement on one host. It is limited to full prefill
and the fixed BF16 scope above. Cross-host transport and unsupported execution
features require separate validation.
25 changes: 25 additions & 0 deletions docs/recipes/ouro_ascend.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,31 @@ curl --fail http://127.0.0.1:8123/v1/completions \
-d '{"model":"ouro","prompt":"The capital of France is","max_tokens":8,"temperature":0,"min_loops":4,"max_loops":4,"exit_threshold":1}'
```

## Same-host 2P2D PD

The PD path supports an experimental same-host 2P2D deployment for Ouro-1.4B.
Use BF16, fixed four loops, greedy decoding, full prefill and `last_exited` KV.
Prefill and decode workers run on separate NPU pools and exchange device
buffers through asynchronous HCCL point-to-point operations.

Expose four physical NPUs and use their logical indices inside the process.
The benchmark writes request outputs, lifecycle timings and per-worker byte
accounting to a JSON file.

```bash
export ASCEND_RT_VISIBLE_DEVICES=0,1,2,3 # replace with four free NPUs
# If another HCCL job uses the default interface, set HCCL_IF_IP and
# HCCL_SOCKET_IFNAME to the host's dedicated HCCL interface before launching.
python benchmarks/ascend_pd_2p2d.py \
--model "$MODEL" \
--output /tmp/ascend-pd-2p2d.json \
--prefill-devices 0 1 \
--decode-devices 2 3
```

The qualified scope excludes FP8 KV, prefix caching, preemption, speculation,
CUDA graphs, WCPB, chunked prefill and cross-host transport.

<a id="6-fixed-depth-asynchronous-engine-plan"></a>
## Fixed-depth asynchronous engine plan

Expand Down
Loading