[NIXL] Prepare KV transfer descriptors as NIXL 1.5 strided lists (#61032)

Signed-off-by: Nick Hill <nickhill123@gmail.com>
Co-authored-by: Ilia Yastrebov <iyastrebov@nvidia.com>
This commit is contained in:
Nick Hill
2026-10-14 18:07:24 +02:00
committed by GitHub
co-authored by Ilia Yastrebov
parent 9e2b579aab
commit eaf25f675a
11 changed files with 343 additions and 227 deletions
+16
View File
@@ -8,6 +8,7 @@ from itertools import chain, count
from typing import Any, Literal
from unittest.mock import Mock
import numpy as np
import torch
from vllm import SamplingParams
@@ -682,3 +683,18 @@ def make_moriio_writer(fake_worker: Any) -> Any:
writer._defer_timeout = 60.0
writer.ensure_worker_started = lambda: None
return writer
def expand_strided_descs(strided_descs: np.ndarray) -> np.ndarray:
"""Expand Nx5 (addr, len, dev, stride, count) rows to one row per block.
Mirrors how NIXL indexes a strided descriptor list, so desc ids computed
by the connector can be resolved to (addr, len, dev) byte ranges.
"""
strided_descs = np.asarray(strided_descs, dtype=np.uint64).reshape(-1, 5)
counts = strided_descs[:, 4].astype(np.intp)
starts = np.cumsum(strided_descs[:, 4]) - strided_descs[:, 4]
out = np.repeat(strided_descs[:, :3], counts, axis=0)
offsets = np.arange(len(out), dtype=np.uint64) - np.repeat(starts, counts)
out[:, 0] += offsets * np.repeat(strided_descs[:, 3], counts)
return out