# RunMyML Inference Bench

Published results and raw samples: https://runmyml.com/bench/

## Run an ONNX export from a model registry

Install uv and use Python 3.11 or later on the execution host. The example uses CPUExecutionProvider and a pinned Hugging Face artifact with a single-file cached-decoder ONNX graph, config.json and tokenizer.json.

```sh
uv run run-registry.py --registry hf --ref onnx-community/SmolLM2-135M-Instruct-ONNX@b8a5c0f183b78c55955a5364f610c36668b5e681 --out fp32.json
uv run run-registry.py --registry hf --ref onnx-community/SmolLM2-135M-Instruct-ONNX@b8a5c0f183b78c55955a5364f610c36668b5e681 --graph onnx/model_int8.onnx --role candidate --out int8.json
```

For MLflow, set MLFLOW_TRACKING_URI and run with `uv run --with mlflow-skinny run-registry.py --registry mlflow --ref models:/NAME/1 --out report.json`. For W&B, authenticate outside the browser, then use `uv run --with wandb run-registry.py --registry wandb --ref ENTITY/wandb-registry-model/COLLECTION:v0 --out report.json`. Supply the registry version and graph name. HF and a local MLflow registry have been exercised. Add `--with sqlalchemy --with alembic` for local SQLite. The W&B adapter awaits a hosted artifact. Multi-file external-data graphs and custom architectures require separate adapters.

Reports include the observed runtime version, file hashes, prompt list, generated token IDs and timing samples. Short CPU runs do not establish task quality, serving latency or comparative vendor performance.


## Full methodology

[Benchmark methodology and Hugging Face integration](methodology/index.html) defines comparison types, source/artifact provenance, paired quality admission, workload and load controls, uncertainty, ranking, and the first experiment. Protocol proposal 0.2 specifies the target process; the current toolkit does not enforce its statistical or provenance admission gates.

## Available tools

- Browser comparison: provider/runtime and workload filters in the catalog, separate cohorts, quality filter, explicit baseline, structured run details, and CSV/JSON export. Imports stay in browser memory and disappear on reload; nothing is uploaded or published.
- Browser configuration builder: pinned Qwen metadata or an imported HF manifest, editable API alias, workload presets, validation, and config download. No provider requests or credentials in the browser.
- Streaming API runner: OpenAI-compatible chat completions, Node.js 22 or newer, no npm dependencies. Exercised against a local mock server.
- Single-GPU runner: Transformers and TheStage through their documented generation interfaces. Prepared, but not yet exercised on a GPU.
- Experiment plan generator: consumes a local HF manifest and creates a non-executable draft with explicit unresolved provenance, evaluation, runtime, workload and budget gates.
- Hugging Face metadata inspector: pins a source revision and records model topology without downloading weights or executing model code.
- Comparison and diagnostics CLI: compares complete runs and attaches author-supplied evidence without changing measurements.

## Geography and time

