# agentx-hf **Repository Path**: ghsync/agentx-hf ## Basic Information - **Project Name**: agentx-hf - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-12-03 - **Last Updated**: 2026-12-04 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # agentx -- single-node AgentX harness for GLM-5.3-Flash at 1M context Everything here is local: no HuggingFace access, no SemiAnalysis account. The harness (`agentx` 1.1.0) replays the **official pinned AgentX corpus** (`semianalysisai/cc-traces-weka-062126`, 393 traces) against a locally running sglang server, and prices the measured tokens with `agentx_econ.py`. ## Layout ``` agentx/ .venv/ isolated agentx environment (python 3.12, built offline) sglang_server.py start / stop / clean a server from a JSON config configs/ base-c64.json the stock server (the baseline) max-c64.json the measured best server configuration max-mtp-c64.json max + MTP draft head (EAGLE 5/1/6, golden AL locked) agentx.yaml.tmpl the client run template (scenario: agentx) golden_al/ committed golden acceptance-length curves (offline) glm-5.3-nvfp4__mtp__native__default-default.yaml REVENUE-OPTIMIZATION.md what was done and what was concluded (decision record) measurements/ the raw measurement notes behind that record todo.md, window-structure.md, overlap-plan.md, final-findings.md run_agentx.py sweep driver: YAML -> agentx profile -> artifacts agentx_econ.py measure an AgentX run and price it probe_perf.py screen: cold prefill / cached turn / decode rate hf_home/ offline HF cache (git-ignored; materialized once offline) logs/ server + client logs of the measured runs results//cN/ per-concurrency artifacts, summary, economics ``` ### The server configuration files A server configuration *is* a JSON file: everything the server needs is in it, so two configurations can be diffed to see exactly how two servers differ. ```json { "tag": "max", "model_path": "/data/GLM-5.3-Flash-NVFP4", "tp_size": 8, "port": 30000, "context_length": 1048576, "gpus": [0, 1, 2, 3, 4, 5, 6, 7], "env": {}, "args": ["--mem-fraction-static", "0.82", "--enable-hierarchical-cache"] } ``` `args` is passed to `sglang.launch_server` verbatim, so any sglang flag can be used in a config without touching the tool. `env` is merged into the server process environment -- use it for `SGLANG_SIMULATE_ACC_*` when running MTP. ### Golden AL curves (offline) Speculative decoding requires a fixed acceptance length so submissions are comparable. The committed curves live under `configs/golden_al/`. For this box's MTP run (`glm-5.3-nvfp4`, method `mtp`, `num_speculative_tokens` = 5): | key | value | |-----|-------| | curve | `glm-5.3-nvfp4__mtp__native__default-default` | | AL at 5 draft tokens | 3.48 | The value is already wired into `configs/max-mtp-c64.json` via `SGLANG_SIMULATE_ACC_LEN`. If you change `speculative-num-steps`, update `SGLANG_SIMULATE_ACC_LEN` to the matching row in the curve file, and keep `num-draft-tokens == num-steps + 1` and `eagle-topk: 1`. ### What is tracked by git Tracked: the harness scripts (`*.py`), `configs/`, and `dist/` (the HF corpus archive, ~9.6 MB, with its `.sha256`). Ignored (regenerable / local-only): `.venv/` (2.4 G, built offline from the wheels already on disk), `hf_home/` (the materialized corpus cache), `results/` and `logs/` (run outputs). The one-off preparation scripts (venv builder, corpus materializer, tokenizer mirror) are deliberately **not** in the repo: they were used once on this box and are not part of the measurement path. ## Environment The agentx venv is deliberately separate from the sglang venv: the sglang venv carries torch/CUDA/flashinfer for serving, the agentx venv carries the harness, `datasets` and `huggingface_hub` for corpus handling. Mixing them tends to break one or the other. ```bash cd /home/qihangkong/llm/agentx .venv/bin/agentx --version # 1.1.0 ``` The venv is deliberately separate from the sglang venv: the sglang venv carries torch/CUDA/flashinfer for serving, the agentx venv carries the harness, `datasets` and `huggingface_hub` for corpus handling. Mixing them tends to break one or the other. It was built offline from the wheels already on disk (copying each wheel's `RECORD` and skipping the torch/triton/nvidia stacks the harness does not need); the builder script is not kept in the repo. ## Corpus: the official one, offline The corpus is the real SemiAnalysis cc-traces corpus, date-pinned to `062126` (393 traces, 98,827 requests). It is **not** regenerated locally -- there is no generator any more. The `semianalysis_cc_traces_weka_062126` public-dataset alias points at `semianalysisai/cc-traces-weka-062126` on the Hub, and the AgentX scenario only stamps `submission_valid=true` for a *pinned* corpus, so the run uses the alias rather than a local `weka_trace` directory. This box has no route to huggingface.co, so the corpus is materialized into an offline HF cache under `agentx/hf_home` (git-ignored). The committed archive under `dist/` contains the hub cache layout (`traces.jsonl` plus metadata); rebuild the cache on another offline box by extracting `dist/` and pointing `HF_HOME` at it: ```bash cat dist/agentx-hf_home.part.* > agentx-hf_home.tar.xz sha256sum -c dist/agentx-hf_home.sha256 tar xJf agentx-hf_home.tar.xz # -> hf_home/ export HF_HOME=$PWD/hf_home export HF_HUB_OFFLINE=1 export HF_DATASETS_OFFLINE=1 ``` The raw corpus is also committed under `dist/` (~9.6 MB, split into parts for transfer plus a `.tar.xz` and a `.sha256`), so the cache can be rebuilt on another offline box from the repository alone. ### What the corpus contains (measured) ``` 393 traces, 98,827 requests (56,798 top-level + 42,029 inside 1,697 subagent groups) requests/trace mean 251.5 max 4,114 L = in + out mean 219,999 p50 143,030 p90 551,498 p99 864,972 max 996,579 input tokens mean 218,922 p50 142,016 p90 549,504 max 989,824 output tokens mean 1,077 p50 444 p90 2,659 max 59,903 requests with in+out > 1,048,576 0 (so a 1M-context server accepts all of them) inter-request gap p50 ~17 s mean ~400 s (the replay honors these) ``` ## Running ```bash # 1. serve: one command, one config file python3 sglang_server.py start configs/max-c64.json # -> 127.0.0.1:30000, context_length 1048576, logs/server_max.log # (waits for /health, then prints the pool sizes and the running-request clamp) # 2. measure python3 run_agentx.py --tag flash-1m \ --model-path /data/GLM-5.3-Flash-NVFP4 \ --url http://127.0.0.1:30000 \ --concurrency 4 8 16 --duration 900 \ --econ-arg=--pricing-model --econ-arg=glm-5.3-flash # 3. stop python3 sglang_server.py stop configs/max-c64.json ``` `sglang_server.py` also has `status` (which servers are up, how much GPU memory is in use) and `clean` (stop everything this tool started and wait for the GPU memory to come back). The driver only *runs*: it renders the YAML, runs `agentx profile -f`, and then hands the artifacts to `agentx_econ.py`, which measures the run and prices it. The two programs are separate because the pricing assumptions (price, discount, duty cycle) change far more often than the measurement path does. Pricing writes `results//c/{summary.json,economics.json}` and the driver collects everything into `results//table.json`. An existing run can be re-priced without replaying it: ```bash python3 agentx_econ.py results/max1-c64/c64 --discount 0.4 --duty 0.4 ``` The defaults are our operating point: 4 折 of the official list price (k3's table: 0.8 / 2.8 / 0.23 RMB per 1M input/output/cache token) and a 40% duty cycle (the traffic is served 9.6 h a day). The model prices the *output* of the box, not the box itself. `agentx_econ.py` is deliberately shallow. It reads the harness's own summary export -- the same artifact the official dashboard reads -- and prices what the box served in the **profiling** phase (the warmup phase is reported separately by the harness and is not counted). The window is the phase wall, `end_time - start_time` = duration + grace period, which is the denominator the official `total_token_throughput` uses, so the rates here match the harness and the dashboard exactly. There is no saturation verdict and no extrapolation: those answer "is the box the limit", which is a different question from "what did it earn". The `agentx` scenario enforces a **900 s** profiling floor. Shorter runs need `--unsafe-override`, which downgrades the violation to a warning and stamps `submission_valid=false` -- fine for tuning screens, not for a submission. ### Warmup: 10 requests per lane `warmupRequestsPerLane` is **10**, the number the official AgentX methodology specifies ("each replay lane then completes 10 additional warmup requests before the measurement barrier opens"), on top of the mandatory `max_tokens=1` snapshot primers the harness issues per lane. It matters because the corpus is a chain -- turn N's prompt is turn N-1's prompt plus the previous assistant turn -- and sglang's radix cache matches on prefix. Too little warmup and only the most recent turns are hot when the barrier opens, so deeper turns re-prefill. The number changes the measured cache-hit rate, so state it alongside any result: a run with `warmupRequestsPerLane: 1` is not comparable with one at 10, and neither is directly comparable with the official dashboard unless the warmup matches. Override with `--warmup N`. ## Sweeping server configurations The AgentX replay is a bad instrument for *ranking* configurations: every configuration pays a cold start of 20-50 minutes, because the corpus' first turn of every session carries ~200 k tokens. The workflow is therefore **screen first, replay second**: ```bash # 1. screen: 3 minutes per configuration, no corpus needed python3 sglang_server.py start configs/max-c64.json .venv/bin/python probe_perf.py --url http://127.0.0.1:30000/v1/chat/completions --out probe.json python3 sglang_server.py stop configs/max-c64.json # 2. replay the survivor with the official corpus .venv/bin/python run_agentx.py --tag max-c64 \ --model-path /data/GLM-5.3-Flash-NVFP4 \ --url http://127.0.0.1:30000 \ --concurrency 64 --duration 900 # 3. price it (also done by step 2, re-run it with other assumptions) python3 agentx_econ.py results/max-c64/c64 ``` One configuration at a time: boot the server from its config, replay, stop. The probe decides which configuration is worth the 30-50 minutes a replay costs, and the replay is what produces the numbers that are kept. ### Measured result on this box (8x RTX 6000D, C64, 900 s profiling) | | stock (`configs/base-c64.json`) | tuned (`configs/max-c64.json`) | |---|---|---| | total tok/s | 9,234.7 | **48,003.0** | | output tok/s | 68.17 | **296.52** | | TTFT p50 | 21,169.6 ms | **889.4 ms** | | TPOT p50 | 312.7 ms | **44.3 ms** | | prompt cache read | 28.47% | **91.62%** | | requests in 900 s | 94 | **441** | The best configuration on this box is now `configs/p-base.json` (the FlashInfer PCIe-IPC all-reduce plus the fp8 all-reduce): **614 requests, Y26.3689 per hour**, GSM8K 98.5% (sgl-eval, 200 examples, temperature 0, no thinking). `REVENUE-OPTIMIZATION.md` records what was tried, what the numbers were, which avenues are closed with evidence, and the two levers that are still open.