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
+
|
| 3 |
+
Research code, tooling, and empirical data for **Logprob Majority-Consensus
|
| 4 |
+
Verification (LMCV)** — a low-cost execution-verification protocol for open,
|
| 5 |
+
decentralized inference networks.
|
| 6 |
+
|
| 7 |
+
## Background
|
| 8 |
+
|
| 9 |
+
In open inference markets, jobs are dispatched to untrusted worker nodes. A core
|
| 10 |
+
integrity question is: *how can the network confirm a worker actually executed
|
| 11 |
+
the user-specified reference model and runtime configuration, without re-running
|
| 12 |
+
the entire generation?* Full recomputation is as expensive as regenerating the
|
| 13 |
+
answer, and comparing only the final text cannot distinguish same-family models,
|
| 14 |
+
quantized variants, or a small model masquerading as a large one.
|
| 15 |
+
|
| 16 |
+
LMCV combines a **token-level probability fingerprint** with **independent
|
| 17 |
+
multi-node consensus**. Once generation is complete, a verifier runs a single
|
| 18 |
+
parallel *teacher-forced prefill* over the frozen `input_ids + output_ids` path,
|
| 19 |
+
reconstructs each position's predictive distribution, and checks the logprob,
|
| 20 |
+
rank, and top-*k* candidate set of each returned token — without decoding token
|
| 21 |
+
by token. For Mixture-of-Experts (MoE) models it adds a *routed-experts joint
|
| 22 |
+
check* using the layer-0 routing fingerprint.
|
| 23 |
+
|
| 24 |
+
See [`paper/LMCV.md`](paper/LMCV.md) for the full write-up.
|
| 25 |
+
|
| 26 |
+
## Repository layout
|
| 27 |
+
|
| 28 |
+
```
|
| 29 |
+
.
|
| 30 |
+
├── paper/ # The LMCV paper (Markdown)
|
| 31 |
+
├── tools/ # Runnable pipelines and scripts
|
| 32 |
+
└── experiments/ # Experiment reports and collected data
|
| 33 |
+
```
|
| 34 |
+
|
| 35 |
+
### `paper/`
|
| 36 |
+
|
| 37 |
+
- **`LMCV.md`** — The complete paper: protocol design (VRF verifier selection,
|
| 38 |
+
commit–reveal, multi-metric decision, two-of-three majority consensus),
|
| 39 |
+
MoE routed-experts extension, and experimental results across Qwen3-32B,
|
| 40 |
+
Qwen3-8B (dense), and Qwen3.6-35B-A3B (MoE).
|
| 41 |
+
|
| 42 |
+
### `tools/`
|
| 43 |
+
|
| 44 |
+
- **`worker_logits_verify/`** — The main, redesigned worker-verify project. Builds
|
| 45 |
+
a *depth-aware logits/logprob fingerprint* along a fixed context path using a
|
| 46 |
+
`transformers` backend (raw logits, logprobs, token rank, top-*k* and probe-token
|
| 47 |
+
fingerprints) to separate legitimate cross-GPU numerical drift from cross-model /
|
| 48 |
+
quantization challenges. Packaged under `src/worker_logits_verify/` with example
|
| 49 |
+
traces.
|
| 50 |
+
- **`vllm_worker_verify_pipeline/`** — Standalone end-to-end pipeline
|
| 51 |
+
(`generate_prompts` → `collect_vllm_worker_evidence` → `verify_vllm_worker_evidence`
|
| 52 |
+
→ `summarize_worker_verify`) driven by vLLM, with calibration, analysis, and
|
| 53 |
+
latency benchmarking scripts.
|
| 54 |
+
- **`moe_routed_experts/`** — Tests whether vLLM decode-time and prefill-time
|
| 55 |
+
`routed_experts` agree for the same `input + output_token_ids` (requires
|
| 56 |
+
`vllm serve <MODEL> --enable-return-routed-experts`).
|
| 57 |
+
|
| 58 |
+
### `experiments/`
|
| 59 |
+
|
| 60 |
+
Reports and collected data for three experiment tracks. Each is described in
|
| 61 |
+
detail in [Experiments in detail](#experiments-in-detail) below.
|
| 62 |
+
|
| 63 |
+
- **`moe-routed-experts/`** — Routed-experts fingerprint differences for a large
|
| 64 |
+
MoE model.
|
| 65 |
+
- **`logprobs/`** — Logprob-fingerprint differences for large dense/MoE LLMs.
|
| 66 |
+
- **`worker-verifier-latency/`** — The cost gap between the worker and the verifier.
|
| 67 |
+
|
| 68 |
+
## Experiments in detail
|
| 69 |
+
|
| 70 |
+
### 1. MoE routed-experts difference (`experiments/moe-routed-experts/`)
|
| 71 |
+
|
| 72 |
+
**Question:** For a Mixture-of-Experts model, can the *routing fingerprint* tell
|
| 73 |
+
the reference model apart from quantized or cross-GPU variants?
|
| 74 |
+
|
| 75 |
+
The verifier runs one teacher-forced prefill over `input_token_ids +
|
| 76 |
+
output_token_ids`, extracts vLLM's `routed_experts`, and compares them against the
|
| 77 |
+
routing recorded in the worker's decode trace. The primary score is the **layer-0
|
| 78 |
+
`entry_mismatch_rate`** (`sum(entry_mismatch_count) / sum(compared_entries)`),
|
| 79 |
+
alongside a `registered_logit_tokens_top_k` legality check that each output token
|
| 80 |
+
falls inside the model's registered top-*k* candidate set.
|
| 81 |
+
|
| 82 |
+
Compared variants are `Qwen/Qwen3.6-35B-A3B` (BF16) vs. `Qwen/Qwen3.6-35B-A3B-FP8`
|
| 83 |
+
(FP8), across GPU pairings (6000ws, H100). Per-pairing route-diff summaries are
|
| 84 |
+
stored as CSV/JSON/Markdown (by sample, by layer, and by sample×layer). The report
|
| 85 |
+
is [`report/moe_model_routed_experts_verifier.md`](experiments/moe-routed-experts/report/moe_model_routed_experts_verifier.md).
|
| 86 |
+
|
| 87 |
+
**Finding:** Where per-token logprob is too noisy for MoE, the layer-0 routed-experts
|
| 88 |
+
fingerprint yields a structurally stable, cross-GPU-reproducible gap between
|
| 89 |
+
same-model and cross-model cases — clean enough to set a production threshold.
|
| 90 |
+
|
| 91 |
+
### 2. LLM logprob difference (`experiments/logprobs/`)
|
| 92 |
+
|
| 93 |
+
**Question:** Can a same-model verifier reconstruct the worker's per-token logprob
|
| 94 |
+
fingerprint well enough to separate legitimate numerical drift (same model, different
|
| 95 |
+
GPU) from an impostor (FP8/AWQ or a smaller model)?
|
| 96 |
+
|
| 97 |
+
The verifier teacher-force replays `input_ids + output_ids` and compares its
|
| 98 |
+
per-position distribution against the worker's `selected_logprob`, `selected_rank`,
|
| 99 |
+
and `top_logprobs`. Rather than a single-token binary test, it uses window-level
|
| 100 |
+
robust aggregation (`mean/p95/p99 abs_logprob_diff`, `rank_delta_rate`, top-*k*
|
| 101 |
+
Jaccard, union-JS) — motivated by the finding that same-model BF16 diffs appear as
|
| 102 |
+
sparse, position-sensitive token spikes, while FP8 adds a broader distribution
|
| 103 |
+
shift on top. Three reports cover this track:
|
| 104 |
+
|
| 105 |
+
- [`LLM-QWen3_8b_bf16_single_sample_verifier_params.md`](experiments/logprobs/reports/LLM-QWen3_8b_bf16_single_sample_verifier_params.md)
|
| 106 |
+
— a tri-state (`PASS` / `REJECT` / `INCONCLUSIVE`) single-sample verifier design
|
| 107 |
+
for dense Qwen3-8B BF16.
|
| 108 |
+
- [`qwen3_6_35b_a3b_6000ws_verifier_testing_report.md`](experiments/logprobs/reports/qwen3_6_35b_a3b_6000ws_verifier_testing_report.md)
|
| 109 |
+
— Qwen3.6-35B-A3B BF16-vs-FP8 logprob comparison (FP8 shows a systematic ~1.4×–1.6×
|
| 110 |
+
bulk-to-p99 shift and worse top-*k* overlap).
|
| 111 |
+
- [`moe_replicates_bf16_vs_fp8_spike_testing_report.md`](experiments/logprobs/reports/moe_replicates_bf16_vs_fp8_spike_testing_report.md)
|
| 112 |
+
— the spike hypothesis test across BF16 replicates justifying window-level median
|
| 113 |
+
aggregation over single-token thresholds.
|
| 114 |
+
|
| 115 |
+
**Finding:** For dense models the same-model BF16 baseline is narrow and stable while
|
| 116 |
+
FP8/AWQ/smaller models separate sharply; for MoE the same-model baseline itself has a
|
| 117 |
+
heavy tail, so window-aggregated metrics (not single-token max) must drive the decision.
|
| 118 |
+
|
| 119 |
+
### 3. Worker-vs-verifier cost difference (`experiments/worker-verifier-latency/`)
|
| 120 |
+
|
| 121 |
+
**Question:** Is verification actually cheaper than generation, and by how much?
|
| 122 |
+
|
| 123 |
+
A vLLM offline benchmark (`benchmark_worker_verifier_latency.py`, Qwen3-8B BF16 on a
|
| 124 |
+
single RTX 4090) times both paths on one shared `LLM` instance across an input×output
|
| 125 |
+
length grid: the **worker** does normal `prefill + serial decode`, the **verifier**
|
| 126 |
+
does a single parallel prefill with `prompt_logprobs=20`. Raw data and summaries live
|
| 127 |
+
under [`data/qwen3_8b/`](experiments/worker-verifier-latency/data/qwen3_8b/); the
|
| 128 |
+
analysis is [`reports/worker_verifier_latency_benchmark_report.md`](experiments/worker-verifier-latency/reports/worker_verifier_latency_benchmark_report.md).
|
| 129 |
+
|
| 130 |
+
**Finding:** Worker cost ≈ `output_len × 17.5 ms` (serial, memory-bandwidth-bound);
|
| 131 |
+
verifier cost ≈ `total_tokens / ~5200 tok/s` (one parallel prefill). For typical
|
| 132 |
+
multi-token outputs the verifier costs about **1%** of a generation
|
| 133 |
+
(worker/verifier ≈ **80×–114×**, peaking at output 1024–2048). The only exception is
|
| 134 |
+
`output_len = 1`, where the verifier's fixed per-position logprob overhead makes it
|
| 135 |
+
slightly slower. Three verifiers together therefore cost roughly **1.9%–14.8%** of a
|
| 136 |
+
single generation.
|
| 137 |
+
|
| 138 |
+
## Key findings
|
| 139 |
+
|
| 140 |
+
- The same-model BF16 replay baseline is narrow and stable across GPUs
|
| 141 |
+
(6000ws / H100 / 4090 / L4), while FP8, AWQ, and heterogeneous smaller models
|
| 142 |
+
separate sharply on p99, rank-delta rate, top-*k* Jaccard, and union-JS.
|
| 143 |
+
- For MoE, per-token logprob is confounded by sparse heavy-tailed spikes, but the
|
| 144 |
+
layer-0 routed-experts fingerprint forms a structurally stable, cross-GPU
|
| 145 |
+
reproducible gap (a BF16 verifier attains TPR = 1.000 with 0.000 false-pass at
|
| 146 |
+
threshold 0.060 under a layer-0 random-5 aggregate).
|
| 147 |
+
- A single verification prefill costs about **1%** of one generation
|
| 148 |
+
(worker/verifier ≈ 80×–114×), so three verifiers together consume roughly
|
| 149 |
+
**1.9%–14.8%** of the GPU time of a single generation.
|
| 150 |
+
|
| 151 |
+
## Getting started
|
| 152 |
+
|
| 153 |
+
Each tool directory carries its own `README.md` with concrete run commands and
|
| 154 |
+
dependencies. The vLLM-based stages generally require `transformers`, `vllm`, and
|
| 155 |
+
a GPU runtime:
|
| 156 |
+
|
| 157 |
+
```bash
|
| 158 |
+
python3 -m pip install transformers vllm
|
| 159 |
+
```
|