The methodology includes a [regional and temporal observation protocol](methodology/index.html#geography), plus `service-observation.plan.example.json`. It separates client network, provider edge and execution region; fresh/reused connections; visible text from response headers; deadline attainment, streaming stalls, failures, retries, costs and sparse-probe coverage. The example is a non-executable design for 10,080 logical requests, not a deployed job or an actual cost estimate. Regional transport collectors, agents, time-series analysis and geography-aware ranking cohorts are not implemented. The existing runner and cohort key cannot be treated as a complete implementation of this protocol.

## Ordered transcript replay

Use the included `config.replay.example.json` to configure fixed conversation snapshots. Each request carries `messages`, `session_index`, `turn` and optional `delay_ms`. Set concurrency to one, warmup to zero and the request count to the number of snapshots. For a cache experiment replace the short text with representative shared context and record the same conditions on both endpoints.

```sh
node run.mjs --config config.replay.example.json --out replay-report.json
```

The runner records TTFT, full response time, visible-stream duration, finish reason and reported cached-input counts. It reports the input-token-weighted hit rate alongside coverage. Missing usage stays unknown. Replay uses fixed assistant messages and never feeds an endpoint's previous answer back into the next turn. Optional inter-turn delays are included in the run's wall-clock rate and excluded from individual request latencies.

For a controlled CPU experiment, add `--prefix-study --requests 8 --tokens 8` to the HF runner. It measures a cold prefill and resident prefix for each length, verifies identical greedy tokens and writes a dedicated JSON report.

## Run an API benchmark

1. Obtain an endpoint or start an inference server. Pass the API key through `INFERENCE_API_KEY`, not a JSON file.
2. Use **Run a benchmark** on the site to prepare `config.json`, or copy `config.example.json`. Record the source model revision, architecture, hardware, software versions, artifact, cache policy, and workload. The two included smoke prompts test execution, not representative performance or quality. The builder imports text-generation manifests only; metadata does not establish runtime compatibility.
3. Run the baseline and candidate with their respective configurations:

```sh
node run.mjs --config baseline-config.json --role baseline --out baseline.json
node run.mjs --config candidate-config.json --out candidate.json
```

4. Add quality evaluation results, import both files on the site, and select a baseline from the same cohort. Keep the report files: browser imports are session-local.

`model` is the name accepted by the API. Optional `source_model` identifies the canonical source checkpoint and is used for cohort matching; `comparison.model` is a fallback before the served name in older/manual configs. The served alias is retained as `environment.served_model`. Pin the same source revision and config hash across aliases, and independently confirm what each endpoint serves. Old configs without a source identity continue to use `model`.

The builder validates the same configuration contract as the CLI. Its presets are starting samples, not capacity measurements. The imported manifest and form contents stay in browser memory. Generated configs include the endpoint and prompts, so keep them separate from public reports. No keys are requested by the form. Quality is `null` until evaluation evidence is added; collecting timings does not pass the quality gate. Advanced quantization details, vendor request extensions, and quality results can be added to the downloaded JSON following this protocol.

The runner uses **closed-loop concurrency**: each worker submits a new request after its previous request completes. This does not measure fixed-arrival-rate capacity or prove maximum throughput. Warmup requests run outside the measured interval. Failures remain in the denominator. Reports omit the endpoint URL, API key, prompts, and generated text. Keep secrets out of configuration names, descriptions, and other report metadata too.

TTFT is client time to the first nonempty text delta. Token counts come only from `usage.completion_tokens`; without it, token throughput is unavailable. An SSE chunk is not a token, and inter-token latency is not inferred. A stream without `[DONE]` and a finish reason counts as incomplete. Unsupported API formats need a separate adapter.

The optional hourly GPU price covers only the measured rental interval, including time spent on failed attempts. It excludes setup, warmup, storage, and licenses. Input/output-token API billing is not automatically calculated in this MVP.

## Run the first single-GPU experiment

Use one L40S or H100, obtain TheStage Elastic Models access, and confirm source-model permissions. Expose exactly one NVIDIA GPU with `CUDA_VISIBLE_DEVICES`. Use separate pinned environments for the reference and optimized stack and save their manifests. The scripts do not install an SDK or download models automatically on the development laptop.

[TheStage setup documentation](https://docs.thestage.ai/elastic_models/docs/source/index.html) describes the platform token and SDK. Llama may also require accepted model terms and `HF_TOKEN`. Keep credentials outside source and reports.

```sh
python run-local.py --engine transformers --role baseline --revision HF_COMMIT_SHA --artifact-id HF_COMMIT_SHA --prompts prompts.smoke.json --out baseline.json
python run-local.py --engine thestage --revision HF_COMMIT_SHA --artifact-id EXACT_VENDOR_ARTIFACT --mode XL --prompts prompts.smoke.json --out thestage-xl.json
```

For Transformers, `--revision` pins the source weights and tokenizer. For TheStage it pins **the tokenizer only**: independently confirm the optimized artifact matches the source checkpoint. The artifact identifier is recorded as a declaration, not proof. This SDK adapter remains experimental until its first GPU validation.

The local runner measures CUDA-synchronized `generate()` with tokenized inputs already resident on GPU, batch size 1, a fixed output-token count, and fresh per-request KV state. TTFT, ITL, energy, and price are unavailable. Peak VRAM is PyTorch allocated memory and excludes other allocators. Loading time is recorded separately; it is not a controlled cold-start benchmark because filesystem and OS caches are not controlled.

## Measurement scope and comparison rules

The unit of evaluation is **source model → optimized artifact → runtime → hardware → workload**. Pin the source revision, topology, platform, input/output lengths, concurrency, generation settings, cache policy, timing boundary, SLO, and quality policy. Differences form separate cohorts. Offline generation, production serving, and hosted-service measurements are not interchangeable.

`measurement_scope: "model"` pairs with `track: "local"`; `measurement_scope: "service"` pairs with `track: "api"`. Old schema 0.1 reports remain compatible: scope is inferred from track. Standalone kernel reports are rejected by the primary comparison. API hardware and model revisions may be declarations rather than observations; disclose that in publication.

A report can mark `role: "baseline"`, or the user can select a baseline in the UI. Both runs must share a cohort and meet their reported quality budgets. p95 speedup is baseline p95 divided by candidate p95. Goodput, cost per successful request, and VRAM changes use their respective complete-run measurements. Missing metrics and zero denominators do not produce estimated gains. These are differences between individual runs; statistical significance is not established automatically.

## Quality admission and publication

Before performance testing, pin the evaluation tasks, source baseline, evaluator version, prompt templates, seed, datasets, and per-task loss budgets. An illustrative budget is 0.5 percentage points of loss, but each task needs a justified margin, sample-size plan and confidence procedure before a non-inferiority claim. The methodology defines a stronger proposed statistical admission process; the current point-score filter does not implement it. MMLU, ARC, and PIQA can be part of an LLM evaluation but do not establish preservation of every model property. Include the target customer tasks. Image/video generation requires a separate protocol; the current runners measure text generation.

A report can include:

```json
{"quality":{"protocol_id":"pinned-quality-protocol","evidence_url":"https://your-evaluation.example/report","tasks":[{"name":"pinned-task-and-metric","n":1000,"baseline":0.8,"candidate":0.798,"max_drop_pp":0.5}]}}
```

The site checks the declared threshold on **every task**. It does not verify the evidence or evaluation adequacy. “Within reported budget” is provisional, not a statistical non-inferiority test. Review uncertainty and paired per-example results separately. Without evaluation, a run is excluded from the quality-filtered view.

The proposed publication process requires raw timings, the actual workload and its hash, environment manifests, quality evidence, disclosed costs and a repetition plan chosen from pilot variability. The full methodology starts with at least five paired baseline/candidate blocks; that floor alone does not establish statistical precision. Earlier three-repetition smoke plans are preliminary, not final ranking admission. Percentiles in this MVP are empirical, without confidence intervals; p99 from 20 requests is unreliable. Capacity claims require longer runs and open-loop load testing. Independent verification requires separate reproduction and is never granted by a browser import.

## Acceleration analysis and kernel appendix

Attach diagnostics after measurement:

```sh
node compare.mjs --report candidate.json --diagnostics diagnostics.json --out annotated.json
node compare.mjs --baseline baseline.json --candidate annotated.json --out comparison.json
```

Start from `diagnostics.example.json`. `baseline_report_id` links the candidate to a reference. `observations` accepts quantization, kernels, compiler, batching, cache, scheduling, data_transfer, communication, and other. Each entry includes a description, evidence level, and evidence reference: a file name, URL, or digest. Do not publish secrets or private paths.

Evidence levels are `unknown`, `vendor_claim`, `configuration`, `profile`, and `ablation`. Labels identify the author-reported evidence type, not independent verification. A reference string does not establish authenticity or adequacy. Configuration identifies a change; profiling observes execution; causal contribution requires a controlled experiment with one changed factor and full-model quality evaluation. Automatic profiler collection and trace parsing are not implemented. Reports accept references to separately collected material.

Optional `kernel_tests` entries contain `name`, `shape`, `dtype`, `hardware`, `reference_us`, `candidate_us`, `correctness`, `tolerance`, and `evidence_ref`. Correctness is `passed`, `failed`, or `not_evaluated`. A microbenchmark ratio is shown only for a passed test with a declared tolerance. It does not affect primary sorting or add to model speedup. Numerical kernel correctness does not replace model-quality evaluation.

Illustration: a serial run takes 100 ms, including a 10 ms operation. Making that operation twice as fast reduces the full run to 95 ms. It does not make the model twice as fast. Real serving also requires checking interaction effects, concurrency, queueing, caches, and input distributions.

Engineering references: [KernelBench](https://github.com/ScalingIntelligence/KernelBench), [GPU MODE](https://github.com/gpu-mode/reference-kernels), and [FlashInfer-Bench](https://flashinfer.ai/2025/10/21/flashinfer-bench.html). This MVP has no standalone kernel leaderboard.

## Quantization, topology, and hardware

Quantization results depend on architecture, tensor shapes, and platform. An INT4 format can have a fast kernel for one matrix shape and require unpacking or fallback for another. Memory compression alone does not establish acceleration. Record MoE structure, attention/KV heads, hidden/intermediate dimensions, batch size, context, and output lengths.

`comparison.architecture` identifies the source topology/config hash; `platform_fingerprint` identifies the platform. Record optimized topology and quantization in `artifact`: weight, activation, KV-cache, and accumulator formats; algorithm, granularity, group size, calibration-data hash, observed kernels, and structural changes. Unknown properties remain unknown. A BF16 loading argument does not establish every internal dtype.

The GPU manifest records VRAM, compute capability, power limit, MIG, driver, and CPU. Multi-GPU experiments also need interconnects and tensor/expert/pipeline parallelism. The local runner is single-process and single-GPU; it is not a cluster benchmark. It does not collect kernel profiler traces. Verify source-weight provenance for optimized artifacts; structural changes can be compared under a common quality budget.

References: [vLLM quantization support](https://docs.vllm.ai/en/latest/features/quantization/) and [TensorRT INT4 weight-only execution](https://docs.nvidia.com/deeplearning/tensorrt/11.4.1/inference-library/quantized-types-explicit-quantization.html).

## Models from registries

The HF metadata inspector resolves a mutable revision to a full commit SHA, reads JSON configuration, and records its hash, topology, declared license, and file list. It does not download weights or execute model code. A real Qwen2.5-7B-Instruct manifest is included. Optional gated/private access uses `HF_TOKEN` on the execution host; the token is not saved.

```sh
node inspect-model.mjs --repo Qwen/Qwen2.5-7B-Instruct --revision main --out manifest.json
node inspect-model.mjs --discover text-generation --limit 8 --out popular-models.json
node plan-experiment.mjs --manifest manifest.json --out experiment.json
```

`experiment.json` is a planning contract, not a run.mjs config. It retains the source identity and lists unresolved execution/publication gates. The command reads local JSON only, downloads no weights and starts no benchmark.

Discovery uses the HF API download counter. This is a selection signal, not a quality score or complete adoption measure. Base models, GGUF artifacts, and instruction models can appear together. Select a workload explicitly and validate optimizer support.

Pass `resolved_revision` to `run-local.py --revision` and keep the manifest with the report. On the execution host, obtain that snapshot and verify weight content hashes, tokenizer/chat template, access rights, dtype, topology, and runtime compatibility. Confirm optimized-artifact provenance too. The inspector does not automatically obtain weights, optimize models, or start GPU jobs. [HF version/download documentation](https://huggingface.co/docs/huggingface_hub/en/guides/download).

The planned W&B Registry connector will resolve aliases and obtain an artifact version, digest, lineage, files, and environment through authorized read-only access. [Public SDK](https://github.com/wandb/wandb/blob/main/wandb/apis/public/api.py). An organization registry is not a global popularity catalog. Run history helps select shapes and workloads but is not controlled performance evidence. Private artifacts and data require permission before publication.

The planned MLflow/Unity Catalog connector will resolve a model URI or alias to an exact version and obtain artifact URI, flavor, signature, and environment. Transformers, ONNX, pyfunc, and custom containers need different execution adapters. [Registry workflows](https://mlflow.org/docs/latest/ml/model-registry/workflow/). Object-storage and OCI version/digest resolvers are also possible but not implemented.

The full path is registry → immutable source artifact → optimizer/runtime adapter → pinned hardware and workload → quality gate → performance report. A registry entry does not establish actual latency or accelerator compatibility.

## Participants and existing benchmarks

The public catalog lists 14 products focused on inference acceleration, including managed text serving, model optimization, media, and throughput-oriented services. Fixed configurations and reproducible evidence determine when a result can be compared. See `landscape.md` for the proposed experiments and `participants.csv` for the shortlist.

Disclose company/project relationships: Inferact/vLLM, RadixArk/SGLang, and Modular/BentoML. Their deployments are not automatically identical. MachGen, fal, Runware, Nunchaku, and LightX2V need image/video protocols rather than the current streaming LLM runner. For asynchronous generation, pin resolution, frames/FPS/duration, steps, sampler/scheduler, guidance, seed, batch, and input. Measure submit-to-ready time and polling cadence; separate queue/execution timings when available and download time. Include prompt alignment and temporal consistency in video quality evaluation.

[Liquid AI / RIPL / DSpark](https://www.liquid.ai/blog/low-latency) is included as a model and runtime supplier. Compare the same LFM checkpoint across engines or with speculation off/on; an LFM-versus-Qwen comparison changes the source model and cannot isolate runtime acceleration. Liquid's [Pipette](https://pipette.liquid.ai/docs/introduction) is also a relevant benchmark: it covers model, quantization, runtime, device, workload, speed, memory, and quality. It is vendor-published, and quality evaluations run separately from device performance tests. See `landscape.md` for the review and proposed tests. Published results are listed in the benchmark Results section.

Existing projects include [Artificial Analysis and Endpoint Accuracy Index](https://artificialanalysis.ai/methodology/endpoint-accuracy-index), [InferenceX](https://github.com/SemiAnalysisAI/InferenceX), [MLPerf Inference](https://docs.mlcommons.org/inference/), [ML.ENERGY](https://ml.energy/), and vendor-maintained [Pruna InferBench](https://docs.pruna.ai/en/stable/setup/benchmarks.html). Our proposed focus is independent evaluation of a specific source-to-optimized artifact transition, including quality, compatibility, and preparation cost. Market differentiation remains a hypothesis.

## Next experiment and validation

1. Obtain one supported GPU and TheStage SDK access; validate both local adapters.
2. Pin the source revision, XL artifact, workload, and quality protocol with an ML team.
3. Use the pilot to freeze the final repetition/quality plan before a baseline/XL confirmation study, then L/M/S. An open BF16-versus-quantized serving comparison can validate the pipeline before commercial SDK access is obtained.
4. Add Pruna after confirming the same source model. Test serving stacks in a separate API cohort.
5. Add host-side telemetry, representative sequence lengths, cache-on/off scenarios, and open-loop load. A remote client cannot measure server VRAM or GPU energy directly.

Run `node --test test.mjs test-registry.mjs test-analysis.mjs test-configuration.mjs test-experiment.mjs`. Build from this directory with `python3 build.py`. Protocol 0.3, 14 November 2026. API mechanics and report handling are tested locally; GPU/vendor execution remains untested.
