Official Inference Code of EAGLE-4
Release 0.1.4: order symm-mem collectives across caller streams
Seyfal Sultanovea927fad3fbe
diff --git a/docs/install.md b/docs/install.mdindex db39a61..2eb49bf 100644--- a/docs/install.md+++ b/docs/install.md@@ -36,7 +36,7 @@ Then follow the [SGLang guide](quickstart-sglang.md).```bashpython3.12 -m venv .venv && source .venv/bin/activate-pip install "eagle-harness[vllm]" "vllm==0.32.0rc1.dev283+eagle.4" \+pip install "eagle-harness[vllm]" "vllm==0.32.0rc1.dev283+eagle.5" \--extra-index-url https://eagle-hq.github.io/EAGLE-4/whl/cu130/ \--extra-index-url https://download.pytorch.org/whl/cu130```diff --git a/docs/release-notes/0.1.4.md b/docs/release-notes/0.1.4.mdnew file mode 100644index 0000000..c0691c1--- /dev/null+++ b/docs/release-notes/0.1.4.md@@ -0,0 +1,53 @@+# EAGLE-4 0.1.4++EAGLE-4 combines a draft model with `eagle-harness` inside your inference engine to adapt speculative decoding to your hardware, batch and workload. Version 0.1.4 is a correctness release for vLLM with tensor parallelism. It fixes two ordering bugs in the symmetric-memory collectives that vLLM and `eagle-harness` use on two or more GPUs. During server startup and CUDA graph capture, vLLM issues these collectives from several CUDA streams, and CUDA does not order work across streams. Two collectives could then overlap on one GPU and share its buffer, so an all-reduce could return wrong sums, the draft's candidate all-gather could mix rows, or the GPUs could deadlock during startup or graph capture.++- vLLM's symmetric-memory all-reduce (on by default, `VLLM_ALLREDUCE_USE_SYMM_MEM=1`) now waits for the previous all-reduce whenever the calling stream changes.+- The `eagle-harness` candidate all-gather on vLLM does the same.++Calls from one stream were already ordered, so steady-state decoding does no extra work. One-GPU vLLM, SGLang and TokenSpeed do not use these paths.++This release ships vLLM `0.32.0rc1.dev283+eagle.5`, built from [eagle-hq/vllm `eagle/v0.1.4`](https://github.com/eagle-hq/vllm/tree/eagle/v0.1.4). It is `+eagle.4` plus the all-reduce fix, with the same native libraries. SGLang CUDA `0.5.23.dev252+eagle.9` and TokenSpeed `0.1.1+eagle.8` are unchanged.++## Install++You don't need to download anything from the release page. In a Python 3.12 environment, install the vLLM packages together:++```bash+pip install "eagle-harness[vllm]==0.1.4" "vllm==0.32.0rc1.dev283+eagle.5" \+ --extra-index-url https://eagle-hq.github.io/EAGLE-4/whl/cu130/ \+ --extra-index-url https://download.pytorch.org/whl/cu130+```++To upgrade a 0.1.3 vLLM environment, run this command, then run `eagle-harness-check`. SGLang and TokenSpeed users can install `eagle-harness==0.1.4` with their 0.1.3 engine pins: the [install guide](../install.md) lists them. Nothing in the configuration changed.++| Engine | 0.1.4 pins |+| --- | --- |+| SGLang CUDA | `eagle-harness[sglang]==0.1.4`, `sglang==0.5.23.dev252+eagle.9` (unchanged) |+| vLLM | `eagle-harness[vllm]==0.1.4`, `vllm==0.32.0rc1.dev283+eagle.5` |+| TokenSpeed | `eagle-harness[tokenspeed]==0.1.4`, `tokenspeed==0.1.1+eagle.8` and its 0.1.3 scheduler, kernel and engine wheels (unchanged) |++## What was checked++- **Stress tests on B300.** Collectives alternated between two calling streams while one GPU lagged 20 ms on every seventh call, and every result was checked:+ - All-reduce: without the fix, 40 of 40 check windows were wrong at both 8 and 2 GPUs. With it, none were.+ - Candidate all-gather: without the fix, 393 of 400 results were wrong at 8 GPUs and up to 226 of 400 at 2 GPUs. With it, none were.+- **Serving check.** We served Qwen3.8-27B with the EAGLE-4 draft on vLLM and compared the fixed build with 0.1.3 on four B300 GPUs and on one, with greedy decoding. The checked build also had three experimental options turned on that this release leaves out; they are off by default and changed no output:+ - Outputs: token-identical between the two builds on all 20 prompts, at both GPU counts. Both builds pass the release correctness check against vLLM without speculation.+ - Logprobs: identical on all 768 checked positions.+ - Speed: four interleaved server starts per build, at 1, 32, 64 and 128 concurrent requests. Every cell is within the start-to-start spread; the fixed build measures 0.99× to 1.04× the throughput of 0.1.3.+ - Measured throughput: 713.6 against 712.6 output tokens per second at 1 request on four GPUs, and 7,890 against 7,858 at 64.++## Limits++This release changes nothing else, so the [0.1.3 limits](0.1.3.md#limits) and [known limits](../known-limits.md) still apply. Two items that the 0.1.3 notes planned for 0.1.4 move to a later release:++- Comparing the vLLM check against plain decoding at the same batch size.+- TokenSpeed static mode with the sliding-window EAGLE-4 draft. Serve mode remains the supported TokenSpeed path.++The 0.1.3 speed tables remain the current speed measurements.++## Files on the release page++Install `eagle-harness` from PyPI. The engine index selects the matching engine wheels from their release assets.+The source archives are for reading or building the code, not required for installation.diff --git a/docs/release.env b/docs/release.envindex 6db01df..336b43c 100644--- a/docs/release.env+++ b/docs/release.env@@ -21,7 +21,7 @@ export EAGLE_VLLM_IMAGE="$EAGLE_IMAGE_ROOT-vllm:$EAGLE_IMAGE_VERSION"export EAGLE_TOKENSPEED_IMAGE="$EAGLE_IMAGE_ROOT-tokenspeed:0.1.3"export EAGLE_SGLANG_VERSION='0.5.23.dev252+eagle.9'export EAGLE_ROCM_VERSION='0.5.23.dev252+eagle.4.rocm'-export EAGLE_VLLM_VERSION='0.32.0rc1.dev283+eagle.4'+export EAGLE_VLLM_VERSION='0.32.0rc1.dev283+eagle.5'export EAGLE_TOKENSPEED_VERSION='0.1.1+eagle.8'export EAGLE_TORCH_CUDA_INDEX='https://download.pytorch.org/whl/cu130'# The pinned SGLang dependency cuda-tile==1.6.0rc5 has vendor wheels here.diff --git a/eagle_harness/compat.py b/eagle_harness/compat.pyindex d100749..b6a71c5 100644--- a/eagle_harness/compat.py+++ b/eagle_harness/compat.py@@ -51,7 +51,7 @@ HOSTS = (Host("vllm",SpecifierSet(">=0.32.0rc1.dev283,!=0.32.0"), # = the `vllm` extra in pyproject.toml- "vLLM 0.32.0rc1.dev283+eagle.4 = main 074c83a09a + eagle-harness hooks and fixes",+ "vLLM 0.32.0rc1.dev283+eagle.5 = main 074c83a09a + eagle-harness hooks and fixes","eagle_harness.vllm.adapter:missing_hooks",),Host(diff --git a/eagle_harness/vllm/candidate_gather.py b/eagle_harness/vllm/candidate_gather.pyindex 626ccce..e2dfb22 100644--- a/eagle_harness/vllm/candidate_gather.py+++ b/eagle_harness/vllm/candidate_gather.py@@ -31,6 +31,16 @@ class CandidateGather:The symmetric buffer is allocated at the first call (a warm-up run, which every rank makes at the same time;never inside a CUDA graph capture) and holds the result until the next call.++ Gathers must run in the order they were issued on every rank: the op's barriers match by order and every gather+ reuses one buffer. vLLM runs the draft from several streams during startup (profiling, warm-up, graph capture),+ and CUDA does not order kernels across streams, so wrong rows or a hang could follow (torch warns "detected+ multiple CUDA streams issuing symm_mem collectives"). When the calling stream changes, the new stream first waits+ for the previous one: for the gathers and for any reads of the previous result issued there. Calls on one stream+ are already ordered, so steady-state decode pays nothing; a fence on every call cost 2.5% of decode at TP2.+ Captures are not fenced: one starts after a device synchronize (torch.cuda.graph) and cannot wait on a stream+ outside it, and a graph replays its gathers in order on the stream that launches it. Torch still prints its+ warning on each stream switch; the warning checks streams, not ordering."""def __init__(self, group: Any, max_rows: int):@@ -38,6 +48,7 @@ class CandidateGather:self.max_rows = max_rowsself.out: torch.Tensor | None = Noneself._tried = False+ self._last_stream: torch.cuda.Stream | None = Nonedef _allocate(self, x: torch.Tensor) -> None:self._tried = True@@ -62,5 +73,10 @@ class CandidateGather:if self.out is None or rows > self.max_rows or x.dtype != self.out.dtype or not x.is_contiguous():return self.group.all_gather(x, dim=0)out = self.out[: world * rows * width].view(world * rows, width)+ if x.is_cuda and not torch.cuda.is_current_stream_capturing():+ stream, last = torch.cuda.current_stream(x.device), self._last_stream+ if last is not None and last != stream:+ stream.wait_stream(last)+ self._last_stream = stream_multimem_all_gather_out(x, self.group.device_group.group_name, out)return outdiff --git a/tests/test_candidate_gather.py b/tests/test_candidate_gather.pyindex 52219ac..d580799 100644--- a/tests/test_candidate_gather.py+++ b/tests/test_candidate_gather.py@@ -100,6 +100,54 @@ def test_candidate_gather_two_ranks_is_the_rank_major_concat():print(sorted(results.get() for _ in range(2)))+def _two_stream_gather(rank: int, world: int, port: int, results) -> None:+ """Gathers issued from two caller streams in turn while one rank lags at a time (vLLM's startup: warm-up, then a+ new stream per graph capture). Each caller copies its result on its own stream before the next gather, as the+ draft does; every copy must hold that step's rows."""+ import time++ import torch.distributed as dist++ from eagle_harness.vllm.candidate_gather import CandidateGather++ torch.cuda.set_device(rank)+ dist.init_process_group("nccl", init_method=f"tcp://127.0.0.1:{port}", rank=rank, world_size=world)+ try:+ group = SimpleNamespace(world_size=world, device_group=dist.group.WORLD, all_gather=None)+ gather = CandidateGather(group, max_rows=64)+ streams = [torch.cuda.Stream() for _ in range(2)]+ copies, bad = [], 0+ for step in range(400):+ if rank == step % world and step % 7 == 0:+ time.sleep(0.02)+ with torch.cuda.stream(streams[step % 2]):+ x = torch.full((16, 24), 1000 * step + rank, dtype=torch.int64, device="cuda")+ copies.append((step, gather(x).clone()))+ if step % 50 == 49:+ torch.cuda.synchronize()+ for s, got in copies:+ want = torch.arange(world, device="cuda").repeat_interleave(16)[:, None] + 1000 * s+ bad += not torch.equal(got, want.expand(-1, 24))+ copies.clear()+ results.put((rank, "multicast" if gather.out is not None else "fallback", bad))+ finally:+ dist.destroy_process_group()++[email protected](torch.cuda.device_count() < 2, reason="needs two GPUs")+def test_candidate_gather_from_two_streams_keeps_every_result():+ """Two streams, lagging ranks: no gather returns or keeps another step's rows, and no rank hangs."""+ import torch.multiprocessing as mp++ world = min(torch.cuda.device_count(), 8)+ ctx = mp.get_context("spawn")+ results = ctx.Queue()+ mp.start_processes(_two_stream_gather, args=(world, 29547, results), nprocs=world, start_method="spawn")+ got = sorted(results.get() for _ in range(world))+ print(got)+ assert all(bad == 0 for _, _, bad in got), got++@pytest.mark.skipif(torch.cuda.device_count() < 1, reason="needs a GPU")def test_candidate_gather_single_rank_is_the_input():"""One rank: the multicast path (when the host has it) returns the input itself."""