test_gh108_config_benchmark.cpp¶
tests/model/test_gh108_config_benchmark.cpp
@file test_gh108_config_benchmark.cpp @brief Decode-configuration benchmarks: the gh#108 quant/config comparison and the gh#153 four-arm MTP throughput measurement.
Owners: @tvanfossen
measure_cold_prefill
PrefillPoint gh153::measure_cold_prefill(const BenchModel &m, entropic::config::BundledModels ®istry, const std::string &prompt)
Measure one cold prefill at one residency level.
tests/model/test_gh108_config_benchmark.cpp:1430
Called by none
Tested by 1 tests
run_prefill_residency_bench
Calls REQUIRE, build_orchestrator, config_yaml, describe_run, dir
Checks
REQUIRE(result.error_code == ENTROPIC_OK);REQUIRE_FALSE(records.empty());REQUIRE(p.prefill_tokens > 0);
Result: absent
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-INFER-019 | tag | measure_cold_prefill → build_orchestrator → initialize → ensure_vram_budget |
Source · 59 lines
PrefillPoint measure_cold_prefill(const BenchModel& m,
entropic::config::BundledModels& registry,
const std::string& prompt) {
PrefillPoint p;
p.gpu_layers = m.gpu_layers;
p.n_ubatch = m.n_ubatch;
BenchProject project(m.label + "_" + m.gpu_layers);
auto orch = build_orchestrator(config_yaml(m, project.dir()), registry);
const RunInfo run = describe_run(m, registry, *orch);
p.resolved_layers = run.resident_layers;
// v2.14.6: what the engine resolved, not what was asked for — `auto` can
// move experts host-side on its own.
p.cpu_moe_layers = run.cpu_moe_layers;
entropic::Message u;
u.role = "user";
u.content = prompt;
entropic::GenerationParams params;
params.temperature = 0.0f;
params.max_tokens = 1; // prefill plus one token: this IS the TTFT call
const auto t0 = std::chrono::steady_clock::now();
const auto result = orch->generate({u}, params, "plain");
const auto t1 = std::chrono::steady_clock::now();
p.ttft_ms = std::chrono::duration<double, std::milli>(t1 - t0).count();
INFO("generation error: " << result.error_message);
REQUIRE(result.error_code == ENTROPIC_OK);
const auto records = orch->generation_records();
REQUIRE_FALSE(records.empty());
p.prefill_tokens = records.back().prefill_tokens;
// gh#194 shipped in v2.13.2. If this is 0 the figure below is
// meaningless, and silently reporting it would be worse than failing.
REQUIRE(p.prefill_tokens > 0);
if (p.ttft_ms > 0.0) {
p.prefill_tok_s =
static_cast<double>(p.prefill_tokens) / p.ttft_ms * 1000.0;
}
// Decode, on the SAME context the cold pass just filled — so it is warm
// by construction and measures the bandwidth-bound half. Without this the
// prefill figures alone would recommend trading layers for batch, and
// decode is exactly what that trade should cost: it streams every weight
// per token and gains nothing from a larger batch.
entropic::GenerationParams decode = params;
decode.max_tokens = 128;
const auto d0 = std::chrono::steady_clock::now();
const auto dres = orch->generate({u}, decode, "plain");
const auto d1 = std::chrono::steady_clock::now();
if (dres.error_code == ENTROPIC_OK && dres.token_count > 0) {
const double ms =
std::chrono::duration<double, std::milli>(d1 - d0).count();
if (ms > 0.0) {
p.decode_tok_s =
static_cast<double>(dres.token_count) / ms * 1000.0;
}
}
return p;
}Activity · 36 steps
run_prefill_residency_bench
void gh153::run_prefill_residency_bench(const BenchModel &base, const std::vector< std::pair< std::string, int > > &levels)
Sweep residency and report what cold prefill costs at each level.
tests/model/test_gh108_config_benchmark.cpp:1505
Called by TEST_CASE
Calls REQUIRE, get, large_prompt, load_registry, measure_cold_prefill, resolve, skip_if_absent
Checks
REQUIRE(load_registry(registry));REQUIRE(registry.get(base.target_key) != nullptr);
Result: absent
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-INFER-019 | tag | run_prefill_residency_bench → measure_cold_prefill → build_orchestrator → initialize → ensure_vram_budget |
Source · 37 lines
void run_prefill_residency_bench(
const BenchModel& base,
const std::vector<std::pair<std::string, int>>& levels) {
entropic::config::BundledModels registry;
REQUIRE(load_registry(registry));
REQUIRE(registry.get(base.target_key) != nullptr);
skip_if_absent(base.target_key, registry.resolve(base.target_key));
const std::string prompt = large_prompt(6000);
std::vector<PrefillPoint> points;
for (const auto& [layers, ubatch] : levels) {
BenchModel m = base;
m.gpu_layers = layers;
m.n_ubatch = ubatch;
points.push_back(measure_cold_prefill(m, registry, prompt));
}
std::printf("\ngh193 COLD PREFILL vs RESIDENCY — %s\n", base.label.c_str());
std::printf(" one cold pass per level, max_tokens=1, prompt ~%d tokens\n",
points.empty() ? 0 : points.front().prefill_tokens);
std::printf(" %-10s %-9s %-9s %-11s %-14s %s\n",
"gpu_layers", "resolved", "n_ubatch", "TTFT ms",
"prefill tok/s", "decode tok/s");
for (const auto& p : points) {
std::printf(" %-10s %-9d %-9d %-11.1f %-14.1f %.1f\n",
p.gpu_layers.c_str(), p.resolved_layers, p.n_ubatch,
p.ttft_ms, p.prefill_tok_s, p.decode_tok_s);
}
if (points.size() >= 2) {
const double best = points.front().prefill_tok_s;
const double worst = points.back().prefill_tok_s;
if (worst > 0.0) {
std::printf(" most-resident is %.2fx the least-resident on "
"prefill\n", best / worst);
}
}
}