Official Inference Code of EAGLE-4
chore(pkg): delete the write-only calibration flag and other orphans
Seyfal Sultanovd148ffe98a37
diff --git a/eagle_harness/core/calibration.py b/eagle_harness/core/calibration.pyindex 958eb47..c705aa9 100644--- a/eagle_harness/core/calibration.py+++ b/eagle_harness/core/calibration.py@@ -9,7 +9,6 @@ The files written here match the golden fixtures for the same raw measurementsLayout under a calibration ``data_path``::config/measure_config.json MeasureParams of the batch being measured- config/task_normal.json [{"task_normal": bool}]: false = unstable, retrytest/bs_<N>/{model,cache}_{slm,llm}/ raw timings (jsonl, one record per line)cost/bs_<N>/{cache,query,model}_{slm,llm}/ fitted costs (json)@@ -23,7 +22,7 @@ import loggingimport osfrom collections import defaultdictfrom dataclasses import asdict, dataclass-from typing import Dict, List, Optional, Sequence, Tuple+from typing import Dict, List, Sequence, Tupleimport numpy as np@@ -150,15 +149,6 @@ class CalibrationPaths:"""Store the measurement settings."""_save_json_lines(os.path.join(self.config, "measure_config.json"), [asdict(params)])- def set_task_normal(self, normal: bool) -> None:- """Store the ``task_normal`` flag of the calibration run."""- _save_json_lines(os.path.join(self.config, "task_normal.json"), [{"task_normal": normal}])-- def task_normal(self) -> bool:- """The stored ``task_normal`` flag."""- rows = load_jsonl(os.path.join(self.config, "task_normal.json"))- return bool(rows[0]["task_normal"])-@dataclass(frozen=True)class CacheSweepPlan:@@ -263,10 +253,9 @@ def fit_cache_costs(batch_size: int,intensity: ComputeIntensity,fast: bool = False,- paths: Optional[CalibrationPaths] = None,) -> float:"""Per-interval attention cost per layer, per query length. Returns the- instability rate; above the limit, ``paths`` gets ``task_normal=false``."""+ instability rate; above the limit, a warning is logged."""interval_data: Dict[int, Dict[int, List[float]]] = defaultdict(lambda: defaultdict(list))for qo_len in query_lens(category, batch_size, intensity, max_query_length):file_path = os.path.join(source, f"cache_qo_len_{qo_len}.jsonl")@@ -290,8 +279,6 @@ def fit_cache_costs(instability = unstable / total if total > 0 else 0.0if instability >= (0.20 if fast else 0.25):logger.warning("High cache-cost instability: %.2f%%", instability * 100)- if paths is not None:- paths.set_task_normal(False)for interval_id in range((cache_length_stop - cache_length_start) // cache_length_step):sequence = means.get(interval_id, [0.0] * max_query_length)@@ -340,7 +327,6 @@ def fit_query_costs(average: bool = False,sliding_window_layers: int = 0,sliding_window: int = 0,- paths: Optional[CalibrationPaths] = None,) -> float:"""Non-attention cost per query length: measured step minus fitted attention."""cache_costs = _load_cache_arrays(cache_source)@@ -379,8 +365,6 @@ def fit_query_costs(instability = unstable / total if total > 0 else 0.0if instability >= 0.30:logger.warning("High query-cost instability: %.2f%%", instability * 100)- if paths is not None:- paths.set_task_normal(False)for qo_len in lens:file_path = os.path.join(target, f"query_{qo_len}.json")with open(file_path, "r+", encoding="utf-8") as f:@@ -505,7 +489,6 @@ def fit_batch(batch_size=bs,intensity=intensity,fast=params.enable_fast_measurement,- paths=paths,)for model, shape, max_q, average in ((DRAFT, draft, params.node_top_k, (not params.enable_fast_measurement) or tp_size > 1),@@ -525,7 +508,6 @@ def fit_batch(average=average,sliding_window_layers=shape.sliding_window_layers,sliding_window=shape.sliding_window,- paths=paths,)for model, shape, max_q, max_cache in ((DRAFT, draft, params.node_top_k, params.node_top_k),@@ -595,7 +577,6 @@ def fit_step_timings() -> None:"""Store the raw timings of one batch size and run all fits, from whole-step timings of the draft and the target."""paths.write_measure_params(params)- paths.set_task_normal(True)bs = params.batch_sizefor model, (shape, timings) in ((DRAFT, draft), (TARGET, target)):save_model_timings(diff --git a/eagle_harness/sglang/algorithm.py b/eagle_harness/sglang/algorithm.pyindex 2e468bd..9b0d145 100644--- a/eagle_harness/sglang/algorithm.py+++ b/eagle_harness/sglang/algorithm.py@@ -90,11 +90,6 @@ def harness_config() -> HarnessConfig:return parse_harness_config(get_spec().speculative_algorithm_config)-def harness_mode() -> Mode:- """The harness mode of this process."""- return harness_config().mode--class EagleHarnessSpecAlgo(CustomSpecAlgo):"""Algorithm-level hooks. One instance per process (the registry's)."""diff --git a/eagle_harness/tokenspeed/__init__.py b/eagle_harness/tokenspeed/__init__.pyindex 38d037d..d898f2f 100644--- a/eagle_harness/tokenspeed/__init__.py+++ b/eagle_harness/tokenspeed/__init__.py@@ -6,12 +6,5 @@Registered through the ``tokenspeed.plugins`` entry point (see pyproject.toml) and TokenSpeed's plugin registries, withthe generic hooks of TokenSpeed branch ``pr-spec-plugin-hooks``; nothing in TokenSpeed is patched.-Modules (``cpu`` = tested without a GPU, ``gpu`` = tested on a GPU):--- ``plugin`` cpu entry point: registers the ``EAGLE_HARNESS`` drafter and the EAGLE-4 draft architecture-- ``hooks`` cpu the TokenSpeed API the adapter uses, checked against the installed TokenSpeed-- ``config`` cpu ``--speculative-algorithm-config`` parsing (static trees)-- ``tree_lanes`` cpu the core draft tree in TokenSpeed's terms: lane masks, verify window and parents-- ``drafter`` gpu ``HarnessDrafter``: TokenSpeed's EAGLE tree round with the core tree and the candidate head-- ``models`` gpu the EAGLE-4 draft model for TokenSpeed (candidate head, no whole-vocab LM head per step)+``docs/architecture.md`` describes the package layout."""diff --git a/eagle_harness/vllm/__init__.py b/eagle_harness/vllm/__init__.pyindex 6355242..f32bdcf 100644--- a/eagle_harness/vllm/__init__.py+++ b/eagle_harness/vllm/__init__.py@@ -6,19 +6,5 @@Registered through the ``vllm.general_plugins`` entry point (see pyproject.toml)and the generic hooks of vLLM branch ``eagle-hooks``; nothing in vLLM is patched.-Modules (``cpu`` = tested without a GPU, ``gpu`` = tested on a GPU):--- ``plugin`` cpu entry point: registers the method and the EAGLE-4 draft architecture-- ``config`` cpu ``method_config`` parsing, the batch-size verify schedule, lookahead, aux layers-- ``adapter`` cpu which vLLM hook carries which EngineAdapter need (checked against vLLM)-- ``models`` gpu the EAGLE-4 draft model for vLLM (candidate head, rows with caller-supplied attention)-- ``speculator`` gpu ``HarnessSpeculator``: chain mode on vLLM's EAGLE loop, tree mode on the verify hooks-- ``tree_drafter`` gpu the draft tree's growth and verify-row selection (one CUDA graph per batch size)-- ``verify_layout`` gpu the verify tree in graph-stable buffers (depth positions, ancestor masks)-- ``tree_attention`` gpu ``CUSTOM`` attention backend: FlashAttention + tree part, merged by log-sum-exp-- ``draft_attention`` gpu per-row key-list attention of the draft tree's steps-- ``tree_accept`` gpu tree walk as the speculator's rejection sampler-- ``round_commit`` gpu KV compaction of the accepted rows, draft inputs in path order (``chainize``)-- ``gdn_tree_verify`` gpu GDN tree verify extension (tree conv, the shared recurrence of ``kernels.gdn_tree_recurrence``,- linear-state commit)+``docs/architecture.md`` describes the package layout."""diff --git a/tests/test_calibration_step_timings.py b/tests/test_calibration_step_timings.pyindex 8a56be4..91cfcae 100644--- a/tests/test_calibration_step_timings.py+++ b/tests/test_calibration_step_timings.py@@ -49,7 +49,6 @@ def test_fits_write_tables_the_cost_model_loads(tmp_path):draft = (AttentionShape(1, 1, 4096), timings(draft_query_lens(1, ComputeIntensity.HIGH), 300.0, 15.0, 2.0))target = (AttentionShape(LAYERS), timings(sorted(verify_buckets(1, ComputeIntensity.HIGH)), 4500.0, 20.0, 1.0))fit_step_timings(paths, params, ComputeIntensity.HIGH, draft, target, tp_size=4)- assert paths.task_normal()table = load_cost_tables(paths.cost)[1]short, long = table.interval_index(300), table.interval_index(3900)verify = table.intervals[long].targetdiff --git a/tools/bench_table.py b/tools/bench_table.pydeleted file mode 100644index 01785b5..0000000--- a/tools/bench_table.py+++ /dev/null@@ -1,49 +0,0 @@-# Copyright 2026 Eagle AI Corp.-# SPDX-License-Identifier: LicenseRef-Eagle-4-Source-Available--"""Table of SPEED-Bench results (``client_speedbench.py`` JSONs) with mean and spread per server.--``python tools/bench_table.py <results dir> [...]``: one row per ``speedbench_<name>[_r<N>].json``-(wall tok/s, accept length, tokens, turns, validity), then per server name the mean wall tok/s and-the spread (max - min) over its repeats.-"""--from __future__ import annotations--import argparse-import collections-import glob-import json-import os-import re--_NAME = re.compile(r"speedbench_(?P<name>.+?)(?:_r(?P<rep>\d+))?\.json$")---def main() -> None:- parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)- parser.add_argument("dirs", nargs="+")- args = parser.parse_args()- by_name = collections.defaultdict(list)- print(f"{'file':60s} {'tok/s':>8} {'accept':>7} {'tokens':>8} {'turns':>6} valid")- for d in args.dirs:- for path in sorted(glob.glob(os.path.join(d, "speedbench_*.json"))):- match = _NAME.search(os.path.basename(path))- with open(path) as f:- summary = json.load(f)["summary"]- overall = summary["all"]- tput, accept = overall["wall_tput"], overall.get("accept_len")- by_name[match["name"]].append(tput)- print(- f"{os.path.relpath(path, d) if len(args.dirs) == 1 else path:60s} {tput:8.1f} "- f"{accept if accept is not None else float('nan'):7.3f} {overall['tokens']:8d} "- f"{summary['turns']:6d} {summary['valid']}"- )- print()- for name, values in sorted(by_name.items()):- mean = sum(values) / len(values)- print(f"{name:20s} n={len(values)} mean {mean:7.1f} tok/s spread {max(values) - min(values):6.1f}")---if __name__ == "__main__":- main()