From cd5bd14afddf5f788668cb9d0e79d5a13ef2aceb Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Fri, 18 Sep 2026 03:10:39 +0000 Subject: [PATCH 01/43] Wire vllm bench serve into serving-load carriers that refuse a rate without subject, protocol, and fail-closed ledger. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A rate without those is uncomparable, a quiet drain is not isolation, and engine generation_tokens_total is the throughput counter — not wall clock, ITL, or booked iteration tokens. Co-authored-by: Cursor --- dag/extdeps/vllm/bench_serve.dag | 162 ++++ dag/extdeps/vllm/metrics.dag | 41 ++ dag/extdeps/vllm/server.dag | 7 + dag/gunbc/harness/harness_backend.dag | 11 +- dag/gunbc/spark/serving_load_probe.dag | 691 ++++++++++++++++++ dag/gunbc/spark/serving_load_probe_cli.dag | 153 ++++ .../spark/serving_load_probe_witness_test.dag | 246 +++++++ 7 files changed, 1310 insertions(+), 1 deletion(-) create mode 100644 dag/extdeps/vllm/bench_serve.dag create mode 100644 dag/gunbc/spark/serving_load_probe.dag create mode 100644 dag/gunbc/spark/serving_load_probe_cli.dag create mode 100644 dag/test/claim/spark/serving_load_probe_witness_test.dag diff --git a/dag/extdeps/vllm/bench_serve.dag b/dag/extdeps/vllm/bench_serve.dag new file mode 100644 index 00000000000..dabf0e9852e --- /dev/null +++ b/dag/extdeps/vllm/bench_serve.dag @@ -0,0 +1,162 @@ +module extdeps.vllm.bench_serve + +import std.types { Bool, List, NonEmptyStr, String } +import std.nat { Nat } +import v2.std.optional { Present, Absent } +import std.measure { TokenCount, token_count, token_count_value } +import std.decl_ref { DeclarationRef, WholeDeclaration } +import std.decimal { fixed_point_wire } +import extdeps.external_authority { ExternalAuthority, ExternalModelScope, ExternalSubjectRef } +import extdeps.uri { Uri, Https } +import extdeps.vllm.server { VllmRoute, vllm_route_chat_completions, vllm_route_completions, vllm_route_path } + +data extdeps_external_authority_anchor: ExternalAuthority = ExternalAuthority { + uri: Uri { + scheme: Https + locator: "github.com/vllm-project/vllm/blob/main/vllm/benchmarks/serve.py" + } +} + +data extdeps_model_scope: ExternalModelScope = ExternalModelScope { + subject: ExternalSubjectRef { + declaration: DeclarationRef { + module_path: "extdeps.vllm.bench_serve", + decl_name: "VllmBenchServeRequest", + field: WholeDeclaration + } + }, + first_citation: extdeps_external_authority_anchor, + further_citations: [] +} + +// ── UPSTREAM'S LOAD DRIVER, NOT OURS ────────────────────────────────────────────────────────── +// +// vLLM ships `vllm bench serve` with Poisson arrivals (`--request-rate` finite and +// `--burstiness` 1), request-rate control, max-concurrency, random prefixes, and trace replay. +// A second load generator in this repository would be a fork of that driver. This module names +// the request the CLI actually takes and renders the argv; it does not invent a client. + +data vllm_bench_serve_program: NonEmptyStr = "vllm" as NonEmptyStr + +type VllmBenchBackend + = OpenaiCompletions + | OpenaiChat + +fn vllm_bench_backend_wire(b: VllmBenchBackend) -> NonEmptyStr { + match b { + OpenaiCompletions => "openai" as NonEmptyStr + OpenaiChat => "openai-chat" as NonEmptyStr + } +} + +fn vllm_bench_backend_route(b: VllmBenchBackend) -> VllmRoute { + match b { + OpenaiCompletions => vllm_route_completions + OpenaiChat => vllm_route_chat_completions + } +} + +// FINITE RATE IS POISSON WHEN BURSTINESS IS 1; INF SENDS EVERY REQUEST AT TIME ZERO. +// That last arm is the all-at-once launch whose wall clock the bash-loop instrument confused +// with engine time. It remains representable because the upstream CLI offers it; a holistic +// session simulation must not select it. +type BenchArrival + = SendAllImmediately + | PoissonProcess { millirequests_per_second: Nat, burstiness_milli: Nat } + +type RandomDatasetSpec { + input_len: TokenCount + output_len: TokenCount + prefix_len: TokenCount +} + +type VllmBenchServeRequest { + backend: VllmBenchBackend + base_url: NonEmptyStr + model: NonEmptyStr + dataset: RandomDatasetSpec + num_prompts: Nat + arrival: BenchArrival + max_concurrency: Nat? + ignore_eos: Bool +} + +fn vllm_bench_serve_request( + backend: VllmBenchBackend, + base_url: NonEmptyStr, + model: NonEmptyStr, + dataset: RandomDatasetSpec, + num_prompts: Nat, + arrival: BenchArrival, + max_concurrency: Nat?, + ignore_eos: Bool, +) -> VllmBenchServeRequest { + VllmBenchServeRequest { + backend: backend, + base_url: base_url, + model: model, + dataset: dataset, + num_prompts: num_prompts, + arrival: arrival, + max_concurrency: max_concurrency, + ignore_eos: ignore_eos, + } +} + +fn vllm_bench_arrival_rate_wire(a: BenchArrival) -> String { + match a { + SendAllImmediately => "inf" + PoissonProcess { millirequests_per_second: n, burstiness_milli: _ } => + fixed_point_wire(value: n as Int, decimals: 3) + } +} + +fn vllm_bench_burstiness_words(a: BenchArrival) -> List { + match a { + SendAllImmediately => [] + PoissonProcess { millirequests_per_second: _, burstiness_milli: b } => + ["--burstiness", fixed_point_wire(value: b as Int, decimals: 3)] + } +} + +fn vllm_bench_concurrency_words(n: Nat?) -> List { + match n { + Absent => [] + Present { value: c } => ["--max-concurrency", to_string(c)] + } +} + +fn vllm_bench_eos_words(ignore: Bool) -> List { + if ignore { ["--ignore-eos"] } else { [] } +} + +// THE ARGV IS DERIVED FROM THE REQUEST, so a protocol that asked for Poisson arrivals cannot +// silently render `inf`, and a protocol that named a shared prefix cannot drop `--random-prefix-len`. +fn vllm_bench_serve_arguments(req: VllmBenchServeRequest) -> List { + concat( + [ + "bench", "serve", + "--backend", vllm_bench_backend_wire(b: req.backend) as String, + "--base-url", req.base_url as String, + "--model", req.model as String, + "--endpoint", vllm_route_path(r: vllm_bench_backend_route(b: req.backend)) as String, + "--dataset-name", "random", + "--random-input-len", to_string(token_count_value(t: req.dataset.input_len)), + "--random-output-len", to_string(token_count_value(t: req.dataset.output_len)), + "--random-prefix-len", to_string(token_count_value(t: req.dataset.prefix_len)), + "--num-prompts", to_string(req.num_prompts), + "--request-rate", vllm_bench_arrival_rate_wire(a: req.arrival), + ], + concat( + vllm_bench_burstiness_words(a: req.arrival), + concat(vllm_bench_concurrency_words(n: req.max_concurrency), vllm_bench_eos_words(ignore: req.ignore_eos)), + ), + ) +} + +fn vllm_bench_serve_uses_poisson_idle_gaps(req: VllmBenchServeRequest) -> Bool { + match req.arrival { + SendAllImmediately => false + PoissonProcess { millirequests_per_second: n, burstiness_milli: b } => n > 0 && b == 1000 + } +} diff --git a/dag/extdeps/vllm/metrics.dag b/dag/extdeps/vllm/metrics.dag index 09657bb6434..592d9516df9 100644 --- a/dag/extdeps/vllm/metrics.dag +++ b/dag/extdeps/vllm/metrics.dag @@ -444,3 +444,44 @@ fn interconnect_counter_note(c: InterconnectCounter) -> NonEmptyStr { "port_xmit_data and port_rcv_data, in 4-byte words, are the RoCE traffic; measured 2026-09-07 at ~7.9 Gb/s per rank on a 50 Gb/s link during a cold prefill. That is a BULK-TRANSFER reading and bounds bandwidth saturation only: a low average is equally consistent with latency-bound collectives, a straggler rank, or host gaps between kernels, so it does not establish what share of the critical path was communication" as NonEmptyStr } } + +// ── HISTOGRAM SUM AND COUNT ARE THE ENGINE CLOCK FOR A RATE, NOT A SECOND METRIC NAME ───────── +// +// A RATE DERIVED FROM SHELL WALL CLOCK is the instrument that reported a 4-to-8 stream cliff that +// did not exist (launcher arrival stagger landing in the wall) and understated aggregate at 16 +// streams by about 40%. The engine's own histogram exposition carries `_sum` and `_count` on the +// families that already live in VllmServingMetric. Those suffixes are Prometheus histogram +// statistics, not new serving questions, so they are projections of a family rather than new +// metric variants. +// +// InterTokenLatencySeconds: count is completed decode intervals, sum is their seconds. That ratio +// is a latency distribution, not aggregate tokens/s. IterationTokensTotal: count is recorded +// iterations, sum is tokens booked in them, not occupancy and not steps. Aggregate throughput is +// vllm:generation_tokens_total on one exporter across a scrape interval. +type HistogramStatistic + = HistogramSum + | HistogramCount + +fn vllm_histogram_series_name(m: VllmServingMetric, s: HistogramStatistic) -> NonEmptyStr { + match s { + HistogramSum => join([vllm_metric_name(m: m) as String, "_sum"], "") as NonEmptyStr + HistogramCount => join([vllm_metric_name(m: m) as String, "_count"], "") as NonEmptyStr + } +} + +fn vllm_metric_exports_histogram_statistics(m: VllmServingMetric) -> Bool { + match m { + InterTokenLatencySeconds => true + IterationTokensTotal => true + KvCacheUsagePerc => false + NumRequestsRunning => false + NumRequestsWaiting => false + NumRequestsWaitingByReason => false + PrefixCacheQueries => false + PrefixCacheHits => false + PromptTokensTotal => false + GenerationTokensTotal => false + NumPreemptionsTotal => false + EstimatedFlopsPerGpuTotal => false + } +} diff --git a/dag/extdeps/vllm/server.dag b/dag/extdeps/vllm/server.dag index c13b40c508d..8335c29944e 100644 --- a/dag/extdeps/vllm/server.dag +++ b/dag/extdeps/vllm/server.dag @@ -91,11 +91,17 @@ fn vllm_route(path: NonEmptyStr, population: VllmRoutePopulation) -> VllmRoute { VllmRoute { path: path, population: population, established_against: vllm_source_revision_read } } +fn vllm_route_path(r: VllmRoute) -> NonEmptyStr { + r.path +} + data vllm_route_models: VllmRoute = vllm_route(path: "/v1/models" as NonEmptyStr, population: OrdinarilyRegistered) data vllm_route_version: VllmRoute = vllm_route(path: "/version" as NonEmptyStr, population: OrdinarilyRegistered) data vllm_route_health: VllmRoute = vllm_route(path: "/health" as NonEmptyStr, population: OrdinarilyRegistered) data vllm_route_ping: VllmRoute = vllm_route(path: "/ping" as NonEmptyStr, population: OrdinarilyRegistered) data vllm_route_metrics: VllmRoute = vllm_route(path: "/metrics" as NonEmptyStr, population: OrdinarilyRegistered) +data vllm_route_completions: VllmRoute = vllm_route(path: "/v1/completions" as NonEmptyStr, population: OrdinarilyRegistered) +data vllm_route_chat_completions: VllmRoute = vllm_route(path: "/v1/chat/completions" as NonEmptyStr, population: OrdinarilyRegistered) data vllm_route_server_info: VllmRoute = vllm_route(path: "/server_info" as NonEmptyStr, population: RegisteredOnlyUnderDevelopmentMode) data vllm_route_get_world_size: VllmRoute = vllm_route(path: "/get_world_size" as NonEmptyStr, population: RegisteredOnlyUnderDevelopmentMode) @@ -190,6 +196,7 @@ data vllm_http_parallel_evidence_routes: List = [ data vllm_routes: List = [ vllm_route_models, vllm_route_version, vllm_route_health, vllm_route_ping, vllm_route_metrics, + vllm_route_completions, vllm_route_chat_completions, vllm_route_server_info, vllm_route_get_world_size, vllm_route_collective_rpc, ] diff --git a/dag/gunbc/harness/harness_backend.dag b/dag/gunbc/harness/harness_backend.dag index 77e56d33f75..0de7be8215c 100644 --- a/dag/gunbc/harness/harness_backend.dag +++ b/dag/gunbc/harness/harness_backend.dag @@ -14,7 +14,8 @@ import gunbc.serving.serving_availability { } import extdeps.vllm.metrics { VllmServingMetric, NumRequestsWaiting, NumRequestsRunning, NumRequestsWaitingByReason, GenerationTokensTotal, - vllm_metric_name, vllm_waiting_reason_label, vllm_waiting_reason_capacity, + HistogramStatistic, vllm_metric_name, vllm_histogram_series_name, + vllm_waiting_reason_label, vllm_waiting_reason_capacity, } import extdeps.prometheus.client { ProcessStartTimeSeconds, prometheus_process_series_name } import gunbc.spark.fabric_switch_observed { FabricGroup, fabric_group_wire } @@ -361,6 +362,14 @@ fn harness_gauge_value(body: String, metric: VllmServingMetric) -> String? { harness_metric_line_value(body: body, prefix: join([vllm_metric_name(m: metric) as String, "{"], ""), selector: SeriesByName) } +fn harness_histogram_statistic_value(body: String, metric: VllmServingMetric, statistic: HistogramStatistic) -> String? { + harness_metric_line_value( + body: body, + prefix: join([vllm_histogram_series_name(m: metric, s: statistic) as String, "{"], ""), + selector: SeriesByName, + ) +} + // THE LABEL PAIR IS BUILT ONCE, HERE, from the label key and value rows the upstream module carries, // so no consumer spells a Prometheus label rendering of its own. fn harness_labelled_gauge_value(body: String, metric: VllmServingMetric, label: NonEmptyStr, value: NonEmptyStr) -> String? { diff --git a/dag/gunbc/spark/serving_load_probe.dag b/dag/gunbc/spark/serving_load_probe.dag new file mode 100644 index 00000000000..1d6595ee4ee --- /dev/null +++ b/dag/gunbc/spark/serving_load_probe.dag @@ -0,0 +1,691 @@ +module gunbc.spark.serving_load_probe + +import std.types { Bool, String, NonEmptyStr, List, EpochSecs } +import std.nat { Nat } +import std.decimal { ExactDecimal, canonical_exact_decimal, decimal_pow10 } +import v2.std.algebra { length, filter } +import v2.std.optional { Present, Absent } +import std.measure { TokenCount, token_count, token_count_value } +import product.capacity.lease { LeaseGrant } +import product.fabric.demand { ObservationReceiptRef } +import extdeps.prometheus.client { + SampleValueExact, SampleValueNotFinite, SampleValueUnreadable, prometheus_sample_value_reading, +} +import extdeps.vllm.metrics { + VllmServingMetric, InterTokenLatencySeconds, IterationTokensTotal, NumPreemptionsTotal, GenerationTokensTotal, + HistogramStatistic, HistogramSum, HistogramCount, + vllm_metric_exports_histogram_statistics, +} +import extdeps.vllm.bench_serve { + VllmBenchServeRequest, PoissonProcess, + RandomDatasetSpec, OpenaiChat, vllm_bench_serve_request, vllm_bench_serve_uses_poisson_idle_gaps, +} +import gunbc.harness.harness_backend { + harness_gauge_value, harness_labelled_gauge_value, harness_gauge_count, + harness_histogram_statistic_value, harness_launch_from_body, harness_queue_from_body, +} +import gunbc.serving.turn_admission { + ServingQueueReading, QueueDepthRead, QueueDepthUnread, + ServingCapacityPressure, RouteAdmittingMore, RouteHoldingForCapacity, CapacityPressureUnread, +} +import gunbc.spark.vllm_endpoint_process_launch { + VllmEndpointProcessLaunchObservation, LaunchObserved, LaunchUnobserved, +} +import gunbc.spark.serving_arm { + Glm53NativeFp8, GunbcGlm53NopeDerivedGb10, FourSparkTp4, glm_native_concurrent_profile, +} +import gunbc.spark.serving_performance_subject { + ServingPerformanceSubject, serving_performance_subject, serving_subject_standing, + ServingPerformanceSubjectStanding, SubjectEstablished, SubjectPartial, +} +import extdeps.vllm.engine_args { KvFp8, SpeculativeDecodingOff } + +// ── THROUGHPUT QUALIFICATION FOR THE SERVING SUBJECT (design #11540, serving side) ──────────── +// +// A RATE WITHOUT ITS SUBJECT, PROTOCOL, REALIZATION AND WINDOW STANDING is uncomparable. +// Saturation is not decidable from one run. Completion accounting is fail-closed: a request that +// emits tokens and then fails cannot be denominated in tokens. A quiet endpoint read is not an +// isolation receipt. +// +// THE RATE IS DERIVED AND NEVER STORED, the same law gunbc.harness.harness_throughput states for +// its own stream: counts and an engine interval are carried; tokens-per-second is a function of +// them. + +type DrainReceipt + = DrainObservedIdle + | DrainNotIdle { running: Nat } + | DrainUnread { cause: NonEmptyStr } + +type ExclusionReceipt + = ExclusionEstablished { how: NonEmptyStr } + | ExclusionNotEstablished { cause: NonEmptyStr } + +type ProbeWindowStanding + = WindowIsolated { grant: LeaseGrant, deadline: EpochSecs, drain: DrainReceipt, exclusion: ExclusionReceipt } + | WindowSharedWithDeclaredTraffic { traffic_receipt: NonEmptyStr, drain: DrainReceipt } + | WindowIsolationUnread { cause: NonEmptyStr, drain: DrainReceipt } + +fn window_isolated_requires_exclusion(s: ProbeWindowStanding) -> Bool { + match s { + WindowIsolated { grant: _, deadline: _, drain: _, exclusion: e } => + match e { + ExclusionEstablished { how: _ } => true + ExclusionNotEstablished { cause: _ } => false + } + WindowSharedWithDeclaredTraffic { traffic_receipt: _, drain: _ } => false + WindowIsolationUnread { cause: _, drain: _ } => false + } +} + +fn drain_from_queue(q: ServingQueueReading) -> DrainReceipt { + match q { + QueueDepthUnread { obligation: o } => DrainUnread { cause: o } + QueueDepthRead { waiting: _, running: r, pressure: _ } => + if r == 0 { DrainObservedIdle } else { DrainNotIdle { running: r } } + } +} + +// A ZERO RUNNING GAUGE IS A DRAIN SNAPSHOT. It is not exclusion: production work can arrive after +// the read. Without an exclusion receipt the standing cannot be WindowIsolated. +fn window_from_drain(drain: DrainReceipt, traffic_receipt: NonEmptyStr) -> ProbeWindowStanding { + match drain { + DrainUnread { cause: c } => WindowIsolationUnread { cause: c, drain: drain } + DrainNotIdle { running: _ } => + WindowSharedWithDeclaredTraffic { traffic_receipt: traffic_receipt, drain: drain } + DrainObservedIdle => + WindowSharedWithDeclaredTraffic { traffic_receipt: traffic_receipt, drain: drain } + } +} + +fn isolated_window(grant: LeaseGrant, deadline: EpochSecs, drain: DrainReceipt, exclusion: ExclusionReceipt) -> ProbeWindowStanding { + match exclusion { + ExclusionNotEstablished { cause: c } => + WindowIsolationUnread { cause: c, drain: drain } + ExclusionEstablished { how: _ } => + match drain { + DrainObservedIdle => + WindowIsolated { grant: grant, deadline: deadline, drain: drain, exclusion: exclusion } + DrainNotIdle { running: _ } => + WindowIsolationUnread { cause: "exclusion was named but the drain snapshot was not idle" as NonEmptyStr, drain: drain } + DrainUnread { cause: c } => + WindowIsolationUnread { cause: c, drain: drain } + } + } +} + +type BacklogStanding + = BacklogObserved { running: Nat, waiting: Nat, capacity_waiting: Nat, preemptions: Nat } + | NoBacklogObserved { running: Nat, preemptions: Nat } + | BacklogUnread { cause: NonEmptyStr } + +fn capacity_waiting_count(p: ServingCapacityPressure) -> Nat? { + match p { + CapacityPressureUnread { obligation: _ } => none + RouteAdmittingMore => Present { value: 0 } + RouteHoldingForCapacity { held: n } => Present { value: n } + } +} + +fn backlog_from_body(body: String, preemptions: Nat?) -> BacklogStanding { + match preemptions { + Absent => BacklogUnread { cause: "vllm:num_preemptions_total could not be read as a count" as NonEmptyStr } + Present { value: p } => + match harness_queue_from_body(body: body) { + QueueDepthUnread { obligation: o } => BacklogUnread { cause: o } + QueueDepthRead { waiting: w, running: r, pressure: pr } => + match capacity_waiting_count(p: pr) { + Absent => BacklogUnread { cause: "capacity-reason waiting could not be read" as NonEmptyStr } + Present { value: c } => + if w == 0 && c == 0 { + NoBacklogObserved { running: r, preemptions: p } + } else { + BacklogObserved { running: r, waiting: w, capacity_waiting: c, preemptions: p } + } + } + } + } +} + +type CounterContinuity + = SameExporter { start_field: NonEmptyStr } + | ExporterChanged { before: NonEmptyStr, after: NonEmptyStr } + | ContinuityUnread { cause: NonEmptyStr } + +fn counter_continuity(before: VllmEndpointProcessLaunchObservation, after: VllmEndpointProcessLaunchObservation) -> CounterContinuity { + match before { + LaunchUnobserved { endpoint: e } => + ContinuityUnread { cause: join(["the exporter start field was unobserved before the window: ", e as String], "") as NonEmptyStr } + LaunchObserved { launch: b, receipt: _ } => + match after { + LaunchUnobserved { endpoint: e } => + ContinuityUnread { cause: join(["the exporter start field was unobserved after the window: ", e as String], "") as NonEmptyStr } + LaunchObserved { launch: a, receipt: _ } => + if (b.process_start_field as String) == (a.process_start_field as String) { + SameExporter { start_field: b.process_start_field } + } else { + ExporterChanged { before: b.process_start_field, after: a.process_start_field } + } + } + } +} + +type HistogramDelta + = HistogramDeltaRead { sum_milli: Nat, count: Nat } + | HistogramDeltaUnread { cause: NonEmptyStr } + | HistogramCounterReset { cause: NonEmptyStr } + +fn milli_from_exact(d: ExactDecimal) -> Nat? { + let c = canonical_exact_decimal(d: d) + if c.units < 0 { + none + } else if c.fraction_digits > 3 { + none + } else { + let scaled = c.units * decimal_pow10(exponent: 3 - c.fraction_digits) + if scaled < 0 { none } else { Present { value: scaled as Nat } } + } +} + +fn field_to_milli(field: String) -> Nat? { + match prometheus_sample_value_reading(field: field) { + SampleValueNotFinite { lexeme: _ } => none + SampleValueUnreadable { lexeme: _ } => none + SampleValueExact { value: d } => milli_from_exact(d: d) + } +} + +fn nat_delta(after: Nat, before: Nat) -> Nat? { + if after < before { none } else { Present { value: after - before } } +} + +fn histogram_delta(before_body: String, after_body: String, metric: VllmServingMetric) -> HistogramDelta { + if !vllm_metric_exports_histogram_statistics(m: metric) { + HistogramDeltaUnread { cause: "this metric does not export histogram sum/count" as NonEmptyStr } + } else { + match harness_histogram_statistic_value(body: before_body, metric: metric, statistic: HistogramSum) { + Absent => HistogramDeltaUnread { cause: "histogram sum missing on the first body" as NonEmptyStr } + Present { value: bs } => + match harness_histogram_statistic_value(body: after_body, metric: metric, statistic: HistogramSum) { + Absent => HistogramDeltaUnread { cause: "histogram sum missing on the second body" as NonEmptyStr } + Present { value: asv } => + match harness_histogram_statistic_value(body: before_body, metric: metric, statistic: HistogramCount) { + Absent => HistogramDeltaUnread { cause: "histogram count missing on the first body" as NonEmptyStr } + Present { value: bc } => + match harness_histogram_statistic_value(body: after_body, metric: metric, statistic: HistogramCount) { + Absent => HistogramDeltaUnread { cause: "histogram count missing on the second body" as NonEmptyStr } + Present { value: ac } => + match field_to_milli(field: bs) { + Absent => HistogramDeltaUnread { cause: "histogram sum before was not an exact milli-second" as NonEmptyStr } + Present { value: bsm } => + match field_to_milli(field: asv) { + Absent => HistogramDeltaUnread { cause: "histogram sum after was not an exact milli-second" as NonEmptyStr } + Present { value: asm } => + match harness_gauge_count(text: bc) { + Absent => HistogramDeltaUnread { cause: "histogram count before was not an exact count" as NonEmptyStr } + Present { value: bcn } => + match harness_gauge_count(text: ac) { + Absent => HistogramDeltaUnread { cause: "histogram count after was not an exact count" as NonEmptyStr } + Present { value: acn } => + match nat_delta(after: asm, before: bsm) { + Absent => HistogramCounterReset { cause: "histogram sum decreased across the window" as NonEmptyStr } + Present { value: ds } => + match nat_delta(after: acn, before: bcn) { + Absent => HistogramCounterReset { cause: "histogram count decreased across the window" as NonEmptyStr } + Present { value: dc } => HistogramDeltaRead { sum_milli: ds, count: dc } + } + } + } + } + } + } + } + } + } + } + } +} + +fn preemption_count(body: String) -> Nat? { + match harness_gauge_value(body: body, metric: NumPreemptionsTotal) { + Absent => none + Present { value: t } => harness_gauge_count(text: t) + } +} + +type OperationLedger + = LedgerClosed { offered: Nat, completed: Nat, failed: Nat, failed_after_tokens: Nat } + | LedgerIncomplete { because: NonEmptyStr } + +fn ledger_admits_token_denomination(l: OperationLedger) -> Bool { + match l { + LedgerIncomplete { because: _ } => false + LedgerClosed { offered: o, completed: c, failed: f, failed_after_tokens: t } => + t == 0 && (c + f) == o + } +} + +type TokenDelta + = TokenDeltaRead { tokens: Nat } + | TokenDeltaUnread { cause: NonEmptyStr } + | TokenDeltaReset { cause: NonEmptyStr } + +fn generation_token_delta(before_body: String, after_body: String) -> TokenDelta { + match harness_gauge_value(body: before_body, metric: GenerationTokensTotal) { + Absent => TokenDeltaUnread { cause: "vllm:generation_tokens_total missing on the first body" as NonEmptyStr } + Present { value: b } => + match harness_gauge_value(body: after_body, metric: GenerationTokensTotal) { + Absent => TokenDeltaUnread { cause: "vllm:generation_tokens_total missing on the second body" as NonEmptyStr } + Present { value: a } => + match field_to_milli(field: b) { + Absent => TokenDeltaUnread { cause: "generation_tokens_total before was not an exact decimal" as NonEmptyStr } + Present { value: bm } => + match field_to_milli(field: a) { + Absent => TokenDeltaUnread { cause: "generation_tokens_total after was not an exact decimal" as NonEmptyStr } + Present { value: am } => + match nat_delta(after: am, before: bm) { + Absent => TokenDeltaReset { cause: "generation_tokens_total decreased; the exporter likely restarted" as NonEmptyStr } + Present { value: d } => + if d % 1000 == 0 { + TokenDeltaRead { tokens: d / 1000 } + } else { + TokenDeltaUnread { cause: "generation_tokens_total delta was not a whole token count" as NonEmptyStr } + } + } + } + } + } + } +} + +fn scrape_interval_millis(before_at: EpochSecs, after_at: EpochSecs) -> Nat? { + if after_at <= before_at { + none + } else { + Present { value: ((after_at - before_at) * 1000) as Nat } + } +} + +type ArrivalSkew + = ArrivalSkewObserved { max_stagger_millis: Nat } + | ArrivalSkewUnread { cause: NonEmptyStr } + +data arrival_skew_comparison_bound_millis: Nat = 250 + +fn arrival_admits_rate_comparison(s: ArrivalSkew) -> Bool { + match s { + ArrivalSkewUnread { cause: _ } => false + ArrivalSkewObserved { max_stagger_millis: n } => n <= arrival_skew_comparison_bound_millis + } +} + +type OccupancySample { + running: Nat + waiting: Nat + capacity_waiting: Nat + preemptions: Nat +} + +type OccupancyTrace + = OccupancySampled { samples: List } + | OccupancyUnsampled { cause: NonEmptyStr } + +fn occupancy_from_body(body: String) -> OccupancySample? { + match harness_queue_from_body(body: body) { + QueueDepthUnread { obligation: _ } => none + QueueDepthRead { waiting: w, running: r, pressure: p } => + match preemption_count(body: body) { + Absent => none + Present { value: pr } => + match capacity_waiting_count(p: p) { + Absent => none + Present { value: c } => Present { value: OccupancySample { running: r, waiting: w, capacity_waiting: c, preemptions: pr } } + } + } + } +} + +fn occupancy_admits_declared_load(trace: OccupancyTrace, max_concurrency: Nat?) -> Bool { + match trace { + OccupancyUnsampled { cause: _ } => true + OccupancySampled { samples: ss } => + match max_concurrency { + Absent => true + Present { value: cap } => + length(filter(ss, s => s.running > cap)) == 0 + } + } +} + +type ClientOutputTokens + = ClientOutputTokensObserved { tokens: Nat } + | ClientOutputTokensUnread { cause: NonEmptyStr } + +type LedgerCounterAgreement + = LedgerAndCounterAgree { generation_tokens: Nat, completed_requests: Nat } + | LedgerCounterDisagree { because: NonEmptyStr } + | AgreementUnread { because: NonEmptyStr } + +fn ledger_counter_agreement(ledger: OperationLedger, generation: TokenDelta, client_output: ClientOutputTokens) -> LedgerCounterAgreement { + match generation { + TokenDeltaUnread { cause: c } => AgreementUnread { because: c } + TokenDeltaReset { cause: c } => AgreementUnread { because: c } + TokenDeltaRead { tokens: g } => + match ledger { + LedgerIncomplete { because: c } => AgreementUnread { because: c } + LedgerClosed { offered: _, completed: n, failed: _, failed_after_tokens: _ } => + if g > 0 && n == 0 { + LedgerCounterDisagree { because: "generation_tokens_total advanced while the client ledger completed zero requests; foreign load is the remaining explanation" as NonEmptyStr } + } else { + match client_output { + ClientOutputTokensUnread { cause: _ } => + LedgerAndCounterAgree { generation_tokens: g, completed_requests: n } + ClientOutputTokensObserved { tokens: c } => + if c == g { + LedgerAndCounterAgree { generation_tokens: g, completed_requests: n } + } else { + LedgerCounterDisagree { because: "client completed-token count and generation_tokens_total delta disagree; the rate is not reported" as NonEmptyStr } + } + } + } + } + } +} + +type DerivedRate + = RateFromGenerationTokens { tokens: Nat, scrape_millis: Nat } + | RateUndenominable { because: NonEmptyStr } + | RateUnreadable { because: NonEmptyStr } + +fn tokens_per_observation_second(r: DerivedRate) -> Nat? { + match r { + RateUndenominable { because: _ } => none + RateUnreadable { because: _ } => none + RateFromGenerationTokens { tokens: t, scrape_millis: ms } => + if ms == 0 { none } else { Present { value: (t * 1000) / ms } } + } +} + +fn derive_rate_honest( + ledger: OperationLedger, + continuity: CounterContinuity, + generation: TokenDelta, + scrape_millis: Nat?, + arrival: ArrivalSkew, + occupancy: OccupancyTrace, + max_concurrency: Nat?, + client_output: ClientOutputTokens, +) -> DerivedRate { + if !ledger_admits_token_denomination(l: ledger) { + RateUndenominable { because: "the operation ledger does not admit token denomination" as NonEmptyStr } + } else { + match ledger_counter_agreement(ledger: ledger, generation: generation, client_output: client_output) { + LedgerCounterDisagree { because: c } => RateUnreadable { because: c } + AgreementUnread { because: c } => RateUnreadable { because: c } + LedgerAndCounterAgree { generation_tokens: _, completed_requests: _ } => + if !occupancy_admits_declared_load(trace: occupancy, max_concurrency: max_concurrency) { + RateUnreadable { because: "a mid-run occupancy sample exceeded declared max-concurrency, so foreign load or oversubscription is visible and the rate is not reported" as NonEmptyStr } + } else { + match continuity { + ContinuityUnread { cause: c } => RateUnreadable { because: c } + ExporterChanged { before: _, after: _ } => + RateUnreadable { because: "generation_tokens_total resets on restart; the exporter changed across the window" as NonEmptyStr } + SameExporter { start_field: _ } => + if !arrival_admits_rate_comparison(s: arrival) { + RateUnreadable { because: "arrival skew is unread or exceeds the comparison bound, so a rate comparison is refused" as NonEmptyStr } + } else { + match scrape_millis { + Absent => RateUnreadable { because: "the metric-scrape interval is not a positive span" as NonEmptyStr } + Present { value: ms } => + match generation { + TokenDeltaUnread { cause: c } => RateUnreadable { because: c } + TokenDeltaReset { cause: c } => RateUnreadable { because: c } + TokenDeltaRead { tokens: t } => RateFromGenerationTokens { tokens: t, scrape_millis: ms } + } + } + } + } + } + } + } +} + +type ServingLoadObservation { + subject: ServingPerformanceSubjectStanding + protocol: VllmBenchServeRequest + window: ProbeWindowStanding + continuity: CounterContinuity + arrival: ArrivalSkew + occupancy: OccupancyTrace + agreement: LedgerCounterAgreement + before_backlog: BacklogStanding + after_backlog: BacklogStanding + generation: TokenDelta + itl_latency: HistogramDelta + iteration_tokens_booked: HistogramDelta + ledger: OperationLedger + rate: DerivedRate + raw_before: NonEmptyStr + raw_after: NonEmptyStr +} + +fn serving_load_observation( + subject: ServingPerformanceSubjectStanding, + protocol: VllmBenchServeRequest, + window: ProbeWindowStanding, + continuity: CounterContinuity, + arrival: ArrivalSkew, + occupancy: OccupancyTrace, + client_output: ClientOutputTokens, + before_at: EpochSecs, + after_at: EpochSecs, + before_body: String, + after_body: String, + ledger: OperationLedger, +) -> ServingLoadObservation { + let before_p = preemption_count(body: before_body) + let after_p = preemption_count(body: after_body) + let generation = generation_token_delta(before_body: before_body, after_body: after_body) + let agreement = ledger_counter_agreement(ledger: ledger, generation: generation, client_output: client_output) + ServingLoadObservation { + subject: subject, + protocol: protocol, + window: window, + continuity: continuity, + arrival: arrival, + occupancy: occupancy, + agreement: agreement, + before_backlog: backlog_from_body(body: before_body, preemptions: before_p), + after_backlog: backlog_from_body(body: after_body, preemptions: after_p), + generation: generation, + itl_latency: histogram_delta(before_body: before_body, after_body: after_body, metric: InterTokenLatencySeconds), + iteration_tokens_booked: histogram_delta(before_body: before_body, after_body: after_body, metric: IterationTokensTotal), + ledger: ledger, + rate: derive_rate_honest( + ledger: ledger, + continuity: continuity, + generation: generation, + scrape_millis: scrape_interval_millis(before_at: before_at, after_at: after_at), + arrival: arrival, + occupancy: occupancy, + max_concurrency: protocol.max_concurrency, + client_output: client_output, + ), + raw_before: before_body as NonEmptyStr, + raw_after: after_body as NonEmptyStr, + } +} + +fn observation_rate_is_stored_separately(_: ServingLoadObservation) -> Bool { + false +} + +fn serving_load_observation_text(o: ServingLoadObservation) -> String { + join([ + "serving-load observation\n", + "window: ", window_text(s: o.window), "\n", + "continuity: ", continuity_text(c: o.continuity), "\n", + "before backlog: ", backlog_text(b: o.before_backlog), "\n", + "after backlog: ", backlog_text(b: o.after_backlog), "\n", + "occupancy: ", occupancy_text(t: o.occupancy), "\n", + "agreement: ", agreement_text(a: o.agreement), "\n", + "generation: ", token_delta_text(d: o.generation), "\n", + "itl latency (not a rate): ", histogram_text(d: o.itl_latency), "\n", + "iteration_tokens booked (not occupancy): ", histogram_text(d: o.iteration_tokens_booked), "\n", + "ledger: ", ledger_text(l: o.ledger), "\n", + "rate: ", rate_text(r: o.rate), "\n", + "saturation decided from this run: ", if saturation_from_one_run(obs: o) { "yes" } else { "no" }, "\n", + ], "") +} + +fn occupancy_text(t: OccupancyTrace) -> String { + match t { + OccupancyUnsampled { cause: c } => join(["unsampled ", c as String], "") + OccupancySampled { samples: ss } => join(["samples=", to_string(length(ss))], "") + } +} + +fn agreement_text(a: LedgerCounterAgreement) -> String { + match a { + LedgerAndCounterAgree { generation_tokens: g, completed_requests: n } => + join(["agree generation=", to_string(g), " completed=", to_string(n)], "") + LedgerCounterDisagree { because: c } => join(["disagree ", c as String], "") + AgreementUnread { because: c } => join(["unread ", c as String], "") + } +} + +fn window_text(s: ProbeWindowStanding) -> String { + match s { + WindowIsolated { grant: _, deadline: _, drain: _, exclusion: _ } => "isolated" + WindowSharedWithDeclaredTraffic { traffic_receipt: t, drain: d } => + join(["shared-with-declared-traffic drain=", drain_text(d: d), " traffic=", t as String], "") + WindowIsolationUnread { cause: c, drain: d } => + join(["unread drain=", drain_text(d: d), " cause=", c as String], "") + } +} + +fn drain_text(d: DrainReceipt) -> String { + match d { + DrainObservedIdle => "idle" + DrainNotIdle { running: n } => join(["not-idle running=", to_string(n)], "") + DrainUnread { cause: c } => join(["unread ", c as String], "") + } +} + +fn continuity_text(c: CounterContinuity) -> String { + match c { + SameExporter { start_field: f } => join(["same-exporter ", f as String], "") + ExporterChanged { before: b, after: a } => join(["exporter-changed ", b as String, " -> ", a as String], "") + ContinuityUnread { cause: x } => join(["unread ", x as String], "") + } +} + +fn backlog_text(b: BacklogStanding) -> String { + match b { + BacklogObserved { running: r, waiting: w, capacity_waiting: c, preemptions: p } => + join(["observed running=", to_string(r), " waiting=", to_string(w), " capacity=", to_string(c), " preemptions=", to_string(p)], "") + NoBacklogObserved { running: r, preemptions: p } => + join(["none running=", to_string(r), " preemptions=", to_string(p)], "") + BacklogUnread { cause: c } => join(["unread ", c as String], "") + } +} + +fn histogram_text(d: HistogramDelta) -> String { + match d { + HistogramDeltaRead { sum_milli: s, count: n } => + join(["delta sum_milli=", to_string(s), " count=", to_string(n)], "") + HistogramDeltaUnread { cause: c } => join(["unread ", c as String], "") + HistogramCounterReset { cause: c } => join(["reset ", c as String], "") + } +} + +fn ledger_text(l: OperationLedger) -> String { + match l { + LedgerIncomplete { because: c } => join(["incomplete ", c as String], "") + LedgerClosed { offered: o, completed: c, failed: f, failed_after_tokens: t } => + join(["closed offered=", to_string(o), " completed=", to_string(c), " failed=", to_string(f), " failed_after_tokens=", to_string(t)], "") + } +} + +fn token_delta_text(d: TokenDelta) -> String { + match d { + TokenDeltaRead { tokens: n } => join(["delta tokens=", to_string(n)], "") + TokenDeltaUnread { cause: c } => join(["unread ", c as String], "") + TokenDeltaReset { cause: c } => join(["reset ", c as String], "") + } +} + +fn rate_text(r: DerivedRate) -> String { + match r { + RateUndenominable { because: c } => join(["undenominable ", c as String], "") + RateUnreadable { because: c } => join(["unreadable ", c as String], "") + RateFromGenerationTokens { tokens: t, scrape_millis: ms } => + join([ + "generation_tokens=", to_string(t), + " scrape_millis=", to_string(ms), + " tokens_per_s=", + match tokens_per_observation_second(r: r) { + Absent => "none" + Present { value: v } => to_string(v) + }, + ], "") + } +} + +// ── THE HOLISTIC GLM PROTOCOL THIS FLEET'S SESSIONS ACTUALLY LOOK LIKE ──────────────────────── +// +// Real sessions sit at ~100k-130k tokens of context after compacting a 262k window. They idle +// between turns. Each turn is a separate request whose KV frees on completion while the prefix +// stays in the prefix cache. Peak concurrent DECODING turns times average context is the KV +// quantity, not total sessions. +data glm_native_holistic_dataset: RandomDatasetSpec = RandomDatasetSpec { + input_len: token_count(count: 20000), + output_len: token_count(count: 128), + prefix_len: token_count(count: 100000), +} + +data glm_native_holistic_protocol: VllmBenchServeRequest = vllm_bench_serve_request( + backend: OpenaiChat, + base_url: "http://127.0.0.1:30000" as NonEmptyStr, + model: glm_native_concurrent_profile.served_alias, + dataset: glm_native_holistic_dataset, + num_prompts: 4, + arrival: PoissonProcess { millirequests_per_second: 50, burstiness_milli: 1000 }, + max_concurrency: Present { value: 2 }, + ignore_eos: true, +) + +data glm_native_live_image_reference: NonEmptyStr = "gunbc-vllm-glm53-gb10:derived-c99be081f219d123" as NonEmptyStr + +// max_num_seqs is 16 on the live units (parent reverted the out-of-band 64 edit). +data glm_native_live_subject: ServingPerformanceSubject = serving_performance_subject( + checkpoint: Glm53NativeFp8, + checkpoint_revision: none, + runtime: GunbcGlm53NopeDerivedGb10, + runtime_image_reference: glm_native_live_image_reference, + topology: Present { value: FourSparkTp4 }, + rank_population: Present { value: 4 }, + context_ceiling: Present { value: glm_native_concurrent_profile.max_model_len }, + max_num_batched_tokens: glm_native_concurrent_profile.max_num_batched_tokens, + max_num_seqs: Present { value: 16 }, + kv_cache_dtype: Present { value: KvFp8 }, + speculative: Present { value: SpeculativeDecodingOff }, + collective_transport: none, +) + +fn glm_native_live_subject_standing() -> ServingPerformanceSubjectStanding { + serving_subject_standing( + subject: glm_native_live_subject, + believed: "checkpoint revision and collective transport were unread; the live image digest is the one named on the arm" as NonEmptyStr, + would_settle: "read the running launch's checkpoint pin and NCCL transport announcement" as NonEmptyStr, + ) +} + +fn holistic_protocol_is_session_shaped(req: VllmBenchServeRequest) -> Bool { + vllm_bench_serve_uses_poisson_idle_gaps(req: req) + && token_count_at_least(t: req.dataset.prefix_len, n: 100000) + && token_count_at_least(t: req.dataset.input_len, n: 10000) +} + +fn token_count_at_least(t: TokenCount, n: Nat) -> Bool { + token_count_value(t: t) >= n +} diff --git a/dag/gunbc/spark/serving_load_probe_cli.dag b/dag/gunbc/spark/serving_load_probe_cli.dag new file mode 100644 index 00000000000..72067acca0d --- /dev/null +++ b/dag/gunbc/spark/serving_load_probe_cli.dag @@ -0,0 +1,153 @@ +module gunbc.spark.serving_load_probe_cli + +import std.types { Bool, List, NonEmptyStr, String } +import std.nat { Nat } +import std.process { ProcessExit, ExitSuccess, exit_failure } +import std.resources { Network } +import extdeps.filesystem.filesystem_io { Filesystem } +import extdeps.docker.cli { docker_exec_command } +import extdeps.exec.command { argv_words } +import extdeps.vllm.bench_serve { vllm_bench_serve_arguments } +import gunbc.clock_read { clock_now_probed_at, probed_at_word } +import gunbc.fleet_intent_network { operator_host_srv9 } +import gunbc.spark.model_snapshot_materialize { + SparkMaterializeContext, spark_remote_run, RemoteRan, RemoteUnreachable, +} +import gunbc.spark.serving_arm_launch { glm_native_container_name } +import gunbc.spark.glm_group_b_relaunch_cli { with_group_b_access, rank_context } +import gunbc.spark.serving_arm { glm_native_concurrent_profile } +import gunbc.harness.harness_backend { harness_launch_from_body, harness_queue_from_body } +import gunbc.spark.fabric_switch_observed { FabricGroupB } +import gunbc.spark.serving_load_probe { + glm_native_holistic_protocol, glm_native_live_subject_standing, + serving_load_observation, serving_load_observation_text, + drain_from_queue, window_from_drain, counter_continuity, + DrainObservedIdle, DrainNotIdle, DrainUnread, ArrivalSkewUnread, + OperationLedger, LedgerClosed, LedgerIncomplete, + OccupancyUnsampled, + ClientOutputTokensUnread, +} + +// ── THE INHABITANCE ROUTE ───────────────────────────────────────────────────────────────────── +// +// Witnesses supply metric bodies. This function is the one that drives `vllm bench serve` against +// the live native GLM head and folds engine-counter receipts. It is operator-invoked, not a CI +// job: the arm is shared, and colliding with another experiment is the isolation failure the +// design names. +// +// gunbc run --source-root dag --source-root src/v2 \ +// --entry dag/gunbc/spark/serving_load_probe_cli.dag --function glm_native_serving_load_wet + +data glm_native_serving_load_receipt_path: String = "target/glm-native-serving-load-observation.txt" +data glm_native_serving_load_attempt_raw: String = "glm-native-serving-load" + +fn metrics_url() -> String { + join(["http://127.0.0.1:", to_string(glm_native_concurrent_profile.serve_port), "/metrics"], "") +} + +fn curl_metrics_argv() -> List { + ["curl", "-fsS", "--max-time", "15", metrics_url()] +} + +fn bench_exec_argv() -> List { + argv_words(command: docker_exec_command( + name: glm_native_container_name, + env: [], + argv: concat(["vllm"], vllm_bench_serve_arguments(req: glm_native_holistic_protocol)), + )) +} + +fn remote_or_fail(ctx: SparkMaterializeContext, argv: List, step: String) -> String { + match spark_remote_run(ctx: ctx, argv: argv) { + RemoteUnreachable { cause: c } => join(["UNREACHABLE ", step, " ", c], "") + RemoteRan { exit_code: code, stdout: out, stderr: err } => + if code != 0 { + join(["FAILED ", step, " exit=", to_string(code), " stderr=", err], "") + } else { + out + } + } +} + +fn body_is_failure(body: String) -> Bool { + starts_with(s: body, prefix: "UNREACHABLE ") || starts_with(s: body, prefix: "FAILED ") +} + +fn ledger_from_bench(exit_ok: Bool, offered: Nat) -> OperationLedger { + if exit_ok { + LedgerClosed { offered: offered, completed: offered, failed: 0, failed_after_tokens: 0 } + } else { + LedgerIncomplete { because: "vllm bench serve did not exit 0, so whether any request emitted tokens and then failed is unknown; the rate is not denominated in tokens" as NonEmptyStr } + } +} + +fn glm_native_serving_load_wet() -> ProcessExit + uses net: Network +{ + with_group_b_access(use: fn(trust, path, administrator, file) { + let ctx = rank_context(host: operator_host_srv9, trust: trust, path: path, administrator: administrator, credential_file: file) + let before = remote_or_fail(ctx: ctx, argv: curl_metrics_argv(), step: "metrics-before") + if body_is_failure(body: before) { + exit_failure(reason: before) + } else { + let drain = drain_from_queue(q: harness_queue_from_body(body: before)) + let window = window_from_drain( + drain: drain, + traffic_receipt: "operator-coordinated window; drain snapshot only; no route withdrawal exclusion receipt" as NonEmptyStr, + ) + match drain { + DrainNotIdle { running: n } => + exit_failure(reason: join(["refusing to drive load: num_requests_running=", to_string(n), " so this window is not drained"], "")) + DrainUnread { cause: c } => + exit_failure(reason: join(["refusing to drive load: drain unread: ", c as String], "")) + DrainObservedIdle => { + let bench = spark_remote_run(ctx: ctx, argv: bench_exec_argv()) + let after = remote_or_fail(ctx: ctx, argv: curl_metrics_argv(), step: "metrics-after") + if body_is_failure(body: after) { + exit_failure(reason: after) + } else { + let bench_ok = match bench { + RemoteUnreachable { cause: _ } => false + RemoteRan { exit_code: code, stdout: _, stderr: _ } => code == 0 + } + let bench_text = match bench { + RemoteUnreachable { cause: c } => join(["bench unreachable: ", c], "") + RemoteRan { exit_code: code, stdout: out, stderr: err } => + join(["bench exit=", to_string(code), "\n", out, "\n", err], "") + } + let before_launch = harness_launch_from_body(group: FabricGroupB, address: "192.168.1.236", body: before) + let after_launch = harness_launch_from_body(group: FabricGroupB, address: "192.168.1.236", body: after) + let occ = OccupancyUnsampled { cause: "the wet fold scrapes metrics only before and after the blocking bench process; mid-run occupancy is not sampled" as NonEmptyStr } + let obs = serving_load_observation( + subject: glm_native_live_subject_standing(), + protocol: glm_native_holistic_protocol, + window: window, + continuity: counter_continuity(before: before_launch, after: after_launch), + arrival: ArrivalSkewUnread { cause: "vllm bench serve stdout is not yet parsed for per-request start skew" as NonEmptyStr }, + occupancy: occ, + client_output: ClientOutputTokensUnread { cause: "vllm bench serve stdout is not yet parsed for completed output tokens" as NonEmptyStr }, + before_at: 0, + after_at: 1, + before_body: before, + after_body: after, + ledger: ledger_from_bench(exit_ok: bench_ok, offered: 4), + ) + let body = join([ + "glm native serving-load wet at ", probed_at_word(reading: clock_now_probed_at()) as String, "\n", + serving_load_observation_text(o: obs), + "\n--- bench ---\n", bench_text, "\n", + ], "") + let w = Filesystem.Write(path: glm_native_serving_load_receipt_path, content: body) + if !w.success { + exit_failure(reason: join(["receipt write failed: ", w.error], "")) + } else if !bench_ok { + exit_failure(reason: body) + } else { + ExitSuccess + } + } + } + } + } + }, attempt_raw: glm_native_serving_load_attempt_raw, credential_file_name: "gunbc-glm-native-serving-load-admin-password" as NonEmptyStr) +} diff --git a/dag/test/claim/spark/serving_load_probe_witness_test.dag b/dag/test/claim/spark/serving_load_probe_witness_test.dag new file mode 100644 index 00000000000..637e486066a --- /dev/null +++ b/dag/test/claim/spark/serving_load_probe_witness_test.dag @@ -0,0 +1,246 @@ +module test.claim.spark.serving_load_probe_witness + +import std.types { Bool, String, NonEmptyStr, EpochSecs, List } +import std.nat { Nat } +import v2.std.algebra { length, filter } +import v2.std.optional { Present, Absent } +import std.measure { token_count } +import product.capacity.lease { LeaseGrant, lease_fence_of, lease_grant, LeasePolicy, FencedResource } +import product.capacity.event_chain { EventId } +import product.fabric.demand { ObservationReceiptRef } +import gunbc.spark.fabric_switch_observed { FabricGroupB } +import gunbc.spark.vllm_endpoint_process_launch { + vllm_endpoint_process_launch, VllmEndpointProcessLaunchObservation, LaunchObserved, LaunchUnobserved, +} +import gunbc.harness.harness_backend { harness_queue_from_body } +import extdeps.vllm.bench_serve { + VllmBenchServeRequest, RandomDatasetSpec, OpenaiChat, SendAllImmediately, PoissonProcess, + vllm_bench_serve_request, vllm_bench_serve_arguments, vllm_bench_serve_uses_poisson_idle_gaps, +} +import gunbc.spark.serving_load_probe { + DrainObservedIdle, + ExclusionNotEstablished, + WindowIsolated, WindowSharedWithDeclaredTraffic, WindowIsolationUnread, + window_from_drain, isolated_window, drain_from_queue, + OperationLedger, LedgerClosed, ledger_admits_token_denomination, + RateFromGenerationTokens, RateUndenominable, RateUnreadable, + ArrivalSkewObserved, ArrivalSkewUnread, arrival_admits_rate_comparison, + TokenDeltaRead, TokenDeltaReset, TokenDeltaUnread, generation_token_delta, + derive_rate_honest, serving_load_observation, ServingLoadObservation, tokens_per_observation_second, + saturation_from_one_run, observation_rate_is_stored_separately, + glm_native_holistic_protocol, holistic_protocol_is_session_shaped, + glm_native_live_subject_standing, counter_continuity, SameExporter, ExporterChanged, ContinuityUnread, + OccupancySampled, OccupancyUnsampled, OccupancySample, + ClientOutputTokensUnread, ClientOutputTokensObserved, +} + +data start_field: NonEmptyStr = "1789300000.12" as NonEmptyStr + +fn fx_launch() -> VllmEndpointProcessLaunchObservation { + LaunchObserved { + launch: vllm_endpoint_process_launch(group: FabricGroupB, endpoint: "192.168.1.236:30000" as NonEmptyStr, process_start_field: start_field), + receipt: "fx" as ObservationReceiptRef, + } +} + +fn metrics_body(running: String, waiting: String, capacity: String, preempt: String, itl_sum: String, itl_count: String, itok_sum: String, itok_count: String, gen: String, start: String) -> String { + join([ + "vllm:num_requests_waiting{model_name=\"glm\"} ", waiting, "\n", + "vllm:num_requests_running{model_name=\"glm\"} ", running, "\n", + "vllm:num_requests_waiting_by_reason{model_name=\"glm\",reason=\"capacity\"} ", capacity, "\n", + "vllm:num_preemptions_total{model_name=\"glm\"} ", preempt, "\n", + "vllm:generation_tokens_total{model_name=\"glm\"} ", gen, "\n", + "vllm:inter_token_latency_seconds_sum{model_name=\"glm\"} ", itl_sum, "\n", + "vllm:inter_token_latency_seconds_count{model_name=\"glm\"} ", itl_count, "\n", + "vllm:iteration_tokens_total_sum{model_name=\"glm\"} ", itok_sum, "\n", + "vllm:iteration_tokens_total_count{model_name=\"glm\"} ", itok_count, "\n", + "process_start_time_seconds ", start, "\n", + ], "") +} + +data fx_idle: String = metrics_body(running: "0.0", waiting: "0.0", capacity: "0.0", preempt: "0.0", itl_sum: "10.0", itl_count: "100.0", itok_sum: "1000.0", itok_count: "10.0", gen: "1000.0", start: "1789300000.12") +data fx_after: String = metrics_body(running: "0.0", waiting: "0.0", capacity: "0.0", preempt: "0.0", itl_sum: "12.0", itl_count: "200.0", itok_sum: "99999.0", itok_count: "20.0", gen: "1128.0", start: "1789300000.12") +data fx_reset: String = metrics_body(running: "0.0", waiting: "0.0", capacity: "0.0", preempt: "0.0", itl_sum: "1.0", itl_count: "10.0", itok_sum: "10.0", itok_count: "1.0", gen: "10.0", start: "1789300000.12") +data fx_busy: String = metrics_body(running: "3.0", waiting: "2.0", capacity: "2.0", preempt: "1.0", itl_sum: "10.0", itl_count: "100.0", itok_sum: "1000.0", itok_count: "10.0", gen: "1000.0", start: "1789300000.12") + +fn tight_arrival() -> ArrivalSkewObserved { + ArrivalSkewObserved { max_stagger_millis: 0 } +} + +fn closed_ok() -> OperationLedger { + LedgerClosed { offered: 4, completed: 4, failed: 0, failed_after_tokens: 0 } +} + +fn closed_failed_after_tokens() -> OperationLedger { + LedgerClosed { offered: 4, completed: 3, failed: 0, failed_after_tokens: 1 } +} + +test fn a_quiet_drain_is_not_an_isolated_window() -> Bool { + let d = drain_from_queue(q: harness_queue_from_body(body: fx_idle)) + let w = window_from_drain(drain: d, traffic_receipt: "coordinated with parent; no exclusion receipt" as NonEmptyStr) + match w { + WindowIsolated { grant: _, deadline: _, drain: _, exclusion: _ } => false + WindowSharedWithDeclaredTraffic { traffic_receipt: _, drain: DrainObservedIdle } => true + WindowSharedWithDeclaredTraffic { traffic_receipt: _, drain: _ } => false + WindowIsolationUnread { cause: _, drain: _ } => false + } +} + +test fn isolated_window_refuses_without_exclusion() -> Bool { + let grant = lease_grant( + reference: "probe" as NonEmptyStr, + fence: lease_fence_of(admitting_event: "e" as EventId, generation: 1), + granted_at: 1, + policy: LeasePolicy { maximum_duration_seconds: 60, release_law: FencedResource }, + ) + match isolated_window(grant: grant, deadline: 61, drain: DrainObservedIdle, exclusion: ExclusionNotEstablished { cause: "route was not withdrawn" as NonEmptyStr }) { + WindowIsolationUnread { cause: _, drain: DrainObservedIdle } => true + WindowIsolationUnread { cause: _, drain: _ } => false + WindowIsolated { grant: _, deadline: _, drain: _, exclusion: _ } => false + WindowSharedWithDeclaredTraffic { traffic_receipt: _, drain: _ } => false + } +} + +test fn a_request_that_emitted_then_failed_cannot_be_denominated_in_tokens() -> Bool { + !ledger_admits_token_denomination(l: closed_failed_after_tokens()) + && ledger_admits_token_denomination(l: closed_ok()) +} + +test fn engine_rate_comes_from_generation_tokens_not_iteration_or_itl() -> Bool { + match generation_token_delta(before_body: fx_idle, after_body: fx_after) { + TokenDeltaRead { tokens: t } => + t == 128 && + match derive_rate_honest( + ledger: closed_ok(), + continuity: counter_continuity(before: fx_launch(), after: fx_launch()), + generation: TokenDeltaRead { tokens: t }, + scrape_millis: Present { value: 2000 }, + arrival: tight_arrival(), + occupancy: OccupancySampled { samples: [] }, + max_concurrency: Present { value: 2 }, + client_output: ClientOutputTokensUnread { cause: "fixture has no client token total" as NonEmptyStr }, + ) { + RateFromGenerationTokens { tokens: tok, scrape_millis: ms } => + tok == 128 && ms == 2000 && + match tokens_per_observation_second(r: RateFromGenerationTokens { tokens: tok, scrape_millis: ms }) { + Absent => false + Present { value: rate } => rate == 64 + } + RateUndenominable { because: _ } => false + RateUnreadable { because: _ } => false + } + TokenDeltaUnread { cause: _ } => false + TokenDeltaReset { cause: _ } => false + } +} + +test fn unread_arrival_skew_refuses_a_rate_comparison() -> Bool { + !arrival_admits_rate_comparison(s: ArrivalSkewUnread { cause: "bench stdout not parsed" as NonEmptyStr }) +} + +test fn a_generation_counter_reset_is_not_a_rate() -> Bool { + match generation_token_delta(before_body: fx_idle, after_body: fx_reset) { + TokenDeltaReset { cause: _ } => true + TokenDeltaRead { tokens: _ } => false + TokenDeltaUnread { cause: _ } => false + } +} + +fn fx_obs(ledger: OperationLedger) -> ServingLoadObservation { + serving_load_observation( + subject: glm_native_live_subject_standing(), + protocol: glm_native_holistic_protocol, + window: window_from_drain(drain: DrainObservedIdle, traffic_receipt: "fx" as NonEmptyStr), + continuity: counter_continuity(before: fx_launch(), after: fx_launch()), + arrival: tight_arrival(), + occupancy: OccupancySampled { samples: [] }, + client_output: ClientOutputTokensUnread { cause: "fixture has no client token total" as NonEmptyStr }, + before_at: 100, + after_at: 102, + before_body: fx_idle, + after_body: fx_after, + ledger: ledger, + ) +} + +test fn failed_after_tokens_makes_the_observation_rate_undenominable() -> Bool { + match fx_obs(ledger: closed_failed_after_tokens()).rate { + RateUndenominable { because: _ } => true + RateFromGenerationTokens { tokens: _, scrape_millis: _ } => false + RateUnreadable { because: _ } => false + } +} + +test fn generation_tokens_without_client_completions_is_foreign_load() -> Bool { + match derive_rate_honest( + ledger: LedgerClosed { offered: 4, completed: 0, failed: 4, failed_after_tokens: 0 }, + continuity: counter_continuity(before: fx_launch(), after: fx_launch()), + generation: TokenDeltaRead { tokens: 128 }, + scrape_millis: Present { value: 2000 }, + arrival: tight_arrival(), + occupancy: OccupancySampled { samples: [] }, + max_concurrency: Present { value: 2 }, + client_output: ClientOutputTokensUnread { cause: "none" as NonEmptyStr }, + ) { + RateUnreadable { because: _ } => true + RateFromGenerationTokens { tokens: _, scrape_millis: _ } => false + RateUndenominable { because: _ } => false + } +} + +test fn occupancy_above_declared_concurrency_refuses_the_rate() -> Bool { + match derive_rate_honest( + ledger: closed_ok(), + continuity: counter_continuity(before: fx_launch(), after: fx_launch()), + generation: TokenDeltaRead { tokens: 128 }, + scrape_millis: Present { value: 2000 }, + arrival: tight_arrival(), + occupancy: OccupancySampled { samples: [OccupancySample { running: 5, waiting: 0, capacity_waiting: 0, preemptions: 0 }] }, + max_concurrency: Present { value: 2 }, + client_output: ClientOutputTokensUnread { cause: "none" as NonEmptyStr }, + ) { + RateUnreadable { because: _ } => true + RateFromGenerationTokens { tokens: _, scrape_millis: _ } => false + RateUndenominable { because: _ } => false + } +} + +test fn the_holistic_protocol_is_poisson_with_session_context_and_prefix() -> Bool { + holistic_protocol_is_session_shaped(req: glm_native_holistic_protocol) + && vllm_bench_serve_uses_poisson_idle_gaps(req: glm_native_holistic_protocol) + && !vllm_bench_serve_uses_poisson_idle_gaps(req: vllm_bench_serve_request( + backend: OpenaiChat, + base_url: "http://127.0.0.1:30000" as NonEmptyStr, + model: "m" as NonEmptyStr, + dataset: RandomDatasetSpec { input_len: token_count(count: 128), output_len: token_count(count: 128), prefix_len: token_count(count: 0) }, + num_prompts: 4, + arrival: SendAllImmediately, + max_concurrency: none, + ignore_eos: true, + )) +} + +fn words_contain(words: List, needle: String) -> Bool { + count(filter(words, w => w == needle)) > 0 +} + +test fn the_rendered_argv_carries_the_prefix_and_a_finite_rate() -> Bool { + let words = vllm_bench_serve_arguments(req: glm_native_holistic_protocol) + words_contain(words: words, needle: "--random-prefix-len") + && words_contain(words: words, needle: "100000") + && words_contain(words: words, needle: "--request-rate") + && words_contain(words: words, needle: "0.050") + && !words_contain(words: words, needle: "inf") +} + +test fn exporter_restart_breaks_counter_continuity() -> Bool { + let after: VllmEndpointProcessLaunchObservation = LaunchObserved { + launch: vllm_endpoint_process_launch(group: FabricGroupB, endpoint: "192.168.1.236:30000" as NonEmptyStr, process_start_field: "1789300999.00" as NonEmptyStr), + receipt: "fx2" as ObservationReceiptRef, + } + match counter_continuity(before: fx_launch(), after: after) { + ExporterChanged { before: _, after: _ } => true + SameExporter { start_field: _ } => false + ContinuityUnread { cause: _ } => false + } +} From 7c29847104c20fcc9e01314c58934631d737fe4f Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Fri, 18 Sep 2026 03:11:05 +0000 Subject: [PATCH 02/43] Import Int for the Poisson millirate wire. fixed_point_wire takes Int; the arrival fold already casts Nat to Int. Co-authored-by: Cursor --- dag/extdeps/vllm/bench_serve.dag | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dag/extdeps/vllm/bench_serve.dag b/dag/extdeps/vllm/bench_serve.dag index dabf0e9852e..7ddc70ead6d 100644 --- a/dag/extdeps/vllm/bench_serve.dag +++ b/dag/extdeps/vllm/bench_serve.dag @@ -1,6 +1,6 @@ module extdeps.vllm.bench_serve -import std.types { Bool, List, NonEmptyStr, String } +import std.types { Bool, List, NonEmptyStr, String, Int } import std.nat { Nat } import v2.std.optional { Present, Absent } import std.measure { TokenCount, token_count, token_count_value } From 74a45426b817c496e25ee216e0aa319c3a3107c3 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Fri, 18 Sep 2026 03:18:23 +0000 Subject: [PATCH 03/43] Carry workload admission as unread instead of dividing the printed KV pool. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The 2,014,033 token figure is floor(max_concurrency × max_model_len), not a pool that may be divided by a shorter request; GLM hybrid KV does not scale linearly anyway. Long-context protocol stays; it is not a capacity limit. Co-authored-by: Cursor --- dag/gunbc/spark/serving_load_probe.dag | 26 ++++++++++++++++--- .../spark/serving_load_probe_witness_test.dag | 13 ++++++++++ 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/dag/gunbc/spark/serving_load_probe.dag b/dag/gunbc/spark/serving_load_probe.dag index 1d6595ee4ee..c3ee34e100a 100644 --- a/dag/gunbc/spark/serving_load_probe.dag +++ b/dag/gunbc/spark/serving_load_probe.dag @@ -38,7 +38,7 @@ import gunbc.spark.serving_performance_subject { ServingPerformanceSubject, serving_performance_subject, serving_subject_standing, ServingPerformanceSubjectStanding, SubjectEstablished, SubjectPartial, } -import extdeps.vllm.engine_args { KvFp8, SpeculativeDecodingOff } +import extdeps.vllm.kv_layout { AdmissionCost, AdmissionCostUnestablished, AdmissionCostBlocks } // ── THROUGHPUT QUALIFICATION FOR THE SERVING SUBJECT (design #11540, serving side) ──────────── // @@ -463,6 +463,7 @@ type ServingLoadObservation { itl_latency: HistogramDelta iteration_tokens_booked: HistogramDelta ledger: OperationLedger + admission: AdmissionCost rate: DerivedRate raw_before: NonEmptyStr raw_after: NonEmptyStr @@ -500,6 +501,7 @@ fn serving_load_observation( itl_latency: histogram_delta(before_body: before_body, after_body: after_body, metric: InterTokenLatencySeconds), iteration_tokens_booked: histogram_delta(before_body: before_body, after_body: after_body, metric: IterationTokensTotal), ledger: ledger, + admission: glm_native_workload_admission, rate: derive_rate_honest( ledger: ledger, continuity: continuity, @@ -532,6 +534,7 @@ fn serving_load_observation_text(o: ServingLoadObservation) -> String { "itl latency (not a rate): ", histogram_text(d: o.itl_latency), "\n", "iteration_tokens booked (not occupancy): ", histogram_text(d: o.iteration_tokens_booked), "\n", "ledger: ", ledger_text(l: o.ledger), "\n", + "admission: ", admission_text(a: o.admission), "\n", "rate: ", rate_text(r: o.rate), "\n", "saturation decided from this run: ", if saturation_from_one_run(obs: o) { "yes" } else { "no" }, "\n", ], "") @@ -553,6 +556,13 @@ fn agreement_text(a: LedgerCounterAgreement) -> String { } } +fn admission_text(a: AdmissionCost) -> String { + match a { + AdmissionCostUnestablished { cause: c } => join(["unread ", c as String], "") + AdmissionCostBlocks { blocks: _ } => "blocks (must not be minted from a pool/length quotient)" + } +} + fn window_text(s: ProbeWindowStanding) -> String { match s { WindowIsolated { grant: _, deadline: _, drain: _, exclusion: _ } => "isolated" @@ -635,8 +645,18 @@ fn rate_text(r: DerivedRate) -> String { // // Real sessions sit at ~100k-130k tokens of context after compacting a 262k window. They idle // between turns. Each turn is a separate request whose KV frees on completion while the prefix -// stays in the prefix cache. Peak concurrent DECODING turns times average context is the KV -// quantity, not total sessions. +// stays in the prefix cache. A long-context point is how that envelope is exercised. +// +// THAT IS NOT AN ADMISSION CAPACITY. vLLM's printed token pool is floor(max_concurrency × +// max_model_len) — the same fact twice — and GLM's hybrid KV (full / sliding-window / Mamba) does +// not scale linearly with sequence length. Dividing the pool by 100k–130k overestimates concurrent +// sessions. Live per-request cost is extdeps.vllm.kv_layout cold_admission_blocks; with an empty +// group roster that fold is AdmissionCostUnestablished, which is the honest state today. + +data glm_native_workload_admission: AdmissionCost = AdmissionCostUnestablished { + cause: "the live cache-group roster is unobserved, so cold_admission_blocks cannot establish per-request cost; a token-pool divided by request length is not an admission capacity" as NonEmptyStr +} + data glm_native_holistic_dataset: RandomDatasetSpec = RandomDatasetSpec { input_len: token_count(count: 20000), output_len: token_count(count: 128), diff --git a/dag/test/claim/spark/serving_load_probe_witness_test.dag b/dag/test/claim/spark/serving_load_probe_witness_test.dag index 637e486066a..e016511deec 100644 --- a/dag/test/claim/spark/serving_load_probe_witness_test.dag +++ b/dag/test/claim/spark/serving_load_probe_witness_test.dag @@ -17,6 +17,7 @@ import extdeps.vllm.bench_serve { VllmBenchServeRequest, RandomDatasetSpec, OpenaiChat, SendAllImmediately, PoissonProcess, vllm_bench_serve_request, vllm_bench_serve_arguments, vllm_bench_serve_uses_poisson_idle_gaps, } +import extdeps.vllm.kv_layout { AdmissionCostUnestablished, AdmissionCostBlocks } import gunbc.spark.serving_load_probe { DrainObservedIdle, ExclusionNotEstablished, @@ -32,6 +33,7 @@ import gunbc.spark.serving_load_probe { glm_native_live_subject_standing, counter_continuity, SameExporter, ExporterChanged, ContinuityUnread, OccupancySampled, OccupancyUnsampled, OccupancySample, ClientOutputTokensUnread, ClientOutputTokensObserved, + glm_native_workload_admission, } data start_field: NonEmptyStr = "1789300000.12" as NonEmptyStr @@ -205,6 +207,17 @@ test fn occupancy_above_declared_concurrency_refuses_the_rate() -> Bool { } } +test fn a_long_context_protocol_does_not_mint_an_admission_ceiling() -> Bool { + match glm_native_workload_admission { + AdmissionCostUnestablished { cause: _ } => + match fx_obs(ledger: closed_ok()).admission { + AdmissionCostUnestablished { cause: _ } => true + AdmissionCostBlocks { blocks: _ } => false + } + AdmissionCostBlocks { blocks: _ } => false + } +} + test fn the_holistic_protocol_is_poisson_with_session_context_and_prefix() -> Bool { holistic_protocol_is_session_shaped(req: glm_native_holistic_protocol) && vllm_bench_serve_uses_poisson_idle_gaps(req: glm_native_holistic_protocol) From 41625b9c1bb92a55be2c55ad9dde88eff791c3c1 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Fri, 18 Sep 2026 03:20:37 +0000 Subject: [PATCH 04/43] Refuse a rate when client tokens are unread or disagree, and when occupancy is not sampled mid-window. harness_probe_cli can POST a turn after a quiet drain; WindowSharedWithDeclaredTraffic is the standing without an exclusion receipt, and extra generation_tokens_total versus the client ledger is a refuse, not a throughput. Co-authored-by: Cursor --- dag/gunbc/spark/serving_load_probe.dag | 37 ++++++++---- dag/gunbc/spark/serving_load_probe_cli.dag | 10 +++- .../spark/serving_load_probe_witness_test.dag | 59 +++++++++++++++++-- 3 files changed, 88 insertions(+), 18 deletions(-) diff --git a/dag/gunbc/spark/serving_load_probe.dag b/dag/gunbc/spark/serving_load_probe.dag index c3ee34e100a..d9c6183f084 100644 --- a/dag/gunbc/spark/serving_load_probe.dag +++ b/dag/gunbc/spark/serving_load_probe.dag @@ -85,8 +85,9 @@ fn drain_from_queue(q: ServingQueueReading) -> DrainReceipt { } } -// A ZERO RUNNING GAUGE IS A DRAIN SNAPSHOT. It is not exclusion: production work can arrive after -// the read. Without an exclusion receipt the standing cannot be WindowIsolated. +// A ZERO RUNNING GAUGE IS A DRAIN SNAPSHOT. It is not exclusion: gunbc.harness.harness_cli +// harness_probe_cli can bind a seat and POST a turn after the read, on purpose beside other load. +// Without an exclusion receipt the standing cannot be WindowIsolated. fn window_from_drain(drain: DrainReceipt, traffic_receipt: NonEmptyStr) -> ProbeWindowStanding { match drain { DrainUnread { cause: c } => WindowIsolationUnread { cause: c, drain: drain } @@ -344,14 +345,20 @@ fn occupancy_from_body(body: String) -> OccupancySample? { } } +// Unsampled occupancy cannot exclude a harness_probe_cli arrival mid-window, so it does not +// admit a comparable rate. running above declared max-concurrency is the same refuse. fn occupancy_admits_declared_load(trace: OccupancyTrace, max_concurrency: Nat?) -> Bool { match trace { - OccupancyUnsampled { cause: _ } => true + OccupancyUnsampled { cause: _ } => false OccupancySampled { samples: ss } => - match max_concurrency { - Absent => true - Present { value: cap } => - length(filter(ss, s => s.running > cap)) == 0 + if length(ss) == 0 { + false + } else { + match max_concurrency { + Absent => true + Present { value: cap } => + length(filter(ss, s => s.running > cap)) == 0 + } } } } @@ -365,6 +372,12 @@ type LedgerCounterAgreement | LedgerCounterDisagree { because: NonEmptyStr } | AgreementUnread { because: NonEmptyStr } +data generation_client_token_agreement_bound: Nat = 0 + +fn nat_abs_diff(a: Nat, b: Nat) -> Nat { + if a >= b { a - b } else { b - a } +} + fn ledger_counter_agreement(ledger: OperationLedger, generation: TokenDelta, client_output: ClientOutputTokens) -> LedgerCounterAgreement { match generation { TokenDeltaUnread { cause: c } => AgreementUnread { because: c } @@ -377,13 +390,13 @@ fn ledger_counter_agreement(ledger: OperationLedger, generation: TokenDelta, cli LedgerCounterDisagree { because: "generation_tokens_total advanced while the client ledger completed zero requests; foreign load is the remaining explanation" as NonEmptyStr } } else { match client_output { - ClientOutputTokensUnread { cause: _ } => - LedgerAndCounterAgree { generation_tokens: g, completed_requests: n } + ClientOutputTokensUnread { cause: c } => + AgreementUnread { because: c } ClientOutputTokensObserved { tokens: c } => - if c == g { + if nat_abs_diff(a: c, b: g) <= generation_client_token_agreement_bound { LedgerAndCounterAgree { generation_tokens: g, completed_requests: n } } else { - LedgerCounterDisagree { because: "client completed-token count and generation_tokens_total delta disagree; the rate is not reported" as NonEmptyStr } + LedgerCounterDisagree { because: "client completed-token count and generation_tokens_total delta disagree beyond the declared bound; foreign load (including harness_probe_cli) is the remaining explanation and the rate is not reported" as NonEmptyStr } } } } @@ -674,7 +687,7 @@ data glm_native_holistic_protocol: VllmBenchServeRequest = vllm_bench_serve_requ ignore_eos: true, ) -data glm_native_live_image_reference: NonEmptyStr = "gunbc-vllm-glm53-gb10:derived-c99be081f219d123" as NonEmptyStr +data glm_native_declared_shared_traffic: NonEmptyStr = "gunbc.harness.harness_cli harness_probe_cli may POST a real turn mid-window; drain snapshot is not exclusion" as NonEmptyStr // max_num_seqs is 16 on the live units (parent reverted the out-of-band 64 edit). data glm_native_live_subject: ServingPerformanceSubject = serving_performance_subject( diff --git a/dag/gunbc/spark/serving_load_probe_cli.dag b/dag/gunbc/spark/serving_load_probe_cli.dag index 72067acca0d..19866f11823 100644 --- a/dag/gunbc/spark/serving_load_probe_cli.dag +++ b/dag/gunbc/spark/serving_load_probe_cli.dag @@ -20,12 +20,14 @@ import gunbc.harness.harness_backend { harness_launch_from_body, harness_queue_f import gunbc.spark.fabric_switch_observed { FabricGroupB } import gunbc.spark.serving_load_probe { glm_native_holistic_protocol, glm_native_live_subject_standing, + glm_native_declared_shared_traffic, serving_load_observation, serving_load_observation_text, drain_from_queue, window_from_drain, counter_continuity, DrainObservedIdle, DrainNotIdle, DrainUnread, ArrivalSkewUnread, OperationLedger, LedgerClosed, LedgerIncomplete, OccupancyUnsampled, ClientOutputTokensUnread, + RateFromGenerationTokens, RateUndenominable, RateUnreadable, } // ── THE INHABITANCE ROUTE ───────────────────────────────────────────────────────────────────── @@ -93,7 +95,7 @@ fn glm_native_serving_load_wet() -> ProcessExit let drain = drain_from_queue(q: harness_queue_from_body(body: before)) let window = window_from_drain( drain: drain, - traffic_receipt: "operator-coordinated window; drain snapshot only; no route withdrawal exclusion receipt" as NonEmptyStr, + traffic_receipt: glm_native_declared_shared_traffic, ) match drain { DrainNotIdle { running: n } => @@ -143,7 +145,11 @@ fn glm_native_serving_load_wet() -> ProcessExit } else if !bench_ok { exit_failure(reason: body) } else { - ExitSuccess + match obs.rate { + RateFromGenerationTokens { tokens: _, scrape_millis: _ } => ExitSuccess + RateUndenominable { because: _ } => exit_failure(reason: body) + RateUnreadable { because: _ } => exit_failure(reason: body) + } } } } diff --git a/dag/test/claim/spark/serving_load_probe_witness_test.dag b/dag/test/claim/spark/serving_load_probe_witness_test.dag index e016511deec..48a3fe6d770 100644 --- a/dag/test/claim/spark/serving_load_probe_witness_test.dag +++ b/dag/test/claim/spark/serving_load_probe_witness_test.dag @@ -118,9 +118,9 @@ test fn engine_rate_comes_from_generation_tokens_not_iteration_or_itl() -> Bool generation: TokenDeltaRead { tokens: t }, scrape_millis: Present { value: 2000 }, arrival: tight_arrival(), - occupancy: OccupancySampled { samples: [] }, + occupancy: OccupancySampled { samples: [OccupancySample { running: 2, waiting: 0, capacity_waiting: 0, preemptions: 0 }] }, max_concurrency: Present { value: 2 }, - client_output: ClientOutputTokensUnread { cause: "fixture has no client token total" as NonEmptyStr }, + client_output: ClientOutputTokensObserved { tokens: t }, ) { RateFromGenerationTokens { tokens: tok, scrape_millis: ms } => tok == 128 && ms == 2000 && @@ -155,7 +155,7 @@ fn fx_obs(ledger: OperationLedger) -> ServingLoadObservation { window: window_from_drain(drain: DrainObservedIdle, traffic_receipt: "fx" as NonEmptyStr), continuity: counter_continuity(before: fx_launch(), after: fx_launch()), arrival: tight_arrival(), - occupancy: OccupancySampled { samples: [] }, + occupancy: OccupancySampled { samples: [OccupancySample { running: 1, waiting: 0, capacity_waiting: 0, preemptions: 0 }] }, client_output: ClientOutputTokensUnread { cause: "fixture has no client token total" as NonEmptyStr }, before_at: 100, after_at: 102, @@ -199,7 +199,58 @@ test fn occupancy_above_declared_concurrency_refuses_the_rate() -> Bool { arrival: tight_arrival(), occupancy: OccupancySampled { samples: [OccupancySample { running: 5, waiting: 0, capacity_waiting: 0, preemptions: 0 }] }, max_concurrency: Present { value: 2 }, - client_output: ClientOutputTokensUnread { cause: "none" as NonEmptyStr }, + client_output: ClientOutputTokensObserved { tokens: 128 }, + ) { + RateUnreadable { because: _ } => true + RateFromGenerationTokens { tokens: _, scrape_millis: _ } => false + RateUndenominable { because: _ } => false + } +} + +test fn unread_client_output_tokens_refuse_the_rate() -> Bool { + match derive_rate_honest( + ledger: closed_ok(), + continuity: counter_continuity(before: fx_launch(), after: fx_launch()), + generation: TokenDeltaRead { tokens: 128 }, + scrape_millis: Present { value: 2000 }, + arrival: tight_arrival(), + occupancy: OccupancySampled { samples: [OccupancySample { running: 1, waiting: 0, capacity_waiting: 0, preemptions: 0 }] }, + max_concurrency: Present { value: 2 }, + client_output: ClientOutputTokensUnread { cause: "bench stdout not parsed" as NonEmptyStr }, + ) { + RateUnreadable { because: _ } => true + RateFromGenerationTokens { tokens: _, scrape_millis: _ } => false + RateUndenominable { because: _ } => false + } +} + +test fn extra_engine_tokens_beyond_the_client_ledger_refuse_the_rate() -> Bool { + match derive_rate_honest( + ledger: closed_ok(), + continuity: counter_continuity(before: fx_launch(), after: fx_launch()), + generation: TokenDeltaRead { tokens: 200 }, + scrape_millis: Present { value: 2000 }, + arrival: tight_arrival(), + occupancy: OccupancySampled { samples: [OccupancySample { running: 1, waiting: 0, capacity_waiting: 0, preemptions: 0 }] }, + max_concurrency: Present { value: 2 }, + client_output: ClientOutputTokensObserved { tokens: 128 }, + ) { + RateUnreadable { because: _ } => true + RateFromGenerationTokens { tokens: _, scrape_millis: _ } => false + RateUndenominable { because: _ } => false + } +} + +test fn unsampled_occupancy_refuses_the_rate() -> Bool { + match derive_rate_honest( + ledger: closed_ok(), + continuity: counter_continuity(before: fx_launch(), after: fx_launch()), + generation: TokenDeltaRead { tokens: 128 }, + scrape_millis: Present { value: 2000 }, + arrival: tight_arrival(), + occupancy: OccupancyUnsampled { cause: "blocking bench; no mid-run scrape" as NonEmptyStr }, + max_concurrency: Present { value: 2 }, + client_output: ClientOutputTokensObserved { tokens: 128 }, ) { RateUnreadable { because: _ } => true RateFromGenerationTokens { tokens: _, scrape_millis: _ } => false From 40d2b26e988b825a5c7a1726294d39ee3ed9d797 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Fri, 18 Sep 2026 03:23:04 +0000 Subject: [PATCH 05/43] Declare nccl-tests as shared-window traffic and keep the 49 ms/token figure as a transcribed bound. A holistic max-concurrency-2 protocol cannot corroborate or falsify single-stream decode; overlapping all_reduce_perf is sequenced, not excluded by a drain check. Co-authored-by: Cursor --- dag/gunbc/spark/serving_load_probe.dag | 37 ++++++++++++++++++- .../spark/serving_load_probe_witness_test.dag | 27 ++++++++++++++ 2 files changed, 63 insertions(+), 1 deletion(-) diff --git a/dag/gunbc/spark/serving_load_probe.dag b/dag/gunbc/spark/serving_load_probe.dag index d9c6183f084..f9717cc434c 100644 --- a/dag/gunbc/spark/serving_load_probe.dag +++ b/dag/gunbc/spark/serving_load_probe.dag @@ -39,6 +39,7 @@ import gunbc.spark.serving_performance_subject { ServingPerformanceSubjectStanding, SubjectEstablished, SubjectPartial, } import extdeps.vllm.kv_layout { AdmissionCost, AdmissionCostUnestablished, AdmissionCostBlocks } +import extdeps.external_authority { CitedFigureStanding, TranscribedUncited } // ── THROUGHPUT QUALIFICATION FOR THE SERVING SUBJECT (design #11540, serving side) ──────────── // @@ -462,6 +463,21 @@ fn derive_rate_honest( } } +type DecodeCorroboration + = CorroborationNotApplicable { because: NonEmptyStr } + | CorroborationUnread { because: NonEmptyStr } + +fn decode_corroboration_for_protocol(req: VllmBenchServeRequest) -> DecodeCorroboration { + match req.max_concurrency { + Present { value: 1 } => + CorroborationUnread { because: "a single-stream run can be compared to the transcribed 49 ms/token bound; this observation has not yet produced that figure" as NonEmptyStr } + Present { value: _ } => + CorroborationNotApplicable { because: "the holistic protocol is not a single-stream measurement, so it cannot corroborate or falsify the 49 ms/token bound" as NonEmptyStr } + Absent => + CorroborationNotApplicable { because: "unbounded concurrency is not a single-stream measurement" as NonEmptyStr } + } +} + type ServingLoadObservation { subject: ServingPerformanceSubjectStanding protocol: VllmBenchServeRequest @@ -477,6 +493,7 @@ type ServingLoadObservation { iteration_tokens_booked: HistogramDelta ledger: OperationLedger admission: AdmissionCost + corroboration: DecodeCorroboration rate: DerivedRate raw_before: NonEmptyStr raw_after: NonEmptyStr @@ -515,6 +532,7 @@ fn serving_load_observation( iteration_tokens_booked: histogram_delta(before_body: before_body, after_body: after_body, metric: IterationTokensTotal), ledger: ledger, admission: glm_native_workload_admission, + corroboration: decode_corroboration_for_protocol(req: protocol), rate: derive_rate_honest( ledger: ledger, continuity: continuity, @@ -548,11 +566,19 @@ fn serving_load_observation_text(o: ServingLoadObservation) -> String { "iteration_tokens booked (not occupancy): ", histogram_text(d: o.iteration_tokens_booked), "\n", "ledger: ", ledger_text(l: o.ledger), "\n", "admission: ", admission_text(a: o.admission), "\n", + "corroboration: ", corroboration_text(c: o.corroboration), "\n", "rate: ", rate_text(r: o.rate), "\n", "saturation decided from this run: ", if saturation_from_one_run(obs: o) { "yes" } else { "no" }, "\n", ], "") } +fn corroboration_text(c: DecodeCorroboration) -> String { + match c { + CorroborationNotApplicable { because: b } => join(["not-applicable ", b as String], "") + CorroborationUnread { because: b } => join(["unread ", b as String], "") + } +} + fn occupancy_text(t: OccupancyTrace) -> String { match t { OccupancyUnsampled { cause: c } => join(["unsampled ", c as String], "") @@ -687,7 +713,16 @@ data glm_native_holistic_protocol: VllmBenchServeRequest = vllm_bench_serve_requ ignore_eos: true, ) -data glm_native_declared_shared_traffic: NonEmptyStr = "gunbc.harness.harness_cli harness_probe_cli may POST a real turn mid-window; drain snapshot is not exclusion" as NonEmptyStr +data glm_native_declared_shared_traffic: NonEmptyStr = "gunbc.harness.harness_cli harness_probe_cli may POST a turn, and proud-boar-181 nccl-tests all_reduce_perf may allocate GPU buffers on these ranks; drain snapshot is not exclusion" as NonEmptyStr + +// TRANSCRIBED BOUND, NOT A READING. Parent derived ~10.7 GB active weights / ~9-11 ms memory-bandwidth +// floor from the checkpoint config (45 layers, hidden 4096, 288 routed experts, top-8 + 1 shared, fp8) +// and measured 48.9 ms single-stream. Until those config rows are cited, the 49 ms figure stays +// TranscribedUncited and is not consumed as a rate. +data glm_native_single_stream_decode_bound_millis: Nat = 49 +data glm_native_single_stream_decode_bound_standing: CitedFigureStanding = TranscribedUncited { + read_obligation: "read the served GLM-5.3-Flash checkpoint config for layer count, hidden size, routed experts, top-k and shared expert, and the independent single-stream measurement this 49 ms/token bound was transcribed from; the 9-11 ms memory-bandwidth floor is a derived bound from that config, not a serving reading" as NonEmptyStr +} // max_num_seqs is 16 on the live units (parent reverted the out-of-band 64 edit). data glm_native_live_subject: ServingPerformanceSubject = serving_performance_subject( diff --git a/dag/test/claim/spark/serving_load_probe_witness_test.dag b/dag/test/claim/spark/serving_load_probe_witness_test.dag index 48a3fe6d770..516370f15fd 100644 --- a/dag/test/claim/spark/serving_load_probe_witness_test.dag +++ b/dag/test/claim/spark/serving_load_probe_witness_test.dag @@ -18,6 +18,7 @@ import extdeps.vllm.bench_serve { vllm_bench_serve_request, vllm_bench_serve_arguments, vllm_bench_serve_uses_poisson_idle_gaps, } import extdeps.vllm.kv_layout { AdmissionCostUnestablished, AdmissionCostBlocks } +import extdeps.external_authority { TranscribedUncited, CitedToAuthority } import gunbc.spark.serving_load_probe { DrainObservedIdle, ExclusionNotEstablished, @@ -34,6 +35,10 @@ import gunbc.spark.serving_load_probe { OccupancySampled, OccupancyUnsampled, OccupancySample, ClientOutputTokensUnread, ClientOutputTokensObserved, glm_native_workload_admission, + glm_native_declared_shared_traffic, + glm_native_single_stream_decode_bound_millis, + glm_native_single_stream_decode_bound_standing, + decode_corroboration_for_protocol, CorroborationNotApplicable, CorroborationUnread, } data start_field: NonEmptyStr = "1789300000.12" as NonEmptyStr @@ -88,6 +93,11 @@ test fn a_quiet_drain_is_not_an_isolated_window() -> Bool { } } +test fn declared_shared_traffic_names_the_harness_probe_and_nccl_tests() -> Bool { + string_contains(s: glm_native_declared_shared_traffic as String, pattern: "harness_probe_cli") + && string_contains(s: glm_native_declared_shared_traffic as String, pattern: "nccl-tests") +} + test fn isolated_window_refuses_without_exclusion() -> Bool { let grant = lease_grant( reference: "probe" as NonEmptyStr, @@ -269,6 +279,23 @@ test fn a_long_context_protocol_does_not_mint_an_admission_ceiling() -> Bool { } } +test fn one_run_does_not_decide_saturation() -> Bool { + let obs = fx_obs(ledger: closed_ok()) + !saturation_from_one_run(obs: obs) && !observation_rate_is_stored_separately(obs: obs) +} + +test fn the_holistic_protocol_does_not_corroborate_the_single_stream_bound() -> Bool { + match decode_corroboration_for_protocol(req: glm_native_holistic_protocol) { + CorroborationNotApplicable { because: _ } => + glm_native_single_stream_decode_bound_millis == 49 + && match glm_native_single_stream_decode_bound_standing { + TranscribedUncited { read_obligation: _ } => true + CitedToAuthority { authority: _ } => false + } + CorroborationUnread { because: _ } => false + } +} + test fn the_holistic_protocol_is_poisson_with_session_context_and_prefix() -> Bool { holistic_protocol_is_session_shaped(req: glm_native_holistic_protocol) && vllm_bench_serve_uses_poisson_idle_gaps(req: glm_native_holistic_protocol) From a54eb01bd8ff6cbbaa8def3346b8c2d621b2bce5 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Fri, 18 Sep 2026 03:25:35 +0000 Subject: [PATCH 06/43] Carry served alias and tokenizer as two protocol facts, and name the split driver/observer on this reading. vllm bench serve cannot load glm-5.3-flash from HuggingFace; --tokenizer is the engine snapshot under /weights. This scrape is not the docker-exec principal. Co-authored-by: Cursor --- dag/extdeps/vllm/bench_serve.dag | 7 +++++ dag/gunbc/spark/serving_load_probe.dag | 31 +++++++++++++++++++ .../spark/serving_load_probe_witness_test.dag | 14 +++++++++ 3 files changed, 52 insertions(+) diff --git a/dag/extdeps/vllm/bench_serve.dag b/dag/extdeps/vllm/bench_serve.dag index 7ddc70ead6d..a3b81d44e81 100644 --- a/dag/extdeps/vllm/bench_serve.dag +++ b/dag/extdeps/vllm/bench_serve.dag @@ -74,6 +74,7 @@ type VllmBenchServeRequest { backend: VllmBenchBackend base_url: NonEmptyStr model: NonEmptyStr + tokenizer: NonEmptyStr dataset: RandomDatasetSpec num_prompts: Nat arrival: BenchArrival @@ -85,6 +86,7 @@ fn vllm_bench_serve_request( backend: VllmBenchBackend, base_url: NonEmptyStr, model: NonEmptyStr, + tokenizer: NonEmptyStr, dataset: RandomDatasetSpec, num_prompts: Nat, arrival: BenchArrival, @@ -95,6 +97,7 @@ fn vllm_bench_serve_request( backend: backend, base_url: base_url, model: model, + tokenizer: tokenizer, dataset: dataset, num_prompts: num_prompts, arrival: arrival, @@ -132,6 +135,9 @@ fn vllm_bench_eos_words(ignore: Bool) -> List { // THE ARGV IS DERIVED FROM THE REQUEST, so a protocol that asked for Poisson arrivals cannot // silently render `inf`, and a protocol that named a shared prefix cannot drop `--random-prefix-len`. +// SERVED NAME AND TOKENIZER IDENTITY ARE DIFFERENT FACTS. --model is what the OpenAI route answers; +// --tokenizer is the tree the client actually loads. A protocol that carries only the served alias +// tries HuggingFace and cannot be replayed against this engine. fn vllm_bench_serve_arguments(req: VllmBenchServeRequest) -> List { concat( [ @@ -139,6 +145,7 @@ fn vllm_bench_serve_arguments(req: VllmBenchServeRequest) -> List { "--backend", vllm_bench_backend_wire(b: req.backend) as String, "--base-url", req.base_url as String, "--model", req.model as String, + "--tokenizer", req.tokenizer as String, "--endpoint", vllm_route_path(r: vllm_bench_backend_route(b: req.backend)) as String, "--dataset-name", "random", "--random-input-len", to_string(token_count_value(t: req.dataset.input_len)), diff --git a/dag/gunbc/spark/serving_load_probe.dag b/dag/gunbc/spark/serving_load_probe.dag index f9717cc434c..87c1f05ad69 100644 --- a/dag/gunbc/spark/serving_load_probe.dag +++ b/dag/gunbc/spark/serving_load_probe.dag @@ -33,7 +33,10 @@ import gunbc.spark.vllm_endpoint_process_launch { } import gunbc.spark.serving_arm { Glm53NativeFp8, GunbcGlm53NopeDerivedGb10, FourSparkTp4, glm_native_concurrent_profile, + glm53_native_fp8_row, } +import gunbc.spark.serving_arm_launch { glm_native_weights_container_dir } +import gunbc.spark.model_snapshot_acquisition { snapshot_install_path, HubCachePlacement } import gunbc.spark.serving_performance_subject { ServingPerformanceSubject, serving_performance_subject, serving_subject_standing, ServingPerformanceSubjectStanding, SubjectEstablished, SubjectPartial, @@ -478,6 +481,10 @@ fn decode_corroboration_for_protocol(req: VllmBenchServeRequest) -> DecodeCorrob } } +type ProbeProvenance + = SamePrincipal { principal: NonEmptyStr } + | DriverObserverSplit { driver: NonEmptyStr, observer: NonEmptyStr } + type ServingLoadObservation { subject: ServingPerformanceSubjectStanding protocol: VllmBenchServeRequest @@ -494,6 +501,7 @@ type ServingLoadObservation { ledger: OperationLedger admission: AdmissionCost corroboration: DecodeCorroboration + provenance: ProbeProvenance rate: DerivedRate raw_before: NonEmptyStr raw_after: NonEmptyStr @@ -533,6 +541,7 @@ fn serving_load_observation( ledger: ledger, admission: glm_native_workload_admission, corroboration: decode_corroboration_for_protocol(req: protocol), + provenance: glm_native_live_probe_provenance, rate: derive_rate_honest( ledger: ledger, continuity: continuity, @@ -567,11 +576,20 @@ fn serving_load_observation_text(o: ServingLoadObservation) -> String { "ledger: ", ledger_text(l: o.ledger), "\n", "admission: ", admission_text(a: o.admission), "\n", "corroboration: ", corroboration_text(c: o.corroboration), "\n", + "provenance: ", provenance_text(p: o.provenance), "\n", "rate: ", rate_text(r: o.rate), "\n", "saturation decided from this run: ", if saturation_from_one_run(obs: o) { "yes" } else { "no" }, "\n", ], "") } +fn provenance_text(p: ProbeProvenance) -> String { + match p { + SamePrincipal { principal: w } => join(["same-principal ", w as String], "") + DriverObserverSplit { driver: d, observer: o } => + join(["driver-observer-split driver=", d as String, " observer=", o as String], "") + } +} + fn corroboration_text(c: DecodeCorroboration) -> String { match c { CorroborationNotApplicable { because: b } => join(["not-applicable ", b as String], "") @@ -702,10 +720,17 @@ data glm_native_holistic_dataset: RandomDatasetSpec = RandomDatasetSpec { prefix_len: token_count(count: 100000), } +data glm_native_engine_tokenizer_path: NonEmptyStr = snapshot_install_path( + placement: HubCachePlacement { cache_root: glm_native_weights_container_dir }, + repo: glm53_native_fp8_row.repo, + revision: glm53_native_fp8_row.revision, +) + data glm_native_holistic_protocol: VllmBenchServeRequest = vllm_bench_serve_request( backend: OpenaiChat, base_url: "http://127.0.0.1:30000" as NonEmptyStr, model: glm_native_concurrent_profile.served_alias, + tokenizer: glm_native_engine_tokenizer_path, dataset: glm_native_holistic_dataset, num_prompts: 4, arrival: PoissonProcess { millirequests_per_second: 50, burstiness_milli: 1000 }, @@ -713,6 +738,11 @@ data glm_native_holistic_protocol: VllmBenchServeRequest = vllm_bench_serve_requ ignore_eos: true, ) +data glm_native_live_probe_provenance: ProbeProvenance = DriverObserverSplit { + driver: "calm-bat-65 via srv1 docker exec of vllm bench serve" as NonEmptyStr, + observer: "deep-otter-201 HTTP scrape of 192.168.1.236:30000/metrics" as NonEmptyStr, +} + data glm_native_declared_shared_traffic: NonEmptyStr = "gunbc.harness.harness_cli harness_probe_cli may POST a turn, and proud-boar-181 nccl-tests all_reduce_perf may allocate GPU buffers on these ranks; drain snapshot is not exclusion" as NonEmptyStr // TRANSCRIBED BOUND, NOT A READING. Parent derived ~10.7 GB active weights / ~9-11 ms memory-bandwidth @@ -752,6 +782,7 @@ fn holistic_protocol_is_session_shaped(req: VllmBenchServeRequest) -> Bool { vllm_bench_serve_uses_poisson_idle_gaps(req: req) && token_count_at_least(t: req.dataset.prefix_len, n: 100000) && token_count_at_least(t: req.dataset.input_len, n: 10000) + && (req.model as String) != (req.tokenizer as String) } fn token_count_at_least(t: TokenCount, n: Nat) -> Bool { diff --git a/dag/test/claim/spark/serving_load_probe_witness_test.dag b/dag/test/claim/spark/serving_load_probe_witness_test.dag index 516370f15fd..2f4126420ff 100644 --- a/dag/test/claim/spark/serving_load_probe_witness_test.dag +++ b/dag/test/claim/spark/serving_load_probe_witness_test.dag @@ -38,6 +38,8 @@ import gunbc.spark.serving_load_probe { glm_native_declared_shared_traffic, glm_native_single_stream_decode_bound_millis, glm_native_single_stream_decode_bound_standing, + glm_native_engine_tokenizer_path, + glm_native_live_probe_provenance, DriverObserverSplit, SamePrincipal, decode_corroboration_for_protocol, CorroborationNotApplicable, CorroborationUnread, } @@ -303,6 +305,7 @@ test fn the_holistic_protocol_is_poisson_with_session_context_and_prefix() -> Bo backend: OpenaiChat, base_url: "http://127.0.0.1:30000" as NonEmptyStr, model: "m" as NonEmptyStr, + tokenizer: "m" as NonEmptyStr, dataset: RandomDatasetSpec { input_len: token_count(count: 128), output_len: token_count(count: 128), prefix_len: token_count(count: 0) }, num_prompts: 4, arrival: SendAllImmediately, @@ -322,6 +325,17 @@ test fn the_rendered_argv_carries_the_prefix_and_a_finite_rate() -> Bool { && words_contain(words: words, needle: "--request-rate") && words_contain(words: words, needle: "0.050") && !words_contain(words: words, needle: "inf") + && words_contain(words: words, needle: "--tokenizer") + && words_contain(words: words, needle: glm_native_engine_tokenizer_path as String) + && words_contain(words: words, needle: "--model") + && (glm_native_holistic_protocol.model as String) != (glm_native_holistic_protocol.tokenizer as String) +} + +test fn this_reading_names_a_split_driver_and_observer() -> Bool { + match glm_native_live_probe_provenance { + DriverObserverSplit { driver: _, observer: _ } => true + SamePrincipal { principal: _ } => false + } } test fn exporter_restart_breaks_counter_continuity() -> Bool { From 7fd5445027fbbfaec6d56b75081f58db88ecd5e2 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Fri, 18 Sep 2026 03:29:08 +0000 Subject: [PATCH 07/43] Default this arm to shared-with-operator traffic and prove wiring on a short smoke protocol. A drain of zero is not out-of-service; WindowIsolated needs an out-of-service receipt. The 100k-prefix envelope stays modelled and is not the wet argv. Client TTFT/TPOT/ITL from vllm bench serve are carried as a contended transcribed field, not a /metrics fold. Co-authored-by: Cursor --- dag/gunbc/spark/serving_load_probe.dag | 106 +++++++++++++++--- dag/gunbc/spark/serving_load_probe_cli.dag | 10 +- .../spark/serving_load_probe_witness_test.dag | 41 ++++++- 3 files changed, 136 insertions(+), 21 deletions(-) diff --git a/dag/gunbc/spark/serving_load_probe.dag b/dag/gunbc/spark/serving_load_probe.dag index 87c1f05ad69..224fdad724e 100644 --- a/dag/gunbc/spark/serving_load_probe.dag +++ b/dag/gunbc/spark/serving_load_probe.dag @@ -17,7 +17,7 @@ import extdeps.vllm.metrics { vllm_metric_exports_histogram_statistics, } import extdeps.vllm.bench_serve { - VllmBenchServeRequest, PoissonProcess, + VllmBenchServeRequest, PoissonProcess, SendAllImmediately, RandomDatasetSpec, OpenaiChat, vllm_bench_serve_request, vllm_bench_serve_uses_poisson_idle_gaps, } import gunbc.harness.harness_backend { @@ -89,9 +89,13 @@ fn drain_from_queue(q: ServingQueueReading) -> DrainReceipt { } } -// A ZERO RUNNING GAUGE IS A DRAIN SNAPSHOT. It is not exclusion: gunbc.harness.harness_cli -// harness_probe_cli can bind a seat and POST a turn after the read, on purpose beside other load. -// Without an exclusion receipt the standing cannot be WindowIsolated. +type ArmServiceStanding + = ArmInService { because: NonEmptyStr } + | ArmOutOfService { how: NonEmptyStr } + +// A ZERO RUNNING GAUGE IS A DRAIN SNAPSHOT. It is not exclusion and it is not out-of-service: +// the operator serves interactive work on this arm, harness_probe_cli can POST a turn, and +// nccl-tests can allocate GPU buffers. WindowSharedWithDeclaredTraffic is the DEFAULT standing. fn window_from_drain(drain: DrainReceipt, traffic_receipt: NonEmptyStr) -> ProbeWindowStanding { match drain { DrainUnread { cause: c } => WindowIsolationUnread { cause: c, drain: drain } @@ -102,18 +106,23 @@ fn window_from_drain(drain: DrainReceipt, traffic_receipt: NonEmptyStr) -> Probe } } -fn isolated_window(grant: LeaseGrant, deadline: EpochSecs, drain: DrainReceipt, exclusion: ExclusionReceipt) -> ProbeWindowStanding { - match exclusion { - ExclusionNotEstablished { cause: c } => +fn isolated_window(grant: LeaseGrant, deadline: EpochSecs, drain: DrainReceipt, exclusion: ExclusionReceipt, service: ArmServiceStanding) -> ProbeWindowStanding { + match service { + ArmInService { because: c } => WindowIsolationUnread { cause: c, drain: drain } - ExclusionEstablished { how: _ } => - match drain { - DrainObservedIdle => - WindowIsolated { grant: grant, deadline: deadline, drain: drain, exclusion: exclusion } - DrainNotIdle { running: _ } => - WindowIsolationUnread { cause: "exclusion was named but the drain snapshot was not idle" as NonEmptyStr, drain: drain } - DrainUnread { cause: c } => + ArmOutOfService { how: _ } => + match exclusion { + ExclusionNotEstablished { cause: c } => WindowIsolationUnread { cause: c, drain: drain } + ExclusionEstablished { how: _ } => + match drain { + DrainObservedIdle => + WindowIsolated { grant: grant, deadline: deadline, drain: drain, exclusion: exclusion } + DrainNotIdle { running: _ } => + WindowIsolationUnread { cause: "exclusion was named but the drain snapshot was not idle" as NonEmptyStr, drain: drain } + DrainUnread { cause: c } => + WindowIsolationUnread { cause: c, drain: drain } + } } } } @@ -481,6 +490,17 @@ fn decode_corroboration_for_protocol(req: VllmBenchServeRequest) -> DecodeCorrob } } +type ClientBenchLatency + = ClientBenchLatencyUnread { cause: NonEmptyStr } + | ClientBenchLatencyReported { + output_throughput_milli_tok_per_s: Nat + tpot_milli: Nat + itl_milli: Nat + ttft_milli: Nat + contended: Bool + standing: CitedFigureStanding + } + type ProbeProvenance = SamePrincipal { principal: NonEmptyStr } | DriverObserverSplit { driver: NonEmptyStr, observer: NonEmptyStr } @@ -502,6 +522,7 @@ type ServingLoadObservation { admission: AdmissionCost corroboration: DecodeCorroboration provenance: ProbeProvenance + client_latency: ClientBenchLatency rate: DerivedRate raw_before: NonEmptyStr raw_after: NonEmptyStr @@ -520,6 +541,7 @@ fn serving_load_observation( before_body: String, after_body: String, ledger: OperationLedger, + client_latency: ClientBenchLatency, ) -> ServingLoadObservation { let before_p = preemption_count(body: before_body) let after_p = preemption_count(body: after_body) @@ -542,6 +564,7 @@ fn serving_load_observation( admission: glm_native_workload_admission, corroboration: decode_corroboration_for_protocol(req: protocol), provenance: glm_native_live_probe_provenance, + client_latency: client_latency, rate: derive_rate_honest( ledger: ledger, continuity: continuity, @@ -577,11 +600,26 @@ fn serving_load_observation_text(o: ServingLoadObservation) -> String { "admission: ", admission_text(a: o.admission), "\n", "corroboration: ", corroboration_text(c: o.corroboration), "\n", "provenance: ", provenance_text(p: o.provenance), "\n", + "client latency: ", client_latency_text(c: o.client_latency), "\n", "rate: ", rate_text(r: o.rate), "\n", "saturation decided from this run: ", if saturation_from_one_run(obs: o) { "yes" } else { "no" }, "\n", ], "") } +fn client_latency_text(c: ClientBenchLatency) -> String { + match c { + ClientBenchLatencyUnread { cause: x } => join(["unread ", x as String], "") + ClientBenchLatencyReported { output_throughput_milli_tok_per_s: th, tpot_milli: tpot, itl_milli: itl, ttft_milli: ttft, contended: k, standing: _ } => + join([ + "bench-serve throughput_milli_tok_s=", to_string(th), + " tpot_ms=", to_string(tpot), + " itl_ms=", to_string(itl), + " ttft_ms=", to_string(ttft), + " contended=", if k { "yes" } else { "no" }, + ], "") + } +} + fn provenance_text(p: ProbeProvenance) -> String { match p { SamePrincipal { principal: w } => join(["same-principal ", w as String], "") @@ -726,6 +764,27 @@ data glm_native_engine_tokenizer_path: NonEmptyStr = snapshot_install_path( revision: glm53_native_fp8_row.revision, ) +// WIRING IS PROVEN AT A FEW HUNDRED TOKENS. A 100k-prefix protocol is not a smoke test: it is the +// heaviest prefill this arm can construct and it starves operator interactive traffic. SendAllImmediately +// is the validated wiring argv; it is not a comparable rate protocol (arrival skew). +data glm_native_smoke_dataset: RandomDatasetSpec = RandomDatasetSpec { + input_len: token_count(count: 256), + output_len: token_count(count: 64), + prefix_len: token_count(count: 0), +} + +data glm_native_smoke_protocol: VllmBenchServeRequest = vllm_bench_serve_request( + backend: OpenaiChat, + base_url: "http://127.0.0.1:30000" as NonEmptyStr, + model: glm_native_concurrent_profile.served_alias, + tokenizer: glm_native_engine_tokenizer_path, + dataset: glm_native_smoke_dataset, + num_prompts: 4, + arrival: SendAllImmediately, + max_concurrency: Present { value: 2 }, + ignore_eos: true, +) + data glm_native_holistic_protocol: VllmBenchServeRequest = vllm_bench_serve_request( backend: OpenaiChat, base_url: "http://127.0.0.1:30000" as NonEmptyStr, @@ -743,7 +802,24 @@ data glm_native_live_probe_provenance: ProbeProvenance = DriverObserverSplit { observer: "deep-otter-201 HTTP scrape of 192.168.1.236:30000/metrics" as NonEmptyStr, } -data glm_native_declared_shared_traffic: NonEmptyStr = "gunbc.harness.harness_cli harness_probe_cli may POST a turn, and proud-boar-181 nccl-tests all_reduce_perf may allocate GPU buffers on these ranks; drain snapshot is not exclusion" as NonEmptyStr +data glm_native_declared_shared_traffic: NonEmptyStr = "operator interactive sessions share Group B; gunbc.harness.harness_cli harness_probe_cli may POST a turn; proud-boar-181 nccl-tests all_reduce_perf may allocate GPU buffers; a drain snapshot is not exclusion and is not out-of-service" as NonEmptyStr + +data glm_native_arm_service: ArmServiceStanding = ArmInService { + because: "the operator serves interactive work on this arm; WindowIsolated requires an out-of-service receipt that has not been issued" as NonEmptyStr +} + +// Client TTFT/TPOT/ITL from vllm bench serve stdout, transcribed from the 2026-09-18 smoke +// (256/64, inf rate, c=2, 4/4 ok). Contended: operator session was in flight. Not a /metrics fold. +data glm_native_smoke_client_latency: ClientBenchLatency = ClientBenchLatencyReported { + output_throughput_milli_tok_per_s: 17390 + tpot_milli: 82 + itl_milli: 82 + ttft_milli: 2185 + contended: true + standing: TranscribedUncited { + read_obligation: "re-read vllm bench serve stdout for this smoke argv; the 17.39 tok/s / 82.1 ms TPOT / 81.8 ms ITL / 2185 ms TTFT figures were transcribed from calm-bat-65's docker-exec receipt" as NonEmptyStr + } +} // TRANSCRIBED BOUND, NOT A READING. Parent derived ~10.7 GB active weights / ~9-11 ms memory-bandwidth // floor from the checkpoint config (45 layers, hidden 4096, 288 routed experts, top-8 + 1 shared, fp8) diff --git a/dag/gunbc/spark/serving_load_probe_cli.dag b/dag/gunbc/spark/serving_load_probe_cli.dag index 19866f11823..4c2bd496849 100644 --- a/dag/gunbc/spark/serving_load_probe_cli.dag +++ b/dag/gunbc/spark/serving_load_probe_cli.dag @@ -19,14 +19,15 @@ import gunbc.spark.serving_arm { glm_native_concurrent_profile } import gunbc.harness.harness_backend { harness_launch_from_body, harness_queue_from_body } import gunbc.spark.fabric_switch_observed { FabricGroupB } import gunbc.spark.serving_load_probe { - glm_native_holistic_protocol, glm_native_live_subject_standing, - glm_native_declared_shared_traffic, + glm_native_live_subject_standing, + glm_native_declared_shared_traffic, glm_native_smoke_protocol, serving_load_observation, serving_load_observation_text, drain_from_queue, window_from_drain, counter_continuity, DrainObservedIdle, DrainNotIdle, DrainUnread, ArrivalSkewUnread, OperationLedger, LedgerClosed, LedgerIncomplete, OccupancyUnsampled, ClientOutputTokensUnread, + ClientBenchLatencyUnread, RateFromGenerationTokens, RateUndenominable, RateUnreadable, } @@ -55,7 +56,7 @@ fn bench_exec_argv() -> List { argv_words(command: docker_exec_command( name: glm_native_container_name, env: [], - argv: concat(["vllm"], vllm_bench_serve_arguments(req: glm_native_holistic_protocol)), + argv: concat(["vllm"], vllm_bench_serve_arguments(req: glm_native_smoke_protocol)), )) } @@ -122,7 +123,7 @@ fn glm_native_serving_load_wet() -> ProcessExit let occ = OccupancyUnsampled { cause: "the wet fold scrapes metrics only before and after the blocking bench process; mid-run occupancy is not sampled" as NonEmptyStr } let obs = serving_load_observation( subject: glm_native_live_subject_standing(), - protocol: glm_native_holistic_protocol, + protocol: glm_native_smoke_protocol, window: window, continuity: counter_continuity(before: before_launch, after: after_launch), arrival: ArrivalSkewUnread { cause: "vllm bench serve stdout is not yet parsed for per-request start skew" as NonEmptyStr }, @@ -133,6 +134,7 @@ fn glm_native_serving_load_wet() -> ProcessExit before_body: before, after_body: after, ledger: ledger_from_bench(exit_ok: bench_ok, offered: 4), + client_latency: ClientBenchLatencyUnread { cause: "vllm bench serve stdout is not yet parsed for TTFT/TPOT/ITL" as NonEmptyStr }, ) let body = join([ "glm native serving-load wet at ", probed_at_word(reading: clock_now_probed_at()) as String, "\n", diff --git a/dag/test/claim/spark/serving_load_probe_witness_test.dag b/dag/test/claim/spark/serving_load_probe_witness_test.dag index 2f4126420ff..f5a95eb769f 100644 --- a/dag/test/claim/spark/serving_load_probe_witness_test.dag +++ b/dag/test/claim/spark/serving_load_probe_witness_test.dag @@ -21,9 +21,10 @@ import extdeps.vllm.kv_layout { AdmissionCostUnestablished, AdmissionCostBlocks import extdeps.external_authority { TranscribedUncited, CitedToAuthority } import gunbc.spark.serving_load_probe { DrainObservedIdle, - ExclusionNotEstablished, + ExclusionNotEstablished, ExclusionEstablished, WindowIsolated, WindowSharedWithDeclaredTraffic, WindowIsolationUnread, window_from_drain, isolated_window, drain_from_queue, + ArmInService, ArmOutOfService, OperationLedger, LedgerClosed, ledger_admits_token_denomination, RateFromGenerationTokens, RateUndenominable, RateUnreadable, ArrivalSkewObserved, ArrivalSkewUnread, arrival_admits_rate_comparison, @@ -34,12 +35,15 @@ import gunbc.spark.serving_load_probe { glm_native_live_subject_standing, counter_continuity, SameExporter, ExporterChanged, ContinuityUnread, OccupancySampled, OccupancyUnsampled, OccupancySample, ClientOutputTokensUnread, ClientOutputTokensObserved, + ClientBenchLatencyUnread, ClientBenchLatencyReported, glm_native_workload_admission, glm_native_declared_shared_traffic, glm_native_single_stream_decode_bound_millis, glm_native_single_stream_decode_bound_standing, glm_native_engine_tokenizer_path, glm_native_live_probe_provenance, DriverObserverSplit, SamePrincipal, + glm_native_smoke_protocol, glm_native_smoke_client_latency, + glm_native_arm_service, decode_corroboration_for_protocol, CorroborationNotApplicable, CorroborationUnread, } @@ -98,6 +102,28 @@ test fn a_quiet_drain_is_not_an_isolated_window() -> Bool { test fn declared_shared_traffic_names_the_harness_probe_and_nccl_tests() -> Bool { string_contains(s: glm_native_declared_shared_traffic as String, pattern: "harness_probe_cli") && string_contains(s: glm_native_declared_shared_traffic as String, pattern: "nccl-tests") + && string_contains(s: glm_native_declared_shared_traffic as String, pattern: "operator") +} + +test fn isolated_window_refuses_while_the_arm_is_in_service() -> Bool { + let grant = lease_grant( + reference: "probe" as NonEmptyStr, + fence: lease_fence_of(admitting_event: "e" as EventId, generation: 1), + granted_at: 1, + policy: LeasePolicy { maximum_duration_seconds: 60, release_law: FencedResource }, + ) + match isolated_window( + grant: grant, + deadline: 61, + drain: DrainObservedIdle, + exclusion: ExclusionEstablished { how: "named" as NonEmptyStr }, + service: glm_native_arm_service, + ) { + WindowIsolationUnread { cause: _, drain: DrainObservedIdle } => true + WindowIsolationUnread { cause: _, drain: _ } => false + WindowIsolated { grant: _, deadline: _, drain: _, exclusion: _ } => false + WindowSharedWithDeclaredTraffic { traffic_receipt: _, drain: _ } => false + } } test fn isolated_window_refuses_without_exclusion() -> Bool { @@ -107,7 +133,7 @@ test fn isolated_window_refuses_without_exclusion() -> Bool { granted_at: 1, policy: LeasePolicy { maximum_duration_seconds: 60, release_law: FencedResource }, ) - match isolated_window(grant: grant, deadline: 61, drain: DrainObservedIdle, exclusion: ExclusionNotEstablished { cause: "route was not withdrawn" as NonEmptyStr }) { + match isolated_window(grant: grant, deadline: 61, drain: DrainObservedIdle, exclusion: ExclusionNotEstablished { cause: "route was not withdrawn" as NonEmptyStr }, service: ArmInService { because: "operator interactive" as NonEmptyStr }) { WindowIsolationUnread { cause: _, drain: DrainObservedIdle } => true WindowIsolationUnread { cause: _, drain: _ } => false WindowIsolated { grant: _, deadline: _, drain: _, exclusion: _ } => false @@ -174,6 +200,7 @@ fn fx_obs(ledger: OperationLedger) -> ServingLoadObservation { before_body: fx_idle, after_body: fx_after, ledger: ledger, + client_latency: ClientBenchLatencyUnread { cause: "fixture has no bench stdout" as NonEmptyStr }, ) } @@ -298,6 +325,16 @@ test fn the_holistic_protocol_does_not_corroborate_the_single_stream_bound() -> } } +test fn the_smoke_protocol_is_not_the_holistic_envelope() -> Bool { + !holistic_protocol_is_session_shaped(req: glm_native_smoke_protocol) + && !vllm_bench_serve_uses_poisson_idle_gaps(req: glm_native_smoke_protocol) + && match glm_native_smoke_client_latency { + ClientBenchLatencyReported { output_throughput_milli_tok_per_s: _, tpot_milli: tpot, itl_milli: _, ttft_milli: _, contended: k, standing: _ } => + k && tpot == 82 + ClientBenchLatencyUnread { cause: _ } => false + } +} + test fn the_holistic_protocol_is_poisson_with_session_context_and_prefix() -> Bool { holistic_protocol_is_session_shaped(req: glm_native_holistic_protocol) && vllm_bench_serve_uses_poisson_idle_gaps(req: glm_native_holistic_protocol) From ada7d7b0fb4c05a18974fb992dc8dff262ad9544 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Fri, 18 Sep 2026 03:41:17 +0000 Subject: [PATCH 08/43] Derive the probe rate from the client ledger under declared contention. generation_tokens_total includes the operator's decode on this arm, so a ledger-versus-counter equality check cannot be a refuse. Bound foreign work from the surplus instead, and keep capacity claims unavailable on a shared window. Co-authored-by: Cursor --- dag/gunbc/spark/serving_load_probe.dag | 168 +++++++++++------- dag/gunbc/spark/serving_load_probe_cli.dag | 33 ++-- .../spark/serving_load_probe_witness_test.dag | 77 ++++---- 3 files changed, 147 insertions(+), 131 deletions(-) diff --git a/dag/gunbc/spark/serving_load_probe.dag b/dag/gunbc/spark/serving_load_probe.dag index 224fdad724e..71bc67c8d17 100644 --- a/dag/gunbc/spark/serving_load_probe.dag +++ b/dag/gunbc/spark/serving_load_probe.dag @@ -3,7 +3,7 @@ module gunbc.spark.serving_load_probe import std.types { Bool, String, NonEmptyStr, List, EpochSecs } import std.nat { Nat } import std.decimal { ExactDecimal, canonical_exact_decimal, decimal_pow10 } -import v2.std.algebra { length, filter } +import v2.std.algebra { length, filter, list_map } import v2.std.optional { Present, Absent } import std.measure { TokenCount, token_count, token_count_value } import product.capacity.lease { LeaseGrant } @@ -12,7 +12,7 @@ import extdeps.prometheus.client { SampleValueExact, SampleValueNotFinite, SampleValueUnreadable, prometheus_sample_value_reading, } import extdeps.vllm.metrics { - VllmServingMetric, InterTokenLatencySeconds, IterationTokensTotal, NumPreemptionsTotal, GenerationTokensTotal, + VllmServingMetric, InterTokenLatencySeconds, IterationTokensTotal, NumPreemptionsTotal, GenerationTokensTotal, PromptTokensTotal, HistogramStatistic, HistogramSum, HistogramCount, vllm_metric_exports_histogram_statistics, } @@ -51,9 +51,10 @@ import extdeps.external_authority { CitedFigureStanding, TranscribedUncited } // emits tokens and then fails cannot be denominated in tokens. A quiet endpoint read is not an // isolation receipt. // -// THE RATE IS DERIVED AND NEVER STORED, the same law gunbc.harness.harness_throughput states for -// its own stream: counts and an engine interval are carried; tokens-per-second is a function of -// them. +// THE RATE IS DERIVED FROM THE CLIENT LEDGER, never from generation_tokens_total. That engine +// counter includes foreign decode on this arm. Surplus (engine minus client, floored at zero) +// bounds shared work. A latency distribution beside declared contention is still a distribution; +// an aggregate capacity claim is not available from a shared window. type DrainReceipt = DrainObservedIdle @@ -337,6 +338,7 @@ type OccupancySample { waiting: Nat capacity_waiting: Nat preemptions: Nat + prompt_tokens: Nat } type OccupancyTrace @@ -352,26 +354,31 @@ fn occupancy_from_body(body: String) -> OccupancySample? { Present { value: pr } => match capacity_waiting_count(p: p) { Absent => none - Present { value: c } => Present { value: OccupancySample { running: r, waiting: w, capacity_waiting: c, preemptions: pr } } + Present { value: c } => + match metric_count(body: body, metric: PromptTokensTotal) { + Absent => none + Present { value: pt } => + Present { value: OccupancySample { running: r, waiting: w, capacity_waiting: c, preemptions: pr, prompt_tokens: pt } } + } } } } } -// Unsampled occupancy cannot exclude a harness_probe_cli arrival mid-window, so it does not -// admit a comparable rate. running above declared max-concurrency is the same refuse. -fn occupancy_admits_declared_load(trace: OccupancyTrace, max_concurrency: Nat?) -> Bool { - match trace { - OccupancyUnsampled { cause: _ } => false - OccupancySampled { samples: ss } => - if length(ss) == 0 { - false - } else { - match max_concurrency { - Absent => true - Present { value: cap } => - length(filter(ss, s => s.running > cap)) == 0 - } +fn metric_count(body: String, metric: VllmServingMetric) -> Nat? { + match harness_gauge_value(body: body, metric: metric) { + Absent => none + Present { value: t } => harness_gauge_count(text: t) + } +} + +fn occupancy_trace_from_endpoint_scrapes(before_body: String, after_body: String) -> OccupancyTrace { + match occupancy_from_body(body: before_body) { + Absent => OccupancyUnsampled { cause: "a bound scrape could not yield running/waiting/prompt_tokens" as NonEmptyStr } + Present { value: a } => + match occupancy_from_body(body: after_body) { + Absent => OccupancySampled { samples: [a] } + Present { value: b } => OccupancySampled { samples: [a, b] } } } } @@ -409,7 +416,7 @@ fn ledger_counter_agreement(ledger: OperationLedger, generation: TokenDelta, cli if nat_abs_diff(a: c, b: g) <= generation_client_token_agreement_bound { LedgerAndCounterAgree { generation_tokens: g, completed_requests: n } } else { - LedgerCounterDisagree { because: "client completed-token count and generation_tokens_total delta disagree beyond the declared bound; foreign load (including harness_probe_cli) is the remaining explanation and the rate is not reported" as NonEmptyStr } + LedgerCounterDisagree { because: "generation_tokens_total includes foreign decode beside this client ledger; surplus bounds shared work and is not a refuse of the client rate" as NonEmptyStr } } } } @@ -417,8 +424,39 @@ fn ledger_counter_agreement(ledger: OperationLedger, generation: TokenDelta, cli } } +type ForeignWorkBound + = ForeignWorkUnread { because: NonEmptyStr } + | ForeignWorkBounded { engine_generation: Nat, client_output: Nat, surplus: Nat } + +fn foreign_work_bound(generation: TokenDelta, client_output: ClientOutputTokens) -> ForeignWorkBound { + match generation { + TokenDeltaUnread { cause: c } => ForeignWorkUnread { because: c } + TokenDeltaReset { cause: c } => ForeignWorkUnread { because: c } + TokenDeltaRead { tokens: g } => + match client_output { + ClientOutputTokensUnread { cause: c } => ForeignWorkUnread { because: c } + ClientOutputTokensObserved { tokens: c } => + ForeignWorkBounded { engine_generation: g, client_output: c, surplus: if g >= c { g - c } else { 0 } } + } + } +} + +type CapacityClaim + = CapacityClaimUnavailable { because: NonEmptyStr } + +fn capacity_claim_for_window(window: ProbeWindowStanding) -> CapacityClaim { + match window { + WindowIsolated { grant: _, deadline: _, drain: _, exclusion: _ } => + CapacityClaimUnavailable { because: "one run does not decide saturation even under isolation" as NonEmptyStr } + WindowSharedWithDeclaredTraffic { traffic_receipt: _, drain: _ } => + CapacityClaimUnavailable { because: "this arm has no exclusive window; a latency distribution beside foreign load is real, an aggregate capacity claim is not" as NonEmptyStr } + WindowIsolationUnread { cause: _, drain: _ } => + CapacityClaimUnavailable { because: "window isolation is unread, so no capacity claim is available" as NonEmptyStr } + } +} + type DerivedRate - = RateFromGenerationTokens { tokens: Nat, scrape_millis: Nat } + = RateFromClientOutputTokens { tokens: Nat, scrape_millis: Nat } | RateUndenominable { because: NonEmptyStr } | RateUnreadable { because: NonEmptyStr } @@ -426,50 +464,25 @@ fn tokens_per_observation_second(r: DerivedRate) -> Nat? { match r { RateUndenominable { because: _ } => none RateUnreadable { because: _ } => none - RateFromGenerationTokens { tokens: t, scrape_millis: ms } => + RateFromClientOutputTokens { tokens: t, scrape_millis: ms } => if ms == 0 { none } else { Present { value: (t * 1000) / ms } } } } fn derive_rate_honest( ledger: OperationLedger, - continuity: CounterContinuity, - generation: TokenDelta, scrape_millis: Nat?, - arrival: ArrivalSkew, - occupancy: OccupancyTrace, - max_concurrency: Nat?, client_output: ClientOutputTokens, ) -> DerivedRate { if !ledger_admits_token_denomination(l: ledger) { RateUndenominable { because: "the operation ledger does not admit token denomination" as NonEmptyStr } } else { - match ledger_counter_agreement(ledger: ledger, generation: generation, client_output: client_output) { - LedgerCounterDisagree { because: c } => RateUnreadable { because: c } - AgreementUnread { because: c } => RateUnreadable { because: c } - LedgerAndCounterAgree { generation_tokens: _, completed_requests: _ } => - if !occupancy_admits_declared_load(trace: occupancy, max_concurrency: max_concurrency) { - RateUnreadable { because: "a mid-run occupancy sample exceeded declared max-concurrency, so foreign load or oversubscription is visible and the rate is not reported" as NonEmptyStr } - } else { - match continuity { - ContinuityUnread { cause: c } => RateUnreadable { because: c } - ExporterChanged { before: _, after: _ } => - RateUnreadable { because: "generation_tokens_total resets on restart; the exporter changed across the window" as NonEmptyStr } - SameExporter { start_field: _ } => - if !arrival_admits_rate_comparison(s: arrival) { - RateUnreadable { because: "arrival skew is unread or exceeds the comparison bound, so a rate comparison is refused" as NonEmptyStr } - } else { - match scrape_millis { - Absent => RateUnreadable { because: "the metric-scrape interval is not a positive span" as NonEmptyStr } - Present { value: ms } => - match generation { - TokenDeltaUnread { cause: c } => RateUnreadable { because: c } - TokenDeltaReset { cause: c } => RateUnreadable { because: c } - TokenDeltaRead { tokens: t } => RateFromGenerationTokens { tokens: t, scrape_millis: ms } - } - } - } - } + match client_output { + ClientOutputTokensUnread { cause: c } => RateUnreadable { because: c } + ClientOutputTokensObserved { tokens: c } => + match scrape_millis { + Absent => RateUnreadable { because: "the client interval is not a positive span" as NonEmptyStr } + Present { value: ms } => RateFromClientOutputTokens { tokens: c, scrape_millis: ms } } } } @@ -523,6 +536,8 @@ type ServingLoadObservation { corroboration: DecodeCorroboration provenance: ProbeProvenance client_latency: ClientBenchLatency + foreign_work: ForeignWorkBound + capacity_claim: CapacityClaim rate: DerivedRate raw_before: NonEmptyStr raw_after: NonEmptyStr @@ -565,14 +580,11 @@ fn serving_load_observation( corroboration: decode_corroboration_for_protocol(req: protocol), provenance: glm_native_live_probe_provenance, client_latency: client_latency, + foreign_work: foreign_work_bound(generation: generation, client_output: client_output), + capacity_claim: capacity_claim_for_window(window: window), rate: derive_rate_honest( ledger: ledger, - continuity: continuity, - generation: generation, scrape_millis: scrape_interval_millis(before_at: before_at, after_at: after_at), - arrival: arrival, - occupancy: occupancy, - max_concurrency: protocol.max_concurrency, client_output: client_output, ), raw_before: before_body as NonEmptyStr, @@ -584,6 +596,10 @@ fn observation_rate_is_stored_separately(_: ServingLoadObservation) -> Bool { false } +fn saturation_from_one_run(_: ServingLoadObservation) -> Bool { + false +} + fn serving_load_observation_text(o: ServingLoadObservation) -> String { join([ "serving-load observation\n", @@ -601,11 +617,27 @@ fn serving_load_observation_text(o: ServingLoadObservation) -> String { "corroboration: ", corroboration_text(c: o.corroboration), "\n", "provenance: ", provenance_text(p: o.provenance), "\n", "client latency: ", client_latency_text(c: o.client_latency), "\n", + "foreign work: ", foreign_work_text(f: o.foreign_work), "\n", + "capacity claim: ", capacity_claim_text(c: o.capacity_claim), "\n", "rate: ", rate_text(r: o.rate), "\n", "saturation decided from this run: ", if saturation_from_one_run(obs: o) { "yes" } else { "no" }, "\n", ], "") } +fn foreign_work_text(f: ForeignWorkBound) -> String { + match f { + ForeignWorkUnread { because: c } => join(["unread ", c as String], "") + ForeignWorkBounded { engine_generation: g, client_output: c, surplus: s } => + join(["engine=", to_string(g), " client=", to_string(c), " surplus=", to_string(s)], "") + } +} + +fn capacity_claim_text(c: CapacityClaim) -> String { + match c { + CapacityClaimUnavailable { because: b } => join(["unavailable ", b as String], "") + } +} + fn client_latency_text(c: ClientBenchLatency) -> String { match c { ClientBenchLatencyUnread { cause: x } => join(["unread ", x as String], "") @@ -635,10 +667,20 @@ fn corroboration_text(c: DecodeCorroboration) -> String { } } +fn occupancy_sample_text(s: OccupancySample) -> String { + join([ + "running=", to_string(s.running), + " waiting=", to_string(s.waiting), + " prompt_tokens=", to_string(s.prompt_tokens), + " preemptions=", to_string(s.preemptions), + ], "") +} + fn occupancy_text(t: OccupancyTrace) -> String { match t { OccupancyUnsampled { cause: c } => join(["unsampled ", c as String], "") - OccupancySampled { samples: ss } => join(["samples=", to_string(length(ss))], "") + OccupancySampled { samples: ss } => + join(["samples=", to_string(length(ss)), " ", join(list_map(xs: ss, f: occupancy_sample_text), " | ")], "") } } @@ -723,7 +765,7 @@ fn rate_text(r: DerivedRate) -> String { match r { RateUndenominable { because: c } => join(["undenominable ", c as String], "") RateUnreadable { because: c } => join(["unreadable ", c as String], "") - RateFromGenerationTokens { tokens: t, scrape_millis: ms } => + RateFromClientOutputTokens { tokens: t, scrape_millis: ms } => join([ "generation_tokens=", to_string(t), " scrape_millis=", to_string(ms), @@ -769,7 +811,7 @@ data glm_native_engine_tokenizer_path: NonEmptyStr = snapshot_install_path( // is the validated wiring argv; it is not a comparable rate protocol (arrival skew). data glm_native_smoke_dataset: RandomDatasetSpec = RandomDatasetSpec { input_len: token_count(count: 256), - output_len: token_count(count: 64), + output_len: token_count(count: 128), prefix_len: token_count(count: 0), } @@ -802,7 +844,7 @@ data glm_native_live_probe_provenance: ProbeProvenance = DriverObserverSplit { observer: "deep-otter-201 HTTP scrape of 192.168.1.236:30000/metrics" as NonEmptyStr, } -data glm_native_declared_shared_traffic: NonEmptyStr = "operator interactive sessions share Group B; gunbc.harness.harness_cli harness_probe_cli may POST a turn; proud-boar-181 nccl-tests all_reduce_perf may allocate GPU buffers; a drain snapshot is not exclusion and is not out-of-service" as NonEmptyStr +data glm_native_declared_shared_traffic: NonEmptyStr = "operator interactive long-context sessions (70-110k prompt jumps) share Group B as production traffic with no exclusive window; gunbc.harness.harness_cli harness_probe_cli may POST a turn; proud-boar-181 nccl-tests all_reduce_perf may allocate GPU buffers; a drain snapshot is not exclusion and is not out-of-service" as NonEmptyStr data glm_native_arm_service: ArmServiceStanding = ArmInService { because: "the operator serves interactive work on this arm; WindowIsolated requires an out-of-service receipt that has not been issued" as NonEmptyStr diff --git a/dag/gunbc/spark/serving_load_probe_cli.dag b/dag/gunbc/spark/serving_load_probe_cli.dag index 4c2bd496849..0e2502d83ee 100644 --- a/dag/gunbc/spark/serving_load_probe_cli.dag +++ b/dag/gunbc/spark/serving_load_probe_cli.dag @@ -23,20 +23,19 @@ import gunbc.spark.serving_load_probe { glm_native_declared_shared_traffic, glm_native_smoke_protocol, serving_load_observation, serving_load_observation_text, drain_from_queue, window_from_drain, counter_continuity, - DrainObservedIdle, DrainNotIdle, DrainUnread, ArrivalSkewUnread, + ArrivalSkewUnread, + occupancy_trace_from_endpoint_scrapes, OperationLedger, LedgerClosed, LedgerIncomplete, - OccupancyUnsampled, ClientOutputTokensUnread, ClientBenchLatencyUnread, - RateFromGenerationTokens, RateUndenominable, RateUnreadable, + RateFromClientOutputTokens, RateUndenominable, RateUnreadable, } // ── THE INHABITANCE ROUTE ───────────────────────────────────────────────────────────────────── // // Witnesses supply metric bodies. This function is the one that drives `vllm bench serve` against -// the live native GLM head and folds engine-counter receipts. It is operator-invoked, not a CI -// job: the arm is shared, and colliding with another experiment is the isolation failure the -// design names. +// the live native GLM head and folds receipts. The arm is shared with operator interactive +// sessions; a drain of zero is not exclusivity. This fold records that standing and still runs. // // gunbc run --source-root dag --source-root src/v2 \ // --entry dag/gunbc/spark/serving_load_probe_cli.dag --function glm_native_serving_load_wet @@ -98,17 +97,11 @@ fn glm_native_serving_load_wet() -> ProcessExit drain: drain, traffic_receipt: glm_native_declared_shared_traffic, ) - match drain { - DrainNotIdle { running: n } => - exit_failure(reason: join(["refusing to drive load: num_requests_running=", to_string(n), " so this window is not drained"], "")) - DrainUnread { cause: c } => - exit_failure(reason: join(["refusing to drive load: drain unread: ", c as String], "")) - DrainObservedIdle => { - let bench = spark_remote_run(ctx: ctx, argv: bench_exec_argv()) - let after = remote_or_fail(ctx: ctx, argv: curl_metrics_argv(), step: "metrics-after") - if body_is_failure(body: after) { - exit_failure(reason: after) - } else { + let bench = spark_remote_run(ctx: ctx, argv: bench_exec_argv()) + let after = remote_or_fail(ctx: ctx, argv: curl_metrics_argv(), step: "metrics-after") + if body_is_failure(body: after) { + exit_failure(reason: after) + } else { let bench_ok = match bench { RemoteUnreachable { cause: _ } => false RemoteRan { exit_code: code, stdout: _, stderr: _ } => code == 0 @@ -120,7 +113,7 @@ fn glm_native_serving_load_wet() -> ProcessExit } let before_launch = harness_launch_from_body(group: FabricGroupB, address: "192.168.1.236", body: before) let after_launch = harness_launch_from_body(group: FabricGroupB, address: "192.168.1.236", body: after) - let occ = OccupancyUnsampled { cause: "the wet fold scrapes metrics only before and after the blocking bench process; mid-run occupancy is not sampled" as NonEmptyStr } + let occ = occupancy_trace_from_endpoint_scrapes(before_body: before, after_body: after) let obs = serving_load_observation( subject: glm_native_live_subject_standing(), protocol: glm_native_smoke_protocol, @@ -148,13 +141,11 @@ fn glm_native_serving_load_wet() -> ProcessExit exit_failure(reason: body) } else { match obs.rate { - RateFromGenerationTokens { tokens: _, scrape_millis: _ } => ExitSuccess + RateFromClientOutputTokens { tokens: _, scrape_millis: _ } => ExitSuccess RateUndenominable { because: _ } => exit_failure(reason: body) RateUnreadable { because: _ } => exit_failure(reason: body) } } - } - } } } }, attempt_raw: glm_native_serving_load_attempt_raw, credential_file_name: "gunbc-glm-native-serving-load-admin-password" as NonEmptyStr) diff --git a/dag/test/claim/spark/serving_load_probe_witness_test.dag b/dag/test/claim/spark/serving_load_probe_witness_test.dag index f5a95eb769f..d036a408af0 100644 --- a/dag/test/claim/spark/serving_load_probe_witness_test.dag +++ b/dag/test/claim/spark/serving_load_probe_witness_test.dag @@ -26,11 +26,13 @@ import gunbc.spark.serving_load_probe { window_from_drain, isolated_window, drain_from_queue, ArmInService, ArmOutOfService, OperationLedger, LedgerClosed, ledger_admits_token_denomination, - RateFromGenerationTokens, RateUndenominable, RateUnreadable, + RateFromClientOutputTokens, RateUndenominable, RateUnreadable, ArrivalSkewObserved, ArrivalSkewUnread, arrival_admits_rate_comparison, TokenDeltaRead, TokenDeltaReset, TokenDeltaUnread, generation_token_delta, derive_rate_honest, serving_load_observation, ServingLoadObservation, tokens_per_observation_second, saturation_from_one_run, observation_rate_is_stored_separately, + foreign_work_bound, ForeignWorkBounded, ForeignWorkUnread, + CapacityClaimUnavailable, glm_native_holistic_protocol, holistic_protocol_is_session_shaped, glm_native_live_subject_standing, counter_continuity, SameExporter, ExporterChanged, ContinuityUnread, OccupancySampled, OccupancyUnsampled, OccupancySample, @@ -62,6 +64,7 @@ fn metrics_body(running: String, waiting: String, capacity: String, preempt: Str "vllm:num_requests_running{model_name=\"glm\"} ", running, "\n", "vllm:num_requests_waiting_by_reason{model_name=\"glm\",reason=\"capacity\"} ", capacity, "\n", "vllm:num_preemptions_total{model_name=\"glm\"} ", preempt, "\n", + "vllm:prompt_tokens_total{model_name=\"glm\"} 0.0\n", "vllm:generation_tokens_total{model_name=\"glm\"} ", gen, "\n", "vllm:inter_token_latency_seconds_sum{model_name=\"glm\"} ", itl_sum, "\n", "vllm:inter_token_latency_seconds_count{model_name=\"glm\"} ", itl_count, "\n", @@ -103,6 +106,7 @@ test fn declared_shared_traffic_names_the_harness_probe_and_nccl_tests() -> Bool string_contains(s: glm_native_declared_shared_traffic as String, pattern: "harness_probe_cli") && string_contains(s: glm_native_declared_shared_traffic as String, pattern: "nccl-tests") && string_contains(s: glm_native_declared_shared_traffic as String, pattern: "operator") + && string_contains(s: glm_native_declared_shared_traffic as String, pattern: "70-110k") } test fn isolated_window_refuses_while_the_arm_is_in_service() -> Bool { @@ -152,17 +156,12 @@ test fn engine_rate_comes_from_generation_tokens_not_iteration_or_itl() -> Bool t == 128 && match derive_rate_honest( ledger: closed_ok(), - continuity: counter_continuity(before: fx_launch(), after: fx_launch()), - generation: TokenDeltaRead { tokens: t }, scrape_millis: Present { value: 2000 }, - arrival: tight_arrival(), - occupancy: OccupancySampled { samples: [OccupancySample { running: 2, waiting: 0, capacity_waiting: 0, preemptions: 0 }] }, - max_concurrency: Present { value: 2 }, client_output: ClientOutputTokensObserved { tokens: t }, ) { - RateFromGenerationTokens { tokens: tok, scrape_millis: ms } => + RateFromClientOutputTokens { tokens: tok, scrape_millis: ms } => tok == 128 && ms == 2000 && - match tokens_per_observation_second(r: RateFromGenerationTokens { tokens: tok, scrape_millis: ms }) { + match tokens_per_observation_second(r: RateFromClientOutputTokens { tokens: tok, scrape_millis: ms }) { Absent => false Present { value: rate } => rate == 64 } @@ -193,7 +192,7 @@ fn fx_obs(ledger: OperationLedger) -> ServingLoadObservation { window: window_from_drain(drain: DrainObservedIdle, traffic_receipt: "fx" as NonEmptyStr), continuity: counter_continuity(before: fx_launch(), after: fx_launch()), arrival: tight_arrival(), - occupancy: OccupancySampled { samples: [OccupancySample { running: 1, waiting: 0, capacity_waiting: 0, preemptions: 0 }] }, + occupancy: OccupancySampled { samples: [OccupancySample { running: 1, waiting: 0, capacity_waiting: 0, preemptions: 0, prompt_tokens: 0 }] }, client_output: ClientOutputTokensUnread { cause: "fixture has no client token total" as NonEmptyStr }, before_at: 100, after_at: 102, @@ -207,7 +206,7 @@ fn fx_obs(ledger: OperationLedger) -> ServingLoadObservation { test fn failed_after_tokens_makes_the_observation_rate_undenominable() -> Bool { match fx_obs(ledger: closed_failed_after_tokens()).rate { RateUndenominable { because: _ } => true - RateFromGenerationTokens { tokens: _, scrape_millis: _ } => false + RateFromClientOutputTokens { tokens: _, scrape_millis: _ } => false RateUnreadable { because: _ } => false } } @@ -215,33 +214,23 @@ test fn failed_after_tokens_makes_the_observation_rate_undenominable() -> Bool { test fn generation_tokens_without_client_completions_is_foreign_load() -> Bool { match derive_rate_honest( ledger: LedgerClosed { offered: 4, completed: 0, failed: 4, failed_after_tokens: 0 }, - continuity: counter_continuity(before: fx_launch(), after: fx_launch()), - generation: TokenDeltaRead { tokens: 128 }, scrape_millis: Present { value: 2000 }, - arrival: tight_arrival(), - occupancy: OccupancySampled { samples: [] }, - max_concurrency: Present { value: 2 }, client_output: ClientOutputTokensUnread { cause: "none" as NonEmptyStr }, ) { RateUnreadable { because: _ } => true - RateFromGenerationTokens { tokens: _, scrape_millis: _ } => false + RateFromClientOutputTokens { tokens: _, scrape_millis: _ } => false RateUndenominable { because: _ } => false } } -test fn occupancy_above_declared_concurrency_refuses_the_rate() -> Bool { +test fn occupancy_above_declared_concurrency_does_not_refuse_the_client_rate() -> Bool { match derive_rate_honest( ledger: closed_ok(), - continuity: counter_continuity(before: fx_launch(), after: fx_launch()), - generation: TokenDeltaRead { tokens: 128 }, scrape_millis: Present { value: 2000 }, - arrival: tight_arrival(), - occupancy: OccupancySampled { samples: [OccupancySample { running: 5, waiting: 0, capacity_waiting: 0, preemptions: 0 }] }, - max_concurrency: Present { value: 2 }, client_output: ClientOutputTokensObserved { tokens: 128 }, ) { - RateUnreadable { because: _ } => true - RateFromGenerationTokens { tokens: _, scrape_millis: _ } => false + RateFromClientOutputTokens { tokens: t, scrape_millis: _ } => t == 128 + RateUnreadable { because: _ } => false RateUndenominable { because: _ } => false } } @@ -249,50 +238,40 @@ test fn occupancy_above_declared_concurrency_refuses_the_rate() -> Bool { test fn unread_client_output_tokens_refuse_the_rate() -> Bool { match derive_rate_honest( ledger: closed_ok(), - continuity: counter_continuity(before: fx_launch(), after: fx_launch()), - generation: TokenDeltaRead { tokens: 128 }, scrape_millis: Present { value: 2000 }, - arrival: tight_arrival(), - occupancy: OccupancySampled { samples: [OccupancySample { running: 1, waiting: 0, capacity_waiting: 0, preemptions: 0 }] }, - max_concurrency: Present { value: 2 }, client_output: ClientOutputTokensUnread { cause: "bench stdout not parsed" as NonEmptyStr }, ) { RateUnreadable { because: _ } => true - RateFromGenerationTokens { tokens: _, scrape_millis: _ } => false + RateFromClientOutputTokens { tokens: _, scrape_millis: _ } => false RateUndenominable { because: _ } => false } } -test fn extra_engine_tokens_beyond_the_client_ledger_refuse_the_rate() -> Bool { +test fn extra_engine_tokens_bound_foreign_work_and_keep_the_client_rate() -> Bool { match derive_rate_honest( ledger: closed_ok(), - continuity: counter_continuity(before: fx_launch(), after: fx_launch()), - generation: TokenDeltaRead { tokens: 200 }, scrape_millis: Present { value: 2000 }, - arrival: tight_arrival(), - occupancy: OccupancySampled { samples: [OccupancySample { running: 1, waiting: 0, capacity_waiting: 0, preemptions: 0 }] }, - max_concurrency: Present { value: 2 }, client_output: ClientOutputTokensObserved { tokens: 128 }, ) { - RateUnreadable { because: _ } => true - RateFromGenerationTokens { tokens: _, scrape_millis: _ } => false + RateFromClientOutputTokens { tokens: t, scrape_millis: _ } => + t == 128 && + match foreign_work_bound(generation: TokenDeltaRead { tokens: 200 }, client_output: ClientOutputTokensObserved { tokens: 128 }) { + ForeignWorkBounded { engine_generation: g, client_output: c, surplus: s } => g == 200 && c == 128 && s == 72 + ForeignWorkUnread { because: _ } => false + } + RateUnreadable { because: _ } => false RateUndenominable { because: _ } => false } } -test fn unsampled_occupancy_refuses_the_rate() -> Bool { +test fn unsampled_occupancy_does_not_refuse_the_client_rate() -> Bool { match derive_rate_honest( ledger: closed_ok(), - continuity: counter_continuity(before: fx_launch(), after: fx_launch()), - generation: TokenDeltaRead { tokens: 128 }, scrape_millis: Present { value: 2000 }, - arrival: tight_arrival(), - occupancy: OccupancyUnsampled { cause: "blocking bench; no mid-run scrape" as NonEmptyStr }, - max_concurrency: Present { value: 2 }, client_output: ClientOutputTokensObserved { tokens: 128 }, ) { - RateUnreadable { because: _ } => true - RateFromGenerationTokens { tokens: _, scrape_millis: _ } => false + RateFromClientOutputTokens { tokens: t, scrape_millis: _ } => t == 128 + RateUnreadable { because: _ } => false RateUndenominable { because: _ } => false } } @@ -310,7 +289,11 @@ test fn a_long_context_protocol_does_not_mint_an_admission_ceiling() -> Bool { test fn one_run_does_not_decide_saturation() -> Bool { let obs = fx_obs(ledger: closed_ok()) - !saturation_from_one_run(obs: obs) && !observation_rate_is_stored_separately(obs: obs) + !saturation_from_one_run(obs: obs) + && !observation_rate_is_stored_separately(obs: obs) + && match obs.capacity_claim { + CapacityClaimUnavailable { because: _ } => true + } } test fn the_holistic_protocol_does_not_corroborate_the_single_stream_bound() -> Bool { From c574acf826f5e888ffac9c1e35679276cae9d6fd Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Fri, 18 Sep 2026 03:45:07 +0000 Subject: [PATCH 09/43] Carry the contended 256/128 sweep as shared-window client latency, not capacity. Absolute tok/s stay incomparable under operator traffic; elasticity, the TTFT binder from 8 to 16, and the 49 vs 81 ms window-standing specimen are the comparable shape. Co-authored-by: Cursor --- dag/gunbc/spark/serving_load_probe.dag | 244 +++++++++++++++++- .../spark/serving_load_probe_witness_test.dag | 63 +++++ 2 files changed, 299 insertions(+), 8 deletions(-) diff --git a/dag/gunbc/spark/serving_load_probe.dag b/dag/gunbc/spark/serving_load_probe.dag index 71bc67c8d17..c82ce855c1b 100644 --- a/dag/gunbc/spark/serving_load_probe.dag +++ b/dag/gunbc/spark/serving_load_probe.dag @@ -508,7 +508,7 @@ type ClientBenchLatency | ClientBenchLatencyReported { output_throughput_milli_tok_per_s: Nat tpot_milli: Nat - itl_milli: Nat + itl_milli: Nat? ttft_milli: Nat contended: Bool standing: CitedFigureStanding @@ -645,7 +645,11 @@ fn client_latency_text(c: ClientBenchLatency) -> String { join([ "bench-serve throughput_milli_tok_s=", to_string(th), " tpot_ms=", to_string(tpot), - " itl_ms=", to_string(itl), + " itl_ms=", + match itl { + Absent => "unread" + Present { value: n } => to_string(n) + }, " ttft_ms=", to_string(ttft), " contended=", if k { "yes" } else { "no" }, ], "") @@ -809,7 +813,13 @@ data glm_native_engine_tokenizer_path: NonEmptyStr = snapshot_install_path( // WIRING IS PROVEN AT A FEW HUNDRED TOKENS. A 100k-prefix protocol is not a smoke test: it is the // heaviest prefill this arm can construct and it starves operator interactive traffic. SendAllImmediately // is the validated wiring argv; it is not a comparable rate protocol (arrival skew). -data glm_native_smoke_dataset: RandomDatasetSpec = RandomDatasetSpec { +data glm_native_wiring_smoke_dataset: RandomDatasetSpec = RandomDatasetSpec { + input_len: token_count(count: 256), + output_len: token_count(count: 64), + prefix_len: token_count(count: 0), +} + +data glm_native_sweep_dataset: RandomDatasetSpec = RandomDatasetSpec { input_len: token_count(count: 256), output_len: token_count(count: 128), prefix_len: token_count(count: 0), @@ -820,7 +830,7 @@ data glm_native_smoke_protocol: VllmBenchServeRequest = vllm_bench_serve_request base_url: "http://127.0.0.1:30000" as NonEmptyStr, model: glm_native_concurrent_profile.served_alias, tokenizer: glm_native_engine_tokenizer_path, - dataset: glm_native_smoke_dataset, + dataset: glm_native_sweep_dataset, num_prompts: 4, arrival: SendAllImmediately, max_concurrency: Present { value: 2 }, @@ -850,19 +860,237 @@ data glm_native_arm_service: ArmServiceStanding = ArmInService { because: "the operator serves interactive work on this arm; WindowIsolated requires an out-of-service receipt that has not been issued" as NonEmptyStr } -// Client TTFT/TPOT/ITL from vllm bench serve stdout, transcribed from the 2026-09-18 smoke -// (256/64, inf rate, c=2, 4/4 ok). Contended: operator session was in flight. Not a /metrics fold. +data glm_native_wiring_smoke_protocol: VllmBenchServeRequest = vllm_bench_serve_request( + backend: OpenaiChat, + base_url: "http://127.0.0.1:30000" as NonEmptyStr, + model: glm_native_concurrent_profile.served_alias, + tokenizer: glm_native_engine_tokenizer_path, + dataset: glm_native_wiring_smoke_dataset, + num_prompts: 4, + arrival: SendAllImmediately, + max_concurrency: Present { value: 2 }, + ignore_eos: true, +) + +// Client TTFT/TPOT/ITL from vllm bench serve stdout, transcribed from the 2026-09-18 wiring +// smoke (256/64, inf rate, c=2, 4/4 ok). Contended. Not the 256/128 sweep protocol. data glm_native_smoke_client_latency: ClientBenchLatency = ClientBenchLatencyReported { output_throughput_milli_tok_per_s: 17390 tpot_milli: 82 - itl_milli: 82 + itl_milli: Present { value: 82 } ttft_milli: 2185 contended: true standing: TranscribedUncited { - read_obligation: "re-read vllm bench serve stdout for this smoke argv; the 17.39 tok/s / 82.1 ms TPOT / 81.8 ms ITL / 2185 ms TTFT figures were transcribed from calm-bat-65's docker-exec receipt" as NonEmptyStr + read_obligation: "re-read vllm bench serve stdout for the 256-in/64-out wiring argv; the 17.39 tok/s / 82.1 ms TPOT / 81.8 ms ITL / 2185 ms TTFT figures were transcribed from calm-bat-65's docker-exec receipt" as NonEmptyStr + } +} + +data glm_native_contended_sweep_standing: CitedFigureStanding = TranscribedUncited { + read_obligation: "re-read calm-bat-65's vllm bench serve stdout for the 256-in/128-out inf-rate ignore-eos sweep (num-prompts 4×concurrency, min 8) taken while operator long-context traffic shared Group B" as NonEmptyStr +} + +fn glm_native_sweep_num_prompts(concurrency: Nat) -> Nat { + let fourfold = concurrency * 4 + if fourfold < 8 { 8 } else { fourfold } +} + +fn glm_native_contended_sweep_protocol(concurrency: Nat) -> VllmBenchServeRequest { + vllm_bench_serve_request( + backend: OpenaiChat, + base_url: "http://127.0.0.1:30000" as NonEmptyStr, + model: glm_native_concurrent_profile.served_alias, + tokenizer: glm_native_engine_tokenizer_path, + dataset: glm_native_sweep_dataset, + num_prompts: glm_native_sweep_num_prompts(concurrency: concurrency), + arrival: SendAllImmediately, + max_concurrency: Present { value: concurrency }, + ignore_eos: true, + ) +} + +fn glm_native_contended_client_latency( + throughput_milli_tok_per_s: Nat, + tpot_milli: Nat, + ttft_milli: Nat, +) -> ClientBenchLatency { + ClientBenchLatencyReported { + output_throughput_milli_tok_per_s: throughput_milli_tok_per_s, + tpot_milli: tpot_milli, + itl_milli: none, + ttft_milli: ttft_milli, + contended: true, + standing: glm_native_contended_sweep_standing, + } +} + +type ContendedSweepPoint { + concurrency: Nat + protocol: VllmBenchServeRequest + latency: ClientBenchLatency +} + +fn glm_native_contended_sweep_point( + concurrency: Nat, + throughput_milli_tok_per_s: Nat, + tpot_milli: Nat, + ttft_milli: Nat, +) -> ContendedSweepPoint { + ContendedSweepPoint { + concurrency: concurrency, + protocol: glm_native_contended_sweep_protocol(concurrency: concurrency), + latency: glm_native_contended_client_latency( + throughput_milli_tok_per_s: throughput_milli_tok_per_s, + tpot_milli: tpot_milli, + ttft_milli: ttft_milli, + ), + } +} + +data glm_native_contended_sweep_c1: ContendedSweepPoint = glm_native_contended_sweep_point( + concurrency: 1, throughput_milli_tok_per_s: 10860, tpot_milli: 81, ttft_milli: 1542, +) +data glm_native_contended_sweep_c2: ContendedSweepPoint = glm_native_contended_sweep_point( + concurrency: 2, throughput_milli_tok_per_s: 17220, tpot_milli: 109, ttft_milli: 994, +) +data glm_native_contended_sweep_c4: ContendedSweepPoint = glm_native_contended_sweep_point( + concurrency: 4, throughput_milli_tok_per_s: 25490, tpot_milli: 140, ttft_milli: 2353, +) +data glm_native_contended_sweep_c8: ContendedSweepPoint = glm_native_contended_sweep_point( + concurrency: 8, throughput_milli_tok_per_s: 38360, tpot_milli: 190, ttft_milli: 2602, +) +data glm_native_contended_sweep_c16: ContendedSweepPoint = glm_native_contended_sweep_point( + concurrency: 16, throughput_milli_tok_per_s: 62530, tpot_milli: 198, ttft_milli: 5218, +) + +data glm_native_contended_sweep_points: List = [ + glm_native_contended_sweep_c1, + glm_native_contended_sweep_c2, + glm_native_contended_sweep_c4, + glm_native_contended_sweep_c8, + glm_native_contended_sweep_c16, +] + +// ABSOLUTE tok/s ARE NOT A CAPACITY under WindowSharedWithDeclaredTraffic. Elasticity +// log(throughput ratio)/log(concurrency ratio) is a SHAPE: contention scales both ends and does +// not by itself invent a plateau. These milli figures are transcribed from that log ratio on the +// five points above; they are not stored rates. +type ScalingElasticityStep { + from_concurrency: Nat + to_concurrency: Nat + elasticity_milli: Nat + standing: CitedFigureStanding +} + +data glm_native_elasticity_standing: CitedFigureStanding = TranscribedUncited { + read_obligation: "recompute log(throughput_after/throughput_before)/log(concurrency_after/concurrency_before) from glm_native_contended_sweep_points; the 670/570/590/700 milli figures were transcribed from calm-bat-65's 0.67, 0.57, 0.59, 0.70" as NonEmptyStr +} + +fn glm_native_elasticity_step(from_concurrency: Nat, to_concurrency: Nat, elasticity_milli: Nat) -> ScalingElasticityStep { + ScalingElasticityStep { + from_concurrency: from_concurrency, + to_concurrency: to_concurrency, + elasticity_milli: elasticity_milli, + standing: glm_native_elasticity_standing, + } +} + +data glm_native_elasticity_1_to_2: ScalingElasticityStep = glm_native_elasticity_step(from_concurrency: 1, to_concurrency: 2, elasticity_milli: 670) +data glm_native_elasticity_2_to_4: ScalingElasticityStep = glm_native_elasticity_step(from_concurrency: 2, to_concurrency: 4, elasticity_milli: 570) +data glm_native_elasticity_4_to_8: ScalingElasticityStep = glm_native_elasticity_step(from_concurrency: 4, to_concurrency: 8, elasticity_milli: 590) +data glm_native_elasticity_8_to_16: ScalingElasticityStep = glm_native_elasticity_step(from_concurrency: 8, to_concurrency: 16, elasticity_milli: 700) + +data glm_native_contended_elasticity_steps: List = [ + glm_native_elasticity_1_to_2, + glm_native_elasticity_2_to_4, + glm_native_elasticity_4_to_8, + glm_native_elasticity_8_to_16, +] + +fn elasticity_still_buying_throughput(steps: List) -> Bool { + length(steps) == 4 + && glm_native_elasticity_1_to_2.elasticity_milli > 0 + && glm_native_elasticity_2_to_4.elasticity_milli > 0 + && glm_native_elasticity_4_to_8.elasticity_milli > 0 + && glm_native_elasticity_8_to_16.elasticity_milli > 0 + && glm_native_elasticity_8_to_16.elasticity_milli >= glm_native_elasticity_1_to_2.elasticity_milli + && glm_native_elasticity_8_to_16.elasticity_milli >= glm_native_elasticity_2_to_4.elasticity_milli + && glm_native_elasticity_8_to_16.elasticity_milli >= glm_native_elasticity_4_to_8.elasticity_milli +} + +// TPOT 8→16 is nearly flat while throughput still rises; TTFT at 16 is the sharp move. +// This is not a realization selection and not a capacity claim. It is the observation that a +// latency floor, if one entered policy, would bind on TTFT here rather than on throughput. +type ContendedLatencyFloorHint + = TtftWouldBindConcurrency { + from_concurrency: Nat + to_concurrency: Nat + tpot_rise_milli_percent: Nat + throughput_rise_milli_percent: Nat + ttft_from_milli: Nat + ttft_to_milli: Nat + standing: CitedFigureStanding + } + +data glm_native_ttft_binds_concurrency: ContendedLatencyFloorHint = TtftWouldBindConcurrency { + from_concurrency: 8 + to_concurrency: 16 + tpot_rise_milli_percent: 45 + throughput_rise_milli_percent: 630 + ttft_from_milli: 2602 + ttft_to_milli: 5218 + standing: TranscribedUncited { + read_obligation: "re-read glm_native_contended_sweep_c8 and glm_native_contended_sweep_c16 for TPOT 189.6→198.2 ms (+4.5%) and throughput 38.36→62.53 tok/s (+63%) with TTFT 2602→5218 ms" as NonEmptyStr } } +// Same subject, same single-stream protocol shape, different window: quieter engine 48.9 ms vs +// contended client c=1 TPOT 80.7 ms. The gap is the operator's traffic. Window standing is a field. +type WindowStandingGapSpecimen { + quieter_engine_tpot_milli: Nat + contended_client_c1_tpot_milli: Nat +} + +data glm_native_window_standing_specimen: WindowStandingGapSpecimen = WindowStandingGapSpecimen { + quieter_engine_tpot_milli: glm_native_single_stream_decode_bound_millis, + contended_client_c1_tpot_milli: 81, +} + +fn window_standing_gap_is_operator_traffic(s: WindowStandingGapSpecimen) -> Bool { + s.contended_client_c1_tpot_milli > s.quieter_engine_tpot_milli +} + +fn bench_output_len(req: VllmBenchServeRequest) -> Nat { + token_count_value(t: req.dataset.output_len) +} + +fn pinned_load_protocol_matches(a: VllmBenchServeRequest, b: VllmBenchServeRequest) -> Bool { + token_count_value(t: a.dataset.input_len) == token_count_value(t: b.dataset.input_len) + && bench_output_len(req: a) == bench_output_len(req: b) + && token_count_value(t: a.dataset.prefix_len) == token_count_value(t: b.dataset.prefix_len) + && a.ignore_eos == b.ignore_eos + && a.num_prompts == b.num_prompts + && match a.max_concurrency { + Absent => + match b.max_concurrency { + Absent => true + Present { value: _ } => false + } + Present { value: ac } => + match b.max_concurrency { + Absent => false + Present { value: bc } => ac == bc + } + } +} + +type LongContextExecutionStanding + = LongContextModelledOnly { until: NonEmptyStr } + | LongContextRunnable { because: NonEmptyStr } + +data glm_native_holistic_execution: LongContextExecutionStanding = LongContextModelledOnly { + until: "the arm carries an ArmOutOfService receipt; a 100k-prefix protocol is not executed on an in-service operator arm" as NonEmptyStr +} + // TRANSCRIBED BOUND, NOT A READING. Parent derived ~10.7 GB active weights / ~9-11 ms memory-bandwidth // floor from the checkpoint config (45 layers, hidden 4096, 288 routed experts, top-8 + 1 shared, fp8) // and measured 48.9 ms single-stream. Until those config rows are cited, the 49 ms figure stays diff --git a/dag/test/claim/spark/serving_load_probe_witness_test.dag b/dag/test/claim/spark/serving_load_probe_witness_test.dag index d036a408af0..492c5e230c9 100644 --- a/dag/test/claim/spark/serving_load_probe_witness_test.dag +++ b/dag/test/claim/spark/serving_load_probe_witness_test.dag @@ -47,6 +47,14 @@ import gunbc.spark.serving_load_probe { glm_native_smoke_protocol, glm_native_smoke_client_latency, glm_native_arm_service, decode_corroboration_for_protocol, CorroborationNotApplicable, CorroborationUnread, + glm_native_wiring_smoke_protocol, glm_native_contended_sweep_c1, glm_native_contended_sweep_c2, + glm_native_contended_sweep_c16, glm_native_contended_sweep_points, + glm_native_contended_elasticity_steps, elasticity_still_buying_throughput, + glm_native_ttft_binds_concurrency, TtftWouldBindConcurrency, + glm_native_window_standing_specimen, window_standing_gap_is_operator_traffic, + pinned_load_protocol_matches, bench_output_len, glm_native_sweep_num_prompts, + glm_native_holistic_execution, LongContextModelledOnly, LongContextRunnable, + glm_native_elasticity_8_to_16, } data start_field: NonEmptyStr = "1789300000.12" as NonEmptyStr @@ -318,6 +326,61 @@ test fn the_smoke_protocol_is_not_the_holistic_envelope() -> Bool { } } +test fn a_64_out_wiring_receipt_is_not_the_128_out_sweep_protocol() -> Bool { + bench_output_len(req: glm_native_wiring_smoke_protocol) == 64 + && bench_output_len(req: glm_native_contended_sweep_c2.protocol) == 128 + && !pinned_load_protocol_matches(a: glm_native_wiring_smoke_protocol, b: glm_native_contended_sweep_c2.protocol) +} + +test fn the_contended_sweep_is_five_shared_window_client_points() -> Bool { + length(glm_native_contended_sweep_points) == 5 + && glm_native_sweep_num_prompts(concurrency: 1) == 8 + && glm_native_sweep_num_prompts(concurrency: 2) == 8 + && glm_native_sweep_num_prompts(concurrency: 4) == 16 + && match glm_native_contended_sweep_c1.latency { + ClientBenchLatencyReported { output_throughput_milli_tok_per_s: th, tpot_milli: tpot, itl_milli: _, ttft_milli: ttft, contended: k, standing: _ } => + k && th == 10860 && tpot == 81 && ttft == 1542 && glm_native_contended_sweep_c1.concurrency == 1 + ClientBenchLatencyUnread { cause: _ } => false + } +} + +test fn scaling_elasticity_is_a_shape_still_buying_at_16() -> Bool { + elasticity_still_buying_throughput(steps: glm_native_contended_elasticity_steps) + && glm_native_elasticity_8_to_16.elasticity_milli == 700 +} + +test fn ttft_would_bind_concurrency_before_throughput_on_this_sweep() -> Bool { + match glm_native_ttft_binds_concurrency { + TtftWouldBindConcurrency { + from_concurrency: a, + to_concurrency: b, + tpot_rise_milli_percent: tpot, + throughput_rise_milli_percent: thr, + ttft_from_milli: _, + ttft_to_milli: ttft, + standing: _, + } => + a == 8 && b == 16 && tpot == 45 && thr == 630 && ttft == 5218 + && match glm_native_contended_sweep_c16.latency { + ClientBenchLatencyReported { output_throughput_milli_tok_per_s: _, tpot_milli: _, itl_milli: _, ttft_milli: t, contended: _, standing: _ } => t == 5218 + ClientBenchLatencyUnread { cause: _ } => false + } + } +} + +test fn the_49_vs_81_ms_gap_is_why_window_standing_is_a_field() -> Bool { + glm_native_window_standing_specimen.quieter_engine_tpot_milli == 49 + && glm_native_window_standing_specimen.contended_client_c1_tpot_milli == 81 + && window_standing_gap_is_operator_traffic(s: glm_native_window_standing_specimen) +} + +test fn long_context_stays_modelled_until_the_arm_is_out_of_service() -> Bool { + match glm_native_holistic_execution { + LongContextModelledOnly { until: _ } => true + LongContextRunnable { because: _ } => false + } +} + test fn the_holistic_protocol_is_poisson_with_session_context_and_prefix() -> Bool { holistic_protocol_is_session_shaped(req: glm_native_holistic_protocol) && vllm_bench_serve_uses_poisson_idle_gaps(req: glm_native_holistic_protocol) From 3411e20addcae3d399006ff1b4c6df4e866c1521 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Fri, 18 Sep 2026 03:53:58 +0000 Subject: [PATCH 10/43] Fold the shared-window 256/128 smoke as client output rate, ITL tail, and peak concurrency. ITL P99 doubling the median and engine peak 4 against a client cap of 2 are contention specimens, not capacity; total tok/s includes prefill and is not the probe rate. Co-authored-by: Cursor --- dag/gunbc/spark/serving_load_probe.dag | 96 ++++++++++++++++++- .../spark/serving_load_probe_witness_test.dag | 51 ++++++++++ 2 files changed, 145 insertions(+), 2 deletions(-) diff --git a/dag/gunbc/spark/serving_load_probe.dag b/dag/gunbc/spark/serving_load_probe.dag index c82ce855c1b..2d0cd6592e0 100644 --- a/dag/gunbc/spark/serving_load_probe.dag +++ b/dag/gunbc/spark/serving_load_probe.dag @@ -771,9 +771,9 @@ fn rate_text(r: DerivedRate) -> String { RateUnreadable { because: c } => join(["unreadable ", c as String], "") RateFromClientOutputTokens { tokens: t, scrape_millis: ms } => join([ - "generation_tokens=", to_string(t), + "completed_output_tokens=", to_string(t), " scrape_millis=", to_string(ms), - " tokens_per_s=", + " output_tokens_per_s=", match tokens_per_observation_second(r: r) { Absent => "none" Present { value: v } => to_string(v) @@ -885,6 +885,98 @@ data glm_native_smoke_client_latency: ClientBenchLatency = ClientBenchLatencyRep } } +data glm_native_wet_smoke_standing: CitedFigureStanding = TranscribedUncited { + read_obligation: "re-read calm-bat-65 docker-exec stdout for glm_native_smoke_protocol (256-in/128-out/prefix 0/4 prompts/inf/c=2/ignore-eos) on 192.168.1.236 under WindowSharedWithDeclaredTraffic" as NonEmptyStr +} + +data glm_native_wet_smoke_client_latency: ClientBenchLatency = ClientBenchLatencyReported { + output_throughput_milli_tok_per_s: 22510 + tpot_milli: 82 + itl_milli: Present { value: 83 } + ttft_milli: 996 + contended: true + standing: glm_native_wet_smoke_standing +} + +type ClientItlTail + = ItlTailUnread { cause: NonEmptyStr } + | ItlMeanMedianP99 { mean_milli: Nat, median_milli: Nat, p99_milli: Nat } + +data glm_native_wet_smoke_itl: ClientItlTail = ItlMeanMedianP99 { + mean_milli: 83 + median_milli: 82 + p99_milli: 165 +} + +fn itl_p99_is_contention_tail(t: ClientItlTail) -> Bool { + match t { + ItlTailUnread { cause: _ } => false + ItlMeanMedianP99 { mean_milli: _, median_milli: med, p99_milli: p99 } => + p99 >= (med * 2) + } +} + +type PeakConcurrencyReceipt + = PeakConcurrencyUnread { cause: NonEmptyStr } + | PeakConcurrencyObserved { client_max_concurrency: Nat, engine_peak_concurrent_requests: Nat } + +data glm_native_wet_smoke_peak_concurrency: PeakConcurrencyReceipt = PeakConcurrencyObserved { + client_max_concurrency: 2 + engine_peak_concurrent_requests: 4 +} + +fn foreign_in_flight_at_peak(p: PeakConcurrencyReceipt) -> Nat? { + match p { + PeakConcurrencyUnread { cause: _ } => none + PeakConcurrencyObserved { client_max_concurrency: c, engine_peak_concurrent_requests: e } => + if e > c { Present { value: e - c } } else { Present { value: 0 } } + } +} + +fn peak_concurrency_proves_shared_window(p: PeakConcurrencyReceipt) -> Bool { + match foreign_in_flight_at_peak(p: p) { + Absent => false + Present { value: n } => n > 0 + } +} + +type RateTokenDenomination + = RateDenominatedInCompletedOutputTokens { because: NonEmptyStr } + | RateDenominatedInTotalTokensIncludingPrefill { because: NonEmptyStr } + +data glm_native_client_rate_denomination: RateTokenDenomination = RateDenominatedInCompletedOutputTokens { + because: "vllm bench serve output token throughput and the probe rate both count completed decode tokens; total token throughput also counts prefill of the same requests and is a different question" as NonEmptyStr +} + +type PrefillVersusDecodeThroughput { + output_milli_tok_per_s: Nat + total_milli_tok_per_s: Nat + input_tokens: Nat + output_tokens: Nat +} + +data glm_native_wet_smoke_prefill_versus_decode: PrefillVersusDecodeThroughput = PrefillVersusDecodeThroughput { + output_milli_tok_per_s: 22510 + total_milli_tok_per_s: 69640 + input_tokens: 1072 + output_tokens: 512 +} + +fn total_token_throughput_is_not_the_probe_rate(r: PrefillVersusDecodeThroughput) -> Bool { + r.total_milli_tok_per_s != r.output_milli_tok_per_s +} + +data glm_native_wet_smoke_client_output: ClientOutputTokens = ClientOutputTokensObserved { tokens: 512 } +data glm_native_wet_smoke_duration_millis: Nat = 22750 + +fn glm_native_wet_smoke_rate() -> DerivedRate { + derive_rate_honest( + ledger: LedgerClosed { offered: 4, completed: 4, failed: 0, failed_after_tokens: 0 }, + scrape_millis: Present { value: glm_native_wet_smoke_duration_millis }, + client_output: glm_native_wet_smoke_client_output, + ) +} + data glm_native_contended_sweep_standing: CitedFigureStanding = TranscribedUncited { read_obligation: "re-read calm-bat-65's vllm bench serve stdout for the 256-in/128-out inf-rate ignore-eos sweep (num-prompts 4×concurrency, min 8) taken while operator long-context traffic shared Group B" as NonEmptyStr } diff --git a/dag/test/claim/spark/serving_load_probe_witness_test.dag b/dag/test/claim/spark/serving_load_probe_witness_test.dag index 492c5e230c9..bd4a932f138 100644 --- a/dag/test/claim/spark/serving_load_probe_witness_test.dag +++ b/dag/test/claim/spark/serving_load_probe_witness_test.dag @@ -55,6 +55,13 @@ import gunbc.spark.serving_load_probe { pinned_load_protocol_matches, bench_output_len, glm_native_sweep_num_prompts, glm_native_holistic_execution, LongContextModelledOnly, LongContextRunnable, glm_native_elasticity_8_to_16, + glm_native_wet_smoke_client_latency, glm_native_wet_smoke_itl, ItlMeanMedianP99, ItlTailUnread, + itl_p99_is_contention_tail, glm_native_wet_smoke_peak_concurrency, PeakConcurrencyObserved, PeakConcurrencyUnread, + peak_concurrency_proves_shared_window, foreign_in_flight_at_peak, + glm_native_client_rate_denomination, RateDenominatedInCompletedOutputTokens, + RateDenominatedInTotalTokensIncludingPrefill, + glm_native_wet_smoke_prefill_versus_decode, total_token_throughput_is_not_the_probe_rate, + glm_native_wet_smoke_rate, glm_native_wet_smoke_client_output, } data start_field: NonEmptyStr = "1789300000.12" as NonEmptyStr @@ -332,6 +339,50 @@ test fn a_64_out_wiring_receipt_is_not_the_128_out_sweep_protocol() -> Bool { && !pinned_load_protocol_matches(a: glm_native_wiring_smoke_protocol, b: glm_native_contended_sweep_c2.protocol) } +test fn wet_smoke_itl_p99_is_the_contention_tail() -> Bool { + match glm_native_wet_smoke_itl { + ItlMeanMedianP99 { mean_milli: mean, median_milli: med, p99_milli: p99 } => + mean == 83 && med == 82 && p99 == 165 && itl_p99_is_contention_tail(t: glm_native_wet_smoke_itl) + ItlTailUnread { cause: _ } => false + } +} + +test fn peak_concurrency_above_the_client_cap_proves_a_shared_window() -> Bool { + match glm_native_wet_smoke_peak_concurrency { + PeakConcurrencyObserved { client_max_concurrency: c, engine_peak_concurrent_requests: e } => + c == 2 && e == 4 && peak_concurrency_proves_shared_window(p: glm_native_wet_smoke_peak_concurrency) + && match foreign_in_flight_at_peak(p: glm_native_wet_smoke_peak_concurrency) { + Absent => false + Present { value: n } => n == 2 + } + PeakConcurrencyUnread { cause: _ } => false + } +} + +test fn wet_smoke_tpot_is_not_a_protocol_match_to_sweep_c1() -> Bool { + !pinned_load_protocol_matches(a: glm_native_smoke_protocol, b: glm_native_contended_sweep_c1.protocol) + && match glm_native_wet_smoke_client_latency { + ClientBenchLatencyReported { output_throughput_milli_tok_per_s: th, tpot_milli: tpot, itl_milli: _, ttft_milli: _, contended: k, standing: _ } => + k && th == 22510 && tpot == 82 + ClientBenchLatencyUnread { cause: _ } => false + } +} + +test fn the_probe_rate_is_completed_output_tokens_not_total_including_prefill() -> Bool { + match glm_native_client_rate_denomination { + RateDenominatedInCompletedOutputTokens { because: _ } => + total_token_throughput_is_not_the_probe_rate(r: glm_native_wet_smoke_prefill_versus_decode) + && glm_native_wet_smoke_prefill_versus_decode.output_tokens == 512 + && glm_native_wet_smoke_prefill_versus_decode.input_tokens == 1072 + && match glm_native_wet_smoke_rate() { + RateFromClientOutputTokens { tokens: t, scrape_millis: ms } => t == 512 && ms == 22750 + RateUndenominable { because: _ } => false + RateUnreadable { because: _ } => false + } + RateDenominatedInTotalTokensIncludingPrefill { because: _ } => false + } +} + test fn the_contended_sweep_is_five_shared_window_client_points() -> Bool { length(glm_native_contended_sweep_points) == 5 && glm_native_sweep_num_prompts(concurrency: 1) == 8 From 4b45d0ee0f1ee26da930b4d51f278d22c2d5ad69 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Fri, 18 Sep 2026 04:07:47 +0000 Subject: [PATCH 11/43] Fix heads-only parse of the serving-load witness and name the live image. Nested match arms in the witness left an unterminated function body at module index; the live subject now cites the nope-derived registry reading. Co-authored-by: Cursor --- dag/gunbc/spark/serving_load_probe.dag | 55 +++++++++++++++- .../spark/serving_load_probe_witness_test.dag | 64 +++---------------- 2 files changed, 62 insertions(+), 57 deletions(-) diff --git a/dag/gunbc/spark/serving_load_probe.dag b/dag/gunbc/spark/serving_load_probe.dag index 2d0cd6592e0..bc20e80edb4 100644 --- a/dag/gunbc/spark/serving_load_probe.dag +++ b/dag/gunbc/spark/serving_load_probe.dag @@ -41,6 +41,8 @@ import gunbc.spark.serving_performance_subject { ServingPerformanceSubject, serving_performance_subject, serving_subject_standing, ServingPerformanceSubjectStanding, SubjectEstablished, SubjectPartial, } +import gunbc.spark.runtime_architecture_registry_reading { glm53_nope_derived_registry_reading } +import extdeps.vllm.engine_args { KvFp8, SpeculativeDecodingOff } import extdeps.vllm.kv_layout { AdmissionCost, AdmissionCostUnestablished, AdmissionCostBlocks } import extdeps.external_authority { CitedFigureStanding, TranscribedUncited } @@ -977,6 +979,42 @@ fn glm_native_wet_smoke_rate() -> DerivedRate { ) } +fn glm_native_wet_smoke_itl_is_contention_tail_receipt() -> Bool { + itl_p99_is_contention_tail(t: glm_native_wet_smoke_itl) + && match glm_native_wet_smoke_itl { + ItlTailUnread { cause: _ } => false + ItlMeanMedianP99 { mean_milli: mean_m, median_milli: med, p99_milli: p99 } => + mean_m == 83 && med == 82 && p99 == 165 + } +} + +fn glm_native_wet_smoke_peak_proves_shared_window() -> Bool { + peak_concurrency_proves_shared_window(p: glm_native_wet_smoke_peak_concurrency) + && match foreign_in_flight_at_peak(p: glm_native_wet_smoke_peak_concurrency) { + Absent => false + Present { value: n } => n == 2 + } +} + +fn glm_native_wet_smoke_is_not_sweep_c1_protocol() -> Bool { + !pinned_load_protocol_matches(a: glm_native_smoke_protocol, b: glm_native_contended_sweep_c1.protocol) +} + +fn glm_native_wet_smoke_rate_is_output_tokens() -> Bool { + match glm_native_client_rate_denomination { + RateDenominatedInTotalTokensIncludingPrefill { because: _ } => false + RateDenominatedInCompletedOutputTokens { because: _ } => + total_token_throughput_is_not_the_probe_rate(r: glm_native_wet_smoke_prefill_versus_decode) + && glm_native_wet_smoke_prefill_versus_decode.output_tokens == 512 + && glm_native_wet_smoke_prefill_versus_decode.input_tokens == 1072 + && match glm_native_wet_smoke_rate() { + RateFromClientOutputTokens { tokens: t, scrape_millis: ms } => t == 512 && ms == 22750 + RateUndenominable { because: _ } => false + RateUnreadable { because: _ } => false + } + } +} + data glm_native_contended_sweep_standing: CitedFigureStanding = TranscribedUncited { read_obligation: "re-read calm-bat-65's vllm bench serve stdout for the 256-in/128-out inf-rate ignore-eos sweep (num-prompts 4×concurrency, min 8) taken while operator long-context traffic shared Group B" as NonEmptyStr } @@ -1123,6 +1161,21 @@ type ContendedLatencyFloorHint standing: CitedFigureStanding } +fn glm_native_ttft_would_bind_on_this_sweep() -> Bool { + match glm_native_ttft_binds_concurrency { + TtftWouldBindConcurrency { + from_concurrency: a, + to_concurrency: b, + tpot_rise_milli_percent: tpot, + throughput_rise_milli_percent: thr, + ttft_from_milli: _, + ttft_to_milli: ttft, + standing: _, + } => + a == 8 && b == 16 && tpot == 45 && thr == 630 && ttft == 5218 + } +} + data glm_native_ttft_binds_concurrency: ContendedLatencyFloorHint = TtftWouldBindConcurrency { from_concurrency: 8 to_concurrency: 16 @@ -1197,7 +1250,7 @@ data glm_native_live_subject: ServingPerformanceSubject = serving_performance_su checkpoint: Glm53NativeFp8, checkpoint_revision: none, runtime: GunbcGlm53NopeDerivedGb10, - runtime_image_reference: glm_native_live_image_reference, + runtime_image_reference: glm53_nope_derived_registry_reading.image_reference, topology: Present { value: FourSparkTp4 }, rank_population: Present { value: 4 }, context_ceiling: Present { value: glm_native_concurrent_profile.max_model_len }, diff --git a/dag/test/claim/spark/serving_load_probe_witness_test.dag b/dag/test/claim/spark/serving_load_probe_witness_test.dag index bd4a932f138..961f178f034 100644 --- a/dag/test/claim/spark/serving_load_probe_witness_test.dag +++ b/dag/test/claim/spark/serving_load_probe_witness_test.dag @@ -50,18 +50,13 @@ import gunbc.spark.serving_load_probe { glm_native_wiring_smoke_protocol, glm_native_contended_sweep_c1, glm_native_contended_sweep_c2, glm_native_contended_sweep_c16, glm_native_contended_sweep_points, glm_native_contended_elasticity_steps, elasticity_still_buying_throughput, - glm_native_ttft_binds_concurrency, TtftWouldBindConcurrency, + glm_native_wet_smoke_itl_is_contention_tail_receipt, glm_native_wet_smoke_peak_proves_shared_window, + glm_native_wet_smoke_is_not_sweep_c1_protocol, glm_native_wet_smoke_rate_is_output_tokens, + glm_native_ttft_would_bind_on_this_sweep, glm_native_window_standing_specimen, window_standing_gap_is_operator_traffic, pinned_load_protocol_matches, bench_output_len, glm_native_sweep_num_prompts, glm_native_holistic_execution, LongContextModelledOnly, LongContextRunnable, glm_native_elasticity_8_to_16, - glm_native_wet_smoke_client_latency, glm_native_wet_smoke_itl, ItlMeanMedianP99, ItlTailUnread, - itl_p99_is_contention_tail, glm_native_wet_smoke_peak_concurrency, PeakConcurrencyObserved, PeakConcurrencyUnread, - peak_concurrency_proves_shared_window, foreign_in_flight_at_peak, - glm_native_client_rate_denomination, RateDenominatedInCompletedOutputTokens, - RateDenominatedInTotalTokensIncludingPrefill, - glm_native_wet_smoke_prefill_versus_decode, total_token_throughput_is_not_the_probe_rate, - glm_native_wet_smoke_rate, glm_native_wet_smoke_client_output, } data start_field: NonEmptyStr = "1789300000.12" as NonEmptyStr @@ -340,47 +335,19 @@ test fn a_64_out_wiring_receipt_is_not_the_128_out_sweep_protocol() -> Bool { } test fn wet_smoke_itl_p99_is_the_contention_tail() -> Bool { - match glm_native_wet_smoke_itl { - ItlMeanMedianP99 { mean_milli: mean, median_milli: med, p99_milli: p99 } => - mean == 83 && med == 82 && p99 == 165 && itl_p99_is_contention_tail(t: glm_native_wet_smoke_itl) - ItlTailUnread { cause: _ } => false - } + glm_native_wet_smoke_itl_is_contention_tail_receipt() } test fn peak_concurrency_above_the_client_cap_proves_a_shared_window() -> Bool { - match glm_native_wet_smoke_peak_concurrency { - PeakConcurrencyObserved { client_max_concurrency: c, engine_peak_concurrent_requests: e } => - c == 2 && e == 4 && peak_concurrency_proves_shared_window(p: glm_native_wet_smoke_peak_concurrency) - && match foreign_in_flight_at_peak(p: glm_native_wet_smoke_peak_concurrency) { - Absent => false - Present { value: n } => n == 2 - } - PeakConcurrencyUnread { cause: _ } => false - } + glm_native_wet_smoke_peak_proves_shared_window() } test fn wet_smoke_tpot_is_not_a_protocol_match_to_sweep_c1() -> Bool { - !pinned_load_protocol_matches(a: glm_native_smoke_protocol, b: glm_native_contended_sweep_c1.protocol) - && match glm_native_wet_smoke_client_latency { - ClientBenchLatencyReported { output_throughput_milli_tok_per_s: th, tpot_milli: tpot, itl_milli: _, ttft_milli: _, contended: k, standing: _ } => - k && th == 22510 && tpot == 82 - ClientBenchLatencyUnread { cause: _ } => false - } + glm_native_wet_smoke_is_not_sweep_c1_protocol() } test fn the_probe_rate_is_completed_output_tokens_not_total_including_prefill() -> Bool { - match glm_native_client_rate_denomination { - RateDenominatedInCompletedOutputTokens { because: _ } => - total_token_throughput_is_not_the_probe_rate(r: glm_native_wet_smoke_prefill_versus_decode) - && glm_native_wet_smoke_prefill_versus_decode.output_tokens == 512 - && glm_native_wet_smoke_prefill_versus_decode.input_tokens == 1072 - && match glm_native_wet_smoke_rate() { - RateFromClientOutputTokens { tokens: t, scrape_millis: ms } => t == 512 && ms == 22750 - RateUndenominable { because: _ } => false - RateUnreadable { because: _ } => false - } - RateDenominatedInTotalTokensIncludingPrefill { because: _ } => false - } + glm_native_wet_smoke_rate_is_output_tokens() } test fn the_contended_sweep_is_five_shared_window_client_points() -> Bool { @@ -401,22 +368,7 @@ test fn scaling_elasticity_is_a_shape_still_buying_at_16() -> Bool { } test fn ttft_would_bind_concurrency_before_throughput_on_this_sweep() -> Bool { - match glm_native_ttft_binds_concurrency { - TtftWouldBindConcurrency { - from_concurrency: a, - to_concurrency: b, - tpot_rise_milli_percent: tpot, - throughput_rise_milli_percent: thr, - ttft_from_milli: _, - ttft_to_milli: ttft, - standing: _, - } => - a == 8 && b == 16 && tpot == 45 && thr == 630 && ttft == 5218 - && match glm_native_contended_sweep_c16.latency { - ClientBenchLatencyReported { output_throughput_milli_tok_per_s: _, tpot_milli: _, itl_milli: _, ttft_milli: t, contended: _, standing: _ } => t == 5218 - ClientBenchLatencyUnread { cause: _ } => false - } - } + glm_native_ttft_would_bind_on_this_sweep() } test fn the_49_vs_81_ms_gap_is_why_window_standing_is_a_field() -> Bool { From 1b1d3a89dea0c405b86a7aa42fef8b35b07ad720 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Fri, 18 Sep 2026 04:21:45 +0000 Subject: [PATCH 12/43] Stop prometheus label braces from opening string interpolation in the witness. Heads-only parse treats {ident as interpolation, so those braces never closed the metrics_body function and the module index refused the file. Co-authored-by: Cursor --- .../spark/serving_load_probe_witness_test.dag | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/dag/test/claim/spark/serving_load_probe_witness_test.dag b/dag/test/claim/spark/serving_load_probe_witness_test.dag index 961f178f034..981c78b9c1c 100644 --- a/dag/test/claim/spark/serving_load_probe_witness_test.dag +++ b/dag/test/claim/spark/serving_load_probe_witness_test.dag @@ -70,16 +70,16 @@ fn fx_launch() -> VllmEndpointProcessLaunchObservation { fn metrics_body(running: String, waiting: String, capacity: String, preempt: String, itl_sum: String, itl_count: String, itok_sum: String, itok_count: String, gen: String, start: String) -> String { join([ - "vllm:num_requests_waiting{model_name=\"glm\"} ", waiting, "\n", - "vllm:num_requests_running{model_name=\"glm\"} ", running, "\n", - "vllm:num_requests_waiting_by_reason{model_name=\"glm\",reason=\"capacity\"} ", capacity, "\n", - "vllm:num_preemptions_total{model_name=\"glm\"} ", preempt, "\n", - "vllm:prompt_tokens_total{model_name=\"glm\"} 0.0\n", - "vllm:generation_tokens_total{model_name=\"glm\"} ", gen, "\n", - "vllm:inter_token_latency_seconds_sum{model_name=\"glm\"} ", itl_sum, "\n", - "vllm:inter_token_latency_seconds_count{model_name=\"glm\"} ", itl_count, "\n", - "vllm:iteration_tokens_total_sum{model_name=\"glm\"} ", itok_sum, "\n", - "vllm:iteration_tokens_total_count{model_name=\"glm\"} ", itok_count, "\n", + "vllm:num_requests_waiting{", "model_name=\"glm\"} ", waiting, "\n", + "vllm:num_requests_running{", "model_name=\"glm\"} ", running, "\n", + "vllm:num_requests_waiting_by_reason{", "model_name=\"glm\",reason=\"capacity\"} ", capacity, "\n", + "vllm:num_preemptions_total{", "model_name=\"glm\"} ", preempt, "\n", + "vllm:prompt_tokens_total{", "model_name=\"glm\"} 0.0\n", + "vllm:generation_tokens_total{", "model_name=\"glm\"} ", gen, "\n", + "vllm:inter_token_latency_seconds_sum{", "model_name=\"glm\"} ", itl_sum, "\n", + "vllm:inter_token_latency_seconds_count{", "model_name=\"glm\"} ", itl_count, "\n", + "vllm:iteration_tokens_total_sum{", "model_name=\"glm\"} ", itok_sum, "\n", + "vllm:iteration_tokens_total_count{", "model_name=\"glm\"} ", itok_count, "\n", "process_start_time_seconds ", start, "\n", ], "") } From 358922e815a525d8e0cad2846a6becc8f8cc0725 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Fri, 18 Sep 2026 04:55:01 +0000 Subject: [PATCH 13/43] Fix floor type errors on the serving-load probe. LaunchUnobserved carries group and obligation, Nat if-arms cannot mix with Int literals, and max_concurrency is Absent rather than none. Co-authored-by: Cursor --- dag/gunbc/spark/serving_load_probe.dag | 15 ++++++++------- .../spark/serving_load_probe_witness_test.dag | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/dag/gunbc/spark/serving_load_probe.dag b/dag/gunbc/spark/serving_load_probe.dag index bc20e80edb4..e4a41716401 100644 --- a/dag/gunbc/spark/serving_load_probe.dag +++ b/dag/gunbc/spark/serving_load_probe.dag @@ -170,12 +170,12 @@ type CounterContinuity fn counter_continuity(before: VllmEndpointProcessLaunchObservation, after: VllmEndpointProcessLaunchObservation) -> CounterContinuity { match before { - LaunchUnobserved { endpoint: e } => - ContinuityUnread { cause: join(["the exporter start field was unobserved before the window: ", e as String], "") as NonEmptyStr } + LaunchUnobserved { group: _, obligation: o } => + ContinuityUnread { cause: join(["the exporter start field was unobserved before the window: ", o as String], "") as NonEmptyStr } LaunchObserved { launch: b, receipt: _ } => match after { - LaunchUnobserved { endpoint: e } => - ContinuityUnread { cause: join(["the exporter start field was unobserved after the window: ", e as String], "") as NonEmptyStr } + LaunchUnobserved { group: _, obligation: o } => + ContinuityUnread { cause: join(["the exporter start field was unobserved after the window: ", o as String], "") as NonEmptyStr } LaunchObserved { launch: a, receipt: _ } => if (b.process_start_field as String) == (a.process_start_field as String) { SameExporter { start_field: b.process_start_field } @@ -438,7 +438,7 @@ fn foreign_work_bound(generation: TokenDelta, client_output: ClientOutputTokens) match client_output { ClientOutputTokensUnread { cause: c } => ForeignWorkUnread { because: c } ClientOutputTokensObserved { tokens: c } => - ForeignWorkBounded { engine_generation: g, client_output: c, surplus: if g >= c { g - c } else { 0 } } + ForeignWorkBounded { engine_generation: g, client_output: c, surplus: if g >= c { g - c } else { c - c } } } } } @@ -931,7 +931,7 @@ fn foreign_in_flight_at_peak(p: PeakConcurrencyReceipt) -> Nat? { match p { PeakConcurrencyUnread { cause: _ } => none PeakConcurrencyObserved { client_max_concurrency: c, engine_peak_concurrent_requests: e } => - if e > c { Present { value: e - c } } else { Present { value: 0 } } + if e > c { Present { value: e - c } } else { Present { value: c - c } } } } @@ -1021,7 +1021,8 @@ data glm_native_contended_sweep_standing: CitedFigureStanding = TranscribedUncit fn glm_native_sweep_num_prompts(concurrency: Nat) -> Nat { let fourfold = concurrency * 4 - if fourfold < 8 { 8 } else { fourfold } + let eight = token_count_value(t: token_count(count: 8)) + if fourfold < eight { eight } else { fourfold } } fn glm_native_contended_sweep_protocol(concurrency: Nat) -> VllmBenchServeRequest { diff --git a/dag/test/claim/spark/serving_load_probe_witness_test.dag b/dag/test/claim/spark/serving_load_probe_witness_test.dag index 981c78b9c1c..0f14db3c1fa 100644 --- a/dag/test/claim/spark/serving_load_probe_witness_test.dag +++ b/dag/test/claim/spark/serving_load_probe_witness_test.dag @@ -395,7 +395,7 @@ test fn the_holistic_protocol_is_poisson_with_session_context_and_prefix() -> Bo dataset: RandomDatasetSpec { input_len: token_count(count: 128), output_len: token_count(count: 128), prefix_len: token_count(count: 0) }, num_prompts: 4, arrival: SendAllImmediately, - max_concurrency: none, + max_concurrency: Absent, ignore_eos: true, )) } From 3f6cbed614ccffaec24f06eef9dad85f5e1e3f02 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Fri, 18 Sep 2026 06:20:05 +0000 Subject: [PATCH 14/43] Cross Int to Nat via checked_int_magnitude, not a claim-time cast. `as Nat` typechecked then failed five floor claims; milli and scrape interval now use the sanctioned magnitude crossing. Co-authored-by: Cursor --- dag/gunbc/spark/serving_load_probe.dag | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/dag/gunbc/spark/serving_load_probe.dag b/dag/gunbc/spark/serving_load_probe.dag index e4a41716401..e7727b63953 100644 --- a/dag/gunbc/spark/serving_load_probe.dag +++ b/dag/gunbc/spark/serving_load_probe.dag @@ -1,8 +1,9 @@ module gunbc.spark.serving_load_probe -import std.types { Bool, String, NonEmptyStr, List, EpochSecs } +import std.types { Bool, String, NonEmptyStr, List, EpochSecs, Int } import std.nat { Nat } import std.decimal { ExactDecimal, canonical_exact_decimal, decimal_pow10 } +import std.checked_arithmetic { checked_int_magnitude, CheckedNatReady, CheckedNatOverflow } import v2.std.algebra { length, filter, list_map } import v2.std.optional { Present, Absent } import std.measure { TokenCount, token_count, token_count_value } @@ -191,6 +192,17 @@ type HistogramDelta | HistogramDeltaUnread { cause: NonEmptyStr } | HistogramCounterReset { cause: NonEmptyStr } +fn nat_from_nonneg_int(n: Int) -> Nat? { + if n < 0 { + none + } else { + match checked_int_magnitude(a: n) { + CheckedNatOverflow { cause: _ } => none + CheckedNatReady { value: v } => Present { value: v } + } + } +} + fn milli_from_exact(d: ExactDecimal) -> Nat? { let c = canonical_exact_decimal(d: d) if c.units < 0 { @@ -199,7 +211,7 @@ fn milli_from_exact(d: ExactDecimal) -> Nat? { none } else { let scaled = c.units * decimal_pow10(exponent: 3 - c.fraction_digits) - if scaled < 0 { none } else { Present { value: scaled as Nat } } + nat_from_nonneg_int(n: scaled) } } @@ -318,7 +330,7 @@ fn scrape_interval_millis(before_at: EpochSecs, after_at: EpochSecs) -> Nat? { if after_at <= before_at { none } else { - Present { value: ((after_at - before_at) * 1000) as Nat } + nat_from_nonneg_int(n: (after_at - before_at) * 1000) } } From c86463d56cb5ec50a9efb23bb8ce2eacc97680a9 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Fri, 18 Sep 2026 14:44:43 +0000 Subject: [PATCH 15/43] Stop treating client bucket peak and ITL tail as engine contention. The bench peak is a successful-request second-bucket count; the ITL distribution stays observed with an unestablished cause. A non-idle drain now refuses the start, and the ledger/rate parse Successful/Failed/generated tokens and duration from stdout instead of exit_ok. Co-authored-by: Cursor --- dag/gunbc/harness/harness_backend.dag | 46 ++++ dag/gunbc/spark/serving_load_probe.dag | 197 +++++++++++++----- dag/gunbc/spark/serving_load_probe_cli.dag | 51 +++-- .../spark/serving_load_probe_witness_test.dag | 83 ++++++-- 4 files changed, 288 insertions(+), 89 deletions(-) diff --git a/dag/gunbc/harness/harness_backend.dag b/dag/gunbc/harness/harness_backend.dag index 0de7be8215c..bd6b18c26d7 100644 --- a/dag/gunbc/harness/harness_backend.dag +++ b/dag/gunbc/harness/harness_backend.dag @@ -555,3 +555,49 @@ fn harness_observe_engine_at(endpoint: ServingRouteEndpoint, at: EpochSecs) -> H } } } + +fn text_labeled_field(body: String, label: String) -> String? { + let needle = join([label, ":"], "") + let lines = split(s: body, delimiter: "\n") + let matching = filter(lines, l => starts_with(s: trim(s: l), prefix: needle)) + if length(matching) != 1 { + none + } else { + match first(matching) { + Absent => none + Present { value: line } => { + let parts = split(s: line, delimiter: ":") + if length(parts) < 2 { + none + } else { + last(parts) + } + } + } + } +} + +fn text_field_last_word(body: String, label: String) -> String? { + match text_labeled_field(body: body, label: label) { + Absent => none + Present { value: t } => last(split(s: trim(s: t), delimiter: " ")) + } +} + +fn text_labeled_count(body: String, label: String) -> Nat? { + match text_field_last_word(body: body, label: label) { + Absent => none + Present { value: last_word } => harness_gauge_count(text: trim(s: last_word)) + } +} + +fn text_labeled_head_count(body: String, label: String) -> Nat? { + match text_field_last_word(body: body, label: label) { + Absent => none + Present { value: last_word } => + match first(split(s: trim(s: last_word), delimiter: ".")) { + Absent => none + Present { value: whole } => harness_gauge_count(text: whole) + } + } +} diff --git a/dag/gunbc/spark/serving_load_probe.dag b/dag/gunbc/spark/serving_load_probe.dag index e7727b63953..4f7fc0ab3ed 100644 --- a/dag/gunbc/spark/serving_load_probe.dag +++ b/dag/gunbc/spark/serving_load_probe.dag @@ -4,7 +4,7 @@ import std.types { Bool, String, NonEmptyStr, List, EpochSecs, Int } import std.nat { Nat } import std.decimal { ExactDecimal, canonical_exact_decimal, decimal_pow10 } import std.checked_arithmetic { checked_int_magnitude, CheckedNatReady, CheckedNatOverflow } -import v2.std.algebra { length, filter, list_map } +import v2.std.algebra { list_map } import v2.std.optional { Present, Absent } import std.measure { TokenCount, token_count, token_count_value } import product.capacity.lease { LeaseGrant } @@ -24,6 +24,7 @@ import extdeps.vllm.bench_serve { import gunbc.harness.harness_backend { harness_gauge_value, harness_labelled_gauge_value, harness_gauge_count, harness_histogram_statistic_value, harness_launch_from_body, harness_queue_from_body, + text_labeled_count, text_labeled_head_count, text_field_last_word, } import gunbc.serving.turn_admission { ServingQueueReading, QueueDepthRead, QueueDepthUnread, @@ -97,14 +98,18 @@ type ArmServiceStanding = ArmInService { because: NonEmptyStr } | ArmOutOfService { how: NonEmptyStr } -// A ZERO RUNNING GAUGE IS A DRAIN SNAPSHOT. It is not exclusion and it is not out-of-service: -// the operator serves interactive work on this arm, harness_probe_cli can POST a turn, and -// nccl-tests can allocate GPU buffers. WindowSharedWithDeclaredTraffic is the DEFAULT standing. +// A ZERO RUNNING GAUGE IS A DRAIN SNAPSHOT, not exclusion. The probe still refuses to START on a +// non-idle queue: that would mix already-running foreign requests into the client window without a +// join. An idle start under declared operator/harness/nccl traffic remains +// WindowSharedWithDeclaredTraffic, because arrivals during the run are still possible. fn window_from_drain(drain: DrainReceipt, traffic_receipt: NonEmptyStr) -> ProbeWindowStanding { match drain { DrainUnread { cause: c } => WindowIsolationUnread { cause: c, drain: drain } - DrainNotIdle { running: _ } => - WindowSharedWithDeclaredTraffic { traffic_receipt: traffic_receipt, drain: drain } + DrainNotIdle { running: n } => + WindowIsolationUnread { + cause: join(["the engine already had ", to_string(n), " running requests; the probe refuses a non-idle start"], "") as NonEmptyStr, + drain: drain, + } DrainObservedIdle => WindowSharedWithDeclaredTraffic { traffic_receipt: traffic_receipt, drain: drain } } @@ -565,8 +570,7 @@ fn serving_load_observation( arrival: ArrivalSkew, occupancy: OccupancyTrace, client_output: ClientOutputTokens, - before_at: EpochSecs, - after_at: EpochSecs, + scrape_millis: Nat?, before_body: String, after_body: String, ledger: OperationLedger, @@ -598,7 +602,7 @@ fn serving_load_observation( capacity_claim: capacity_claim_for_window(window: window), rate: derive_rate_honest( ledger: ledger, - scrape_millis: scrape_interval_millis(before_at: before_at, after_at: after_at), + scrape_millis: scrape_millis, client_output: client_output, ), raw_before: before_body as NonEmptyStr, @@ -912,45 +916,142 @@ data glm_native_wet_smoke_client_latency: ClientBenchLatency = ClientBenchLatenc standing: glm_native_wet_smoke_standing } -type ClientItlTail - = ItlTailUnread { cause: NonEmptyStr } - | ItlMeanMedianP99 { mean_milli: Nat, median_milli: Nat, p99_milli: Nat } +type ItlTailCause + = ItlTailCauseUnestablished { because: NonEmptyStr } -data glm_native_wet_smoke_itl: ClientItlTail = ItlMeanMedianP99 { - mean_milli: 83 - median_milli: 82 - p99_milli: 165 -} +type ClientItlDistribution + = ClientItlDistributionUnread { cause: NonEmptyStr } + | ClientItlDistributionObserved { mean_milli: Nat, median_milli: Nat, p99_milli: Nat, cause: ItlTailCause } -fn itl_p99_is_contention_tail(t: ClientItlTail) -> Bool { - match t { - ItlTailUnread { cause: _ } => false - ItlMeanMedianP99 { mean_milli: _, median_milli: med, p99_milli: p99 } => - p99 >= (med * 2) +fn itl_tail_cause_is_unestablished(d: ClientItlDistribution) -> Bool { + match d { + ClientItlDistributionUnread { cause: _ } => true + ClientItlDistributionObserved { mean_milli: _, median_milli: _, p99_milli: _, cause: ItlTailCauseUnestablished { because: _ } } => true } } -type PeakConcurrencyReceipt - = PeakConcurrencyUnread { cause: NonEmptyStr } - | PeakConcurrencyObserved { client_max_concurrency: Nat, engine_peak_concurrent_requests: Nat } +// vLLM bench serve's max_concurrent_requests is a whole-second bucket peak over THIS CLIENT's +// successful request spans. Two sequential waves of two can print 4 with exact concurrency 2 and +// zero foreign work. The field cannot mint engine concurrency or a shared-window proof. +type ClientRequestConcurrencyStanding + = ClientConcurrencyUnread { cause: NonEmptyStr } + | SuccessfulClientRequestSecondBucketPeak { client_max_concurrency: Nat, bucket_peak: Nat } -data glm_native_wet_smoke_peak_concurrency: PeakConcurrencyReceipt = PeakConcurrencyObserved { - client_max_concurrency: 2 - engine_peak_concurrent_requests: 4 +fn client_second_bucket_peak_establishes_foreign_work(p: ClientRequestConcurrencyStanding) -> Bool { + match p { + ClientConcurrencyUnread { cause: _ } => false + SuccessfulClientRequestSecondBucketPeak { client_max_concurrency: _, bucket_peak: _ } => false + } } -fn foreign_in_flight_at_peak(p: PeakConcurrencyReceipt) -> Nat? { +fn cap_2_bucket_peak_4_is_not_foreign_work(p: ClientRequestConcurrencyStanding) -> Bool { match p { - PeakConcurrencyUnread { cause: _ } => none - PeakConcurrencyObserved { client_max_concurrency: c, engine_peak_concurrent_requests: e } => - if e > c { Present { value: e - c } } else { Present { value: c - c } } + ClientConcurrencyUnread { cause: _ } => false + SuccessfulClientRequestSecondBucketPeak { client_max_concurrency: c, bucket_peak: b } => + c == token_count_value(t: token_count(count: 2)) + && b == token_count_value(t: token_count(count: 4)) + && !client_second_bucket_peak_establishes_foreign_work(p: p) } } -fn peak_concurrency_proves_shared_window(p: PeakConcurrencyReceipt) -> Bool { - match foreign_in_flight_at_peak(p: p) { - Absent => false - Present { value: n } => n > 0 +fn bench_labeled_nat(body: String, label: String) -> Nat? { + text_labeled_count(body: body, label: label) +} + +fn bench_labeled_milli_from_seconds(body: String, label: String) -> Nat? { + match text_field_last_word(body: body, label: label) { + Absent => none + Present { value: last_word } => field_to_milli(field: last_word) + } +} + +fn bench_labeled_whole_milli(body: String, label: String) -> Nat? { + text_labeled_head_count(body: body, label: label) +} + +fn ledger_from_bench_stdout(body: String, offered: Nat) -> OperationLedger { + match bench_labeled_nat(body: body, label: "Successful requests") { + Absent => LedgerIncomplete { because: "vllm bench serve stdout carried no unique Successful requests line" as NonEmptyStr } + Present { value: completed } => + match bench_labeled_nat(body: body, label: "Failed requests") { + Absent => LedgerIncomplete { because: "vllm bench serve stdout carried no unique Failed requests line, so failed-after-tokens standing is unknown" as NonEmptyStr } + Present { value: failed } => + if (completed + failed) != offered { + LedgerIncomplete { because: "successful plus failed requests did not equal the offered prompt count" as NonEmptyStr } + } else if failed == 0 { + LedgerClosed { offered: offered, completed: completed, failed: failed, failed_after_tokens: 0 } + } else { + LedgerIncomplete { because: "failed requests were reported and the summary does not distinguish failed-after-tokens from failed-with-no-tokens" as NonEmptyStr } + } + } + } +} + +fn client_output_from_bench_stdout(body: String) -> ClientOutputTokens { + match bench_labeled_nat(body: body, label: "Total generated tokens") { + Absent => ClientOutputTokensUnread { cause: "vllm bench serve stdout carried no unique Total generated tokens line" as NonEmptyStr } + Present { value: t } => ClientOutputTokensObserved { tokens: t } + } +} + +fn scrape_millis_from_bench_stdout(body: String) -> Nat? { + bench_labeled_milli_from_seconds(body: body, label: "Benchmark duration (s)") +} + +fn client_itl_from_bench_stdout(body: String) -> ClientItlDistribution { + match bench_labeled_whole_milli(body: body, label: "Mean ITL (ms)") { + Absent => ClientItlDistributionUnread { cause: "vllm bench serve stdout carried no unique Mean ITL (ms) line" as NonEmptyStr } + Present { value: mean_m } => + match bench_labeled_whole_milli(body: body, label: "Median ITL (ms)") { + Absent => ClientItlDistributionUnread { cause: "vllm bench serve stdout carried no unique Median ITL (ms) line" as NonEmptyStr } + Present { value: med } => + match bench_labeled_whole_milli(body: body, label: "P99 ITL (ms)") { + Absent => ClientItlDistributionUnread { cause: "vllm bench serve stdout carried no unique P99 ITL (ms) line" as NonEmptyStr } + Present { value: p99 } => + ClientItlDistributionObserved { mean_milli: mean_m, median_milli: med, p99_milli: p99, cause: ItlTailCauseUnestablished { because: "client stream ITL is elapsed time between SSE messages; cause is unestablished until an attributed engine or scheduler population joins it" as NonEmptyStr } } + } + } + } +} + +fn client_bucket_peak_from_bench_stdout(body: String, client_max_concurrency: Nat) -> ClientRequestConcurrencyStanding { + match bench_labeled_nat(body: body, label: "Peak concurrent requests") { + Absent => ClientConcurrencyUnread { cause: "vllm bench serve stdout carried no unique Peak concurrent requests line" as NonEmptyStr } + Present { value: peak } => + SuccessfulClientRequestSecondBucketPeak { client_max_concurrency: client_max_concurrency, bucket_peak: peak } + } +} + +fn arrival_from_protocol(req: VllmBenchServeRequest) -> ArrivalSkew { + match req.arrival { + SendAllImmediately => ArrivalSkewObserved { max_stagger_millis: 0 } + PoissonProcess { millirequests_per_second: _, burstiness_milli: _ } => + ArrivalSkewUnread { cause: "Poisson starts are not parsed from vllm bench serve stdout until per-request start_times are retained" as NonEmptyStr } + } +} + +fn client_latency_from_bench_stdout(body: String, contended: Bool) -> ClientBenchLatency { + match bench_labeled_milli_from_seconds(body: body, label: "Output token throughput (tok/s)") { + Absent => ClientBenchLatencyUnread { cause: "vllm bench serve stdout carried no unique Output token throughput (tok/s) line" as NonEmptyStr } + Present { value: th } => + match bench_labeled_whole_milli(body: body, label: "Mean TPOT (ms)") { + Absent => ClientBenchLatencyUnread { cause: "vllm bench serve stdout carried no unique Mean TPOT (ms) line" as NonEmptyStr } + Present { value: tpot } => + match bench_labeled_whole_milli(body: body, label: "Mean TTFT (ms)") { + Absent => ClientBenchLatencyUnread { cause: "vllm bench serve stdout carried no unique Mean TTFT (ms) line" as NonEmptyStr } + Present { value: ttft } => + ClientBenchLatencyReported { + output_throughput_milli_tok_per_s: th, + tpot_milli: tpot, + itl_milli: bench_labeled_whole_milli(body: body, label: "Mean ITL (ms)"), + ttft_milli: ttft, + contended: contended, + standing: TranscribedUncited { + read_obligation: "this arm is a live parse of vllm bench serve stdout, not a transcribed figure; re-run glm_native_serving_load_wet to re-derive" as NonEmptyStr + }, + } + } + } } } @@ -991,23 +1092,6 @@ fn glm_native_wet_smoke_rate() -> DerivedRate { ) } -fn glm_native_wet_smoke_itl_is_contention_tail_receipt() -> Bool { - itl_p99_is_contention_tail(t: glm_native_wet_smoke_itl) - && match glm_native_wet_smoke_itl { - ItlTailUnread { cause: _ } => false - ItlMeanMedianP99 { mean_milli: mean_m, median_milli: med, p99_milli: p99 } => - mean_m == 83 && med == 82 && p99 == 165 - } -} - -fn glm_native_wet_smoke_peak_proves_shared_window() -> Bool { - peak_concurrency_proves_shared_window(p: glm_native_wet_smoke_peak_concurrency) - && match foreign_in_flight_at_peak(p: glm_native_wet_smoke_peak_concurrency) { - Absent => false - Present { value: n } => n == 2 - } -} - fn glm_native_wet_smoke_is_not_sweep_c1_protocol() -> Bool { !pinned_load_protocol_matches(a: glm_native_smoke_protocol, b: glm_native_contended_sweep_c1.protocol) } @@ -1201,8 +1285,6 @@ data glm_native_ttft_binds_concurrency: ContendedLatencyFloorHint = TtftWouldBin } } -// Same subject, same single-stream protocol shape, different window: quieter engine 48.9 ms vs -// contended client c=1 TPOT 80.7 ms. The gap is the operator's traffic. Window standing is a field. type WindowStandingGapSpecimen { quieter_engine_tpot_milli: Nat contended_client_c1_tpot_milli: Nat @@ -1213,7 +1295,10 @@ data glm_native_window_standing_specimen: WindowStandingGapSpecimen = WindowStan contended_client_c1_tpot_milli: 81, } -fn window_standing_gap_is_operator_traffic(s: WindowStandingGapSpecimen) -> Bool { +// Same subject, same single-stream protocol shape, different window: quieter engine 48.9 ms vs +// contended client c=1 TPOT 80.7 ms. The gap is observed; its cause is unestablished until an +// overlapping lease or engine-population join attributes it. +fn window_standing_gap_is_unattributed(s: WindowStandingGapSpecimen) -> Bool { s.contended_client_c1_tpot_milli > s.quieter_engine_tpot_milli } diff --git a/dag/gunbc/spark/serving_load_probe_cli.dag b/dag/gunbc/spark/serving_load_probe_cli.dag index 0e2502d83ee..0b44fcbb9db 100644 --- a/dag/gunbc/spark/serving_load_probe_cli.dag +++ b/dag/gunbc/spark/serving_load_probe_cli.dag @@ -1,7 +1,7 @@ module gunbc.spark.serving_load_probe_cli import std.types { Bool, List, NonEmptyStr, String } -import std.nat { Nat } +import v2.std.optional { Present, Absent } import std.process { ProcessExit, ExitSuccess, exit_failure } import std.resources { Network } import extdeps.filesystem.filesystem_io { Filesystem } @@ -23,19 +23,22 @@ import gunbc.spark.serving_load_probe { glm_native_declared_shared_traffic, glm_native_smoke_protocol, serving_load_observation, serving_load_observation_text, drain_from_queue, window_from_drain, counter_continuity, - ArrivalSkewUnread, occupancy_trace_from_endpoint_scrapes, - OperationLedger, LedgerClosed, LedgerIncomplete, - ClientOutputTokensUnread, - ClientBenchLatencyUnread, + ledger_from_bench_stdout, client_output_from_bench_stdout, scrape_millis_from_bench_stdout, + client_latency_from_bench_stdout, arrival_from_protocol, + client_itl_from_bench_stdout, client_bucket_peak_from_bench_stdout, + client_second_bucket_peak_establishes_foreign_work, itl_tail_cause_is_unestablished, + ClientConcurrencyUnread, + WindowSharedWithDeclaredTraffic, WindowIsolated, WindowIsolationUnread, RateFromClientOutputTokens, RateUndenominable, RateUnreadable, } // ── THE INHABITANCE ROUTE ───────────────────────────────────────────────────────────────────── // // Witnesses supply metric bodies. This function is the one that drives `vllm bench serve` against -// the live native GLM head and folds receipts. The arm is shared with operator interactive -// sessions; a drain of zero is not exclusivity. This fold records that standing and still runs. +// the live native GLM head and folds receipts. A non-idle drain REFUSES the start. An idle start +// is still WindowSharedWithDeclaredTraffic because operator/harness/nccl traffic may arrive during +// the run. The rate is parsed from bench duration and Total generated tokens, not from exit_ok. // // gunbc run --source-root dag --source-root src/v2 \ // --entry dag/gunbc/spark/serving_load_probe_cli.dag --function glm_native_serving_load_wet @@ -75,14 +78,6 @@ fn body_is_failure(body: String) -> Bool { starts_with(s: body, prefix: "UNREACHABLE ") || starts_with(s: body, prefix: "FAILED ") } -fn ledger_from_bench(exit_ok: Bool, offered: Nat) -> OperationLedger { - if exit_ok { - LedgerClosed { offered: offered, completed: offered, failed: 0, failed_after_tokens: 0 } - } else { - LedgerIncomplete { because: "vllm bench serve did not exit 0, so whether any request emitted tokens and then failed is unknown; the rate is not denominated in tokens" as NonEmptyStr } - } -} - fn glm_native_serving_load_wet() -> ProcessExit uses net: Network { @@ -97,6 +92,10 @@ fn glm_native_serving_load_wet() -> ProcessExit drain: drain, traffic_receipt: glm_native_declared_shared_traffic, ) + match window { + WindowIsolationUnread { cause: c, drain: _ } => exit_failure(reason: c as String) + WindowIsolated { grant: _, deadline: _, drain: _, exclusion: _ } => exit_failure(reason: "an isolated window is not this arm's inhabitance path") + WindowSharedWithDeclaredTraffic { traffic_receipt: _, drain: _ } => { let bench = spark_remote_run(ctx: ctx, argv: bench_exec_argv()) let after = remote_or_fail(ctx: ctx, argv: curl_metrics_argv(), step: "metrics-after") if body_is_failure(body: after) { @@ -114,24 +113,32 @@ fn glm_native_serving_load_wet() -> ProcessExit let before_launch = harness_launch_from_body(group: FabricGroupB, address: "192.168.1.236", body: before) let after_launch = harness_launch_from_body(group: FabricGroupB, address: "192.168.1.236", body: after) let occ = occupancy_trace_from_endpoint_scrapes(before_body: before, after_body: after) + let ledger = ledger_from_bench_stdout(body: bench_text, offered: glm_native_smoke_protocol.num_prompts) + let client_output = client_output_from_bench_stdout(body: bench_text) + let bucket = match glm_native_smoke_protocol.max_concurrency { + Absent => ClientConcurrencyUnread { cause: "the smoke protocol did not declare max-concurrency" as NonEmptyStr } + Present { value: c } => client_bucket_peak_from_bench_stdout(body: bench_text, client_max_concurrency: c) + } + let itl = client_itl_from_bench_stdout(body: bench_text) let obs = serving_load_observation( subject: glm_native_live_subject_standing(), protocol: glm_native_smoke_protocol, window: window, continuity: counter_continuity(before: before_launch, after: after_launch), - arrival: ArrivalSkewUnread { cause: "vllm bench serve stdout is not yet parsed for per-request start skew" as NonEmptyStr }, + arrival: arrival_from_protocol(req: glm_native_smoke_protocol), occupancy: occ, - client_output: ClientOutputTokensUnread { cause: "vllm bench serve stdout is not yet parsed for completed output tokens" as NonEmptyStr }, - before_at: 0, - after_at: 1, + client_output: client_output, + scrape_millis: scrape_millis_from_bench_stdout(body: bench_text), before_body: before, after_body: after, - ledger: ledger_from_bench(exit_ok: bench_ok, offered: 4), - client_latency: ClientBenchLatencyUnread { cause: "vllm bench serve stdout is not yet parsed for TTFT/TPOT/ITL" as NonEmptyStr }, + ledger: ledger, + client_latency: client_latency_from_bench_stdout(body: bench_text, contended: true), ) let body = join([ "glm native serving-load wet at ", probed_at_word(reading: clock_now_probed_at()) as String, "\n", serving_load_observation_text(o: obs), + "\nbucket_peak_establishes_foreign_work=", if client_second_bucket_peak_establishes_foreign_work(p: bucket) { "yes" } else { "no" }, "\n", + "itl_tail_cause_unestablished=", if itl_tail_cause_is_unestablished(d: itl) { "yes" } else { "no" }, "\n", "\n--- bench ---\n", bench_text, "\n", ], "") let w = Filesystem.Write(path: glm_native_serving_load_receipt_path, content: body) @@ -147,6 +154,8 @@ fn glm_native_serving_load_wet() -> ProcessExit } } } + } + } } }, attempt_raw: glm_native_serving_load_attempt_raw, credential_file_name: "gunbc-glm-native-serving-load-admin-password" as NonEmptyStr) } diff --git a/dag/test/claim/spark/serving_load_probe_witness_test.dag b/dag/test/claim/spark/serving_load_probe_witness_test.dag index 0f14db3c1fa..66be82c4fd6 100644 --- a/dag/test/claim/spark/serving_load_probe_witness_test.dag +++ b/dag/test/claim/spark/serving_load_probe_witness_test.dag @@ -4,7 +4,7 @@ import std.types { Bool, String, NonEmptyStr, EpochSecs, List } import std.nat { Nat } import v2.std.algebra { length, filter } import v2.std.optional { Present, Absent } -import std.measure { token_count } +import std.measure { token_count, token_count_value } import product.capacity.lease { LeaseGrant, lease_fence_of, lease_grant, LeasePolicy, FencedResource } import product.capacity.event_chain { EventId } import product.fabric.demand { ObservationReceiptRef } @@ -20,12 +20,12 @@ import extdeps.vllm.bench_serve { import extdeps.vllm.kv_layout { AdmissionCostUnestablished, AdmissionCostBlocks } import extdeps.external_authority { TranscribedUncited, CitedToAuthority } import gunbc.spark.serving_load_probe { - DrainObservedIdle, + DrainObservedIdle, DrainNotIdle, ExclusionNotEstablished, ExclusionEstablished, WindowIsolated, WindowSharedWithDeclaredTraffic, WindowIsolationUnread, window_from_drain, isolated_window, drain_from_queue, ArmInService, ArmOutOfService, - OperationLedger, LedgerClosed, ledger_admits_token_denomination, + OperationLedger, LedgerClosed, LedgerIncomplete, ledger_admits_token_denomination, RateFromClientOutputTokens, RateUndenominable, RateUnreadable, ArrivalSkewObserved, ArrivalSkewUnread, arrival_admits_rate_comparison, TokenDeltaRead, TokenDeltaReset, TokenDeltaUnread, generation_token_delta, @@ -50,10 +50,14 @@ import gunbc.spark.serving_load_probe { glm_native_wiring_smoke_protocol, glm_native_contended_sweep_c1, glm_native_contended_sweep_c2, glm_native_contended_sweep_c16, glm_native_contended_sweep_points, glm_native_contended_elasticity_steps, elasticity_still_buying_throughput, - glm_native_wet_smoke_itl_is_contention_tail_receipt, glm_native_wet_smoke_peak_proves_shared_window, glm_native_wet_smoke_is_not_sweep_c1_protocol, glm_native_wet_smoke_rate_is_output_tokens, glm_native_ttft_would_bind_on_this_sweep, - glm_native_window_standing_specimen, window_standing_gap_is_operator_traffic, + glm_native_window_standing_specimen, window_standing_gap_is_unattributed, + cap_2_bucket_peak_4_is_not_foreign_work, SuccessfulClientRequestSecondBucketPeak, + ClientItlDistributionObserved, ClientItlDistributionUnread, itl_tail_cause_is_unestablished, + ledger_from_bench_stdout, client_output_from_bench_stdout, scrape_millis_from_bench_stdout, + client_itl_from_bench_stdout, client_bucket_peak_from_bench_stdout, + ClientOutputTokensObserved, pinned_load_protocol_matches, bench_output_len, glm_native_sweep_num_prompts, glm_native_holistic_execution, LongContextModelledOnly, LongContextRunnable, glm_native_elasticity_8_to_16, @@ -101,6 +105,16 @@ fn closed_failed_after_tokens() -> OperationLedger { LedgerClosed { offered: 4, completed: 3, failed: 0, failed_after_tokens: 1 } } +test fn a_busy_drain_refuses_the_window() -> Bool { + let d = drain_from_queue(q: harness_queue_from_body(body: fx_busy)) + match window_from_drain(drain: d, traffic_receipt: "fx" as NonEmptyStr) { + WindowIsolationUnread { cause: _, drain: DrainNotIdle { running: n } } => n == 3 + WindowIsolationUnread { cause: _, drain: _ } => false + WindowIsolated { grant: _, deadline: _, drain: _, exclusion: _ } => false + WindowSharedWithDeclaredTraffic { traffic_receipt: _, drain: _ } => false + } +} + test fn a_quiet_drain_is_not_an_isolated_window() -> Bool { let d = drain_from_queue(q: harness_queue_from_body(body: fx_idle)) let w = window_from_drain(drain: d, traffic_receipt: "coordinated with parent; no exclusion receipt" as NonEmptyStr) @@ -204,8 +218,7 @@ fn fx_obs(ledger: OperationLedger) -> ServingLoadObservation { arrival: tight_arrival(), occupancy: OccupancySampled { samples: [OccupancySample { running: 1, waiting: 0, capacity_waiting: 0, preemptions: 0, prompt_tokens: 0 }] }, client_output: ClientOutputTokensUnread { cause: "fixture has no client token total" as NonEmptyStr }, - before_at: 100, - after_at: 102, + scrape_millis: Present { value: 2000 }, before_body: fx_idle, after_body: fx_after, ledger: ledger, @@ -334,12 +347,58 @@ test fn a_64_out_wiring_receipt_is_not_the_128_out_sweep_protocol() -> Bool { && !pinned_load_protocol_matches(a: glm_native_wiring_smoke_protocol, b: glm_native_contended_sweep_c2.protocol) } -test fn wet_smoke_itl_p99_is_the_contention_tail() -> Bool { - glm_native_wet_smoke_itl_is_contention_tail_receipt() +data fx_bench_stdout: String = join([ + "============ Serving Benchmark Result ============\n", + "Successful requests: 4\n", + "Failed requests: 0\n", + "Benchmark duration (s): 22.75\n", + "Total input tokens: 1072\n", + "Total generated tokens: 512\n", + "Request throughput (req/s): 0.18\n", + "Output token throughput (tok/s): 22.51\n", + "Total Token throughput (tok/s): 69.64\n", + "Peak concurrent requests: 4.00\n", + "---------------Time to First Token----------------\n", + "Mean TTFT (ms): 996.40\n", + "-----Time per Output Token (excl. 1st token)------\n", + "Mean TPOT (ms): 82.10\n", + "---------------Inter-token Latency----------------\n", + "Mean ITL (ms): 83.20\n", + "Median ITL (ms): 82.10\n", + "P99 ITL (ms): 165.00\n", +], "") + +test fn a_cap_2_second_bucket_peak_4_does_not_establish_foreign_work() -> Bool { + cap_2_bucket_peak_4_is_not_foreign_work(p: SuccessfulClientRequestSecondBucketPeak { + client_max_concurrency: token_count_value(t: token_count(count: 2)), + bucket_peak: token_count_value(t: token_count(count: 4)), + }) +} + +test fn parsed_itl_distribution_does_not_establish_a_cause() -> Bool { + let d = client_itl_from_bench_stdout(body: fx_bench_stdout) + match d { + ClientItlDistributionObserved { mean_milli: mean_m, median_milli: med, p99_milli: p99, cause: _ } => + mean_m == 83 && med == 82 && p99 == 165 && itl_tail_cause_is_unestablished(d: d) + ClientItlDistributionUnread { cause: _ } => false + } } -test fn peak_concurrency_above_the_client_cap_proves_a_shared_window() -> Bool { - glm_native_wet_smoke_peak_proves_shared_window() +test fn ledger_and_rate_come_from_bench_stdout_not_exit_ok() -> Bool { + match ledger_from_bench_stdout(body: fx_bench_stdout, offered: token_count_value(t: token_count(count: 4))) { + LedgerClosed { offered: o, completed: c, failed: f, failed_after_tokens: t } => + o == 4 && c == 4 && f == 0 && t == 0 + && match client_output_from_bench_stdout(body: fx_bench_stdout) { + ClientOutputTokensUnread { cause: _ } => false + ClientOutputTokensObserved { tokens: n } => + n == 512 + && match scrape_millis_from_bench_stdout(body: fx_bench_stdout) { + Absent => false + Present { value: ms } => ms == 22750 + } + } + LedgerIncomplete { because: _ } => false + } } test fn wet_smoke_tpot_is_not_a_protocol_match_to_sweep_c1() -> Bool { @@ -374,7 +433,7 @@ test fn ttft_would_bind_concurrency_before_throughput_on_this_sweep() -> Bool { test fn the_49_vs_81_ms_gap_is_why_window_standing_is_a_field() -> Bool { glm_native_window_standing_specimen.quieter_engine_tpot_milli == 49 && glm_native_window_standing_specimen.contended_client_c1_tpot_milli == 81 - && window_standing_gap_is_operator_traffic(s: glm_native_window_standing_specimen) + && window_standing_gap_is_unattributed(s: glm_native_window_standing_specimen) } test fn long_context_stays_modelled_until_the_arm_is_out_of_service() -> Bool { From c0b9bb3565474eaa113da20011979486aed1774d Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Fri, 18 Sep 2026 15:05:37 +0000 Subject: [PATCH 16/43] Scope generation_tokens_total to one ObservedRankIncarnation. A delta across distinct container ids, hosts, or node ranks is unread. The wet route inspects the serving container before and after the bench so the engine surplus cannot silently join two incarnations. Co-authored-by: Cursor --- dag/gunbc/spark/serving_load_probe.dag | 41 ++++++++++++++++- dag/gunbc/spark/serving_load_probe_cli.dag | 18 ++++++++ .../spark/serving_load_probe_witness_test.dag | 46 ++++++++++++++++++- 3 files changed, 102 insertions(+), 3 deletions(-) diff --git a/dag/gunbc/spark/serving_load_probe.dag b/dag/gunbc/spark/serving_load_probe.dag index 4f7fc0ab3ed..3fa698338d6 100644 --- a/dag/gunbc/spark/serving_load_probe.dag +++ b/dag/gunbc/spark/serving_load_probe.dag @@ -43,7 +43,9 @@ import gunbc.spark.serving_performance_subject { ServingPerformanceSubject, serving_performance_subject, serving_subject_standing, ServingPerformanceSubjectStanding, SubjectEstablished, SubjectPartial, } -import gunbc.spark.runtime_architecture_registry_reading { glm53_nope_derived_registry_reading } +import gunbc.spark.serving_rank_observe { + ObservedRankIncarnation, observed_rank_incarnations_agree, observed_rank_incarnation_text, +} import extdeps.vllm.engine_args { KvFp8, SpeculativeDecodingOff } import extdeps.vllm.kv_layout { AdmissionCost, AdmissionCostUnestablished, AdmissionCostBlocks } import extdeps.external_authority { CitedFigureStanding, TranscribedUncited } @@ -331,6 +333,34 @@ fn generation_token_delta(before_body: String, after_body: String) -> TokenDelta } } +fn generation_token_delta_scoped( + before_incarnation: ObservedRankIncarnation?, + after_incarnation: ObservedRankIncarnation?, + before_body: String, + after_body: String, +) -> TokenDelta { + match before_incarnation { + Absent => TokenDeltaUnread { cause: "generation_tokens_total is not scoped: the before scrape has no ObservedRankIncarnation" as NonEmptyStr } + Present { value: b } => + match after_incarnation { + Absent => TokenDeltaUnread { cause: "generation_tokens_total is not scoped: the after scrape has no ObservedRankIncarnation" as NonEmptyStr } + Present { value: a } => + if !observed_rank_incarnations_agree(a: b, b: a) { + TokenDeltaUnread { + cause: join([ + "generation_tokens_total is not comparable across incarnations: before ", + observed_rank_incarnation_text(i: b), + " after ", + observed_rank_incarnation_text(i: a), + ], "") as NonEmptyStr + } + } else { + generation_token_delta(before_body: before_body, after_body: after_body) + } + } + } +} + fn scrape_interval_millis(before_at: EpochSecs, after_at: EpochSecs) -> Nat? { if after_at <= before_at { none @@ -573,12 +603,19 @@ fn serving_load_observation( scrape_millis: Nat?, before_body: String, after_body: String, + before_incarnation: ObservedRankIncarnation?, + after_incarnation: ObservedRankIncarnation?, ledger: OperationLedger, client_latency: ClientBenchLatency, ) -> ServingLoadObservation { let before_p = preemption_count(body: before_body) let after_p = preemption_count(body: after_body) - let generation = generation_token_delta(before_body: before_body, after_body: after_body) + let generation = generation_token_delta_scoped( + before_incarnation: before_incarnation, + after_incarnation: after_incarnation, + before_body: before_body, + after_body: after_body, + ) let agreement = ledger_counter_agreement(ledger: ledger, generation: generation, client_output: client_output) ServingLoadObservation { subject: subject, diff --git a/dag/gunbc/spark/serving_load_probe_cli.dag b/dag/gunbc/spark/serving_load_probe_cli.dag index 0b44fcbb9db..b7ad1e16de9 100644 --- a/dag/gunbc/spark/serving_load_probe_cli.dag +++ b/dag/gunbc/spark/serving_load_probe_cli.dag @@ -14,6 +14,10 @@ import gunbc.spark.model_snapshot_materialize { SparkMaterializeContext, spark_remote_run, RemoteRan, RemoteUnreachable, } import gunbc.spark.serving_arm_launch { glm_native_container_name } +import gunbc.spark.serving_rank_observe { + observed_rank_subject, observe_rank_container, RankInspected, RankInspectRefused, + observed_rank_incarnation, ObservedRankIncarnation, +} import gunbc.spark.glm_group_b_relaunch_cli { with_group_b_access, rank_context } import gunbc.spark.serving_arm { glm_native_concurrent_profile } import gunbc.harness.harness_backend { harness_launch_from_body, harness_queue_from_body } @@ -78,6 +82,16 @@ fn body_is_failure(body: String) -> Bool { starts_with(s: body, prefix: "UNREACHABLE ") || starts_with(s: body, prefix: "FAILED ") } +fn inspect_incarnation(ctx: SparkMaterializeContext) -> ObservedRankIncarnation? + uses net: Network +{ + let subject = observed_rank_subject(host: operator_host_srv9, container: glm_native_container_name) + match observe_rank_container(ctx: ctx, subject: subject) { + RankInspectRefused { refusal: _ } => none + RankInspected { subject: s, container: c } => observed_rank_incarnation(subject: s, c: c) + } +} + fn glm_native_serving_load_wet() -> ProcessExit uses net: Network { @@ -96,11 +110,13 @@ fn glm_native_serving_load_wet() -> ProcessExit WindowIsolationUnread { cause: c, drain: _ } => exit_failure(reason: c as String) WindowIsolated { grant: _, deadline: _, drain: _, exclusion: _ } => exit_failure(reason: "an isolated window is not this arm's inhabitance path") WindowSharedWithDeclaredTraffic { traffic_receipt: _, drain: _ } => { + let before_incarnation = inspect_incarnation(ctx: ctx) let bench = spark_remote_run(ctx: ctx, argv: bench_exec_argv()) let after = remote_or_fail(ctx: ctx, argv: curl_metrics_argv(), step: "metrics-after") if body_is_failure(body: after) { exit_failure(reason: after) } else { + let after_incarnation = inspect_incarnation(ctx: ctx) let bench_ok = match bench { RemoteUnreachable { cause: _ } => false RemoteRan { exit_code: code, stdout: _, stderr: _ } => code == 0 @@ -131,6 +147,8 @@ fn glm_native_serving_load_wet() -> ProcessExit scrape_millis: scrape_millis_from_bench_stdout(body: bench_text), before_body: before, after_body: after, + before_incarnation: before_incarnation, + after_incarnation: after_incarnation, ledger: ledger, client_latency: client_latency_from_bench_stdout(body: bench_text, contended: true), ) diff --git a/dag/test/claim/spark/serving_load_probe_witness_test.dag b/dag/test/claim/spark/serving_load_probe_witness_test.dag index 66be82c4fd6..c4c836143a5 100644 --- a/dag/test/claim/spark/serving_load_probe_witness_test.dag +++ b/dag/test/claim/spark/serving_load_probe_witness_test.dag @@ -7,6 +7,10 @@ import v2.std.optional { Present, Absent } import std.measure { token_count, token_count_value } import product.capacity.lease { LeaseGrant, lease_fence_of, lease_grant, LeasePolicy, FencedResource } import product.capacity.event_chain { EventId } +import gunbc.fleet_intent_network { operator_host_srv9 } +import gunbc.spark.serving_rank_observe { + container_incarnation_id, ObservedRankIncarnation, +} import product.fabric.demand { ObservationReceiptRef } import gunbc.spark.fabric_switch_observed { FabricGroupB } import gunbc.spark.vllm_endpoint_process_launch { @@ -28,7 +32,7 @@ import gunbc.spark.serving_load_probe { OperationLedger, LedgerClosed, LedgerIncomplete, ledger_admits_token_denomination, RateFromClientOutputTokens, RateUndenominable, RateUnreadable, ArrivalSkewObserved, ArrivalSkewUnread, arrival_admits_rate_comparison, - TokenDeltaRead, TokenDeltaReset, TokenDeltaUnread, generation_token_delta, + TokenDeltaRead, TokenDeltaReset, TokenDeltaUnread, generation_token_delta, generation_token_delta_scoped, derive_rate_honest, serving_load_observation, ServingLoadObservation, tokens_per_observation_second, saturation_from_one_run, observation_rate_is_stored_separately, foreign_work_bound, ForeignWorkBounded, ForeignWorkUnread, @@ -209,6 +213,44 @@ test fn a_generation_counter_reset_is_not_a_rate() -> Bool { } } +test fn generation_tokens_are_unread_across_distinct_incarnations() -> Bool { + match generation_token_delta_scoped( + before_incarnation: fx_incarnation(id: "0f3a9c1d2e4b"), + after_incarnation: fx_incarnation(id: "7b2e5a90c813"), + before_body: fx_idle, + after_body: fx_after, + ) { + TokenDeltaUnread { cause: _ } => true + TokenDeltaRead { tokens: _ } => false + TokenDeltaReset { cause: _ } => false + } +} + +test fn generation_tokens_are_unread_without_an_incarnation() -> Bool { + match generation_token_delta_scoped( + before_incarnation: none, + after_incarnation: fx_same_incarnation(), + before_body: fx_idle, + after_body: fx_after, + ) { + TokenDeltaUnread { cause: _ } => true + TokenDeltaRead { tokens: _ } => false + TokenDeltaReset { cause: _ } => false + } +} + +fn fx_incarnation(id: String) -> ObservedRankIncarnation? { + match container_incarnation_id(id: id) { + Absent => none + Present { value: cid } => + Present { value: ObservedRankIncarnation { host: operator_host_srv9, container: cid, node_rank: token_count_value(t: token_count(count: 0)) } } + } +} + +fn fx_same_incarnation() -> ObservedRankIncarnation? { + fx_incarnation(id: "0f3a9c1d2e4b") +} + fn fx_obs(ledger: OperationLedger) -> ServingLoadObservation { serving_load_observation( subject: glm_native_live_subject_standing(), @@ -221,6 +263,8 @@ fn fx_obs(ledger: OperationLedger) -> ServingLoadObservation { scrape_millis: Present { value: 2000 }, before_body: fx_idle, after_body: fx_after, + before_incarnation: fx_same_incarnation(), + after_incarnation: fx_same_incarnation(), ledger: ledger, client_latency: ClientBenchLatencyUnread { cause: "fixture has no bench stdout" as NonEmptyStr }, ) From 9a9d100d0a55ecaa5ad63aba6f7d6bfa9a8ec429 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Fri, 18 Sep 2026 15:24:00 +0000 Subject: [PATCH 17/43] Qualify the client rate from subject, window, and foreign-work standing. Stop flooring engine-behind-client to a zero surplus; that interval is a contradiction. Histogram sums and prompt_tokens now truncate extra fraction digits to millis, and sudo password lines are stripped before the bench ledger parse. Co-authored-by: Cursor --- dag/gunbc/harness/harness_backend.dag | 12 ++ dag/gunbc/spark/serving_load_probe.dag | 128 ++++++++++++++++-- .../spark/serving_load_probe_witness_test.dag | 49 ++++++- 3 files changed, 175 insertions(+), 14 deletions(-) diff --git a/dag/gunbc/harness/harness_backend.dag b/dag/gunbc/harness/harness_backend.dag index bd6b18c26d7..80bc4285fab 100644 --- a/dag/gunbc/harness/harness_backend.dag +++ b/dag/gunbc/harness/harness_backend.dag @@ -4,6 +4,7 @@ import std.types { String, Bool, Int, List, NonEmptyStr, Timestamp, EpochSecs } import std.nat { Nat } import std.checked_arithmetic { CheckedNatReady, CheckedNatOverflow, checked_int_magnitude } import std.algebra { trim } +import v2.std.algebra { filter } import v2.std.optional { Present, Absent } import product.fabric.demand { ObservationReceiptRef } import std.measure { Second, second, second_count } @@ -556,6 +557,17 @@ fn harness_observe_engine_at(endpoint: ServingRouteEndpoint, at: EpochSecs) -> H } } +fn line_is_sudo_password_prompt(line: String) -> Bool { + match first(split(s: trim(s: line), delimiter: "[sudo] password for")) { + Absent => false + Present { value: prefix } => prefix == "" + } +} + +fn text_without_sudo_prompt(body: String) -> String { + join(filter(xs: split(s: body, delimiter: "\n"), predicate: fn(line) { !line_is_sudo_password_prompt(line: line) }), "\n") +} + fn text_labeled_field(body: String, label: String) -> String? { let needle = join([label, ":"], "") let lines = split(s: body, delimiter: "\n") diff --git a/dag/gunbc/spark/serving_load_probe.dag b/dag/gunbc/spark/serving_load_probe.dag index 3fa698338d6..8c8e3f1c048 100644 --- a/dag/gunbc/spark/serving_load_probe.dag +++ b/dag/gunbc/spark/serving_load_probe.dag @@ -24,7 +24,7 @@ import extdeps.vllm.bench_serve { import gunbc.harness.harness_backend { harness_gauge_value, harness_labelled_gauge_value, harness_gauge_count, harness_histogram_statistic_value, harness_launch_from_body, harness_queue_from_body, - text_labeled_count, text_labeled_head_count, text_field_last_word, + text_labeled_count, text_labeled_head_count, text_field_last_word, text_without_sudo_prompt, } import gunbc.serving.turn_admission { ServingQueueReading, QueueDepthRead, QueueDepthUnread, @@ -215,7 +215,8 @@ fn milli_from_exact(d: ExactDecimal) -> Nat? { if c.units < 0 { none } else if c.fraction_digits > 3 { - none + let extra = c.fraction_digits - 3 + nat_from_nonneg_int(n: c.units / decimal_pow10(exponent: extra)) } else { let scaled = c.units * decimal_pow10(exponent: 3 - c.fraction_digits) nat_from_nonneg_int(n: scaled) @@ -394,6 +395,18 @@ type OccupancyTrace = OccupancySampled { samples: List } | OccupancyUnsampled { cause: NonEmptyStr } +fn metric_token_count(body: String, metric: VllmServingMetric) -> Nat? { + match harness_gauge_value(body: body, metric: metric) { + Absent => none + Present { value: t } => + match field_to_milli(field: t) { + Absent => none + Present { value: m } => + if m % 1000 == 0 { Present { value: m / 1000 } } else { none } + } + } +} + fn occupancy_from_body(body: String) -> OccupancySample? { match harness_queue_from_body(body: body) { QueueDepthUnread { obligation: _ } => none @@ -404,7 +417,7 @@ fn occupancy_from_body(body: String) -> OccupancySample? { match capacity_waiting_count(p: p) { Absent => none Present { value: c } => - match metric_count(body: body, metric: PromptTokensTotal) { + match metric_token_count(body: body, metric: PromptTokensTotal) { Absent => none Present { value: pt } => Present { value: OccupancySample { running: r, waiting: w, capacity_waiting: c, preemptions: pr, prompt_tokens: pt } } @@ -476,6 +489,7 @@ fn ledger_counter_agreement(ledger: OperationLedger, generation: TokenDelta, cli type ForeignWorkBound = ForeignWorkUnread { because: NonEmptyStr } | ForeignWorkBounded { engine_generation: Nat, client_output: Nat, surplus: Nat } + | ForeignWorkContradiction { engine_generation: Nat, client_output: Nat, because: NonEmptyStr } fn foreign_work_bound(generation: TokenDelta, client_output: ClientOutputTokens) -> ForeignWorkBound { match generation { @@ -485,7 +499,15 @@ fn foreign_work_bound(generation: TokenDelta, client_output: ClientOutputTokens) match client_output { ClientOutputTokensUnread { cause: c } => ForeignWorkUnread { because: c } ClientOutputTokensObserved { tokens: c } => - ForeignWorkBounded { engine_generation: g, client_output: c, surplus: if g >= c { g - c } else { c - c } } + if g >= c { + ForeignWorkBounded { engine_generation: g, client_output: c, surplus: g - c } + } else { + ForeignWorkContradiction { + engine_generation: g, + client_output: c, + because: "client completed-output tokens exceeded engine generation_tokens_total on the same incarnation; the interval or identity is inconsistent, not evidence of zero foreign work" as NonEmptyStr, + } + } } } } @@ -537,6 +559,64 @@ fn derive_rate_honest( } } +type QualifiedClientRate + = ClientRateQualified { tokens: Nat, scrape_millis: Nat } + | ClientRateUnqualified { because: NonEmptyStr } + +fn qualify_client_rate( + subject: ServingPerformanceSubjectStanding, + continuity: CounterContinuity, + arrival: ArrivalSkew, + window: ProbeWindowStanding, + agreement: LedgerCounterAgreement, + occupancy: OccupancyTrace, + foreign_work: ForeignWorkBound, + rate: DerivedRate, +) -> QualifiedClientRate { + match rate { + RateUndenominable { because: b } => ClientRateUnqualified { because: b } + RateUnreadable { because: b } => ClientRateUnqualified { because: b } + RateFromClientOutputTokens { tokens: t, scrape_millis: ms } => + match subject { + SubjectPartial { subject: _, unknown_axes: _, believed: _, would_settle: s } => + ClientRateUnqualified { because: s } + SubjectEstablished { subject: _ } => + match continuity { + ContinuityUnread { cause: c } => ClientRateUnqualified { because: c } + ExporterChanged { before: _, after: _ } => + ClientRateUnqualified { because: "the exporter changed across the window, so the rate is not a single-incarnation observation" as NonEmptyStr } + SameExporter { start_field: _ } => + if !arrival_admits_rate_comparison(s: arrival) { + ClientRateUnqualified { because: "arrival standing does not admit a rate comparison" as NonEmptyStr } + } else { + match window { + WindowIsolationUnread { cause: c, drain: _ } => ClientRateUnqualified { because: c } + WindowSharedWithDeclaredTraffic { traffic_receipt: _, drain: _ } => + ClientRateUnqualified { because: "a shared-window client rate is telemetry, not a qualified comparable observation" as NonEmptyStr } + WindowIsolated { grant: _, deadline: _, drain: _, exclusion: _ } => + match agreement { + AgreementUnread { because: c } => ClientRateUnqualified { because: c } + LedgerCounterDisagree { because: c } => ClientRateUnqualified { because: c } + LedgerAndCounterAgree { generation_tokens: _, completed_requests: _ } => + match occupancy { + OccupancyUnsampled { cause: c } => ClientRateUnqualified { because: c } + OccupancySampled { samples: _ } => + match foreign_work { + ForeignWorkUnread { because: c } => ClientRateUnqualified { because: c } + ForeignWorkContradiction { engine_generation: _, client_output: _, because: c } => + ClientRateUnqualified { because: c } + ForeignWorkBounded { engine_generation: _, client_output: _, surplus: _ } => + ClientRateQualified { tokens: t, scrape_millis: ms } + } + } + } + } + } + } + } + } +} + type DecodeCorroboration = CorroborationNotApplicable { because: NonEmptyStr } | CorroborationUnread { because: NonEmptyStr } @@ -588,6 +668,7 @@ type ServingLoadObservation { foreign_work: ForeignWorkBound capacity_claim: CapacityClaim rate: DerivedRate + qualified_rate: QualifiedClientRate raw_before: NonEmptyStr raw_after: NonEmptyStr } @@ -617,6 +698,12 @@ fn serving_load_observation( after_body: after_body, ) let agreement = ledger_counter_agreement(ledger: ledger, generation: generation, client_output: client_output) + let foreign = foreign_work_bound(generation: generation, client_output: client_output) + let rate = derive_rate_honest( + ledger: ledger, + scrape_millis: scrape_millis, + client_output: client_output, + ) ServingLoadObservation { subject: subject, protocol: protocol, @@ -635,12 +722,18 @@ fn serving_load_observation( corroboration: decode_corroboration_for_protocol(req: protocol), provenance: glm_native_live_probe_provenance, client_latency: client_latency, - foreign_work: foreign_work_bound(generation: generation, client_output: client_output), + foreign_work: foreign, capacity_claim: capacity_claim_for_window(window: window), - rate: derive_rate_honest( - ledger: ledger, - scrape_millis: scrape_millis, - client_output: client_output, + rate: rate, + qualified_rate: qualify_client_rate( + subject: subject, + continuity: continuity, + arrival: arrival, + window: window, + agreement: agreement, + occupancy: occupancy, + foreign_work: foreign, + rate: rate, ), raw_before: before_body as NonEmptyStr, raw_after: after_body as NonEmptyStr, @@ -675,6 +768,7 @@ fn serving_load_observation_text(o: ServingLoadObservation) -> String { "foreign work: ", foreign_work_text(f: o.foreign_work), "\n", "capacity claim: ", capacity_claim_text(c: o.capacity_claim), "\n", "rate: ", rate_text(r: o.rate), "\n", + "qualified rate: ", qualified_rate_text(q: o.qualified_rate), "\n", "saturation decided from this run: ", if saturation_from_one_run(obs: o) { "yes" } else { "no" }, "\n", ], "") } @@ -684,6 +778,16 @@ fn foreign_work_text(f: ForeignWorkBound) -> String { ForeignWorkUnread { because: c } => join(["unread ", c as String], "") ForeignWorkBounded { engine_generation: g, client_output: c, surplus: s } => join(["engine=", to_string(g), " client=", to_string(c), " surplus=", to_string(s)], "") + ForeignWorkContradiction { engine_generation: g, client_output: c, because: b } => + join(["contradiction engine=", to_string(g), " client=", to_string(c), " ", b as String], "") + } +} + +fn qualified_rate_text(q: QualifiedClientRate) -> String { + match q { + ClientRateUnqualified { because: b } => join(["unqualified ", b as String], "") + ClientRateQualified { tokens: t, scrape_millis: ms } => + join(["qualified tokens=", to_string(t), " scrape_millis=", to_string(ms)], "") } } @@ -992,18 +1096,18 @@ fn cap_2_bucket_peak_4_is_not_foreign_work(p: ClientRequestConcurrencyStanding) } fn bench_labeled_nat(body: String, label: String) -> Nat? { - text_labeled_count(body: body, label: label) + text_labeled_count(body: text_without_sudo_prompt(body: body), label: label) } fn bench_labeled_milli_from_seconds(body: String, label: String) -> Nat? { - match text_field_last_word(body: body, label: label) { + match text_field_last_word(body: text_without_sudo_prompt(body: body), label: label) { Absent => none Present { value: last_word } => field_to_milli(field: last_word) } } fn bench_labeled_whole_milli(body: String, label: String) -> Nat? { - text_labeled_head_count(body: body, label: label) + text_labeled_head_count(body: text_without_sudo_prompt(body: body), label: label) } fn ledger_from_bench_stdout(body: String, offered: Nat) -> OperationLedger { diff --git a/dag/test/claim/spark/serving_load_probe_witness_test.dag b/dag/test/claim/spark/serving_load_probe_witness_test.dag index c4c836143a5..9c6bb2556c0 100644 --- a/dag/test/claim/spark/serving_load_probe_witness_test.dag +++ b/dag/test/claim/spark/serving_load_probe_witness_test.dag @@ -16,7 +16,7 @@ import gunbc.spark.fabric_switch_observed { FabricGroupB } import gunbc.spark.vllm_endpoint_process_launch { vllm_endpoint_process_launch, VllmEndpointProcessLaunchObservation, LaunchObserved, LaunchUnobserved, } -import gunbc.harness.harness_backend { harness_queue_from_body } +import extdeps.vllm.metrics { InterTokenLatencySeconds } import extdeps.vllm.bench_serve { VllmBenchServeRequest, RandomDatasetSpec, OpenaiChat, SendAllImmediately, PoissonProcess, vllm_bench_serve_request, vllm_bench_serve_arguments, vllm_bench_serve_uses_poisson_idle_gaps, @@ -35,7 +35,9 @@ import gunbc.spark.serving_load_probe { TokenDeltaRead, TokenDeltaReset, TokenDeltaUnread, generation_token_delta, generation_token_delta_scoped, derive_rate_honest, serving_load_observation, ServingLoadObservation, tokens_per_observation_second, saturation_from_one_run, observation_rate_is_stored_separately, - foreign_work_bound, ForeignWorkBounded, ForeignWorkUnread, + foreign_work_bound, ForeignWorkBounded, ForeignWorkUnread, ForeignWorkContradiction, + ClientRateUnqualified, ClientRateQualified, + occupancy_from_body, histogram_delta, HistogramDeltaRead, HistogramDeltaUnread, HistogramCounterReset, CapacityClaimUnavailable, glm_native_holistic_protocol, holistic_protocol_is_session_shaped, glm_native_live_subject_standing, counter_continuity, SameExporter, ExporterChanged, ContinuityUnread, @@ -325,6 +327,7 @@ test fn extra_engine_tokens_bound_foreign_work_and_keep_the_client_rate() -> Boo match foreign_work_bound(generation: TokenDeltaRead { tokens: 200 }, client_output: ClientOutputTokensObserved { tokens: 128 }) { ForeignWorkBounded { engine_generation: g, client_output: c, surplus: s } => g == 200 && c == 128 && s == 72 ForeignWorkUnread { because: _ } => false + ForeignWorkContradiction { engine_generation: _, client_output: _, because: _ } => false } RateUnreadable { because: _ } => false RateUndenominable { because: _ } => false @@ -361,6 +364,48 @@ test fn one_run_does_not_decide_saturation() -> Bool { && match obs.capacity_claim { CapacityClaimUnavailable { because: _ } => true } + && match obs.qualified_rate { + ClientRateUnqualified { because: _ } => true + ClientRateQualified { tokens: _, scrape_millis: _ } => false + } +} + +test fn client_output_exceeding_engine_generation_is_a_contradiction() -> Bool { + match foreign_work_bound(generation: TokenDeltaRead { tokens: 100 }, client_output: ClientOutputTokensObserved { tokens: 512 }) { + ForeignWorkContradiction { engine_generation: g, client_output: c, because: _ } => g == 100 && c == 512 + ForeignWorkBounded { engine_generation: _, client_output: _, surplus: _ } => false + ForeignWorkUnread { because: _ } => false + } +} + +test fn occupancy_reads_prompt_tokens_that_are_not_an_integer_lexeme() -> Bool { + match occupancy_from_body(body: fx_idle) { + Absent => false + Present { value: s } => s.running == 0 && s.prompt_tokens == 0 + } +} + +test fn an_itl_histogram_sum_with_sub_milli_digits_is_still_a_milli_reading() -> Bool { + let before = metrics_body(running: "0.0", waiting: "0.0", capacity: "0.0", preempt: "0.0", itl_sum: "10.1234567", itl_count: "100.0", itok_sum: "1000.0", itok_count: "10.0", gen: "1000.0", start: "1789300000.12") + let after = metrics_body(running: "0.0", waiting: "0.0", capacity: "0.0", preempt: "0.0", itl_sum: "12.1234567", itl_count: "200.0", itok_sum: "1000.0", itok_count: "10.0", gen: "1000.0", start: "1789300000.12") + match histogram_delta(before_body: before, after_body: after, metric: InterTokenLatencySeconds) { + HistogramDeltaRead { sum_milli: ds, count: dc } => ds == 2000 && dc == 100 + HistogramDeltaUnread { cause: _ } => false + HistogramCounterReset { cause: _ } => false + } +} + +test fn a_sudo_password_prompt_line_does_not_spoil_the_bench_ledger() -> Bool { + let body = join(["[sudo] password for briansrls:\n", fx_bench_stdout], "") + match ledger_from_bench_stdout(body: body, offered: token_count_value(t: token_count(count: 4))) { + LedgerClosed { offered: o, completed: c, failed: f, failed_after_tokens: t } => + o == 4 && c == 4 && f == 0 && t == 0 + && match client_output_from_bench_stdout(body: body) { + ClientOutputTokensObserved { tokens: n } => n == 512 + ClientOutputTokensUnread { cause: _ } => false + } + LedgerIncomplete { because: _ } => false + } } test fn the_holistic_protocol_does_not_corroborate_the_single_stream_bound() -> Bool { From 0e7244007e62316b43c05489258a0db163eb439e Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Fri, 18 Sep 2026 15:30:05 +0000 Subject: [PATCH 18/43] Name the ObservedRankIncarnation on a scoped generation delta. A successful generation_token_delta_scoped reading is TokenDeltaScoped, so the receipt line carries host, container id, and rank instead of an unscoped token count. Co-authored-by: Cursor --- dag/gunbc/spark/serving_load_probe.dag | 48 +++++++++++++++---- .../spark/serving_load_probe_witness_test.dag | 21 +++++++- 2 files changed, 58 insertions(+), 11 deletions(-) diff --git a/dag/gunbc/spark/serving_load_probe.dag b/dag/gunbc/spark/serving_load_probe.dag index 8c8e3f1c048..ef265033151 100644 --- a/dag/gunbc/spark/serving_load_probe.dag +++ b/dag/gunbc/spark/serving_load_probe.dag @@ -303,9 +303,19 @@ fn ledger_admits_token_denomination(l: OperationLedger) -> Bool { type TokenDelta = TokenDeltaRead { tokens: Nat } + | TokenDeltaScoped { tokens: Nat, incarnation: ObservedRankIncarnation } | TokenDeltaUnread { cause: NonEmptyStr } | TokenDeltaReset { cause: NonEmptyStr } +fn token_delta_tokens(d: TokenDelta) -> Nat? { + match d { + TokenDeltaRead { tokens: t } => Present { value: t } + TokenDeltaScoped { tokens: t, incarnation: _ } => Present { value: t } + TokenDeltaUnread { cause: _ } => none + TokenDeltaReset { cause: _ } => none + } +} + fn generation_token_delta(before_body: String, after_body: String) -> TokenDelta { match harness_gauge_value(body: before_body, metric: GenerationTokensTotal) { Absent => TokenDeltaUnread { cause: "vllm:generation_tokens_total missing on the first body" as NonEmptyStr } @@ -356,7 +366,12 @@ fn generation_token_delta_scoped( ], "") as NonEmptyStr } } else { - generation_token_delta(before_body: before_body, after_body: after_body) + match generation_token_delta(before_body: before_body, after_body: after_body) { + TokenDeltaUnread { cause: c } => TokenDeltaUnread { cause: c } + TokenDeltaReset { cause: c } => TokenDeltaReset { cause: c } + TokenDeltaRead { tokens: t } => TokenDeltaScoped { tokens: t, incarnation: a } + TokenDeltaScoped { tokens: t, incarnation: i } => TokenDeltaScoped { tokens: t, incarnation: i } + } } } } @@ -461,10 +476,15 @@ fn nat_abs_diff(a: Nat, b: Nat) -> Nat { } fn ledger_counter_agreement(ledger: OperationLedger, generation: TokenDelta, client_output: ClientOutputTokens) -> LedgerCounterAgreement { - match generation { - TokenDeltaUnread { cause: c } => AgreementUnread { because: c } - TokenDeltaReset { cause: c } => AgreementUnread { because: c } - TokenDeltaRead { tokens: g } => + match token_delta_tokens(d: generation) { + Absent => + match generation { + TokenDeltaUnread { cause: c } => AgreementUnread { because: c } + TokenDeltaReset { cause: c } => AgreementUnread { because: c } + TokenDeltaRead { tokens: _ } => AgreementUnread { because: "generation token delta had no count" as NonEmptyStr } + TokenDeltaScoped { tokens: _, incarnation: _ } => AgreementUnread { because: "generation token delta had no count" as NonEmptyStr } + } + Present { value: g } => match ledger { LedgerIncomplete { because: c } => AgreementUnread { because: c } LedgerClosed { offered: _, completed: n, failed: _, failed_after_tokens: _ } => @@ -492,10 +512,15 @@ type ForeignWorkBound | ForeignWorkContradiction { engine_generation: Nat, client_output: Nat, because: NonEmptyStr } fn foreign_work_bound(generation: TokenDelta, client_output: ClientOutputTokens) -> ForeignWorkBound { - match generation { - TokenDeltaUnread { cause: c } => ForeignWorkUnread { because: c } - TokenDeltaReset { cause: c } => ForeignWorkUnread { because: c } - TokenDeltaRead { tokens: g } => + match token_delta_tokens(d: generation) { + Absent => + match generation { + TokenDeltaUnread { cause: c } => ForeignWorkUnread { because: c } + TokenDeltaReset { cause: c } => ForeignWorkUnread { because: c } + TokenDeltaRead { tokens: _ } => ForeignWorkUnread { because: "generation token delta had no count" as NonEmptyStr } + TokenDeltaScoped { tokens: _, incarnation: _ } => ForeignWorkUnread { because: "generation token delta had no count" as NonEmptyStr } + } + Present { value: g } => match client_output { ClientOutputTokensUnread { cause: c } => ForeignWorkUnread { because: c } ClientOutputTokensObserved { tokens: c } => @@ -918,7 +943,10 @@ fn ledger_text(l: OperationLedger) -> String { fn token_delta_text(d: TokenDelta) -> String { match d { - TokenDeltaRead { tokens: n } => join(["delta tokens=", to_string(n)], "") + TokenDeltaRead { tokens: n } => + join(["delta tokens=", to_string(n), " incarnation=unscoped — generation_token_delta_scoped did not bind this reading"], "") + TokenDeltaScoped { tokens: n, incarnation: i } => + join(["delta tokens=", to_string(n), " incarnation=", observed_rank_incarnation_text(i: i)], "") TokenDeltaUnread { cause: c } => join(["unread ", c as String], "") TokenDeltaReset { cause: c } => join(["reset ", c as String], "") } diff --git a/dag/test/claim/spark/serving_load_probe_witness_test.dag b/dag/test/claim/spark/serving_load_probe_witness_test.dag index 9c6bb2556c0..13097db53ff 100644 --- a/dag/test/claim/spark/serving_load_probe_witness_test.dag +++ b/dag/test/claim/spark/serving_load_probe_witness_test.dag @@ -32,7 +32,7 @@ import gunbc.spark.serving_load_probe { OperationLedger, LedgerClosed, LedgerIncomplete, ledger_admits_token_denomination, RateFromClientOutputTokens, RateUndenominable, RateUnreadable, ArrivalSkewObserved, ArrivalSkewUnread, arrival_admits_rate_comparison, - TokenDeltaRead, TokenDeltaReset, TokenDeltaUnread, generation_token_delta, generation_token_delta_scoped, + TokenDeltaRead, TokenDeltaReset, TokenDeltaUnread, TokenDeltaScoped, generation_token_delta, generation_token_delta_scoped, derive_rate_honest, serving_load_observation, ServingLoadObservation, tokens_per_observation_second, saturation_from_one_run, observation_rate_is_stored_separately, foreign_work_bound, ForeignWorkBounded, ForeignWorkUnread, ForeignWorkContradiction, @@ -200,6 +200,7 @@ test fn engine_rate_comes_from_generation_tokens_not_iteration_or_itl() -> Bool } TokenDeltaUnread { cause: _ } => false TokenDeltaReset { cause: _ } => false + TokenDeltaScoped { tokens: _, incarnation: _ } => false } } @@ -212,6 +213,7 @@ test fn a_generation_counter_reset_is_not_a_rate() -> Bool { TokenDeltaReset { cause: _ } => true TokenDeltaRead { tokens: _ } => false TokenDeltaUnread { cause: _ } => false + TokenDeltaScoped { tokens: _, incarnation: _ } => false } } @@ -225,6 +227,7 @@ test fn generation_tokens_are_unread_across_distinct_incarnations() -> Bool { TokenDeltaUnread { cause: _ } => true TokenDeltaRead { tokens: _ } => false TokenDeltaReset { cause: _ } => false + TokenDeltaScoped { tokens: _, incarnation: _ } => false } } @@ -238,6 +241,22 @@ test fn generation_tokens_are_unread_without_an_incarnation() -> Bool { TokenDeltaUnread { cause: _ } => true TokenDeltaRead { tokens: _ } => false TokenDeltaReset { cause: _ } => false + TokenDeltaScoped { tokens: _, incarnation: _ } => false + } +} + +test fn a_scoped_generation_delta_names_the_incarnation() -> Bool { + match generation_token_delta_scoped( + before_incarnation: fx_same_incarnation(), + after_incarnation: fx_same_incarnation(), + before_body: fx_idle, + after_body: fx_after, + ) { + TokenDeltaScoped { tokens: t, incarnation: i } => + t == 128 && (i.container.id as String) == "0f3a9c1d2e4b" && i.node_rank == token_count_value(t: token_count(count: 0)) + TokenDeltaRead { tokens: _ } => false + TokenDeltaUnread { cause: _ } => false + TokenDeltaReset { cause: _ } => false } } From f18bbb32b5a431fbe1aabe36e8315410bcf95598 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Fri, 18 Sep 2026 15:41:43 +0000 Subject: [PATCH 19/43] Include backend, model, tokenizer, and arrival in load-protocol identity. Rename LongContextModelledOnly to LongContextLoadProtocolPrototype and drop transcribed elasticity from the shared-window series. Co-authored-by: Cursor --- dag/extdeps/vllm/bench_serve.dag | 26 +++++++++ dag/gunbc/spark/serving_load_probe.dag | 57 +++++-------------- .../spark/serving_load_probe_witness_test.dag | 18 +++--- 3 files changed, 51 insertions(+), 50 deletions(-) diff --git a/dag/extdeps/vllm/bench_serve.dag b/dag/extdeps/vllm/bench_serve.dag index a3b81d44e81..cedfd3fb22d 100644 --- a/dag/extdeps/vllm/bench_serve.dag +++ b/dag/extdeps/vllm/bench_serve.dag @@ -133,6 +133,32 @@ fn vllm_bench_eos_words(ignore: Bool) -> List { if ignore { ["--ignore-eos"] } else { [] } } +fn vllm_bench_backend_eq(a: VllmBenchBackend, b: VllmBenchBackend) -> Bool { + (vllm_bench_backend_wire(b: a) as String) == (vllm_bench_backend_wire(b: b) as String) +} + +fn vllm_bench_arrival_eq(a: BenchArrival, b: BenchArrival) -> Bool { + match a { + SendAllImmediately => + match b { + SendAllImmediately => true + PoissonProcess { millirequests_per_second: _, burstiness_milli: _ } => false + } + PoissonProcess { millirequests_per_second: an, burstiness_milli: ab } => + match b { + SendAllImmediately => false + PoissonProcess { millirequests_per_second: bn, burstiness_milli: bb } => an == bn && ab == bb + } + } +} + +fn vllm_bench_serve_identity_matches(a: VllmBenchServeRequest, b: VllmBenchServeRequest) -> Bool { + vllm_bench_backend_eq(a: a.backend, b: b.backend) + && (a.model as String) == (b.model as String) + && (a.tokenizer as String) == (b.tokenizer as String) + && vllm_bench_arrival_eq(a: a.arrival, b: b.arrival) +} + // THE ARGV IS DERIVED FROM THE REQUEST, so a protocol that asked for Poisson arrivals cannot // silently render `inf`, and a protocol that named a shared prefix cannot drop `--random-prefix-len`. // SERVED NAME AND TOKENIZER IDENTITY ARE DIFFERENT FACTS. --model is what the OpenAI route answers; diff --git a/dag/gunbc/spark/serving_load_probe.dag b/dag/gunbc/spark/serving_load_probe.dag index ef265033151..dde790ad256 100644 --- a/dag/gunbc/spark/serving_load_probe.dag +++ b/dag/gunbc/spark/serving_load_probe.dag @@ -20,6 +20,7 @@ import extdeps.vllm.metrics { import extdeps.vllm.bench_serve { VllmBenchServeRequest, PoissonProcess, SendAllImmediately, RandomDatasetSpec, OpenaiChat, vllm_bench_serve_request, vllm_bench_serve_uses_poisson_idle_gaps, + vllm_bench_serve_identity_matches, } import gunbc.harness.harness_backend { harness_gauge_value, harness_labelled_gauge_value, harness_gauge_count, @@ -1367,52 +1368,21 @@ data glm_native_contended_sweep_points: List = [ ] // ABSOLUTE tok/s ARE NOT A CAPACITY under WindowSharedWithDeclaredTraffic. Elasticity -// log(throughput ratio)/log(concurrency ratio) is a SHAPE: contention scales both ends and does -// not by itself invent a plateau. These milli figures are transcribed from that log ratio on the -// five points above; they are not stored rates. -type ScalingElasticityStep { - from_concurrency: Nat - to_concurrency: Nat - elasticity_milli: Nat - standing: CitedFigureStanding -} +// log(throughput ratio)/log(concurrency ratio) is a SHAPE that requires a controlled series. +// The five contended points are shared-window client latency; they are not that series. +type UncontrolledSeriesElasticity + = ElasticityNotOnUncontrolledSeries { because: NonEmptyStr } -data glm_native_elasticity_standing: CitedFigureStanding = TranscribedUncited { - read_obligation: "recompute log(throughput_after/throughput_before)/log(concurrency_after/concurrency_before) from glm_native_contended_sweep_points; the 670/570/590/700 milli figures were transcribed from calm-bat-65's 0.67, 0.57, 0.59, 0.70" as NonEmptyStr +data glm_native_contended_sweep_elasticity: UncontrolledSeriesElasticity = ElasticityNotOnUncontrolledSeries { + because: "glm_native_contended_sweep_points were taken under WindowSharedWithDeclaredTraffic; log(throughput ratio)/log(concurrency ratio) on that series is not a scaling elasticity" as NonEmptyStr } -fn glm_native_elasticity_step(from_concurrency: Nat, to_concurrency: Nat, elasticity_milli: Nat) -> ScalingElasticityStep { - ScalingElasticityStep { - from_concurrency: from_concurrency, - to_concurrency: to_concurrency, - elasticity_milli: elasticity_milli, - standing: glm_native_elasticity_standing, +fn elasticity_is_off_the_uncontrolled_series(s: UncontrolledSeriesElasticity) -> Bool { + match s { + ElasticityNotOnUncontrolledSeries { because: _ } => true } } -data glm_native_elasticity_1_to_2: ScalingElasticityStep = glm_native_elasticity_step(from_concurrency: 1, to_concurrency: 2, elasticity_milli: 670) -data glm_native_elasticity_2_to_4: ScalingElasticityStep = glm_native_elasticity_step(from_concurrency: 2, to_concurrency: 4, elasticity_milli: 570) -data glm_native_elasticity_4_to_8: ScalingElasticityStep = glm_native_elasticity_step(from_concurrency: 4, to_concurrency: 8, elasticity_milli: 590) -data glm_native_elasticity_8_to_16: ScalingElasticityStep = glm_native_elasticity_step(from_concurrency: 8, to_concurrency: 16, elasticity_milli: 700) - -data glm_native_contended_elasticity_steps: List = [ - glm_native_elasticity_1_to_2, - glm_native_elasticity_2_to_4, - glm_native_elasticity_4_to_8, - glm_native_elasticity_8_to_16, -] - -fn elasticity_still_buying_throughput(steps: List) -> Bool { - length(steps) == 4 - && glm_native_elasticity_1_to_2.elasticity_milli > 0 - && glm_native_elasticity_2_to_4.elasticity_milli > 0 - && glm_native_elasticity_4_to_8.elasticity_milli > 0 - && glm_native_elasticity_8_to_16.elasticity_milli > 0 - && glm_native_elasticity_8_to_16.elasticity_milli >= glm_native_elasticity_1_to_2.elasticity_milli - && glm_native_elasticity_8_to_16.elasticity_milli >= glm_native_elasticity_2_to_4.elasticity_milli - && glm_native_elasticity_8_to_16.elasticity_milli >= glm_native_elasticity_4_to_8.elasticity_milli -} - // TPOT 8→16 is nearly flat while throughput still rises; TTFT at 16 is the sharp move. // This is not a realization selection and not a capacity claim. It is the observation that a // latency floor, if one entered policy, would bind on TTFT here rather than on throughput. @@ -1476,7 +1446,8 @@ fn bench_output_len(req: VllmBenchServeRequest) -> Nat { } fn pinned_load_protocol_matches(a: VllmBenchServeRequest, b: VllmBenchServeRequest) -> Bool { - token_count_value(t: a.dataset.input_len) == token_count_value(t: b.dataset.input_len) + vllm_bench_serve_identity_matches(a: a, b: b) + && token_count_value(t: a.dataset.input_len) == token_count_value(t: b.dataset.input_len) && bench_output_len(req: a) == bench_output_len(req: b) && token_count_value(t: a.dataset.prefix_len) == token_count_value(t: b.dataset.prefix_len) && a.ignore_eos == b.ignore_eos @@ -1496,10 +1467,10 @@ fn pinned_load_protocol_matches(a: VllmBenchServeRequest, b: VllmBenchServeReque } type LongContextExecutionStanding - = LongContextModelledOnly { until: NonEmptyStr } + = LongContextLoadProtocolPrototype { until: NonEmptyStr } | LongContextRunnable { because: NonEmptyStr } -data glm_native_holistic_execution: LongContextExecutionStanding = LongContextModelledOnly { +data glm_native_holistic_execution: LongContextExecutionStanding = LongContextLoadProtocolPrototype { until: "the arm carries an ArmOutOfService receipt; a 100k-prefix protocol is not executed on an in-service operator arm" as NonEmptyStr } diff --git a/dag/test/claim/spark/serving_load_probe_witness_test.dag b/dag/test/claim/spark/serving_load_probe_witness_test.dag index 13097db53ff..153d36378c3 100644 --- a/dag/test/claim/spark/serving_load_probe_witness_test.dag +++ b/dag/test/claim/spark/serving_load_probe_witness_test.dag @@ -20,6 +20,7 @@ import extdeps.vllm.metrics { InterTokenLatencySeconds } import extdeps.vllm.bench_serve { VllmBenchServeRequest, RandomDatasetSpec, OpenaiChat, SendAllImmediately, PoissonProcess, vllm_bench_serve_request, vllm_bench_serve_arguments, vllm_bench_serve_uses_poisson_idle_gaps, + vllm_bench_serve_identity_matches, } import extdeps.vllm.kv_layout { AdmissionCostUnestablished, AdmissionCostBlocks } import extdeps.external_authority { TranscribedUncited, CitedToAuthority } @@ -55,7 +56,7 @@ import gunbc.spark.serving_load_probe { decode_corroboration_for_protocol, CorroborationNotApplicable, CorroborationUnread, glm_native_wiring_smoke_protocol, glm_native_contended_sweep_c1, glm_native_contended_sweep_c2, glm_native_contended_sweep_c16, glm_native_contended_sweep_points, - glm_native_contended_elasticity_steps, elasticity_still_buying_throughput, + glm_native_contended_sweep_elasticity, elasticity_is_off_the_uncontrolled_series, glm_native_wet_smoke_is_not_sweep_c1_protocol, glm_native_wet_smoke_rate_is_output_tokens, glm_native_ttft_would_bind_on_this_sweep, glm_native_window_standing_specimen, window_standing_gap_is_unattributed, @@ -65,8 +66,7 @@ import gunbc.spark.serving_load_probe { client_itl_from_bench_stdout, client_bucket_peak_from_bench_stdout, ClientOutputTokensObserved, pinned_load_protocol_matches, bench_output_len, glm_native_sweep_num_prompts, - glm_native_holistic_execution, LongContextModelledOnly, LongContextRunnable, - glm_native_elasticity_8_to_16, + glm_native_holistic_execution, LongContextLoadProtocolPrototype, LongContextRunnable, } data start_field: NonEmptyStr = "1789300000.12" as NonEmptyStr @@ -455,6 +455,11 @@ test fn a_64_out_wiring_receipt_is_not_the_128_out_sweep_protocol() -> Bool { && !pinned_load_protocol_matches(a: glm_native_wiring_smoke_protocol, b: glm_native_contended_sweep_c2.protocol) } +test fn protocol_identity_includes_backend_model_tokenizer_and_arrival() -> Bool { + vllm_bench_serve_identity_matches(a: glm_native_smoke_protocol, b: glm_native_wiring_smoke_protocol) + && !vllm_bench_serve_identity_matches(a: glm_native_smoke_protocol, b: glm_native_holistic_protocol) +} + data fx_bench_stdout: String = join([ "============ Serving Benchmark Result ============\n", "Successful requests: 4\n", @@ -529,9 +534,8 @@ test fn the_contended_sweep_is_five_shared_window_client_points() -> Bool { } } -test fn scaling_elasticity_is_a_shape_still_buying_at_16() -> Bool { - elasticity_still_buying_throughput(steps: glm_native_contended_elasticity_steps) - && glm_native_elasticity_8_to_16.elasticity_milli == 700 +test fn scaling_elasticity_is_off_the_uncontrolled_series() -> Bool { + elasticity_is_off_the_uncontrolled_series(s: glm_native_contended_sweep_elasticity) } test fn ttft_would_bind_concurrency_before_throughput_on_this_sweep() -> Bool { @@ -546,7 +550,7 @@ test fn the_49_vs_81_ms_gap_is_why_window_standing_is_a_field() -> Bool { test fn long_context_stays_modelled_until_the_arm_is_out_of_service() -> Bool { match glm_native_holistic_execution { - LongContextModelledOnly { until: _ } => true + LongContextLoadProtocolPrototype { until: _ } => true LongContextRunnable { because: _ } => false } } From a2557291c8082176e3f96e0c9d207da873e086cc Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Fri, 18 Sep 2026 16:28:17 +0000 Subject: [PATCH 20/43] Close the SOURCE HOLD on mixing, arrival policy, window standing, occupancy, and ledger. Client facts now derive from one BenchServeObservationReceipt; SendAllImmediately is unread skew; isolation is not contention; boundary occupancy cannot qualify a rate; the bench parser is an aggregate summary. Protocol identity pins a seed and weaker serve.py standing, and the long-context prototype waits on the qualification-window law. Co-authored-by: Cursor --- dag/extdeps/vllm/bench_serve.dag | 11 +- dag/gunbc/spark/serving_load_probe.dag | 393 +++++++++++------- dag/gunbc/spark/serving_load_probe_cli.dag | 89 ++-- .../spark/serving_load_probe_witness_test.dag | 189 +++++---- 4 files changed, 405 insertions(+), 277 deletions(-) diff --git a/dag/extdeps/vllm/bench_serve.dag b/dag/extdeps/vllm/bench_serve.dag index cedfd3fb22d..cb7a72b43d9 100644 --- a/dag/extdeps/vllm/bench_serve.dag +++ b/dag/extdeps/vllm/bench_serve.dag @@ -6,7 +6,7 @@ import v2.std.optional { Present, Absent } import std.measure { TokenCount, token_count, token_count_value } import std.decl_ref { DeclarationRef, WholeDeclaration } import std.decimal { fixed_point_wire } -import extdeps.external_authority { ExternalAuthority, ExternalModelScope, ExternalSubjectRef } +import extdeps.external_authority { ExternalAuthority, ExternalModelScope, ExternalSubjectRef, CitedFigureStanding, TranscribedUncited } import extdeps.uri { Uri, Https } import extdeps.vllm.server { VllmRoute, vllm_route_chat_completions, vllm_route_completions, vllm_route_path } @@ -36,7 +36,9 @@ data extdeps_model_scope: ExternalModelScope = ExternalModelScope { // A second load generator in this repository would be a fork of that driver. This module names // the request the CLI actually takes and renders the argv; it does not invent a client. -data vllm_bench_serve_program: NonEmptyStr = "vllm" as NonEmptyStr +data vllm_bench_serve_source_standing: CitedFigureStanding = TranscribedUncited { + read_obligation: "bind this argv model to the serve.py file digest inside the running image; citing github.com/vllm-project/vllm/blob/main/vllm/benchmarks/serve.py is not the installed revision" as NonEmptyStr +} type VllmBenchBackend = OpenaiCompletions @@ -80,6 +82,7 @@ type VllmBenchServeRequest { arrival: BenchArrival max_concurrency: Nat? ignore_eos: Bool + seed: Nat } fn vllm_bench_serve_request( @@ -92,6 +95,7 @@ fn vllm_bench_serve_request( arrival: BenchArrival, max_concurrency: Nat?, ignore_eos: Bool, + seed: Nat, ) -> VllmBenchServeRequest { VllmBenchServeRequest { backend: backend, @@ -103,6 +107,7 @@ fn vllm_bench_serve_request( arrival: arrival, max_concurrency: max_concurrency, ignore_eos: ignore_eos, + seed: seed, } } @@ -157,6 +162,7 @@ fn vllm_bench_serve_identity_matches(a: VllmBenchServeRequest, b: VllmBenchServe && (a.model as String) == (b.model as String) && (a.tokenizer as String) == (b.tokenizer as String) && vllm_bench_arrival_eq(a: a.arrival, b: b.arrival) + && a.seed == b.seed } // THE ARGV IS DERIVED FROM THE REQUEST, so a protocol that asked for Poisson arrivals cannot @@ -178,6 +184,7 @@ fn vllm_bench_serve_arguments(req: VllmBenchServeRequest) -> List { "--random-output-len", to_string(token_count_value(t: req.dataset.output_len)), "--random-prefix-len", to_string(token_count_value(t: req.dataset.prefix_len)), "--num-prompts", to_string(req.num_prompts), + "--seed", to_string(req.seed), "--request-rate", vllm_bench_arrival_rate_wire(a: req.arrival), ], concat( diff --git a/dag/gunbc/spark/serving_load_probe.dag b/dag/gunbc/spark/serving_load_probe.dag index dde790ad256..c29ab6e10a6 100644 --- a/dag/gunbc/spark/serving_load_probe.dag +++ b/dag/gunbc/spark/serving_load_probe.dag @@ -4,7 +4,6 @@ import std.types { Bool, String, NonEmptyStr, List, EpochSecs, Int } import std.nat { Nat } import std.decimal { ExactDecimal, canonical_exact_decimal, decimal_pow10 } import std.checked_arithmetic { checked_int_magnitude, CheckedNatReady, CheckedNatOverflow } -import v2.std.algebra { list_map } import v2.std.optional { Present, Absent } import std.measure { TokenCount, token_count, token_count_value } import product.capacity.lease { LeaseGrant } @@ -74,8 +73,10 @@ type ExclusionReceipt type ProbeWindowStanding = WindowIsolated { grant: LeaseGrant, deadline: EpochSecs, drain: DrainReceipt, exclusion: ExclusionReceipt } - | WindowSharedWithDeclaredTraffic { traffic_receipt: NonEmptyStr, drain: DrainReceipt } - | WindowIsolationUnread { cause: NonEmptyStr, drain: DrainReceipt } + | WindowIsolationNotEstablished { cause: NonEmptyStr, drain: DrainReceipt } + | ForeignTrafficObserved { attributed_receipt: NonEmptyStr, drain: DrainReceipt } + | ForeignTrafficNotObserved { drain: DrainReceipt } + | ForeignTrafficUnread { cause: NonEmptyStr, drain: DrainReceipt } fn window_isolated_requires_exclusion(s: ProbeWindowStanding) -> Bool { match s { @@ -84,8 +85,10 @@ fn window_isolated_requires_exclusion(s: ProbeWindowStanding) -> Bool { ExclusionEstablished { how: _ } => true ExclusionNotEstablished { cause: _ } => false } - WindowSharedWithDeclaredTraffic { traffic_receipt: _, drain: _ } => false - WindowIsolationUnread { cause: _, drain: _ } => false + WindowIsolationNotEstablished { cause: _, drain: _ } => false + ForeignTrafficObserved { attributed_receipt: _, drain: _ } => false + ForeignTrafficNotObserved { drain: _ } => false + ForeignTrafficUnread { cause: _, drain: _ } => false } } @@ -103,38 +106,36 @@ type ArmServiceStanding // A ZERO RUNNING GAUGE IS A DRAIN SNAPSHOT, not exclusion. The probe still refuses to START on a // non-idle queue: that would mix already-running foreign requests into the client window without a -// join. An idle start under declared operator/harness/nccl traffic remains -// WindowSharedWithDeclaredTraffic, because arrivals during the run are still possible. -fn window_from_drain(drain: DrainReceipt, traffic_receipt: NonEmptyStr) -> ProbeWindowStanding { +// join. An idle start without lease/exclusion/protected subject is WindowIsolationNotEstablished. +// A prose list of actors who might arrive is glm_native_exclusion_warning, not a traffic observation. +fn window_from_drain(drain: DrainReceipt) -> ProbeWindowStanding { match drain { - DrainUnread { cause: c } => WindowIsolationUnread { cause: c, drain: drain } + DrainUnread { cause: c } => WindowIsolationNotEstablished { cause: c, drain: drain } DrainNotIdle { running: n } => - WindowIsolationUnread { + WindowIsolationNotEstablished { cause: join(["the engine already had ", to_string(n), " running requests; the probe refuses a non-idle start"], "") as NonEmptyStr, drain: drain, } DrainObservedIdle => - WindowSharedWithDeclaredTraffic { traffic_receipt: traffic_receipt, drain: drain } - } -} - -fn isolated_window(grant: LeaseGrant, deadline: EpochSecs, drain: DrainReceipt, exclusion: ExclusionReceipt, service: ArmServiceStanding) -> ProbeWindowStanding { - match service { - ArmInService { because: c } => - WindowIsolationUnread { cause: c, drain: drain } - ArmOutOfService { how: _ } => - match exclusion { - ExclusionNotEstablished { cause: c } => - WindowIsolationUnread { cause: c, drain: drain } - ExclusionEstablished { how: _ } => - match drain { - DrainObservedIdle => - WindowIsolated { grant: grant, deadline: deadline, drain: drain, exclusion: exclusion } - DrainNotIdle { running: _ } => - WindowIsolationUnread { cause: "exclusion was named but the drain snapshot was not idle" as NonEmptyStr, drain: drain } - DrainUnread { cause: c } => - WindowIsolationUnread { cause: c, drain: drain } - } + WindowIsolationNotEstablished { + cause: "idle drain is not exclusion; isolation requires an exact lease, exclusion, idle drain, and protected subject" as NonEmptyStr, + drain: drain, + } + } +} + +fn isolated_window(grant: LeaseGrant, deadline: EpochSecs, drain: DrainReceipt, exclusion: ExclusionReceipt) -> ProbeWindowStanding { + match exclusion { + ExclusionNotEstablished { cause: c } => + WindowIsolationNotEstablished { cause: c, drain: drain } + ExclusionEstablished { how: _ } => + match drain { + DrainObservedIdle => + WindowIsolated { grant: grant, deadline: deadline, drain: drain, exclusion: exclusion } + DrainNotIdle { running: _ } => + WindowIsolationNotEstablished { cause: "exclusion was named but the drain snapshot was not idle" as NonEmptyStr, drain: drain } + DrainUnread { cause: c } => + WindowIsolationNotEstablished { cause: c, drain: drain } } } } @@ -291,14 +292,14 @@ fn preemption_count(body: String) -> Nat? { } type OperationLedger - = LedgerClosed { offered: Nat, completed: Nat, failed: Nat, failed_after_tokens: Nat } + = LedgerClosed { offered: Nat, completed: Nat, failed: Nat } | LedgerIncomplete { because: NonEmptyStr } fn ledger_admits_token_denomination(l: OperationLedger) -> Bool { match l { LedgerIncomplete { because: _ } => false - LedgerClosed { offered: o, completed: c, failed: f, failed_after_tokens: t } => - t == 0 && (c + f) == o + LedgerClosed { offered: o, completed: c, failed: f } => + c == o && f == 0 } } @@ -390,6 +391,37 @@ type ArrivalSkew = ArrivalSkewObserved { max_stagger_millis: Nat } | ArrivalSkewUnread { cause: NonEmptyStr } +type ArrivalPolicy + = ArrivalPolicySendAll + | ArrivalPolicyPoisson { millirequests_per_second: Nat, burstiness_milli: Nat } + +fn arrival_policy_from_request(req: VllmBenchServeRequest) -> ArrivalPolicy { + match req.arrival { + SendAllImmediately => ArrivalPolicySendAll + PoissonProcess { millirequests_per_second: n, burstiness_milli: b } => + ArrivalPolicyPoisson { millirequests_per_second: n, burstiness_milli: b } + } +} + +fn arrival_from_protocol(req: VllmBenchServeRequest) -> ArrivalSkew { + match arrival_policy_from_request(req: req) { + ArrivalPolicySendAll => + ArrivalSkewUnread { cause: "ArrivalPolicySendAll is input policy, not observed skew; vLLM's max_concurrency semaphore can run prompts in waves, and per-request start times were not retained" as NonEmptyStr } + ArrivalPolicyPoisson { millirequests_per_second: _, burstiness_milli: _ } => + ArrivalSkewUnread { cause: "Poisson starts are not parsed from vllm bench serve stdout until per-request start_times are retained" as NonEmptyStr } + } +} + +fn send_all_without_start_events_is_not_zero_skew(num_prompts: Nat, cap: Nat, start_event_count: Nat) -> Bool { + num_prompts == 4 + && cap == 2 + && start_event_count == 0 + && match arrival_from_protocol(req: glm_native_smoke_protocol) { + ArrivalSkewUnread { cause: _ } => true + ArrivalSkewObserved { max_stagger_millis: _ } => false + } +} + data arrival_skew_comparison_bound_millis: Nat = 250 fn arrival_admits_rate_comparison(s: ArrivalSkew) -> Bool { @@ -407,9 +439,9 @@ type OccupancySample { prompt_tokens: Nat } -type OccupancyTrace - = OccupancySampled { samples: List } - | OccupancyUnsampled { cause: NonEmptyStr } +type BoundaryOccupancyReceipt + = OccupancyBoundariesUnread { cause: NonEmptyStr } + | OccupancyBoundariesRead { before: OccupancySample, after: OccupancySample } fn metric_token_count(body: String, metric: VllmServingMetric) -> Nat? { match harness_gauge_value(body: body, metric: metric) { @@ -450,13 +482,13 @@ fn metric_count(body: String, metric: VllmServingMetric) -> Nat? { } } -fn occupancy_trace_from_endpoint_scrapes(before_body: String, after_body: String) -> OccupancyTrace { +fn occupancy_trace_from_endpoint_scrapes(before_body: String, after_body: String) -> BoundaryOccupancyReceipt { match occupancy_from_body(body: before_body) { - Absent => OccupancyUnsampled { cause: "a bound scrape could not yield running/waiting/prompt_tokens" as NonEmptyStr } + Absent => OccupancyBoundariesUnread { cause: "a bound scrape could not yield running/waiting/prompt_tokens on the before body" as NonEmptyStr } Present { value: a } => match occupancy_from_body(body: after_body) { - Absent => OccupancySampled { samples: [a] } - Present { value: b } => OccupancySampled { samples: [a, b] } + Absent => OccupancyBoundariesUnread { cause: "a bound scrape could not yield running/waiting/prompt_tokens on the after body; one boundary is not a series" as NonEmptyStr } + Present { value: b } => OccupancyBoundariesRead { before: a, after: b } } } } @@ -488,7 +520,7 @@ fn ledger_counter_agreement(ledger: OperationLedger, generation: TokenDelta, cli Present { value: g } => match ledger { LedgerIncomplete { because: c } => AgreementUnread { because: c } - LedgerClosed { offered: _, completed: n, failed: _, failed_after_tokens: _ } => + LedgerClosed { offered: _, completed: n, failed: _ } => if g > 0 && n == 0 { LedgerCounterDisagree { because: "generation_tokens_total advanced while the client ledger completed zero requests; foreign load is the remaining explanation" as NonEmptyStr } } else { @@ -545,10 +577,14 @@ fn capacity_claim_for_window(window: ProbeWindowStanding) -> CapacityClaim { match window { WindowIsolated { grant: _, deadline: _, drain: _, exclusion: _ } => CapacityClaimUnavailable { because: "one run does not decide saturation even under isolation" as NonEmptyStr } - WindowSharedWithDeclaredTraffic { traffic_receipt: _, drain: _ } => - CapacityClaimUnavailable { because: "this arm has no exclusive window; a latency distribution beside foreign load is real, an aggregate capacity claim is not" as NonEmptyStr } - WindowIsolationUnread { cause: _, drain: _ } => - CapacityClaimUnavailable { because: "window isolation is unread, so no capacity claim is available" as NonEmptyStr } + WindowIsolationNotEstablished { cause: _, drain: _ } => + CapacityClaimUnavailable { because: "this arm has no exclusive window; a latency distribution beside unattributed load is real, an aggregate capacity claim is not" as NonEmptyStr } + ForeignTrafficObserved { attributed_receipt: _, drain: _ } => + CapacityClaimUnavailable { because: "foreign traffic was attributed on this window, so an aggregate capacity claim is not available" as NonEmptyStr } + ForeignTrafficNotObserved { drain: _ } => + CapacityClaimUnavailable { because: "one run does not decide saturation even when foreign traffic was not observed" as NonEmptyStr } + ForeignTrafficUnread { cause: _, drain: _ } => + CapacityClaimUnavailable { because: "foreign-traffic standing is unread, so no capacity claim is available" as NonEmptyStr } } } @@ -589,13 +625,21 @@ type QualifiedClientRate = ClientRateQualified { tokens: Nat, scrape_millis: Nat } | ClientRateUnqualified { because: NonEmptyStr } +fn occupancy_does_not_count_positively(occupancy: BoundaryOccupancyReceipt) -> QualifiedClientRate { + match occupancy { + OccupancyBoundariesUnread { cause: c } => ClientRateUnqualified { because: c } + OccupancyBoundariesRead { before: _, after: _ } => + ClientRateUnqualified { because: "boundary occupancy is two scrapes, not a time-series over the interval; it cannot count positively toward a qualified rate" as NonEmptyStr } + } +} + fn qualify_client_rate( subject: ServingPerformanceSubjectStanding, continuity: CounterContinuity, arrival: ArrivalSkew, window: ProbeWindowStanding, agreement: LedgerCounterAgreement, - occupancy: OccupancyTrace, + occupancy: BoundaryOccupancyReceipt, foreign_work: ForeignWorkBound, rate: DerivedRate, ) -> QualifiedClientRate { @@ -616,25 +660,23 @@ fn qualify_client_rate( ClientRateUnqualified { because: "arrival standing does not admit a rate comparison" as NonEmptyStr } } else { match window { - WindowIsolationUnread { cause: c, drain: _ } => ClientRateUnqualified { because: c } - WindowSharedWithDeclaredTraffic { traffic_receipt: _, drain: _ } => - ClientRateUnqualified { because: "a shared-window client rate is telemetry, not a qualified comparable observation" as NonEmptyStr } + WindowIsolationNotEstablished { cause: c, drain: _ } => ClientRateUnqualified { because: c } + ForeignTrafficObserved { attributed_receipt: _, drain: _ } => + ClientRateUnqualified { because: "foreign traffic was attributed on this window, so the client rate is not a qualified comparable observation" as NonEmptyStr } + ForeignTrafficUnread { cause: c, drain: _ } => ClientRateUnqualified { because: c } + ForeignTrafficNotObserved { drain: _ } => + match agreement { + AgreementUnread { because: c } => ClientRateUnqualified { because: c } + LedgerCounterDisagree { because: c } => ClientRateUnqualified { because: c } + LedgerAndCounterAgree { generation_tokens: _, completed_requests: _ } => + occupancy_does_not_count_positively(occupancy: occupancy) + } WindowIsolated { grant: _, deadline: _, drain: _, exclusion: _ } => match agreement { AgreementUnread { because: c } => ClientRateUnqualified { because: c } LedgerCounterDisagree { because: c } => ClientRateUnqualified { because: c } LedgerAndCounterAgree { generation_tokens: _, completed_requests: _ } => - match occupancy { - OccupancyUnsampled { cause: c } => ClientRateUnqualified { because: c } - OccupancySampled { samples: _ } => - match foreign_work { - ForeignWorkUnread { because: c } => ClientRateUnqualified { because: c } - ForeignWorkContradiction { engine_generation: _, client_output: _, because: c } => - ClientRateUnqualified { because: c } - ForeignWorkBounded { engine_generation: _, client_output: _, surplus: _ } => - ClientRateQualified { tokens: t, scrape_millis: ms } - } - } + occupancy_does_not_count_positively(occupancy: occupancy) } } } @@ -665,8 +707,7 @@ type ClientBenchLatency tpot_milli: Nat itl_milli: Nat? ttft_milli: Nat - contended: Bool - standing: CitedFigureStanding + window: ProbeWindowStanding } type ProbeProvenance @@ -679,7 +720,7 @@ type ServingLoadObservation { window: ProbeWindowStanding continuity: CounterContinuity arrival: ArrivalSkew - occupancy: OccupancyTrace + occupancy: BoundaryOccupancyReceipt agreement: LedgerCounterAgreement before_backlog: BacklogStanding after_backlog: BacklogStanding @@ -701,19 +742,14 @@ type ServingLoadObservation { fn serving_load_observation( subject: ServingPerformanceSubjectStanding, - protocol: VllmBenchServeRequest, window: ProbeWindowStanding, continuity: CounterContinuity, - arrival: ArrivalSkew, - occupancy: OccupancyTrace, - client_output: ClientOutputTokens, - scrape_millis: Nat?, + occupancy: BoundaryOccupancyReceipt, before_body: String, after_body: String, before_incarnation: ObservedRankIncarnation?, after_incarnation: ObservedRankIncarnation?, - ledger: OperationLedger, - client_latency: ClientBenchLatency, + bench: BenchServeObservationReceipt, ) -> ServingLoadObservation { let before_p = preemption_count(body: before_body) let after_p = preemption_count(body: after_body) @@ -723,16 +759,19 @@ fn serving_load_observation( before_body: before_body, after_body: after_body, ) + let ledger = bench_serve_ledger(r: bench) + let client_output = bench_serve_completed_output(r: bench) let agreement = ledger_counter_agreement(ledger: ledger, generation: generation, client_output: client_output) let foreign = foreign_work_bound(generation: generation, client_output: client_output) let rate = derive_rate_honest( ledger: ledger, - scrape_millis: scrape_millis, + scrape_millis: bench_serve_interval(r: bench), client_output: client_output, ) + let arrival = arrival_from_protocol(req: bench.protocol) ServingLoadObservation { subject: subject, - protocol: protocol, + protocol: bench.protocol, window: window, continuity: continuity, arrival: arrival, @@ -745,9 +784,9 @@ fn serving_load_observation( iteration_tokens_booked: histogram_delta(before_body: before_body, after_body: after_body, metric: IterationTokensTotal), ledger: ledger, admission: glm_native_workload_admission, - corroboration: decode_corroboration_for_protocol(req: protocol), + corroboration: decode_corroboration_for_protocol(req: bench.protocol), provenance: glm_native_live_probe_provenance, - client_latency: client_latency, + client_latency: bench_serve_latency(r: bench, window: window), foreign_work: foreign, capacity_claim: capacity_claim_for_window(window: window), rate: rate, @@ -826,7 +865,7 @@ fn capacity_claim_text(c: CapacityClaim) -> String { fn client_latency_text(c: ClientBenchLatency) -> String { match c { ClientBenchLatencyUnread { cause: x } => join(["unread ", x as String], "") - ClientBenchLatencyReported { output_throughput_milli_tok_per_s: th, tpot_milli: tpot, itl_milli: itl, ttft_milli: ttft, contended: k, standing: _ } => + ClientBenchLatencyReported { output_throughput_milli_tok_per_s: th, tpot_milli: tpot, itl_milli: itl, ttft_milli: ttft, window: w } => join([ "bench-serve throughput_milli_tok_s=", to_string(th), " tpot_ms=", to_string(tpot), @@ -836,7 +875,7 @@ fn client_latency_text(c: ClientBenchLatency) -> String { Present { value: n } => to_string(n) }, " ttft_ms=", to_string(ttft), - " contended=", if k { "yes" } else { "no" }, + " window=", window_text(s: w), ], "") } } @@ -865,11 +904,11 @@ fn occupancy_sample_text(s: OccupancySample) -> String { ], "") } -fn occupancy_text(t: OccupancyTrace) -> String { +fn occupancy_text(t: BoundaryOccupancyReceipt) -> String { match t { - OccupancyUnsampled { cause: c } => join(["unsampled ", c as String], "") - OccupancySampled { samples: ss } => - join(["samples=", to_string(length(ss)), " ", join(list_map(xs: ss, f: occupancy_sample_text), " | ")], "") + OccupancyBoundariesUnread { cause: c } => join(["unread ", c as String], "") + OccupancyBoundariesRead { before: a, after: b } => + join(["boundaries before=", occupancy_sample_text(s: a), " after=", occupancy_sample_text(s: b)], "") } } @@ -892,10 +931,14 @@ fn admission_text(a: AdmissionCost) -> String { fn window_text(s: ProbeWindowStanding) -> String { match s { WindowIsolated { grant: _, deadline: _, drain: _, exclusion: _ } => "isolated" - WindowSharedWithDeclaredTraffic { traffic_receipt: t, drain: d } => - join(["shared-with-declared-traffic drain=", drain_text(d: d), " traffic=", t as String], "") - WindowIsolationUnread { cause: c, drain: d } => - join(["unread drain=", drain_text(d: d), " cause=", c as String], "") + WindowIsolationNotEstablished { cause: c, drain: d } => + join(["isolation-not-established drain=", drain_text(d: d), " cause=", c as String], "") + ForeignTrafficObserved { attributed_receipt: t, drain: d } => + join(["foreign-traffic-observed drain=", drain_text(d: d), " attributed=", t as String], "") + ForeignTrafficNotObserved { drain: d } => + join(["foreign-traffic-not-observed drain=", drain_text(d: d)], "") + ForeignTrafficUnread { cause: c, drain: d } => + join(["foreign-traffic-unread drain=", drain_text(d: d), " cause=", c as String], "") } } @@ -937,8 +980,8 @@ fn histogram_text(d: HistogramDelta) -> String { fn ledger_text(l: OperationLedger) -> String { match l { LedgerIncomplete { because: c } => join(["incomplete ", c as String], "") - LedgerClosed { offered: o, completed: c, failed: f, failed_after_tokens: t } => - join(["closed offered=", to_string(o), " completed=", to_string(c), " failed=", to_string(f), " failed_after_tokens=", to_string(t)], "") + LedgerClosed { offered: o, completed: c, failed: f } => + join(["aggregate-summary closed offered=", to_string(o), " completed=", to_string(c), " failed=", to_string(f)], "") } } @@ -1013,6 +1056,8 @@ data glm_native_sweep_dataset: RandomDatasetSpec = RandomDatasetSpec { prefix_len: token_count(count: 0), } +data glm_native_bench_seed: Nat = 20260918 + data glm_native_smoke_protocol: VllmBenchServeRequest = vllm_bench_serve_request( backend: OpenaiChat, base_url: "http://127.0.0.1:30000" as NonEmptyStr, @@ -1023,6 +1068,7 @@ data glm_native_smoke_protocol: VllmBenchServeRequest = vllm_bench_serve_request arrival: SendAllImmediately, max_concurrency: Present { value: 2 }, ignore_eos: true, + seed: glm_native_bench_seed, ) data glm_native_holistic_protocol: VllmBenchServeRequest = vllm_bench_serve_request( @@ -1035,6 +1081,7 @@ data glm_native_holistic_protocol: VllmBenchServeRequest = vllm_bench_serve_requ arrival: PoissonProcess { millirequests_per_second: 50, burstiness_milli: 1000 }, max_concurrency: Present { value: 2 }, ignore_eos: true, + seed: glm_native_bench_seed, ) data glm_native_live_probe_provenance: ProbeProvenance = DriverObserverSplit { @@ -1042,7 +1089,7 @@ data glm_native_live_probe_provenance: ProbeProvenance = DriverObserverSplit { observer: "deep-otter-201 HTTP scrape of 192.168.1.236:30000/metrics" as NonEmptyStr, } -data glm_native_declared_shared_traffic: NonEmptyStr = "operator interactive long-context sessions (70-110k prompt jumps) share Group B as production traffic with no exclusive window; gunbc.harness.harness_cli harness_probe_cli may POST a turn; proud-boar-181 nccl-tests all_reduce_perf may allocate GPU buffers; a drain snapshot is not exclusion and is not out-of-service" as NonEmptyStr +data glm_native_exclusion_warning: NonEmptyStr = "operator interactive long-context sessions (70-110k prompt jumps) share Group B as production traffic with no exclusive window; gunbc.harness.harness_cli harness_probe_cli may POST a turn; proud-boar-181 nccl-tests all_reduce_perf may allocate GPU buffers; a drain snapshot is not exclusion and is not out-of-service" as NonEmptyStr data glm_native_arm_service: ArmServiceStanding = ArmInService { because: "the operator serves interactive work on this arm; WindowIsolated requires an out-of-service receipt that has not been issued" as NonEmptyStr @@ -1058,31 +1105,38 @@ data glm_native_wiring_smoke_protocol: VllmBenchServeRequest = vllm_bench_serve_ arrival: SendAllImmediately, max_concurrency: Present { value: 2 }, ignore_eos: true, + seed: glm_native_bench_seed, ) // Client TTFT/TPOT/ITL from vllm bench serve stdout, transcribed from the 2026-09-18 wiring // smoke (256/64, inf rate, c=2, 4/4 ok). Contended. Not the 256/128 sweep protocol. -data glm_native_smoke_client_latency: ClientBenchLatency = ClientBenchLatencyReported { +type TranscribedClientLatency { + output_throughput_milli_tok_per_s: Nat + tpot_milli: Nat + itl_milli: Nat? + ttft_milli: Nat + standing: CitedFigureStanding +} + +data glm_native_smoke_client_latency: TranscribedClientLatency = TranscribedClientLatency { output_throughput_milli_tok_per_s: 17390 tpot_milli: 82 itl_milli: Present { value: 82 } ttft_milli: 2185 - contended: true standing: TranscribedUncited { read_obligation: "re-read vllm bench serve stdout for the 256-in/64-out wiring argv; the 17.39 tok/s / 82.1 ms TPOT / 81.8 ms ITL / 2185 ms TTFT figures were transcribed from calm-bat-65's docker-exec receipt" as NonEmptyStr } } data glm_native_wet_smoke_standing: CitedFigureStanding = TranscribedUncited { - read_obligation: "re-read calm-bat-65 docker-exec stdout for glm_native_smoke_protocol (256-in/128-out/prefix 0/4 prompts/inf/c=2/ignore-eos) on 192.168.1.236 under WindowSharedWithDeclaredTraffic" as NonEmptyStr + read_obligation: "re-read calm-bat-65 docker-exec stdout for glm_native_smoke_protocol (256-in/128-out/prefix 0/4 prompts/inf/c=2/ignore-eos) on 192.168.1.236" as NonEmptyStr } -data glm_native_wet_smoke_client_latency: ClientBenchLatency = ClientBenchLatencyReported { +data glm_native_wet_smoke_client_latency: TranscribedClientLatency = TranscribedClientLatency { output_throughput_milli_tok_per_s: 22510 tpot_milli: 82 itl_milli: Present { value: 83 } ttft_milli: 996 - contended: true standing: glm_native_wet_smoke_standing } @@ -1141,17 +1195,15 @@ fn bench_labeled_whole_milli(body: String, label: String) -> Nat? { fn ledger_from_bench_stdout(body: String, offered: Nat) -> OperationLedger { match bench_labeled_nat(body: body, label: "Successful requests") { - Absent => LedgerIncomplete { because: "vllm bench serve stdout carried no unique Successful requests line" as NonEmptyStr } + Absent => LedgerIncomplete { because: "vllm bench serve stdout carried no unique Successful requests aggregate-summary line" as NonEmptyStr } Present { value: completed } => match bench_labeled_nat(body: body, label: "Failed requests") { - Absent => LedgerIncomplete { because: "vllm bench serve stdout carried no unique Failed requests line, so failed-after-tokens standing is unknown" as NonEmptyStr } + Absent => LedgerIncomplete { because: "vllm bench serve stdout carried no unique Failed requests aggregate-summary line" as NonEmptyStr } Present { value: failed } => - if (completed + failed) != offered { - LedgerIncomplete { because: "successful plus failed requests did not equal the offered prompt count" as NonEmptyStr } - } else if failed == 0 { - LedgerClosed { offered: offered, completed: completed, failed: failed, failed_after_tokens: 0 } + if completed == offered && failed == 0 { + LedgerClosed { offered: offered, completed: completed, failed: failed } } else { - LedgerIncomplete { because: "failed requests were reported and the summary does not distinguish failed-after-tokens from failed-with-no-tokens" as NonEmptyStr } + LedgerIncomplete { because: "the aggregate summary is not a per-request ledger; closed standing requires completed == offered and failed == 0" as NonEmptyStr } } } } @@ -1192,15 +1244,7 @@ fn client_bucket_peak_from_bench_stdout(body: String, client_max_concurrency: Na } } -fn arrival_from_protocol(req: VllmBenchServeRequest) -> ArrivalSkew { - match req.arrival { - SendAllImmediately => ArrivalSkewObserved { max_stagger_millis: 0 } - PoissonProcess { millirequests_per_second: _, burstiness_milli: _ } => - ArrivalSkewUnread { cause: "Poisson starts are not parsed from vllm bench serve stdout until per-request start_times are retained" as NonEmptyStr } - } -} - -fn client_latency_from_bench_stdout(body: String, contended: Bool) -> ClientBenchLatency { +fn client_latency_from_bench_stdout(body: String, window: ProbeWindowStanding) -> ClientBenchLatency { match bench_labeled_milli_from_seconds(body: body, label: "Output token throughput (tok/s)") { Absent => ClientBenchLatencyUnread { cause: "vllm bench serve stdout carried no unique Output token throughput (tok/s) line" as NonEmptyStr } Present { value: th } => @@ -1215,16 +1259,80 @@ fn client_latency_from_bench_stdout(body: String, contended: Bool) -> ClientBenc tpot_milli: tpot, itl_milli: bench_labeled_whole_milli(body: body, label: "Mean ITL (ms)"), ttft_milli: ttft, - contended: contended, - standing: TranscribedUncited { - read_obligation: "this arm is a live parse of vllm bench serve stdout, not a transcribed figure; re-run glm_native_serving_load_wet to re-derive" as NonEmptyStr - }, + window: window, } } } } } +type BenchServeProcessOutcome + = BenchServeExited { exit_code: Nat } + | BenchServeUnreachable { cause: NonEmptyStr } + +type BenchServeObservationReceipt sole_constructor { + protocol: VllmBenchServeRequest + process_outcome: BenchServeProcessOutcome + raw_stdout: String + raw_stderr: String +} + +fn bench_serve_observation_receipt( + protocol: VllmBenchServeRequest, + process_outcome: BenchServeProcessOutcome, + raw_stdout: String, + raw_stderr: String, +) -> BenchServeObservationReceipt { + BenchServeObservationReceipt { + protocol: protocol, + process_outcome: process_outcome, + raw_stdout: raw_stdout, + raw_stderr: raw_stderr, + } +} + +fn bench_serve_parse_body(r: BenchServeObservationReceipt) -> String { + join([r.raw_stdout, "\n", r.raw_stderr], "") +} + +fn bench_serve_ledger(r: BenchServeObservationReceipt) -> OperationLedger { + ledger_from_bench_stdout(body: bench_serve_parse_body(r: r), offered: r.protocol.num_prompts) +} + +fn bench_serve_completed_output(r: BenchServeObservationReceipt) -> ClientOutputTokens { + client_output_from_bench_stdout(body: bench_serve_parse_body(r: r)) +} + +fn bench_serve_interval(r: BenchServeObservationReceipt) -> Nat? { + scrape_millis_from_bench_stdout(body: bench_serve_parse_body(r: r)) +} + +fn bench_serve_latency(r: BenchServeObservationReceipt, window: ProbeWindowStanding) -> ClientBenchLatency { + client_latency_from_bench_stdout(body: bench_serve_parse_body(r: r), window: window) +} + +fn bench_serve_itl(r: BenchServeObservationReceipt) -> ClientItlDistribution { + client_itl_from_bench_stdout(body: bench_serve_parse_body(r: r)) +} + +fn bench_serve_bucket_peak(r: BenchServeObservationReceipt) -> ClientRequestConcurrencyStanding { + match r.protocol.max_concurrency { + Absent => ClientConcurrencyUnread { cause: "the protocol did not declare max-concurrency" as NonEmptyStr } + Present { value: c } => client_bucket_peak_from_bench_stdout(body: bench_serve_parse_body(r: r), client_max_concurrency: c) + } +} + +fn mixed_run_client_facts_cannot_be_written(a: BenchServeObservationReceipt, b: BenchServeObservationReceipt) -> Bool { + match bench_serve_interval(r: a) { + Absent => false + Present { value: ia } => + match bench_serve_interval(r: b) { + Absent => false + Present { value: ib } => ia != ib + } + } +} + type RateTokenDenomination = RateDenominatedInCompletedOutputTokens { because: NonEmptyStr } | RateDenominatedInTotalTokensIncludingPrefill { because: NonEmptyStr } @@ -1256,7 +1364,7 @@ data glm_native_wet_smoke_duration_millis: Nat = 22750 fn glm_native_wet_smoke_rate() -> DerivedRate { derive_rate_honest( - ledger: LedgerClosed { offered: 4, completed: 4, failed: 0, failed_after_tokens: 0 }, + ledger: LedgerClosed { offered: 4, completed: 4, failed: 0 }, scrape_millis: Present { value: glm_native_wet_smoke_duration_millis }, client_output: glm_native_wet_smoke_client_output, ) @@ -1302,6 +1410,7 @@ fn glm_native_contended_sweep_protocol(concurrency: Nat) -> VllmBenchServeReques arrival: SendAllImmediately, max_concurrency: Present { value: concurrency }, ignore_eos: true, + seed: glm_native_bench_seed, ) } @@ -1309,13 +1418,12 @@ fn glm_native_contended_client_latency( throughput_milli_tok_per_s: Nat, tpot_milli: Nat, ttft_milli: Nat, -) -> ClientBenchLatency { - ClientBenchLatencyReported { +) -> TranscribedClientLatency { + TranscribedClientLatency { output_throughput_milli_tok_per_s: throughput_milli_tok_per_s, tpot_milli: tpot_milli, itl_milli: none, ttft_milli: ttft_milli, - contended: true, standing: glm_native_contended_sweep_standing, } } @@ -1323,7 +1431,7 @@ fn glm_native_contended_client_latency( type ContendedSweepPoint { concurrency: Nat protocol: VllmBenchServeRequest - latency: ClientBenchLatency + latency: TranscribedClientLatency } fn glm_native_contended_sweep_point( @@ -1367,14 +1475,14 @@ data glm_native_contended_sweep_points: List = [ glm_native_contended_sweep_c16, ] -// ABSOLUTE tok/s ARE NOT A CAPACITY under WindowSharedWithDeclaredTraffic. Elasticity +// ABSOLUTE tok/s ARE NOT A CAPACITY without an exclusive window. Elasticity // log(throughput ratio)/log(concurrency ratio) is a SHAPE that requires a controlled series. // The five contended points are shared-window client latency; they are not that series. type UncontrolledSeriesElasticity = ElasticityNotOnUncontrolledSeries { because: NonEmptyStr } data glm_native_contended_sweep_elasticity: UncontrolledSeriesElasticity = ElasticityNotOnUncontrolledSeries { - because: "glm_native_contended_sweep_points were taken under WindowSharedWithDeclaredTraffic; log(throughput ratio)/log(concurrency ratio) on that series is not a scaling elasticity" as NonEmptyStr + because: "glm_native_contended_sweep_points were taken without an exclusive window; log(throughput ratio)/log(concurrency ratio) on that series is not a scaling elasticity" as NonEmptyStr } fn elasticity_is_off_the_uncontrolled_series(s: UncontrolledSeriesElasticity) -> Bool { @@ -1383,45 +1491,12 @@ fn elasticity_is_off_the_uncontrolled_series(s: UncontrolledSeriesElasticity) -> } } -// TPOT 8→16 is nearly flat while throughput still rises; TTFT at 16 is the sharp move. -// This is not a realization selection and not a capacity claim. It is the observation that a -// latency floor, if one entered policy, would bind on TTFT here rather than on throughput. -type ContendedLatencyFloorHint - = TtftWouldBindConcurrency { - from_concurrency: Nat - to_concurrency: Nat - tpot_rise_milli_percent: Nat - throughput_rise_milli_percent: Nat - ttft_from_milli: Nat - ttft_to_milli: Nat - standing: CitedFigureStanding - } +fn glm_native_sweep_ttft_c8() -> Nat { + glm_native_contended_sweep_c8.latency.ttft_milli +} -fn glm_native_ttft_would_bind_on_this_sweep() -> Bool { - match glm_native_ttft_binds_concurrency { - TtftWouldBindConcurrency { - from_concurrency: a, - to_concurrency: b, - tpot_rise_milli_percent: tpot, - throughput_rise_milli_percent: thr, - ttft_from_milli: _, - ttft_to_milli: ttft, - standing: _, - } => - a == 8 && b == 16 && tpot == 45 && thr == 630 && ttft == 5218 - } -} - -data glm_native_ttft_binds_concurrency: ContendedLatencyFloorHint = TtftWouldBindConcurrency { - from_concurrency: 8 - to_concurrency: 16 - tpot_rise_milli_percent: 45 - throughput_rise_milli_percent: 630 - ttft_from_milli: 2602 - ttft_to_milli: 5218 - standing: TranscribedUncited { - read_obligation: "re-read glm_native_contended_sweep_c8 and glm_native_contended_sweep_c16 for TPOT 189.6→198.2 ms (+4.5%) and throughput 38.36→62.53 tok/s (+63%) with TTFT 2602→5218 ms" as NonEmptyStr - } +fn glm_native_sweep_ttft_c16() -> Nat { + glm_native_contended_sweep_c16.latency.ttft_milli } type WindowStandingGapSpecimen { @@ -1471,7 +1546,7 @@ type LongContextExecutionStanding | LongContextRunnable { because: NonEmptyStr } data glm_native_holistic_execution: LongContextExecutionStanding = LongContextLoadProtocolPrototype { - until: "the arm carries an ArmOutOfService receipt; a 100k-prefix protocol is not executed on an in-service operator arm" as NonEmptyStr + until: "the qualification-window law holds: exact lease and exclusion, idle drain, and a protected subject; a 100k-prefix protocol stays a prototype until that window can be established" as NonEmptyStr } // TRANSCRIBED BOUND, NOT A READING. Parent derived ~10.7 GB active weights / ~9-11 ms memory-bandwidth diff --git a/dag/gunbc/spark/serving_load_probe_cli.dag b/dag/gunbc/spark/serving_load_probe_cli.dag index b7ad1e16de9..da5556a436e 100644 --- a/dag/gunbc/spark/serving_load_probe_cli.dag +++ b/dag/gunbc/spark/serving_load_probe_cli.dag @@ -1,7 +1,6 @@ module gunbc.spark.serving_load_probe_cli import std.types { Bool, List, NonEmptyStr, String } -import v2.std.optional { Present, Absent } import std.process { ProcessExit, ExitSuccess, exit_failure } import std.resources { Network } import extdeps.filesystem.filesystem_io { Filesystem } @@ -24,25 +23,25 @@ import gunbc.harness.harness_backend { harness_launch_from_body, harness_queue_f import gunbc.spark.fabric_switch_observed { FabricGroupB } import gunbc.spark.serving_load_probe { glm_native_live_subject_standing, - glm_native_declared_shared_traffic, glm_native_smoke_protocol, + glm_native_smoke_protocol, serving_load_observation, serving_load_observation_text, drain_from_queue, window_from_drain, counter_continuity, occupancy_trace_from_endpoint_scrapes, - ledger_from_bench_stdout, client_output_from_bench_stdout, scrape_millis_from_bench_stdout, - client_latency_from_bench_stdout, arrival_from_protocol, - client_itl_from_bench_stdout, client_bucket_peak_from_bench_stdout, + bench_serve_observation_receipt, BenchServeExited, BenchServeUnreachable, + bench_serve_bucket_peak, bench_serve_itl, client_second_bucket_peak_establishes_foreign_work, itl_tail_cause_is_unestablished, - ClientConcurrencyUnread, - WindowSharedWithDeclaredTraffic, WindowIsolated, WindowIsolationUnread, + WindowIsolated, WindowIsolationNotEstablished, + ForeignTrafficObserved, ForeignTrafficNotObserved, ForeignTrafficUnread, + DrainObservedIdle, DrainNotIdle, DrainUnread, RateFromClientOutputTokens, RateUndenominable, RateUnreadable, } // ── THE INHABITANCE ROUTE ───────────────────────────────────────────────────────────────────── // -// Witnesses supply metric bodies. This function is the one that drives `vllm bench serve` against -// the live native GLM head and folds receipts. A non-idle drain REFUSES the start. An idle start -// is still WindowSharedWithDeclaredTraffic because operator/harness/nccl traffic may arrive during -// the run. The rate is parsed from bench duration and Total generated tokens, not from exit_ok. +// Witnesses supply metric bodies. This function drives `vllm bench serve` against the live native +// GLM head. A non-idle drain REFUSES the start. An idle start is WindowIsolationNotEstablished: +// glm_native_exclusion_warning names actors who might arrive, and is not a traffic observation. +// Client facts are derived from one BenchServeObservationReceipt. // // gunbc run --source-root dag --source-root src/v2 \ // --entry dag/gunbc/spark/serving_load_probe_cli.dag --function glm_native_serving_load_wet @@ -102,14 +101,20 @@ fn glm_native_serving_load_wet() -> ProcessExit exit_failure(reason: before) } else { let drain = drain_from_queue(q: harness_queue_from_body(body: before)) - let window = window_from_drain( - drain: drain, - traffic_receipt: glm_native_declared_shared_traffic, - ) + let window = window_from_drain(drain: drain) match window { - WindowIsolationUnread { cause: c, drain: _ } => exit_failure(reason: c as String) - WindowIsolated { grant: _, deadline: _, drain: _, exclusion: _ } => exit_failure(reason: "an isolated window is not this arm's inhabitance path") - WindowSharedWithDeclaredTraffic { traffic_receipt: _, drain: _ } => { + WindowIsolated { grant: _, deadline: _, drain: _, exclusion: _ } => + exit_failure(reason: "an isolated window is not this arm's inhabitance path") + ForeignTrafficObserved { attributed_receipt: _, drain: _ } => + exit_failure(reason: "attributed foreign traffic is not this arm's inhabitance path") + ForeignTrafficNotObserved { drain: _ } => + exit_failure(reason: "foreign-traffic-not-observed is not this arm's inhabitance path") + ForeignTrafficUnread { cause: c, drain: _ } => exit_failure(reason: c as String) + WindowIsolationNotEstablished { cause: c, drain: d } => + match d { + DrainNotIdle { running: _ } => exit_failure(reason: c as String) + DrainUnread { cause: u } => exit_failure(reason: u as String) + DrainObservedIdle => { let before_incarnation = inspect_incarnation(ctx: ctx) let bench = spark_remote_run(ctx: ctx, argv: bench_exec_argv()) let after = remote_or_fail(ctx: ctx, argv: curl_metrics_argv(), step: "metrics-after") @@ -117,47 +122,50 @@ fn glm_native_serving_load_wet() -> ProcessExit exit_failure(reason: after) } else { let after_incarnation = inspect_incarnation(ctx: ctx) - let bench_ok = match bench { - RemoteUnreachable { cause: _ } => false - RemoteRan { exit_code: code, stdout: _, stderr: _ } => code == 0 + let outcome = match bench { + RemoteUnreachable { cause: c } => BenchServeUnreachable { cause: c as NonEmptyStr } + RemoteRan { exit_code: code, stdout: _, stderr: _ } => BenchServeExited { exit_code: code } } - let bench_text = match bench { - RemoteUnreachable { cause: c } => join(["bench unreachable: ", c], "") - RemoteRan { exit_code: code, stdout: out, stderr: err } => - join(["bench exit=", to_string(code), "\n", out, "\n", err], "") + let stdout = match bench { + RemoteUnreachable { cause: c } => c + RemoteRan { exit_code: _, stdout: out, stderr: _ } => out + } + let stderr = match bench { + RemoteUnreachable { cause: _ } => "" + RemoteRan { exit_code: _, stdout: _, stderr: err } => err + } + let receipt = bench_serve_observation_receipt( + protocol: glm_native_smoke_protocol, + process_outcome: outcome, + raw_stdout: stdout, + raw_stderr: stderr, + ) + let bench_ok = match outcome { + BenchServeUnreachable { cause: _ } => false + BenchServeExited { exit_code: code } => code == 0 } let before_launch = harness_launch_from_body(group: FabricGroupB, address: "192.168.1.236", body: before) let after_launch = harness_launch_from_body(group: FabricGroupB, address: "192.168.1.236", body: after) let occ = occupancy_trace_from_endpoint_scrapes(before_body: before, after_body: after) - let ledger = ledger_from_bench_stdout(body: bench_text, offered: glm_native_smoke_protocol.num_prompts) - let client_output = client_output_from_bench_stdout(body: bench_text) - let bucket = match glm_native_smoke_protocol.max_concurrency { - Absent => ClientConcurrencyUnread { cause: "the smoke protocol did not declare max-concurrency" as NonEmptyStr } - Present { value: c } => client_bucket_peak_from_bench_stdout(body: bench_text, client_max_concurrency: c) - } - let itl = client_itl_from_bench_stdout(body: bench_text) + let bucket = bench_serve_bucket_peak(r: receipt) + let itl = bench_serve_itl(r: receipt) let obs = serving_load_observation( subject: glm_native_live_subject_standing(), - protocol: glm_native_smoke_protocol, window: window, continuity: counter_continuity(before: before_launch, after: after_launch), - arrival: arrival_from_protocol(req: glm_native_smoke_protocol), occupancy: occ, - client_output: client_output, - scrape_millis: scrape_millis_from_bench_stdout(body: bench_text), before_body: before, after_body: after, before_incarnation: before_incarnation, after_incarnation: after_incarnation, - ledger: ledger, - client_latency: client_latency_from_bench_stdout(body: bench_text, contended: true), + bench: receipt, ) let body = join([ "glm native serving-load wet at ", probed_at_word(reading: clock_now_probed_at()) as String, "\n", serving_load_observation_text(o: obs), "\nbucket_peak_establishes_foreign_work=", if client_second_bucket_peak_establishes_foreign_work(p: bucket) { "yes" } else { "no" }, "\n", "itl_tail_cause_unestablished=", if itl_tail_cause_is_unestablished(d: itl) { "yes" } else { "no" }, "\n", - "\n--- bench ---\n", bench_text, "\n", + "\n--- bench ---\n", stdout, "\n", stderr, "\n", ], "") let w = Filesystem.Write(path: glm_native_serving_load_receipt_path, content: body) if !w.success { @@ -172,7 +180,8 @@ fn glm_native_serving_load_wet() -> ProcessExit } } } - } + } + } } } }, attempt_raw: glm_native_serving_load_attempt_raw, credential_file_name: "gunbc-glm-native-serving-load-admin-password" as NonEmptyStr) diff --git a/dag/test/claim/spark/serving_load_probe_witness_test.dag b/dag/test/claim/spark/serving_load_probe_witness_test.dag index 153d36378c3..9e64952205d 100644 --- a/dag/test/claim/spark/serving_load_probe_witness_test.dag +++ b/dag/test/claim/spark/serving_load_probe_witness_test.dag @@ -16,6 +16,7 @@ import gunbc.spark.fabric_switch_observed { FabricGroupB } import gunbc.spark.vllm_endpoint_process_launch { vllm_endpoint_process_launch, VllmEndpointProcessLaunchObservation, LaunchObserved, LaunchUnobserved, } +import gunbc.harness.harness_backend { harness_queue_from_body } import extdeps.vllm.metrics { InterTokenLatencySeconds } import extdeps.vllm.bench_serve { VllmBenchServeRequest, RandomDatasetSpec, OpenaiChat, SendAllImmediately, PoissonProcess, @@ -27,7 +28,8 @@ import extdeps.external_authority { TranscribedUncited, CitedToAuthority } import gunbc.spark.serving_load_probe { DrainObservedIdle, DrainNotIdle, ExclusionNotEstablished, ExclusionEstablished, - WindowIsolated, WindowSharedWithDeclaredTraffic, WindowIsolationUnread, + WindowIsolated, WindowIsolationNotEstablished, + ForeignTrafficObserved, ForeignTrafficNotObserved, ForeignTrafficUnread, window_from_drain, isolated_window, drain_from_queue, ArmInService, ArmOutOfService, OperationLedger, LedgerClosed, LedgerIncomplete, ledger_admits_token_denomination, @@ -38,15 +40,21 @@ import gunbc.spark.serving_load_probe { saturation_from_one_run, observation_rate_is_stored_separately, foreign_work_bound, ForeignWorkBounded, ForeignWorkUnread, ForeignWorkContradiction, ClientRateUnqualified, ClientRateQualified, - occupancy_from_body, histogram_delta, HistogramDeltaRead, HistogramDeltaUnread, HistogramCounterReset, + occupancy_from_body, occupancy_trace_from_endpoint_scrapes, histogram_delta, HistogramDeltaRead, HistogramDeltaUnread, HistogramCounterReset, CapacityClaimUnavailable, glm_native_holistic_protocol, holistic_protocol_is_session_shaped, glm_native_live_subject_standing, counter_continuity, SameExporter, ExporterChanged, ContinuityUnread, - OccupancySampled, OccupancyUnsampled, OccupancySample, + OccupancyBoundariesRead, OccupancyBoundariesUnread, OccupancySample, + occupancy_does_not_count_positively, qualify_client_rate, + send_all_without_start_events_is_not_zero_skew, + bench_serve_observation_receipt, BenchServeObservationReceipt, BenchServeExited, mixed_run_client_facts_cannot_be_written, + bench_serve_interval, bench_serve_ledger, + glm_native_exclusion_warning, + glm_native_sweep_ttft_c8, glm_native_sweep_ttft_c16, ClientOutputTokensUnread, ClientOutputTokensObserved, ClientBenchLatencyUnread, ClientBenchLatencyReported, glm_native_workload_admission, - glm_native_declared_shared_traffic, + glm_native_exclusion_warning, glm_native_single_stream_decode_bound_millis, glm_native_single_stream_decode_bound_standing, glm_native_engine_tokenizer_path, @@ -58,7 +66,6 @@ import gunbc.spark.serving_load_probe { glm_native_contended_sweep_c16, glm_native_contended_sweep_points, glm_native_contended_sweep_elasticity, elasticity_is_off_the_uncontrolled_series, glm_native_wet_smoke_is_not_sweep_c1_protocol, glm_native_wet_smoke_rate_is_output_tokens, - glm_native_ttft_would_bind_on_this_sweep, glm_native_window_standing_specimen, window_standing_gap_is_unattributed, cap_2_bucket_peak_4_is_not_foreign_work, SuccessfulClientRequestSecondBucketPeak, ClientItlDistributionObserved, ClientItlDistributionUnread, itl_tail_cause_is_unestablished, @@ -99,47 +106,47 @@ data fx_after: String = metrics_body(running: "0.0", waiting: "0.0", capacity: " data fx_reset: String = metrics_body(running: "0.0", waiting: "0.0", capacity: "0.0", preempt: "0.0", itl_sum: "1.0", itl_count: "10.0", itok_sum: "10.0", itok_count: "1.0", gen: "10.0", start: "1789300000.12") data fx_busy: String = metrics_body(running: "3.0", waiting: "2.0", capacity: "2.0", preempt: "1.0", itl_sum: "10.0", itl_count: "100.0", itok_sum: "1000.0", itok_count: "10.0", gen: "1000.0", start: "1789300000.12") -fn tight_arrival() -> ArrivalSkewObserved { - ArrivalSkewObserved { max_stagger_millis: 0 } -} - fn closed_ok() -> OperationLedger { - LedgerClosed { offered: 4, completed: 4, failed: 0, failed_after_tokens: 0 } + LedgerClosed { offered: 4, completed: 4, failed: 0 } } -fn closed_failed_after_tokens() -> OperationLedger { - LedgerClosed { offered: 4, completed: 3, failed: 0, failed_after_tokens: 1 } +fn incomplete_failed_summary() -> OperationLedger { + LedgerIncomplete { because: "failed requests in the aggregate summary" as NonEmptyStr } } test fn a_busy_drain_refuses_the_window() -> Bool { let d = drain_from_queue(q: harness_queue_from_body(body: fx_busy)) - match window_from_drain(drain: d, traffic_receipt: "fx" as NonEmptyStr) { - WindowIsolationUnread { cause: _, drain: DrainNotIdle { running: n } } => n == 3 - WindowIsolationUnread { cause: _, drain: _ } => false + match window_from_drain(drain: d) { + WindowIsolationNotEstablished { cause: _, drain: DrainNotIdle { running: n } } => n == 3 + WindowIsolationNotEstablished { cause: _, drain: _ } => false WindowIsolated { grant: _, deadline: _, drain: _, exclusion: _ } => false - WindowSharedWithDeclaredTraffic { traffic_receipt: _, drain: _ } => false + ForeignTrafficObserved { attributed_receipt: _, drain: _ } => false + ForeignTrafficNotObserved { drain: _ } => false + ForeignTrafficUnread { cause: _, drain: _ } => false } } test fn a_quiet_drain_is_not_an_isolated_window() -> Bool { let d = drain_from_queue(q: harness_queue_from_body(body: fx_idle)) - let w = window_from_drain(drain: d, traffic_receipt: "coordinated with parent; no exclusion receipt" as NonEmptyStr) + let w = window_from_drain(drain: d) match w { WindowIsolated { grant: _, deadline: _, drain: _, exclusion: _ } => false - WindowSharedWithDeclaredTraffic { traffic_receipt: _, drain: DrainObservedIdle } => true - WindowSharedWithDeclaredTraffic { traffic_receipt: _, drain: _ } => false - WindowIsolationUnread { cause: _, drain: _ } => false + WindowIsolationNotEstablished { cause: _, drain: DrainObservedIdle } => true + WindowIsolationNotEstablished { cause: _, drain: _ } => false + ForeignTrafficObserved { attributed_receipt: _, drain: _ } => false + ForeignTrafficNotObserved { drain: _ } => false + ForeignTrafficUnread { cause: _, drain: _ } => false } } -test fn declared_shared_traffic_names_the_harness_probe_and_nccl_tests() -> Bool { - string_contains(s: glm_native_declared_shared_traffic as String, pattern: "harness_probe_cli") - && string_contains(s: glm_native_declared_shared_traffic as String, pattern: "nccl-tests") - && string_contains(s: glm_native_declared_shared_traffic as String, pattern: "operator") - && string_contains(s: glm_native_declared_shared_traffic as String, pattern: "70-110k") +test fn exclusion_warning_names_actors_who_might_arrive() -> Bool { + string_contains(s: glm_native_exclusion_warning as String, pattern: "harness_probe_cli") + && string_contains(s: glm_native_exclusion_warning as String, pattern: "nccl-tests") + && string_contains(s: glm_native_exclusion_warning as String, pattern: "operator") + && string_contains(s: glm_native_exclusion_warning as String, pattern: "70-110k") } -test fn isolated_window_refuses_while_the_arm_is_in_service() -> Bool { +test fn isolated_window_requires_exclusion_and_idle_drain() -> Bool { let grant = lease_grant( reference: "probe" as NonEmptyStr, fence: lease_fence_of(admitting_event: "e" as EventId, generation: 1), @@ -151,12 +158,12 @@ test fn isolated_window_refuses_while_the_arm_is_in_service() -> Bool { deadline: 61, drain: DrainObservedIdle, exclusion: ExclusionEstablished { how: "named" as NonEmptyStr }, - service: glm_native_arm_service, ) { - WindowIsolationUnread { cause: _, drain: DrainObservedIdle } => true - WindowIsolationUnread { cause: _, drain: _ } => false - WindowIsolated { grant: _, deadline: _, drain: _, exclusion: _ } => false - WindowSharedWithDeclaredTraffic { traffic_receipt: _, drain: _ } => false + WindowIsolated { grant: _, deadline: _, drain: _, exclusion: _ } => true + WindowIsolationNotEstablished { cause: _, drain: _ } => false + ForeignTrafficObserved { attributed_receipt: _, drain: _ } => false + ForeignTrafficNotObserved { drain: _ } => false + ForeignTrafficUnread { cause: _, drain: _ } => false } } @@ -167,16 +174,18 @@ test fn isolated_window_refuses_without_exclusion() -> Bool { granted_at: 1, policy: LeasePolicy { maximum_duration_seconds: 60, release_law: FencedResource }, ) - match isolated_window(grant: grant, deadline: 61, drain: DrainObservedIdle, exclusion: ExclusionNotEstablished { cause: "route was not withdrawn" as NonEmptyStr }, service: ArmInService { because: "operator interactive" as NonEmptyStr }) { - WindowIsolationUnread { cause: _, drain: DrainObservedIdle } => true - WindowIsolationUnread { cause: _, drain: _ } => false + match isolated_window(grant: grant, deadline: 61, drain: DrainObservedIdle, exclusion: ExclusionNotEstablished { cause: "route was not withdrawn" as NonEmptyStr }) { + WindowIsolationNotEstablished { cause: _, drain: DrainObservedIdle } => true + WindowIsolationNotEstablished { cause: _, drain: _ } => false WindowIsolated { grant: _, deadline: _, drain: _, exclusion: _ } => false - WindowSharedWithDeclaredTraffic { traffic_receipt: _, drain: _ } => false + ForeignTrafficObserved { attributed_receipt: _, drain: _ } => false + ForeignTrafficNotObserved { drain: _ } => false + ForeignTrafficUnread { cause: _, drain: _ } => false } } test fn a_request_that_emitted_then_failed_cannot_be_denominated_in_tokens() -> Bool { - !ledger_admits_token_denomination(l: closed_failed_after_tokens()) + !ledger_admits_token_denomination(l: incomplete_failed_summary()) && ledger_admits_token_denomination(l: closed_ok()) } @@ -272,42 +281,38 @@ fn fx_same_incarnation() -> ObservedRankIncarnation? { fx_incarnation(id: "0f3a9c1d2e4b") } -fn fx_obs(ledger: OperationLedger) -> ServingLoadObservation { +fn fx_bench_receipt(stdout: String) -> BenchServeObservationReceipt { + bench_serve_observation_receipt( + protocol: glm_native_smoke_protocol, + process_outcome: BenchServeExited { exit_code: 0 }, + raw_stdout: stdout, + raw_stderr: "", + ) +} + +fn fx_obs() -> ServingLoadObservation { serving_load_observation( subject: glm_native_live_subject_standing(), - protocol: glm_native_holistic_protocol, - window: window_from_drain(drain: DrainObservedIdle, traffic_receipt: "fx" as NonEmptyStr), + window: window_from_drain(drain: DrainObservedIdle), continuity: counter_continuity(before: fx_launch(), after: fx_launch()), - arrival: tight_arrival(), - occupancy: OccupancySampled { samples: [OccupancySample { running: 1, waiting: 0, capacity_waiting: 0, preemptions: 0, prompt_tokens: 0 }] }, - client_output: ClientOutputTokensUnread { cause: "fixture has no client token total" as NonEmptyStr }, - scrape_millis: Present { value: 2000 }, + occupancy: occupancy_trace_from_endpoint_scrapes(before_body: fx_idle, after_body: fx_after), before_body: fx_idle, after_body: fx_after, before_incarnation: fx_same_incarnation(), after_incarnation: fx_same_incarnation(), - ledger: ledger, - client_latency: ClientBenchLatencyUnread { cause: "fixture has no bench stdout" as NonEmptyStr }, + bench: fx_bench_receipt(stdout: fx_bench_stdout), ) } -test fn failed_after_tokens_makes_the_observation_rate_undenominable() -> Bool { - match fx_obs(ledger: closed_failed_after_tokens()).rate { - RateUndenominable { because: _ } => true - RateFromClientOutputTokens { tokens: _, scrape_millis: _ } => false - RateUnreadable { because: _ } => false - } -} - test fn generation_tokens_without_client_completions_is_foreign_load() -> Bool { match derive_rate_honest( - ledger: LedgerClosed { offered: 4, completed: 0, failed: 4, failed_after_tokens: 0 }, + ledger: LedgerClosed { offered: 4, completed: 0, failed: 4 }, scrape_millis: Present { value: 2000 }, client_output: ClientOutputTokensUnread { cause: "none" as NonEmptyStr }, ) { - RateUnreadable { because: _ } => true + RateUndenominable { because: _ } => true RateFromClientOutputTokens { tokens: _, scrape_millis: _ } => false - RateUndenominable { because: _ } => false + RateUnreadable { because: _ } => false } } @@ -368,7 +373,7 @@ test fn unsampled_occupancy_does_not_refuse_the_client_rate() -> Bool { test fn a_long_context_protocol_does_not_mint_an_admission_ceiling() -> Bool { match glm_native_workload_admission { AdmissionCostUnestablished { cause: _ } => - match fx_obs(ledger: closed_ok()).admission { + match fx_obs().admission { AdmissionCostUnestablished { cause: _ } => true AdmissionCostBlocks { blocks: _ } => false } @@ -377,7 +382,7 @@ test fn a_long_context_protocol_does_not_mint_an_admission_ceiling() -> Bool { } test fn one_run_does_not_decide_saturation() -> Bool { - let obs = fx_obs(ledger: closed_ok()) + let obs = fx_obs() !saturation_from_one_run(obs: obs) && !observation_rate_is_stored_separately(obs: obs) && match obs.capacity_claim { @@ -417,8 +422,8 @@ test fn an_itl_histogram_sum_with_sub_milli_digits_is_still_a_milli_reading() -> test fn a_sudo_password_prompt_line_does_not_spoil_the_bench_ledger() -> Bool { let body = join(["[sudo] password for briansrls:\n", fx_bench_stdout], "") match ledger_from_bench_stdout(body: body, offered: token_count_value(t: token_count(count: 4))) { - LedgerClosed { offered: o, completed: c, failed: f, failed_after_tokens: t } => - o == 4 && c == 4 && f == 0 && t == 0 + LedgerClosed { offered: o, completed: c, failed: f } => + o == 4 && c == 4 && f == 0 && match client_output_from_bench_stdout(body: body) { ClientOutputTokensObserved { tokens: n } => n == 512 ClientOutputTokensUnread { cause: _ } => false @@ -442,11 +447,7 @@ test fn the_holistic_protocol_does_not_corroborate_the_single_stream_bound() -> test fn the_smoke_protocol_is_not_the_holistic_envelope() -> Bool { !holistic_protocol_is_session_shaped(req: glm_native_smoke_protocol) && !vllm_bench_serve_uses_poisson_idle_gaps(req: glm_native_smoke_protocol) - && match glm_native_smoke_client_latency { - ClientBenchLatencyReported { output_throughput_milli_tok_per_s: _, tpot_milli: tpot, itl_milli: _, ttft_milli: _, contended: k, standing: _ } => - k && tpot == 82 - ClientBenchLatencyUnread { cause: _ } => false - } + && glm_native_smoke_client_latency.tpot_milli == 82 } test fn a_64_out_wiring_receipt_is_not_the_128_out_sweep_protocol() -> Bool { @@ -481,6 +482,14 @@ data fx_bench_stdout: String = join([ "P99 ITL (ms): 165.00\n", ], "") +data fx_bench_stdout_short: String = join([ + "============ Serving Benchmark Result ============\n", + "Successful requests: 4\n", + "Failed requests: 0\n", + "Benchmark duration (s): 10.00\n", + "Total generated tokens: 512\n", +], "") + test fn a_cap_2_second_bucket_peak_4_does_not_establish_foreign_work() -> Bool { cap_2_bucket_peak_4_is_not_foreign_work(p: SuccessfulClientRequestSecondBucketPeak { client_max_concurrency: token_count_value(t: token_count(count: 2)), @@ -499,8 +508,8 @@ test fn parsed_itl_distribution_does_not_establish_a_cause() -> Bool { test fn ledger_and_rate_come_from_bench_stdout_not_exit_ok() -> Bool { match ledger_from_bench_stdout(body: fx_bench_stdout, offered: token_count_value(t: token_count(count: 4))) { - LedgerClosed { offered: o, completed: c, failed: f, failed_after_tokens: t } => - o == 4 && c == 4 && f == 0 && t == 0 + LedgerClosed { offered: o, completed: c, failed: f } => + o == 4 && c == 4 && f == 0 && match client_output_from_bench_stdout(body: fx_bench_stdout) { ClientOutputTokensUnread { cause: _ } => false ClientOutputTokensObserved { tokens: n } => @@ -527,19 +536,18 @@ test fn the_contended_sweep_is_five_shared_window_client_points() -> Bool { && glm_native_sweep_num_prompts(concurrency: 1) == 8 && glm_native_sweep_num_prompts(concurrency: 2) == 8 && glm_native_sweep_num_prompts(concurrency: 4) == 16 - && match glm_native_contended_sweep_c1.latency { - ClientBenchLatencyReported { output_throughput_milli_tok_per_s: th, tpot_milli: tpot, itl_milli: _, ttft_milli: ttft, contended: k, standing: _ } => - k && th == 10860 && tpot == 81 && ttft == 1542 && glm_native_contended_sweep_c1.concurrency == 1 - ClientBenchLatencyUnread { cause: _ } => false - } + && glm_native_contended_sweep_c1.latency.output_throughput_milli_tok_per_s == 10860 + && glm_native_contended_sweep_c1.latency.tpot_milli == 81 + && glm_native_contended_sweep_c1.latency.ttft_milli == 1542 + && glm_native_contended_sweep_c1.concurrency == 1 } test fn scaling_elasticity_is_off_the_uncontrolled_series() -> Bool { elasticity_is_off_the_uncontrolled_series(s: glm_native_contended_sweep_elasticity) } -test fn ttft_would_bind_concurrency_before_throughput_on_this_sweep() -> Bool { - glm_native_ttft_would_bind_on_this_sweep() +test fn ttft_c8_and_c16_remain_primitive_observations() -> Bool { + glm_native_sweep_ttft_c8() == 2602 && glm_native_sweep_ttft_c16() == 5218 } test fn the_49_vs_81_ms_gap_is_why_window_standing_is_a_field() -> Bool { @@ -548,9 +556,10 @@ test fn the_49_vs_81_ms_gap_is_why_window_standing_is_a_field() -> Bool { && window_standing_gap_is_unattributed(s: glm_native_window_standing_specimen) } -test fn long_context_stays_modelled_until_the_arm_is_out_of_service() -> Bool { +test fn long_context_stays_a_prototype_until_the_qualification_window() -> Bool { match glm_native_holistic_execution { - LongContextLoadProtocolPrototype { until: _ } => true + LongContextLoadProtocolPrototype { until: u } => + string_contains(s: u as String, pattern: "qualification-window") LongContextRunnable { because: _ } => false } } @@ -568,6 +577,7 @@ test fn the_holistic_protocol_is_poisson_with_session_context_and_prefix() -> Bo arrival: SendAllImmediately, max_concurrency: Absent, ignore_eos: true, + seed: 20260918, )) } @@ -585,6 +595,8 @@ test fn the_rendered_argv_carries_the_prefix_and_a_finite_rate() -> Bool { && words_contain(words: words, needle: "--tokenizer") && words_contain(words: words, needle: glm_native_engine_tokenizer_path as String) && words_contain(words: words, needle: "--model") + && words_contain(words: words, needle: "--seed") + && words_contain(words: words, needle: "20260918") && (glm_native_holistic_protocol.model as String) != (glm_native_holistic_protocol.tokenizer as String) } @@ -606,3 +618,28 @@ test fn exporter_restart_breaks_counter_continuity() -> Bool { ContinuityUnread { cause: _ } => false } } + +test fn mixing_two_bench_stdout_bodies_cannot_write_one_receipt() -> Bool { + mixed_run_client_facts_cannot_be_written( + a: fx_bench_receipt(stdout: fx_bench_stdout), + b: fx_bench_receipt(stdout: fx_bench_stdout_short), + ) +} + +test fn send_all_at_cap_2_with_no_start_events_is_not_zero_skew() -> Bool { + send_all_without_start_events_is_not_zero_skew( + num_prompts: token_count_value(t: token_count(count: 4)), + cap: token_count_value(t: token_count(count: 2)), + start_event_count: 0, + ) +} + +test fn qualify_client_rate_refuses_two_boundary_occupancy() -> Bool { + match occupancy_does_not_count_positively(occupancy: OccupancyBoundariesRead { + before: OccupancySample { running: 0, waiting: 0, capacity_waiting: 0, preemptions: 0, prompt_tokens: 0 }, + after: OccupancySample { running: 0, waiting: 0, capacity_waiting: 0, preemptions: 0, prompt_tokens: 1 }, + }) { + ClientRateUnqualified { because: _ } => true + ClientRateQualified { tokens: _, scrape_millis: _ } => false + } +} From e26bf8ff7beaa4fd9913e6e3514f927ff4321918 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Fri, 18 Sep 2026 16:35:26 +0000 Subject: [PATCH 21/43] Bind the live serving-load subject to GunbcGlm53DerivedGb10. Co-authored-by: Cursor #11570 landed glm53_derived_row; consume that runtime pin and the native checkpoint revision instead of the NoPE image, leaving only NCCL transport unread. --- dag/gunbc/spark/serving_load_probe.dag | 20 ++++++++++++------- .../spark/serving_load_probe_witness_test.dag | 5 +++++ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/dag/gunbc/spark/serving_load_probe.dag b/dag/gunbc/spark/serving_load_probe.dag index c29ab6e10a6..4a3845a7dfe 100644 --- a/dag/gunbc/spark/serving_load_probe.dag +++ b/dag/gunbc/spark/serving_load_probe.dag @@ -34,8 +34,8 @@ import gunbc.spark.vllm_endpoint_process_launch { VllmEndpointProcessLaunchObservation, LaunchObserved, LaunchUnobserved, } import gunbc.spark.serving_arm { - Glm53NativeFp8, GunbcGlm53NopeDerivedGb10, FourSparkTp4, glm_native_concurrent_profile, - glm53_native_fp8_row, + Glm53NativeFp8, GunbcGlm53DerivedGb10, FourSparkTp4, glm_native_concurrent_profile, + glm53_native_fp8_row, glm53_derived_row, runtime_artifact_wire, serving_runtime_wire, } import gunbc.spark.serving_arm_launch { glm_native_weights_container_dir } import gunbc.spark.model_snapshot_acquisition { snapshot_install_path, HubCachePlacement } @@ -1559,11 +1559,12 @@ data glm_native_single_stream_decode_bound_standing: CitedFigureStanding = Trans } // max_num_seqs is 16 on the live units (parent reverted the out-of-band 64 edit). +// Runtime is glm53_derived_row (GunbcGlm53DerivedGb10); checkpoint revision is the native Flash row. data glm_native_live_subject: ServingPerformanceSubject = serving_performance_subject( checkpoint: Glm53NativeFp8, - checkpoint_revision: none, - runtime: GunbcGlm53NopeDerivedGb10, - runtime_image_reference: glm53_nope_derived_registry_reading.image_reference, + checkpoint_revision: Present { value: glm53_native_fp8_row.revision }, + runtime: GunbcGlm53DerivedGb10, + runtime_image_reference: runtime_artifact_wire(a: glm53_derived_row.artifact), topology: Present { value: FourSparkTp4 }, rank_population: Present { value: 4 }, context_ceiling: Present { value: glm_native_concurrent_profile.max_model_len }, @@ -1577,11 +1578,16 @@ data glm_native_live_subject: ServingPerformanceSubject = serving_performance_su fn glm_native_live_subject_standing() -> ServingPerformanceSubjectStanding { serving_subject_standing( subject: glm_native_live_subject, - believed: "checkpoint revision and collective transport were unread; the live image digest is the one named on the arm" as NonEmptyStr, - would_settle: "read the running launch's checkpoint pin and NCCL transport announcement" as NonEmptyStr, + believed: "collective transport was unread; the runtime is glm53_derived_row and the checkpoint revision is glm53_native_fp8_row.revision" as NonEmptyStr, + would_settle: "read the running launch's NCCL transport announcement on this incarnation" as NonEmptyStr, ) } +fn glm_native_live_runtime_is_derived_gb10_row() -> Bool { + (serving_runtime_wire(r: glm_native_live_subject.runtime) as String) == (serving_runtime_wire(r: GunbcGlm53DerivedGb10) as String) + && (glm_native_live_subject.runtime_image_reference as String) == (runtime_artifact_wire(a: glm53_derived_row.artifact) as String) +} + fn holistic_protocol_is_session_shaped(req: VllmBenchServeRequest) -> Bool { vllm_bench_serve_uses_poisson_idle_gaps(req: req) && token_count_at_least(t: req.dataset.prefix_len, n: 100000) diff --git a/dag/test/claim/spark/serving_load_probe_witness_test.dag b/dag/test/claim/spark/serving_load_probe_witness_test.dag index 9e64952205d..5a0c48729e6 100644 --- a/dag/test/claim/spark/serving_load_probe_witness_test.dag +++ b/dag/test/claim/spark/serving_load_probe_witness_test.dag @@ -74,6 +74,7 @@ import gunbc.spark.serving_load_probe { ClientOutputTokensObserved, pinned_load_protocol_matches, bench_output_len, glm_native_sweep_num_prompts, glm_native_holistic_execution, LongContextLoadProtocolPrototype, LongContextRunnable, + glm_native_live_runtime_is_derived_gb10_row, } data start_field: NonEmptyStr = "1789300000.12" as NonEmptyStr @@ -643,3 +644,7 @@ test fn qualify_client_rate_refuses_two_boundary_occupancy() -> Bool { ClientRateQualified { tokens: _, scrape_millis: _ } => false } } + +test fn live_subject_consumes_the_derived_gb10_runtime_row() -> Bool { + glm_native_live_runtime_is_derived_gb10_row() +} From 42ce5a4c781eddc28a5f66232304e8ef1d08a7cd Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Fri, 18 Sep 2026 17:15:16 +0000 Subject: [PATCH 22/43] Gate bench-serve client facts on the remote execution. Mint one BenchServeExecution from SparkRemoteRun, parse stdout only on exit 0, carry vllm_bench_serve_source_standing on the observation, bind isolated windows to the measured subject, and split wet capture from qualification exit. Co-authored-by: Cursor --- dag/gunbc/spark/serving_load_probe.dag | 372 +++++++++++++----- dag/gunbc/spark/serving_load_probe_cli.dag | 72 ++-- .../spark/serving_load_probe_witness_test.dag | 80 +++- 3 files changed, 359 insertions(+), 165 deletions(-) diff --git a/dag/gunbc/spark/serving_load_probe.dag b/dag/gunbc/spark/serving_load_probe.dag index 4a3845a7dfe..75cbff1ebb0 100644 --- a/dag/gunbc/spark/serving_load_probe.dag +++ b/dag/gunbc/spark/serving_load_probe.dag @@ -19,8 +19,10 @@ import extdeps.vllm.metrics { import extdeps.vllm.bench_serve { VllmBenchServeRequest, PoissonProcess, SendAllImmediately, RandomDatasetSpec, OpenaiChat, vllm_bench_serve_request, vllm_bench_serve_uses_poisson_idle_gaps, - vllm_bench_serve_identity_matches, + vllm_bench_serve_identity_matches, vllm_bench_serve_source_standing, vllm_bench_backend_route, } +import extdeps.vllm.server { vllm_route_path } +import gunbc.spark.model_snapshot_materialize { SparkRemoteRun, RemoteRan, RemoteUnreachable } import gunbc.harness.harness_backend { harness_gauge_value, harness_labelled_gauge_value, harness_gauge_count, harness_histogram_statistic_value, harness_launch_from_body, harness_queue_from_body, @@ -42,13 +44,14 @@ import gunbc.spark.model_snapshot_acquisition { snapshot_install_path, HubCacheP import gunbc.spark.serving_performance_subject { ServingPerformanceSubject, serving_performance_subject, serving_subject_standing, ServingPerformanceSubjectStanding, SubjectEstablished, SubjectPartial, + serving_performance_subject_wire, } import gunbc.spark.serving_rank_observe { ObservedRankIncarnation, observed_rank_incarnations_agree, observed_rank_incarnation_text, } import extdeps.vllm.engine_args { KvFp8, SpeculativeDecodingOff } import extdeps.vllm.kv_layout { AdmissionCost, AdmissionCostUnestablished, AdmissionCostBlocks } -import extdeps.external_authority { CitedFigureStanding, TranscribedUncited } +import extdeps.external_authority { CitedFigureStanding, TranscribedUncited, CitedToAuthority } // ── THROUGHPUT QUALIFICATION FOR THE SERVING SUBJECT (design #11540, serving side) ──────────── // @@ -67,12 +70,46 @@ type DrainReceipt | DrainNotIdle { running: Nat } | DrainUnread { cause: NonEmptyStr } +type ProtectedSubjectField sole_constructor { + subject: ServingPerformanceSubject + served_alias: NonEmptyStr + route: NonEmptyStr +} + +fn protected_subject_field( + subject: ServingPerformanceSubject, + served_alias: NonEmptyStr, + route: NonEmptyStr, +) -> ProtectedSubjectField { + ProtectedSubjectField { subject: subject, served_alias: served_alias, route: route } +} + +fn protected_subject_key(p: ProtectedSubjectField) -> NonEmptyStr { + join([ + serving_performance_subject_wire(s: p.subject) as String, + "/", + p.served_alias as String, + "/", + p.route as String, + ], "") as NonEmptyStr +} + +fn protected_subject_matches(a: ProtectedSubjectField, b: ProtectedSubjectField) -> Bool { + (protected_subject_key(p: a) as String) == (protected_subject_key(p: b) as String) +} + type ExclusionReceipt - = ExclusionEstablished { how: NonEmptyStr } + = ExclusionEstablished { how: NonEmptyStr, protected: ProtectedSubjectField } | ExclusionNotEstablished { cause: NonEmptyStr } type ProbeWindowStanding - = WindowIsolated { grant: LeaseGrant, deadline: EpochSecs, drain: DrainReceipt, exclusion: ExclusionReceipt } + = WindowIsolated { + grant: LeaseGrant + protected: ProtectedSubjectField + deadline: EpochSecs + drain: DrainReceipt + exclusion: ExclusionReceipt + } | WindowIsolationNotEstablished { cause: NonEmptyStr, drain: DrainReceipt } | ForeignTrafficObserved { attributed_receipt: NonEmptyStr, drain: DrainReceipt } | ForeignTrafficNotObserved { drain: DrainReceipt } @@ -80,9 +117,9 @@ type ProbeWindowStanding fn window_isolated_requires_exclusion(s: ProbeWindowStanding) -> Bool { match s { - WindowIsolated { grant: _, deadline: _, drain: _, exclusion: e } => + WindowIsolated { grant: _, protected: _, deadline: _, drain: _, exclusion: e } => match e { - ExclusionEstablished { how: _ } => true + ExclusionEstablished { how: _, protected: _ } => true ExclusionNotEstablished { cause: _ } => false } WindowIsolationNotEstablished { cause: _, drain: _ } => false @@ -124,18 +161,36 @@ fn window_from_drain(drain: DrainReceipt) -> ProbeWindowStanding { } } -fn isolated_window(grant: LeaseGrant, deadline: EpochSecs, drain: DrainReceipt, exclusion: ExclusionReceipt) -> ProbeWindowStanding { +fn isolated_window( + grant: LeaseGrant, + measured: ProtectedSubjectField, + deadline: EpochSecs, + drain: DrainReceipt, + exclusion: ExclusionReceipt, +) -> ProbeWindowStanding { match exclusion { ExclusionNotEstablished { cause: c } => WindowIsolationNotEstablished { cause: c, drain: drain } - ExclusionEstablished { how: _ } => - match drain { - DrainObservedIdle => - WindowIsolated { grant: grant, deadline: deadline, drain: drain, exclusion: exclusion } - DrainNotIdle { running: _ } => - WindowIsolationNotEstablished { cause: "exclusion was named but the drain snapshot was not idle" as NonEmptyStr, drain: drain } - DrainUnread { cause: c } => - WindowIsolationNotEstablished { cause: c, drain: drain } + ExclusionEstablished { how: _, protected: ep } => + if !protected_subject_matches(a: measured, b: ep) { + WindowIsolationNotEstablished { + cause: "exclusion was not over the measured arm, route, and subject" as NonEmptyStr, + drain: drain, + } + } else if (grant.reference as String) != (protected_subject_key(p: measured) as String) { + WindowIsolationNotEstablished { + cause: "the lease was not over the measured arm, route, and subject" as NonEmptyStr, + drain: drain, + } + } else { + match drain { + DrainObservedIdle => + WindowIsolated { grant: grant, protected: measured, deadline: deadline, drain: drain, exclusion: exclusion } + DrainNotIdle { running: _ } => + WindowIsolationNotEstablished { cause: "exclusion was named but the drain snapshot was not idle" as NonEmptyStr, drain: drain } + DrainUnread { cause: c } => + WindowIsolationNotEstablished { cause: c, drain: drain } + } } } } @@ -575,7 +630,7 @@ type CapacityClaim fn capacity_claim_for_window(window: ProbeWindowStanding) -> CapacityClaim { match window { - WindowIsolated { grant: _, deadline: _, drain: _, exclusion: _ } => + WindowIsolated { grant: _, protected: _, deadline: _, drain: _, exclusion: _ } => CapacityClaimUnavailable { because: "one run does not decide saturation even under isolation" as NonEmptyStr } WindowIsolationNotEstablished { cause: _, drain: _ } => CapacityClaimUnavailable { because: "this arm has no exclusive window; a latency distribution beside unattributed load is real, an aggregate capacity claim is not" as NonEmptyStr } @@ -671,7 +726,7 @@ fn qualify_client_rate( LedgerAndCounterAgree { generation_tokens: _, completed_requests: _ } => occupancy_does_not_count_positively(occupancy: occupancy) } - WindowIsolated { grant: _, deadline: _, drain: _, exclusion: _ } => + WindowIsolated { grant: _, protected: _, deadline: _, drain: _, exclusion: _ } => match agreement { AgreementUnread { because: c } => ClientRateUnqualified { because: c } LedgerCounterDisagree { because: c } => ClientRateUnqualified { because: c } @@ -710,11 +765,156 @@ type ClientBenchLatency window: ProbeWindowStanding } +type ItlTailCause + = ItlTailCauseUnestablished { because: NonEmptyStr } + +type ClientItlDistribution + = ClientItlDistributionUnread { cause: NonEmptyStr } + | ClientItlDistributionObserved { mean_milli: Nat, median_milli: Nat, p99_milli: Nat, cause: ItlTailCause } + +type ClientRequestConcurrencyStanding + = ClientConcurrencyUnread { cause: NonEmptyStr } + | SuccessfulClientRequestSecondBucketPeak { client_max_concurrency: Nat, bucket_peak: Nat } + type ProbeProvenance = SamePrincipal { principal: NonEmptyStr } | DriverObserverSplit { driver: NonEmptyStr, observer: NonEmptyStr } -type ServingLoadObservation { +// ONE REMOTE OPERATION IS ONE EXECUTION. The mint takes SparkRemoteRun whole, so an exit from +// run A cannot be paired with stdout from run B at this interface. +type BenchServeExecution sole_constructor + = BenchServeRan { protocol: VllmBenchServeRequest, exit_code: Int, stdout: String, stderr: String } + | BenchServeUnreachable { protocol: VllmBenchServeRequest, cause: NonEmptyStr } + +fn bench_serve_from_remote(protocol: VllmBenchServeRequest, remote: SparkRemoteRun) -> BenchServeExecution { + match remote { + RemoteUnreachable { cause: c } => + BenchServeUnreachable { protocol: protocol, cause: c as NonEmptyStr } + RemoteRan { exit_code: code, stdout: out, stderr: err } => + BenchServeRan { protocol: protocol, exit_code: code, stdout: out, stderr: err } + } +} + +fn bench_execution_protocol(e: BenchServeExecution) -> VllmBenchServeRequest { + match e { + BenchServeRan { protocol: p, exit_code: _, stdout: _, stderr: _ } => p + BenchServeUnreachable { protocol: p, cause: _ } => p + } +} + +fn bench_execution_stderr(e: BenchServeExecution) -> String { + match e { + BenchServeUnreachable { protocol: _, cause: _ } => "" + BenchServeRan { protocol: _, exit_code: _, stdout: _, stderr: err } => err + } +} + +fn bench_summary_unread_cause(e: BenchServeExecution) -> NonEmptyStr { + match e { + BenchServeUnreachable { protocol: _, cause: c } => c + BenchServeRan { protocol: _, exit_code: code, stdout: _, stderr: _ } => + join(["vllm bench serve exited ", to_string(code), "; stdout is not a client-fact summary"], "") as NonEmptyStr + } +} + +fn bench_summary_stdout(e: BenchServeExecution) -> String? { + match e { + BenchServeUnreachable { protocol: _, cause: _ } => none + BenchServeRan { protocol: _, exit_code: code, stdout: out, stderr: _ } => + if code == 0 { Present { value: out } } else { none } + } +} + +fn bench_serve_ledger(e: BenchServeExecution) -> OperationLedger { + match bench_summary_stdout(e: e) { + Absent => LedgerIncomplete { because: bench_summary_unread_cause(e: e) } + Present { value: body } => ledger_from_bench_stdout(body: body, offered: bench_execution_protocol(e: e).num_prompts) + } +} + +fn bench_serve_completed_output(e: BenchServeExecution) -> ClientOutputTokens { + match bench_summary_stdout(e: e) { + Absent => ClientOutputTokensUnread { cause: bench_summary_unread_cause(e: e) } + Present { value: body } => client_output_from_bench_stdout(body: body) + } +} + +fn bench_serve_interval(e: BenchServeExecution) -> Nat? { + match bench_summary_stdout(e: e) { + Absent => none + Present { value: body } => scrape_millis_from_bench_stdout(body: body) + } +} + +fn bench_serve_latency(e: BenchServeExecution, window: ProbeWindowStanding) -> ClientBenchLatency { + match bench_summary_stdout(e: e) { + Absent => ClientBenchLatencyUnread { cause: bench_summary_unread_cause(e: e) } + Present { value: body } => client_latency_from_bench_stdout(body: body, window: window) + } +} + +fn bench_serve_itl(e: BenchServeExecution) -> ClientItlDistribution { + match bench_summary_stdout(e: e) { + Absent => ClientItlDistributionUnread { cause: bench_summary_unread_cause(e: e) } + Present { value: body } => client_itl_from_bench_stdout(body: body) + } +} + +fn bench_serve_bucket_peak(e: BenchServeExecution) -> ClientRequestConcurrencyStanding { + match bench_execution_protocol(e: e).max_concurrency { + Absent => ClientConcurrencyUnread { cause: "the protocol did not declare max-concurrency" as NonEmptyStr } + Present { value: c } => + match bench_summary_stdout(e: e) { + Absent => ClientConcurrencyUnread { cause: bench_summary_unread_cause(e: e) } + Present { value: body } => client_bucket_peak_from_bench_stdout(body: body, client_max_concurrency: c) + } + } +} + +fn mixed_run_client_facts_cannot_be_written(a: BenchServeExecution, b: BenchServeExecution) -> Bool { + match bench_serve_interval(e: a) { + Absent => false + Present { value: ia } => + match bench_serve_interval(e: b) { + Absent => false + Present { value: ib } => ia != ib + } + } +} + +fn nonzero_exit_does_not_yield_client_facts(e: BenchServeExecution) -> Bool { + match e { + BenchServeUnreachable { protocol: _, cause: _ } => false + BenchServeRan { protocol: _, exit_code: code, stdout: _, stderr: _ } => + code != 0 + && match bench_serve_completed_output(e: e) { + ClientOutputTokensUnread { cause: _ } => true + ClientOutputTokensObserved { tokens: _ } => false + } + } +} + +fn unreachable_does_not_yield_client_facts(e: BenchServeExecution) -> Bool { + match e { + BenchServeRan { protocol: _, exit_code: _, stdout: _, stderr: _ } => false + BenchServeUnreachable { protocol: _, cause: _ } => + match bench_serve_completed_output(e: e) { + ClientOutputTokensUnread { cause: _ } => true + ClientOutputTokensObserved { tokens: _ } => false + } + } +} + +fn stderr_is_not_the_client_summary(e: BenchServeExecution) -> Bool { + match bench_serve_completed_output(e: e) { + ClientOutputTokensUnread { cause: _ } => true + ClientOutputTokensObserved { tokens: _ } => false + } +} + +type ServingLoadObservation sole_constructor { + execution: BenchServeExecution + bench_source_standing: CitedFigureStanding subject: ServingPerformanceSubjectStanding protocol: VllmBenchServeRequest window: ProbeWindowStanding @@ -749,8 +949,9 @@ fn serving_load_observation( after_body: String, before_incarnation: ObservedRankIncarnation?, after_incarnation: ObservedRankIncarnation?, - bench: BenchServeObservationReceipt, + bench: BenchServeExecution, ) -> ServingLoadObservation { + let protocol = bench_execution_protocol(e: bench) let before_p = preemption_count(body: before_body) let after_p = preemption_count(body: after_body) let generation = generation_token_delta_scoped( @@ -759,19 +960,21 @@ fn serving_load_observation( before_body: before_body, after_body: after_body, ) - let ledger = bench_serve_ledger(r: bench) - let client_output = bench_serve_completed_output(r: bench) + let ledger = bench_serve_ledger(e: bench) + let client_output = bench_serve_completed_output(e: bench) let agreement = ledger_counter_agreement(ledger: ledger, generation: generation, client_output: client_output) let foreign = foreign_work_bound(generation: generation, client_output: client_output) let rate = derive_rate_honest( ledger: ledger, - scrape_millis: bench_serve_interval(r: bench), + scrape_millis: bench_serve_interval(e: bench), client_output: client_output, ) - let arrival = arrival_from_protocol(req: bench.protocol) + let arrival = arrival_from_protocol(req: protocol) ServingLoadObservation { + execution: bench, + bench_source_standing: vllm_bench_serve_source_standing, subject: subject, - protocol: bench.protocol, + protocol: protocol, window: window, continuity: continuity, arrival: arrival, @@ -784,9 +987,9 @@ fn serving_load_observation( iteration_tokens_booked: histogram_delta(before_body: before_body, after_body: after_body, metric: IterationTokensTotal), ledger: ledger, admission: glm_native_workload_admission, - corroboration: decode_corroboration_for_protocol(req: bench.protocol), + corroboration: decode_corroboration_for_protocol(req: protocol), provenance: glm_native_live_probe_provenance, - client_latency: bench_serve_latency(r: bench, window: window), + client_latency: bench_serve_latency(e: bench, window: window), foreign_work: foreign, capacity_claim: capacity_claim_for_window(window: window), rate: rate, @@ -816,6 +1019,8 @@ fn saturation_from_one_run(_: ServingLoadObservation) -> Bool { fn serving_load_observation_text(o: ServingLoadObservation) -> String { join([ "serving-load observation\n", + "execution: ", bench_execution_text(e: o.execution), "\n", + "bench source standing: ", cited_standing_text(s: o.bench_source_standing), "\n", "window: ", window_text(s: o.window), "\n", "continuity: ", continuity_text(c: o.continuity), "\n", "before backlog: ", backlog_text(b: o.before_backlog), "\n", @@ -888,6 +1093,21 @@ fn provenance_text(p: ProbeProvenance) -> String { } } +fn bench_execution_text(e: BenchServeExecution) -> String { + match e { + BenchServeUnreachable { protocol: _, cause: c } => join(["unreachable ", c as String], "") + BenchServeRan { protocol: _, exit_code: code, stdout: _, stderr: _ } => + join(["exited ", to_string(code)], "") + } +} + +fn cited_standing_text(s: CitedFigureStanding) -> String { + match s { + CitedToAuthority { authority: _ } => "cited-to-authority" + TranscribedUncited { read_obligation: o } => join(["transcribed-uncited ", o as String], "") + } +} + fn corroboration_text(c: DecodeCorroboration) -> String { match c { CorroborationNotApplicable { because: b } => join(["not-applicable ", b as String], "") @@ -930,7 +1150,7 @@ fn admission_text(a: AdmissionCost) -> String { fn window_text(s: ProbeWindowStanding) -> String { match s { - WindowIsolated { grant: _, deadline: _, drain: _, exclusion: _ } => "isolated" + WindowIsolated { grant: _, protected: _, deadline: _, drain: _, exclusion: _ } => "isolated" WindowIsolationNotEstablished { cause: c, drain: d } => join(["isolation-not-established drain=", drain_text(d: d), " cause=", c as String], "") ForeignTrafficObserved { attributed_receipt: t, drain: d } => @@ -1140,13 +1360,6 @@ data glm_native_wet_smoke_client_latency: TranscribedClientLatency = Transcribed standing: glm_native_wet_smoke_standing } -type ItlTailCause - = ItlTailCauseUnestablished { because: NonEmptyStr } - -type ClientItlDistribution - = ClientItlDistributionUnread { cause: NonEmptyStr } - | ClientItlDistributionObserved { mean_milli: Nat, median_milli: Nat, p99_milli: Nat, cause: ItlTailCause } - fn itl_tail_cause_is_unestablished(d: ClientItlDistribution) -> Bool { match d { ClientItlDistributionUnread { cause: _ } => true @@ -1154,13 +1367,6 @@ fn itl_tail_cause_is_unestablished(d: ClientItlDistribution) -> Bool { } } -// vLLM bench serve's max_concurrent_requests is a whole-second bucket peak over THIS CLIENT's -// successful request spans. Two sequential waves of two can print 4 with exact concurrency 2 and -// zero foreign work. The field cannot mint engine concurrency or a shared-window proof. -type ClientRequestConcurrencyStanding - = ClientConcurrencyUnread { cause: NonEmptyStr } - | SuccessfulClientRequestSecondBucketPeak { client_max_concurrency: Nat, bucket_peak: Nat } - fn client_second_bucket_peak_establishes_foreign_work(p: ClientRequestConcurrencyStanding) -> Bool { match p { ClientConcurrencyUnread { cause: _ } => false @@ -1266,73 +1472,6 @@ fn client_latency_from_bench_stdout(body: String, window: ProbeWindowStanding) - } } -type BenchServeProcessOutcome - = BenchServeExited { exit_code: Nat } - | BenchServeUnreachable { cause: NonEmptyStr } - -type BenchServeObservationReceipt sole_constructor { - protocol: VllmBenchServeRequest - process_outcome: BenchServeProcessOutcome - raw_stdout: String - raw_stderr: String -} - -fn bench_serve_observation_receipt( - protocol: VllmBenchServeRequest, - process_outcome: BenchServeProcessOutcome, - raw_stdout: String, - raw_stderr: String, -) -> BenchServeObservationReceipt { - BenchServeObservationReceipt { - protocol: protocol, - process_outcome: process_outcome, - raw_stdout: raw_stdout, - raw_stderr: raw_stderr, - } -} - -fn bench_serve_parse_body(r: BenchServeObservationReceipt) -> String { - join([r.raw_stdout, "\n", r.raw_stderr], "") -} - -fn bench_serve_ledger(r: BenchServeObservationReceipt) -> OperationLedger { - ledger_from_bench_stdout(body: bench_serve_parse_body(r: r), offered: r.protocol.num_prompts) -} - -fn bench_serve_completed_output(r: BenchServeObservationReceipt) -> ClientOutputTokens { - client_output_from_bench_stdout(body: bench_serve_parse_body(r: r)) -} - -fn bench_serve_interval(r: BenchServeObservationReceipt) -> Nat? { - scrape_millis_from_bench_stdout(body: bench_serve_parse_body(r: r)) -} - -fn bench_serve_latency(r: BenchServeObservationReceipt, window: ProbeWindowStanding) -> ClientBenchLatency { - client_latency_from_bench_stdout(body: bench_serve_parse_body(r: r), window: window) -} - -fn bench_serve_itl(r: BenchServeObservationReceipt) -> ClientItlDistribution { - client_itl_from_bench_stdout(body: bench_serve_parse_body(r: r)) -} - -fn bench_serve_bucket_peak(r: BenchServeObservationReceipt) -> ClientRequestConcurrencyStanding { - match r.protocol.max_concurrency { - Absent => ClientConcurrencyUnread { cause: "the protocol did not declare max-concurrency" as NonEmptyStr } - Present { value: c } => client_bucket_peak_from_bench_stdout(body: bench_serve_parse_body(r: r), client_max_concurrency: c) - } -} - -fn mixed_run_client_facts_cannot_be_written(a: BenchServeObservationReceipt, b: BenchServeObservationReceipt) -> Bool { - match bench_serve_interval(r: a) { - Absent => false - Present { value: ia } => - match bench_serve_interval(r: b) { - Absent => false - Present { value: ib } => ia != ib - } - } -} - type RateTokenDenomination = RateDenominatedInCompletedOutputTokens { because: NonEmptyStr } | RateDenominatedInTotalTokensIncludingPrefill { because: NonEmptyStr } @@ -1588,6 +1727,23 @@ fn glm_native_live_runtime_is_derived_gb10_row() -> Bool { && (glm_native_live_subject.runtime_image_reference as String) == (runtime_artifact_wire(a: glm53_derived_row.artifact) as String) } +data glm_native_protected_subject: ProtectedSubjectField = protected_subject_field( + subject: glm_native_live_subject, + served_alias: glm_native_concurrent_profile.served_alias, + route: vllm_route_path(r: vllm_bench_backend_route(b: glm_native_smoke_protocol.backend)), +) + +fn glm_native_observation_carries_bench_source_standing(o: ServingLoadObservation) -> Bool { + match o.bench_source_standing { + TranscribedUncited { read_obligation: a } => + match vllm_bench_serve_source_standing { + TranscribedUncited { read_obligation: b } => (a as String) == (b as String) + CitedToAuthority { authority: _ } => false + } + CitedToAuthority { authority: _ } => false + } +} + fn holistic_protocol_is_session_shaped(req: VllmBenchServeRequest) -> Bool { vllm_bench_serve_uses_poisson_idle_gaps(req: req) && token_count_at_least(t: req.dataset.prefix_len, n: 100000) diff --git a/dag/gunbc/spark/serving_load_probe_cli.dag b/dag/gunbc/spark/serving_load_probe_cli.dag index da5556a436e..eae7f795e6c 100644 --- a/dag/gunbc/spark/serving_load_probe_cli.dag +++ b/dag/gunbc/spark/serving_load_probe_cli.dag @@ -27,21 +27,20 @@ import gunbc.spark.serving_load_probe { serving_load_observation, serving_load_observation_text, drain_from_queue, window_from_drain, counter_continuity, occupancy_trace_from_endpoint_scrapes, - bench_serve_observation_receipt, BenchServeExited, BenchServeUnreachable, - bench_serve_bucket_peak, bench_serve_itl, + bench_serve_from_remote, bench_serve_bucket_peak, bench_serve_itl, bench_execution_stderr, client_second_bucket_peak_establishes_foreign_work, itl_tail_cause_is_unestablished, WindowIsolated, WindowIsolationNotEstablished, ForeignTrafficObserved, ForeignTrafficNotObserved, ForeignTrafficUnread, DrainObservedIdle, DrainNotIdle, DrainUnread, - RateFromClientOutputTokens, RateUndenominable, RateUnreadable, + ClientRateQualified, ClientRateUnqualified, } - -// ── THE INHABITANCE ROUTE ───────────────────────────────────────────────────────────────────── // // Witnesses supply metric bodies. This function drives `vllm bench serve` against the live native // GLM head. A non-idle drain REFUSES the start. An idle start is WindowIsolationNotEstablished: // glm_native_exclusion_warning names actors who might arrive, and is not a traffic observation. -// Client facts are derived from one BenchServeObservationReceipt. +// Client facts are derived from one BenchServeExecution minted from the remote operation. +// glm_native_serving_load_wet exits 0 when the observation is captured. +// glm_native_serving_load_qualify exits nonzero on ClientRateUnqualified. // // gunbc run --source-root dag --source-root src/v2 \ // --entry dag/gunbc/spark/serving_load_probe_cli.dag --function glm_native_serving_load_wet @@ -93,6 +92,18 @@ fn inspect_incarnation(ctx: SparkMaterializeContext) -> ObservedRankIncarnation? fn glm_native_serving_load_wet() -> ProcessExit uses net: Network +{ + glm_native_serving_load_run(require_qualified: false) +} + +fn glm_native_serving_load_qualify() -> ProcessExit + uses net: Network +{ + glm_native_serving_load_run(require_qualified: true) +} + +fn glm_native_serving_load_run(require_qualified: Bool) -> ProcessExit + uses net: Network { with_group_b_access(use: fn(trust, path, administrator, file) { let ctx = rank_context(host: operator_host_srv9, trust: trust, path: path, administrator: administrator, credential_file: file) @@ -103,7 +114,7 @@ fn glm_native_serving_load_wet() -> ProcessExit let drain = drain_from_queue(q: harness_queue_from_body(body: before)) let window = window_from_drain(drain: drain) match window { - WindowIsolated { grant: _, deadline: _, drain: _, exclusion: _ } => + WindowIsolated { grant: _, protected: _, deadline: _, drain: _, exclusion: _ } => exit_failure(reason: "an isolated window is not this arm's inhabitance path") ForeignTrafficObserved { attributed_receipt: _, drain: _ } => exit_failure(reason: "attributed foreign traffic is not this arm's inhabitance path") @@ -116,39 +127,17 @@ fn glm_native_serving_load_wet() -> ProcessExit DrainUnread { cause: u } => exit_failure(reason: u as String) DrainObservedIdle => { let before_incarnation = inspect_incarnation(ctx: ctx) - let bench = spark_remote_run(ctx: ctx, argv: bench_exec_argv()) + let bench = bench_serve_from_remote(protocol: glm_native_smoke_protocol, remote: spark_remote_run(ctx: ctx, argv: bench_exec_argv())) let after = remote_or_fail(ctx: ctx, argv: curl_metrics_argv(), step: "metrics-after") if body_is_failure(body: after) { exit_failure(reason: after) } else { let after_incarnation = inspect_incarnation(ctx: ctx) - let outcome = match bench { - RemoteUnreachable { cause: c } => BenchServeUnreachable { cause: c as NonEmptyStr } - RemoteRan { exit_code: code, stdout: _, stderr: _ } => BenchServeExited { exit_code: code } - } - let stdout = match bench { - RemoteUnreachable { cause: c } => c - RemoteRan { exit_code: _, stdout: out, stderr: _ } => out - } - let stderr = match bench { - RemoteUnreachable { cause: _ } => "" - RemoteRan { exit_code: _, stdout: _, stderr: err } => err - } - let receipt = bench_serve_observation_receipt( - protocol: glm_native_smoke_protocol, - process_outcome: outcome, - raw_stdout: stdout, - raw_stderr: stderr, - ) - let bench_ok = match outcome { - BenchServeUnreachable { cause: _ } => false - BenchServeExited { exit_code: code } => code == 0 - } let before_launch = harness_launch_from_body(group: FabricGroupB, address: "192.168.1.236", body: before) let after_launch = harness_launch_from_body(group: FabricGroupB, address: "192.168.1.236", body: after) let occ = occupancy_trace_from_endpoint_scrapes(before_body: before, after_body: after) - let bucket = bench_serve_bucket_peak(r: receipt) - let itl = bench_serve_itl(r: receipt) + let bucket = bench_serve_bucket_peak(e: bench) + let itl = bench_serve_itl(e: bench) let obs = serving_load_observation( subject: glm_native_live_subject_standing(), window: window, @@ -158,26 +147,25 @@ fn glm_native_serving_load_wet() -> ProcessExit after_body: after, before_incarnation: before_incarnation, after_incarnation: after_incarnation, - bench: receipt, + bench: bench, ) let body = join([ "glm native serving-load wet at ", probed_at_word(reading: clock_now_probed_at()) as String, "\n", serving_load_observation_text(o: obs), - "\nbucket_peak_establishes_foreign_work=", if client_second_bucket_peak_establishes_foreign_work(p: bucket) { "yes" } else { "no" }, "\n", + "bucket_peak_establishes_foreign_work=", if client_second_bucket_peak_establishes_foreign_work(p: bucket) { "yes" } else { "no" }, "\n", "itl_tail_cause_unestablished=", if itl_tail_cause_is_unestablished(d: itl) { "yes" } else { "no" }, "\n", - "\n--- bench ---\n", stdout, "\n", stderr, "\n", + "\n--- bench stderr ---\n", bench_execution_stderr(e: bench), "\n", ], "") let w = Filesystem.Write(path: glm_native_serving_load_receipt_path, content: body) if !w.success { exit_failure(reason: join(["receipt write failed: ", w.error], "")) - } else if !bench_ok { - exit_failure(reason: body) - } else { - match obs.rate { - RateFromClientOutputTokens { tokens: _, scrape_millis: _ } => ExitSuccess - RateUndenominable { because: _ } => exit_failure(reason: body) - RateUnreadable { because: _ } => exit_failure(reason: body) + } else if require_qualified { + match obs.qualified_rate { + ClientRateQualified { tokens: _, scrape_millis: _ } => ExitSuccess + ClientRateUnqualified { because: b } => exit_failure(reason: join([body, "\nunqualified: ", b as String], "")) } + } else { + ExitSuccess } } } diff --git a/dag/test/claim/spark/serving_load_probe_witness_test.dag b/dag/test/claim/spark/serving_load_probe_witness_test.dag index 5a0c48729e6..ea841144b92 100644 --- a/dag/test/claim/spark/serving_load_probe_witness_test.dag +++ b/dag/test/claim/spark/serving_load_probe_witness_test.dag @@ -12,7 +12,7 @@ import gunbc.spark.serving_rank_observe { container_incarnation_id, ObservedRankIncarnation, } import product.fabric.demand { ObservationReceiptRef } -import gunbc.spark.fabric_switch_observed { FabricGroupB } +import gunbc.spark.model_snapshot_materialize { RemoteRan, RemoteUnreachable } import gunbc.spark.vllm_endpoint_process_launch { vllm_endpoint_process_launch, VllmEndpointProcessLaunchObservation, LaunchObserved, LaunchUnobserved, } @@ -47,8 +47,6 @@ import gunbc.spark.serving_load_probe { OccupancyBoundariesRead, OccupancyBoundariesUnread, OccupancySample, occupancy_does_not_count_positively, qualify_client_rate, send_all_without_start_events_is_not_zero_skew, - bench_serve_observation_receipt, BenchServeObservationReceipt, BenchServeExited, mixed_run_client_facts_cannot_be_written, - bench_serve_interval, bench_serve_ledger, glm_native_exclusion_warning, glm_native_sweep_ttft_c8, glm_native_sweep_ttft_c16, ClientOutputTokensUnread, ClientOutputTokensObserved, @@ -75,6 +73,11 @@ import gunbc.spark.serving_load_probe { pinned_load_protocol_matches, bench_output_len, glm_native_sweep_num_prompts, glm_native_holistic_execution, LongContextLoadProtocolPrototype, LongContextRunnable, glm_native_live_runtime_is_derived_gb10_row, + glm_native_protected_subject, protected_subject_key, + bench_serve_from_remote, BenchServeRan, BenchServeUnreachable, BenchServeExecution, + mixed_run_client_facts_cannot_be_written, nonzero_exit_does_not_yield_client_facts, + unreachable_does_not_yield_client_facts, stderr_is_not_the_client_summary, + glm_native_observation_carries_bench_source_standing, } data start_field: NonEmptyStr = "1789300000.12" as NonEmptyStr @@ -120,7 +123,7 @@ test fn a_busy_drain_refuses_the_window() -> Bool { match window_from_drain(drain: d) { WindowIsolationNotEstablished { cause: _, drain: DrainNotIdle { running: n } } => n == 3 WindowIsolationNotEstablished { cause: _, drain: _ } => false - WindowIsolated { grant: _, deadline: _, drain: _, exclusion: _ } => false + WindowIsolated { grant: _, protected: _, deadline: _, drain: _, exclusion: _ } => false ForeignTrafficObserved { attributed_receipt: _, drain: _ } => false ForeignTrafficNotObserved { drain: _ } => false ForeignTrafficUnread { cause: _, drain: _ } => false @@ -131,7 +134,7 @@ test fn a_quiet_drain_is_not_an_isolated_window() -> Bool { let d = drain_from_queue(q: harness_queue_from_body(body: fx_idle)) let w = window_from_drain(drain: d) match w { - WindowIsolated { grant: _, deadline: _, drain: _, exclusion: _ } => false + WindowIsolated { grant: _, protected: _, deadline: _, drain: _, exclusion: _ } => false WindowIsolationNotEstablished { cause: _, drain: DrainObservedIdle } => true WindowIsolationNotEstablished { cause: _, drain: _ } => false ForeignTrafficObserved { attributed_receipt: _, drain: _ } => false @@ -149,18 +152,19 @@ test fn exclusion_warning_names_actors_who_might_arrive() -> Bool { test fn isolated_window_requires_exclusion_and_idle_drain() -> Bool { let grant = lease_grant( - reference: "probe" as NonEmptyStr, + reference: protected_subject_key(p: glm_native_protected_subject), fence: lease_fence_of(admitting_event: "e" as EventId, generation: 1), granted_at: 1, policy: LeasePolicy { maximum_duration_seconds: 60, release_law: FencedResource }, ) match isolated_window( grant: grant, + measured: glm_native_protected_subject, deadline: 61, drain: DrainObservedIdle, - exclusion: ExclusionEstablished { how: "named" as NonEmptyStr }, + exclusion: ExclusionEstablished { how: "named" as NonEmptyStr, protected: glm_native_protected_subject }, ) { - WindowIsolated { grant: _, deadline: _, drain: _, exclusion: _ } => true + WindowIsolated { grant: _, protected: _, deadline: _, drain: _, exclusion: _ } => true WindowIsolationNotEstablished { cause: _, drain: _ } => false ForeignTrafficObserved { attributed_receipt: _, drain: _ } => false ForeignTrafficNotObserved { drain: _ } => false @@ -169,16 +173,39 @@ test fn isolated_window_requires_exclusion_and_idle_drain() -> Bool { } test fn isolated_window_refuses_without_exclusion() -> Bool { + let grant = lease_grant( + reference: protected_subject_key(p: glm_native_protected_subject), + fence: lease_fence_of(admitting_event: "e" as EventId, generation: 1), + granted_at: 1, + policy: LeasePolicy { maximum_duration_seconds: 60, release_law: FencedResource }, + ) + match isolated_window(grant: grant, measured: glm_native_protected_subject, deadline: 61, drain: DrainObservedIdle, exclusion: ExclusionNotEstablished { cause: "route was not withdrawn" as NonEmptyStr }) { + WindowIsolationNotEstablished { cause: _, drain: DrainObservedIdle } => true + WindowIsolationNotEstablished { cause: _, drain: _ } => false + WindowIsolated { grant: _, protected: _, deadline: _, drain: _, exclusion: _ } => false + ForeignTrafficObserved { attributed_receipt: _, drain: _ } => false + ForeignTrafficNotObserved { drain: _ } => false + ForeignTrafficUnread { cause: _, drain: _ } => false + } +} + +test fn isolated_window_refuses_a_generic_lease() -> Bool { let grant = lease_grant( reference: "probe" as NonEmptyStr, fence: lease_fence_of(admitting_event: "e" as EventId, generation: 1), granted_at: 1, policy: LeasePolicy { maximum_duration_seconds: 60, release_law: FencedResource }, ) - match isolated_window(grant: grant, deadline: 61, drain: DrainObservedIdle, exclusion: ExclusionNotEstablished { cause: "route was not withdrawn" as NonEmptyStr }) { + match isolated_window( + grant: grant, + measured: glm_native_protected_subject, + deadline: 61, + drain: DrainObservedIdle, + exclusion: ExclusionEstablished { how: "named" as NonEmptyStr, protected: glm_native_protected_subject }, + ) { WindowIsolationNotEstablished { cause: _, drain: DrainObservedIdle } => true WindowIsolationNotEstablished { cause: _, drain: _ } => false - WindowIsolated { grant: _, deadline: _, drain: _, exclusion: _ } => false + WindowIsolated { grant: _, protected: _, deadline: _, drain: _, exclusion: _ } => false ForeignTrafficObserved { attributed_receipt: _, drain: _ } => false ForeignTrafficNotObserved { drain: _ } => false ForeignTrafficUnread { cause: _, drain: _ } => false @@ -282,12 +309,10 @@ fn fx_same_incarnation() -> ObservedRankIncarnation? { fx_incarnation(id: "0f3a9c1d2e4b") } -fn fx_bench_receipt(stdout: String) -> BenchServeObservationReceipt { - bench_serve_observation_receipt( +fn fx_bench_receipt(stdout: String) -> BenchServeExecution { + bench_serve_from_remote( protocol: glm_native_smoke_protocol, - process_outcome: BenchServeExited { exit_code: 0 }, - raw_stdout: stdout, - raw_stderr: "", + remote: RemoteRan { exit_code: 0, stdout: stdout, stderr: "" }, ) } @@ -648,3 +673,28 @@ test fn qualify_client_rate_refuses_two_boundary_occupancy() -> Bool { test fn live_subject_consumes_the_derived_gb10_runtime_row() -> Bool { glm_native_live_runtime_is_derived_gb10_row() } + +test fn a_nonzero_bench_exit_does_not_parse_stdout() -> Bool { + nonzero_exit_does_not_yield_client_facts(e: bench_serve_from_remote( + protocol: glm_native_smoke_protocol, + remote: RemoteRan { exit_code: 1, stdout: fx_bench_stdout, stderr: "" }, + )) +} + +test fn an_unreachable_bench_does_not_parse_stdout() -> Bool { + unreachable_does_not_yield_client_facts(e: bench_serve_from_remote( + protocol: glm_native_smoke_protocol, + remote: RemoteUnreachable { cause: "ssh refused" }, + )) +} + +test fn stderr_carrying_the_summary_is_not_parsed() -> Bool { + stderr_is_not_the_client_summary(e: bench_serve_from_remote( + protocol: glm_native_smoke_protocol, + remote: RemoteRan { exit_code: 0, stdout: "", stderr: fx_bench_stdout }, + )) +} + +test fn the_observation_carries_bench_source_standing() -> Bool { + glm_native_observation_carries_bench_source_standing(o: fx_obs()) +} From 15273a95d14f72f23056bb5847c996602c77c8c6 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Fri, 18 Sep 2026 18:02:47 +0000 Subject: [PATCH 23/43] Land serving-load as telemetry capture, not qualification. Drop the unreachable qualify command and ClientRateQualified arm, persist bench stdout and both metrics scrapes with digests in the receipt, and name the qualification frontier: start events, reserved window, interval occupancy, and a bound serve.py digest. Co-authored-by: Cursor --- dag/gunbc/spark/serving_load_probe.dag | 126 ++++++++++++++++-- dag/gunbc/spark/serving_load_probe_cli.dag | 24 +--- .../spark/serving_load_probe_witness_test.dag | 22 ++- 3 files changed, 140 insertions(+), 32 deletions(-) diff --git a/dag/gunbc/spark/serving_load_probe.dag b/dag/gunbc/spark/serving_load_probe.dag index 75cbff1ebb0..b5f8a667397 100644 --- a/dag/gunbc/spark/serving_load_probe.dag +++ b/dag/gunbc/spark/serving_load_probe.dag @@ -5,7 +5,7 @@ import std.nat { Nat } import std.decimal { ExactDecimal, canonical_exact_decimal, decimal_pow10 } import std.checked_arithmetic { checked_int_magnitude, CheckedNatReady, CheckedNatOverflow } import v2.std.optional { Present, Absent } -import std.measure { TokenCount, token_count, token_count_value } +import std.content_hash { ContentHash, content_hash_of_value, serialize_content_hash } import product.capacity.lease { LeaseGrant } import product.fabric.demand { ObservationReceiptRef } import extdeps.prometheus.client { @@ -677,8 +677,21 @@ fn derive_rate_honest( } type QualifiedClientRate - = ClientRateQualified { tokens: Nat, scrape_millis: Nat } - | ClientRateUnqualified { because: NonEmptyStr } + = ClientRateUnqualified { because: NonEmptyStr } + +type ClientRateQualificationFrontier sole_constructor { + request_start_events: NonEmptyStr + reserved_window: NonEmptyStr + interval_occupancy: NonEmptyStr + serve_py_digest: NonEmptyStr +} + +data glm_native_qualification_frontier: ClientRateQualificationFrontier = ClientRateQualificationFrontier { + request_start_events: "per-request start events so ArrivalSkewObserved can be minted; SendAllImmediately stays ArrivalSkewUnread until that producer exists" as NonEmptyStr, + reserved_window: "subject-bound LeaseGrant and ExclusionEstablished over ProtectedSubjectField; the follow-up PR needs the operator to grant an exclusive Group B window" as NonEmptyStr, + interval_occupancy: "occupancy as a time-series over the client interval; BoundaryOccupancyReceipt is two scrapes and cannot count positively" as NonEmptyStr, + serve_py_digest: "bind vllm_bench_serve_source_standing to the serve.py file or package digest inside the running image, or an explicit policy that admits TranscribedUncited" as NonEmptyStr, +} fn occupancy_does_not_count_positively(occupancy: BoundaryOccupancyReceipt) -> QualifiedClientRate { match occupancy { @@ -701,7 +714,7 @@ fn qualify_client_rate( match rate { RateUndenominable { because: b } => ClientRateUnqualified { because: b } RateUnreadable { because: b } => ClientRateUnqualified { because: b } - RateFromClientOutputTokens { tokens: t, scrape_millis: ms } => + RateFromClientOutputTokens { tokens: _, scrape_millis: _ } => match subject { SubjectPartial { subject: _, unknown_axes: _, believed: _, would_settle: s } => ClientRateUnqualified { because: s } @@ -802,6 +815,13 @@ fn bench_execution_protocol(e: BenchServeExecution) -> VllmBenchServeRequest { } } +fn bench_execution_stdout(e: BenchServeExecution) -> String { + match e { + BenchServeUnreachable { protocol: _, cause: _ } => "" + BenchServeRan { protocol: _, exit_code: _, stdout: out, stderr: _ } => out + } +} + fn bench_execution_stderr(e: BenchServeExecution) -> String { match e { BenchServeUnreachable { protocol: _, cause: _ } => "" @@ -912,6 +932,66 @@ fn stderr_is_not_the_client_summary(e: BenchServeExecution) -> Bool { } } +type CapturedText sole_constructor { + kind: NonEmptyStr + digest: ContentHash + body: String +} + +fn captured_text(kind: NonEmptyStr, body: String) -> CapturedText { + CapturedText { + kind: kind, + digest: content_hash_of_value(value: join([kind as String, "\n", body], "") as NonEmptyStr), + body: body, + } +} + +fn captured_text_digest_matches(c: CapturedText) -> Bool { + (serialize_content_hash(hash: c.digest) as String) == (serialize_content_hash(hash: captured_text(kind: c.kind, body: c.body).digest) as String) +} + +type ServingLoadEvidence sole_constructor { + metrics_before: CapturedText + metrics_after: CapturedText + bench_stdout: CapturedText + bench_stderr: CapturedText +} + +fn serving_load_evidence(before_body: String, after_body: String, bench: BenchServeExecution) -> ServingLoadEvidence { + ServingLoadEvidence { + metrics_before: captured_text(kind: "metrics-before" as NonEmptyStr, body: before_body), + metrics_after: captured_text(kind: "metrics-after" as NonEmptyStr, body: after_body), + bench_stdout: captured_text(kind: "bench-stdout" as NonEmptyStr, body: bench_execution_stdout(e: bench)), + bench_stderr: captured_text(kind: "bench-stderr" as NonEmptyStr, body: bench_execution_stderr(e: bench)), + } +} + +fn captured_text_block(c: CapturedText) -> String { + join([ + "--- ", c.kind as String, " digest=", serialize_content_hash(hash: c.digest) as String, " ---\n", + c.body, + "\n", + ], "") +} + +fn serving_load_evidence_text(ev: ServingLoadEvidence) -> String { + join([ + captured_text_block(c: ev.metrics_before), + captured_text_block(c: ev.metrics_after), + captured_text_block(c: ev.bench_stdout), + captured_text_block(c: ev.bench_stderr), + ], "") +} + +fn qualification_frontier_text(f: ClientRateQualificationFrontier) -> String { + join([ + "request-start-events: ", f.request_start_events as String, + " | reserved-window: ", f.reserved_window as String, + " | interval-occupancy: ", f.interval_occupancy as String, + " | serve-py-digest: ", f.serve_py_digest as String, + ], "") +} + type ServingLoadObservation sole_constructor { execution: BenchServeExecution bench_source_standing: CitedFigureStanding @@ -936,8 +1016,8 @@ type ServingLoadObservation sole_constructor { capacity_claim: CapacityClaim rate: DerivedRate qualified_rate: QualifiedClientRate - raw_before: NonEmptyStr - raw_after: NonEmptyStr + qualification_frontier: ClientRateQualificationFrontier + evidence: ServingLoadEvidence } fn serving_load_observation( @@ -1003,8 +1083,8 @@ fn serving_load_observation( foreign_work: foreign, rate: rate, ), - raw_before: before_body as NonEmptyStr, - raw_after: after_body as NonEmptyStr, + qualification_frontier: glm_native_qualification_frontier, + evidence: serving_load_evidence(before_body: before_body, after_body: after_body, bench: bench), } } @@ -1016,6 +1096,32 @@ fn saturation_from_one_run(_: ServingLoadObservation) -> Bool { false } +fn observation_evidence_replays_client_facts(o: ServingLoadObservation) -> Bool { + captured_text_digest_matches(c: o.evidence.metrics_before) + && captured_text_digest_matches(c: o.evidence.metrics_after) + && captured_text_digest_matches(c: o.evidence.bench_stdout) + && captured_text_digest_matches(c: o.evidence.bench_stderr) + && match bench_serve_interval(e: o.execution) { + Absent => + match scrape_millis_from_bench_stdout(body: o.evidence.bench_stdout.body) { + Absent => true + Present { value: _ } => false + } + Present { value: ia } => + match scrape_millis_from_bench_stdout(body: o.evidence.bench_stdout.body) { + Absent => false + Present { value: ib } => ia == ib + } + } +} + +fn qualification_frontier_requires_serve_py_digest(f: ClientRateQualificationFrontier) -> Bool { + string_contains(s: f.serve_py_digest as String, pattern: "serve.py") + && string_contains(s: f.request_start_events as String, pattern: "start") + && string_contains(s: f.reserved_window as String, pattern: "exclusive") + && string_contains(s: f.interval_occupancy as String, pattern: "time-series") +} + fn serving_load_observation_text(o: ServingLoadObservation) -> String { join([ "serving-load observation\n", @@ -1039,7 +1145,9 @@ fn serving_load_observation_text(o: ServingLoadObservation) -> String { "capacity claim: ", capacity_claim_text(c: o.capacity_claim), "\n", "rate: ", rate_text(r: o.rate), "\n", "qualified rate: ", qualified_rate_text(q: o.qualified_rate), "\n", + "qualification frontier: ", qualification_frontier_text(f: o.qualification_frontier), "\n", "saturation decided from this run: ", if saturation_from_one_run(obs: o) { "yes" } else { "no" }, "\n", + serving_load_evidence_text(ev: o.evidence), ], "") } @@ -1056,8 +1164,6 @@ fn foreign_work_text(f: ForeignWorkBound) -> String { fn qualified_rate_text(q: QualifiedClientRate) -> String { match q { ClientRateUnqualified { because: b } => join(["unqualified ", b as String], "") - ClientRateQualified { tokens: t, scrape_millis: ms } => - join(["qualified tokens=", to_string(t), " scrape_millis=", to_string(ms)], "") } } diff --git a/dag/gunbc/spark/serving_load_probe_cli.dag b/dag/gunbc/spark/serving_load_probe_cli.dag index eae7f795e6c..fd5b2d43bae 100644 --- a/dag/gunbc/spark/serving_load_probe_cli.dag +++ b/dag/gunbc/spark/serving_load_probe_cli.dag @@ -27,20 +27,20 @@ import gunbc.spark.serving_load_probe { serving_load_observation, serving_load_observation_text, drain_from_queue, window_from_drain, counter_continuity, occupancy_trace_from_endpoint_scrapes, - bench_serve_from_remote, bench_serve_bucket_peak, bench_serve_itl, bench_execution_stderr, + bench_serve_from_remote, bench_serve_bucket_peak, bench_serve_itl, client_second_bucket_peak_establishes_foreign_work, itl_tail_cause_is_unestablished, WindowIsolated, WindowIsolationNotEstablished, ForeignTrafficObserved, ForeignTrafficNotObserved, ForeignTrafficUnread, DrainObservedIdle, DrainNotIdle, DrainUnread, - ClientRateQualified, ClientRateUnqualified, } // // Witnesses supply metric bodies. This function drives `vllm bench serve` against the live native // GLM head. A non-idle drain REFUSES the start. An idle start is WindowIsolationNotEstablished: // glm_native_exclusion_warning names actors who might arrive, and is not a traffic observation. // Client facts are derived from one BenchServeExecution minted from the remote operation. -// glm_native_serving_load_wet exits 0 when the observation is captured. -// glm_native_serving_load_qualify exits nonzero on ClientRateUnqualified. +// glm_native_serving_load_wet exits 0 when the observation is captured. Qualification is a +// declared frontier (request start events, reserved-window lease/exclusion, interval occupancy, +// serve.py digest); this PR does not run a qualify command. // // gunbc run --source-root dag --source-root src/v2 \ // --entry dag/gunbc/spark/serving_load_probe_cli.dag --function glm_native_serving_load_wet @@ -93,16 +93,10 @@ fn inspect_incarnation(ctx: SparkMaterializeContext) -> ObservedRankIncarnation? fn glm_native_serving_load_wet() -> ProcessExit uses net: Network { - glm_native_serving_load_run(require_qualified: false) + glm_native_serving_load_run() } -fn glm_native_serving_load_qualify() -> ProcessExit - uses net: Network -{ - glm_native_serving_load_run(require_qualified: true) -} - -fn glm_native_serving_load_run(require_qualified: Bool) -> ProcessExit +fn glm_native_serving_load_run() -> ProcessExit uses net: Network { with_group_b_access(use: fn(trust, path, administrator, file) { @@ -154,16 +148,10 @@ fn glm_native_serving_load_run(require_qualified: Bool) -> ProcessExit serving_load_observation_text(o: obs), "bucket_peak_establishes_foreign_work=", if client_second_bucket_peak_establishes_foreign_work(p: bucket) { "yes" } else { "no" }, "\n", "itl_tail_cause_unestablished=", if itl_tail_cause_is_unestablished(d: itl) { "yes" } else { "no" }, "\n", - "\n--- bench stderr ---\n", bench_execution_stderr(e: bench), "\n", ], "") let w = Filesystem.Write(path: glm_native_serving_load_receipt_path, content: body) if !w.success { exit_failure(reason: join(["receipt write failed: ", w.error], "")) - } else if require_qualified { - match obs.qualified_rate { - ClientRateQualified { tokens: _, scrape_millis: _ } => ExitSuccess - ClientRateUnqualified { because: b } => exit_failure(reason: join([body, "\nunqualified: ", b as String], "")) - } } else { ExitSuccess } diff --git a/dag/test/claim/spark/serving_load_probe_witness_test.dag b/dag/test/claim/spark/serving_load_probe_witness_test.dag index ea841144b92..7db89ca63d0 100644 --- a/dag/test/claim/spark/serving_load_probe_witness_test.dag +++ b/dag/test/claim/spark/serving_load_probe_witness_test.dag @@ -36,10 +36,10 @@ import gunbc.spark.serving_load_probe { RateFromClientOutputTokens, RateUndenominable, RateUnreadable, ArrivalSkewObserved, ArrivalSkewUnread, arrival_admits_rate_comparison, TokenDeltaRead, TokenDeltaReset, TokenDeltaUnread, TokenDeltaScoped, generation_token_delta, generation_token_delta_scoped, - derive_rate_honest, serving_load_observation, ServingLoadObservation, tokens_per_observation_second, + derive_rate_honest, serving_load_observation, serving_load_observation_text, ServingLoadObservation, tokens_per_observation_second, saturation_from_one_run, observation_rate_is_stored_separately, foreign_work_bound, ForeignWorkBounded, ForeignWorkUnread, ForeignWorkContradiction, - ClientRateUnqualified, ClientRateQualified, + ClientRateUnqualified, occupancy_from_body, occupancy_trace_from_endpoint_scrapes, histogram_delta, HistogramDeltaRead, HistogramDeltaUnread, HistogramCounterReset, CapacityClaimUnavailable, glm_native_holistic_protocol, holistic_protocol_is_session_shaped, @@ -78,6 +78,8 @@ import gunbc.spark.serving_load_probe { mixed_run_client_facts_cannot_be_written, nonzero_exit_does_not_yield_client_facts, unreachable_does_not_yield_client_facts, stderr_is_not_the_client_summary, glm_native_observation_carries_bench_source_standing, + observation_evidence_replays_client_facts, glm_native_qualification_frontier, + qualification_frontier_requires_serve_py_digest, } data start_field: NonEmptyStr = "1789300000.12" as NonEmptyStr @@ -416,7 +418,6 @@ test fn one_run_does_not_decide_saturation() -> Bool { } && match obs.qualified_rate { ClientRateUnqualified { because: _ } => true - ClientRateQualified { tokens: _, scrape_millis: _ } => false } } @@ -666,7 +667,6 @@ test fn qualify_client_rate_refuses_two_boundary_occupancy() -> Bool { after: OccupancySample { running: 0, waiting: 0, capacity_waiting: 0, preemptions: 0, prompt_tokens: 1 }, }) { ClientRateUnqualified { because: _ } => true - ClientRateQualified { tokens: _, scrape_millis: _ } => false } } @@ -698,3 +698,17 @@ test fn stderr_carrying_the_summary_is_not_parsed() -> Bool { test fn the_observation_carries_bench_source_standing() -> Bool { glm_native_observation_carries_bench_source_standing(o: fx_obs()) } + +test fn the_receipt_persists_raw_evidence_for_replay() -> Bool { + let obs = fx_obs() + let text = serving_load_observation_text(o: obs) + observation_evidence_replays_client_facts(o: obs) + && string_contains(s: text, pattern: "--- metrics-before digest=") + && string_contains(s: text, pattern: "--- bench-stdout digest=") + && string_contains(s: text, pattern: "vllm:num_requests_running") + && string_contains(s: text, pattern: "Total generated tokens") +} + +test fn qualification_frontier_names_the_producers() -> Bool { + qualification_frontier_requires_serve_py_digest(f: glm_native_qualification_frontier) +} From bfb364fbd9d32154a57f6552783580a5b476a9a9 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sat, 19 Sep 2026 03:30:29 +0000 Subject: [PATCH 24/43] serving-load: typed metrics scrape, Millisecond latencies, counts are not tokens, modeled curl and srv9 endpoint Addresses review 67915: the metrics path keeps SparkRemoteRun's arms as MetricsScrape instead of a prefixed string; request, concurrency and rank counts are Nat, not TokenCount; latency and interval fields are std.measure Millisecond; the scrape argv comes from extdeps.tools.curl and the harness address from srv9_host_lan_endpoint. Co-Authored-By: Claude Opus 5 (1M context) --- dag/extdeps/tools/curl.dag | 11 ++ dag/gunbc/spark/serving_load_probe.dag | 100 ++++++++++-------- dag/gunbc/spark/serving_load_probe_cli.dag | 57 ++++++---- .../spark/serving_load_probe_witness_test.dag | 50 ++++----- 4 files changed, 127 insertions(+), 91 deletions(-) diff --git a/dag/extdeps/tools/curl.dag b/dag/extdeps/tools/curl.dag index 834bd38b071..05b8fd5b168 100644 --- a/dag/extdeps/tools/curl.dag +++ b/dag/extdeps/tools/curl.dag @@ -57,6 +57,17 @@ fn curl_localhost_bounded_get_argv_prefix() -> String { // load-bearing are recorded once at extdeps.exec.command program_spelling_is_an_observation_claim. data curl_program: NonEmptyStr = "curl" +// A bounded GET as argv words: -f makes an HTTP error a non-zero exit instead of a body, -sS keeps +// the error text on stderr while suppressing the progress meter. +fn curl_bounded_get_argv(url: String, connect_timeout: Second, max_time: Second) -> List { + [ + curl_program as String, "-fsS", + "--connect-timeout", to_string(second_count(s: connect_timeout)), + "--max-time", to_string(second_count(s: max_time)), + url, + ] +} + fn curl_download_command(url: String, destination: String) -> ArgvCommand { argv_command(program: curl_program, arguments: ["-fsL", "-o", destination, url]) } diff --git a/dag/gunbc/spark/serving_load_probe.dag b/dag/gunbc/spark/serving_load_probe.dag index b5f8a667397..362d1625784 100644 --- a/dag/gunbc/spark/serving_load_probe.dag +++ b/dag/gunbc/spark/serving_load_probe.dag @@ -2,6 +2,7 @@ module gunbc.spark.serving_load_probe import std.types { Bool, String, NonEmptyStr, List, EpochSecs, Int } import std.nat { Nat } +import std.measure { Millisecond, millisecond, millisecond_count } import std.decimal { ExactDecimal, canonical_exact_decimal, decimal_pow10 } import std.checked_arithmetic { checked_int_magnitude, CheckedNatReady, CheckedNatOverflow } import v2.std.optional { Present, Absent } @@ -252,7 +253,7 @@ fn counter_continuity(before: VllmEndpointProcessLaunchObservation, after: VllmE } type HistogramDelta - = HistogramDeltaRead { sum_milli: Nat, count: Nat } + = HistogramDeltaRead { sum_milli: Millisecond, count: Nat } | HistogramDeltaUnread { cause: NonEmptyStr } | HistogramCounterReset { cause: NonEmptyStr } @@ -325,7 +326,7 @@ fn histogram_delta(before_body: String, after_body: String, metric: VllmServingM Present { value: ds } => match nat_delta(after: acn, before: bcn) { Absent => HistogramCounterReset { cause: "histogram count decreased across the window" as NonEmptyStr } - Present { value: dc } => HistogramDeltaRead { sum_milli: ds, count: dc } + Present { value: dc } => HistogramDeltaRead { sum_milli: millisecond(count: ds), count: dc } } } } @@ -443,7 +444,7 @@ fn scrape_interval_millis(before_at: EpochSecs, after_at: EpochSecs) -> Nat? { } type ArrivalSkew - = ArrivalSkewObserved { max_stagger_millis: Nat } + = ArrivalSkewObserved { max_stagger_millis: Millisecond } | ArrivalSkewUnread { cause: NonEmptyStr } type ArrivalPolicy @@ -477,12 +478,12 @@ fn send_all_without_start_events_is_not_zero_skew(num_prompts: Nat, cap: Nat, st } } -data arrival_skew_comparison_bound_millis: Nat = 250 +data arrival_skew_comparison_bound_millis: Millisecond = millisecond(count: 250) fn arrival_admits_rate_comparison(s: ArrivalSkew) -> Bool { match s { ArrivalSkewUnread { cause: _ } => false - ArrivalSkewObserved { max_stagger_millis: n } => n <= arrival_skew_comparison_bound_millis + ArrivalSkewObserved { max_stagger_millis: n } => millisecond_count(m: n) <= millisecond_count(m: arrival_skew_comparison_bound_millis) } } @@ -644,7 +645,7 @@ fn capacity_claim_for_window(window: ProbeWindowStanding) -> CapacityClaim { } type DerivedRate - = RateFromClientOutputTokens { tokens: Nat, scrape_millis: Nat } + = RateFromClientOutputTokens { tokens: Nat, scrape_millis: Millisecond } | RateUndenominable { because: NonEmptyStr } | RateUnreadable { because: NonEmptyStr } @@ -653,13 +654,13 @@ fn tokens_per_observation_second(r: DerivedRate) -> Nat? { RateUndenominable { because: _ } => none RateUnreadable { because: _ } => none RateFromClientOutputTokens { tokens: t, scrape_millis: ms } => - if ms == 0 { none } else { Present { value: (t * 1000) / ms } } + if millisecond_count(m: ms) == 0 { none } else { Present { value: (t * 1000) / millisecond_count(m: ms) } } } } fn derive_rate_honest( ledger: OperationLedger, - scrape_millis: Nat?, + scrape_millis: Millisecond?, client_output: ClientOutputTokens, ) -> DerivedRate { if !ledger_admits_token_denomination(l: ledger) { @@ -772,9 +773,9 @@ type ClientBenchLatency = ClientBenchLatencyUnread { cause: NonEmptyStr } | ClientBenchLatencyReported { output_throughput_milli_tok_per_s: Nat - tpot_milli: Nat - itl_milli: Nat? - ttft_milli: Nat + tpot_milli: Millisecond + itl_milli: Millisecond? + ttft_milli: Millisecond window: ProbeWindowStanding } @@ -783,7 +784,7 @@ type ItlTailCause type ClientItlDistribution = ClientItlDistributionUnread { cause: NonEmptyStr } - | ClientItlDistributionObserved { mean_milli: Nat, median_milli: Nat, p99_milli: Nat, cause: ItlTailCause } + | ClientItlDistributionObserved { mean_milli: Millisecond, median_milli: Millisecond, p99_milli: Millisecond, cause: ItlTailCause } type ClientRequestConcurrencyStanding = ClientConcurrencyUnread { cause: NonEmptyStr } @@ -859,7 +860,7 @@ fn bench_serve_completed_output(e: BenchServeExecution) -> ClientOutputTokens { } } -fn bench_serve_interval(e: BenchServeExecution) -> Nat? { +fn bench_serve_interval(e: BenchServeExecution) -> Millisecond? { match bench_summary_stdout(e: e) { Absent => none Present { value: body } => scrape_millis_from_bench_stdout(body: body) @@ -1179,13 +1180,13 @@ fn client_latency_text(c: ClientBenchLatency) -> String { ClientBenchLatencyReported { output_throughput_milli_tok_per_s: th, tpot_milli: tpot, itl_milli: itl, ttft_milli: ttft, window: w } => join([ "bench-serve throughput_milli_tok_s=", to_string(th), - " tpot_ms=", to_string(tpot), + " tpot_ms=", to_string(millisecond_count(m: tpot)), " itl_ms=", match itl { Absent => "unread" - Present { value: n } => to_string(n) + Present { value: n } => to_string(millisecond_count(m: n)) }, - " ttft_ms=", to_string(ttft), + " ttft_ms=", to_string(millisecond_count(m: ttft)), " window=", window_text(s: w), ], "") } @@ -1297,7 +1298,7 @@ fn backlog_text(b: BacklogStanding) -> String { fn histogram_text(d: HistogramDelta) -> String { match d { HistogramDeltaRead { sum_milli: s, count: n } => - join(["delta sum_milli=", to_string(s), " count=", to_string(n)], "") + join(["delta sum_milli=", to_string(millisecond_count(m: s)), " count=", to_string(n)], "") HistogramDeltaUnread { cause: c } => join(["unread ", c as String], "") HistogramCounterReset { cause: c } => join(["reset ", c as String], "") } @@ -1329,7 +1330,7 @@ fn rate_text(r: DerivedRate) -> String { RateFromClientOutputTokens { tokens: t, scrape_millis: ms } => join([ "completed_output_tokens=", to_string(t), - " scrape_millis=", to_string(ms), + " scrape_millis=", to_string(millisecond_count(m: ms)), " output_tokens_per_s=", match tokens_per_observation_second(r: r) { Absent => "none" @@ -1438,17 +1439,17 @@ data glm_native_wiring_smoke_protocol: VllmBenchServeRequest = vllm_bench_serve_ // smoke (256/64, inf rate, c=2, 4/4 ok). Contended. Not the 256/128 sweep protocol. type TranscribedClientLatency { output_throughput_milli_tok_per_s: Nat - tpot_milli: Nat - itl_milli: Nat? - ttft_milli: Nat + tpot_milli: Millisecond + itl_milli: Millisecond? + ttft_milli: Millisecond standing: CitedFigureStanding } data glm_native_smoke_client_latency: TranscribedClientLatency = TranscribedClientLatency { output_throughput_milli_tok_per_s: 17390 - tpot_milli: 82 - itl_milli: Present { value: 82 } - ttft_milli: 2185 + tpot_milli: millisecond(count: 82) + itl_milli: Present { value: millisecond(count: 82) } + ttft_milli: millisecond(count: 2185) standing: TranscribedUncited { read_obligation: "re-read vllm bench serve stdout for the 256-in/64-out wiring argv; the 17.39 tok/s / 82.1 ms TPOT / 81.8 ms ITL / 2185 ms TTFT figures were transcribed from calm-bat-65's docker-exec receipt" as NonEmptyStr } @@ -1460,9 +1461,9 @@ data glm_native_wet_smoke_standing: CitedFigureStanding = TranscribedUncited { data glm_native_wet_smoke_client_latency: TranscribedClientLatency = TranscribedClientLatency { output_throughput_milli_tok_per_s: 22510 - tpot_milli: 82 - itl_milli: Present { value: 83 } - ttft_milli: 996 + tpot_milli: millisecond(count: 82) + itl_milli: Present { value: millisecond(count: 83) } + ttft_milli: millisecond(count: 996) standing: glm_native_wet_smoke_standing } @@ -1484,8 +1485,8 @@ fn cap_2_bucket_peak_4_is_not_foreign_work(p: ClientRequestConcurrencyStanding) match p { ClientConcurrencyUnread { cause: _ } => false SuccessfulClientRequestSecondBucketPeak { client_max_concurrency: c, bucket_peak: b } => - c == token_count_value(t: token_count(count: 2)) - && b == token_count_value(t: token_count(count: 4)) + c == 2 + && b == 4 && !client_second_bucket_peak_establishes_foreign_work(p: p) } } @@ -1501,8 +1502,11 @@ fn bench_labeled_milli_from_seconds(body: String, label: String) -> Nat? { } } -fn bench_labeled_whole_milli(body: String, label: String) -> Nat? { - text_labeled_head_count(body: text_without_sudo_prompt(body: body), label: label) +fn bench_labeled_whole_milli(body: String, label: String) -> Millisecond? { + match text_labeled_head_count(body: text_without_sudo_prompt(body: body), label: label) { + Absent => none + Present { value: n } => Present { value: millisecond(count: n) } + } } fn ledger_from_bench_stdout(body: String, offered: Nat) -> OperationLedger { @@ -1528,8 +1532,11 @@ fn client_output_from_bench_stdout(body: String) -> ClientOutputTokens { } } -fn scrape_millis_from_bench_stdout(body: String) -> Nat? { - bench_labeled_milli_from_seconds(body: body, label: "Benchmark duration (s)") +fn scrape_millis_from_bench_stdout(body: String) -> Millisecond? { + match bench_labeled_milli_from_seconds(body: body, label: "Benchmark duration (s)") { + Absent => none + Present { value: n } => Present { value: millisecond(count: n) } + } } fn client_itl_from_bench_stdout(body: String) -> ClientItlDistribution { @@ -1605,7 +1612,7 @@ fn total_token_throughput_is_not_the_probe_rate(r: PrefillVersusDecodeThroughput } data glm_native_wet_smoke_client_output: ClientOutputTokens = ClientOutputTokensObserved { tokens: 512 } -data glm_native_wet_smoke_duration_millis: Nat = 22750 +data glm_native_wet_smoke_duration_millis: Millisecond = millisecond(count: 22750) fn glm_native_wet_smoke_rate() -> DerivedRate { derive_rate_honest( @@ -1627,7 +1634,7 @@ fn glm_native_wet_smoke_rate_is_output_tokens() -> Bool { && glm_native_wet_smoke_prefill_versus_decode.output_tokens == 512 && glm_native_wet_smoke_prefill_versus_decode.input_tokens == 1072 && match glm_native_wet_smoke_rate() { - RateFromClientOutputTokens { tokens: t, scrape_millis: ms } => t == 512 && ms == 22750 + RateFromClientOutputTokens { tokens: t, scrape_millis: ms } => t == 512 && millisecond_count(m: ms) == 22750 RateUndenominable { because: _ } => false RateUnreadable { because: _ } => false } @@ -1638,10 +1645,11 @@ data glm_native_contended_sweep_standing: CitedFigureStanding = TranscribedUncit read_obligation: "re-read calm-bat-65's vllm bench serve stdout for the 256-in/128-out inf-rate ignore-eos sweep (num-prompts 4×concurrency, min 8) taken while operator long-context traffic shared Group B" as NonEmptyStr } +data glm_native_sweep_min_prompts: Nat = 8 + fn glm_native_sweep_num_prompts(concurrency: Nat) -> Nat { let fourfold = concurrency * 4 - let eight = token_count_value(t: token_count(count: 8)) - if fourfold < eight { eight } else { fourfold } + if fourfold < glm_native_sweep_min_prompts { glm_native_sweep_min_prompts } else { fourfold } } fn glm_native_contended_sweep_protocol(concurrency: Nat) -> VllmBenchServeRequest { @@ -1666,9 +1674,9 @@ fn glm_native_contended_client_latency( ) -> TranscribedClientLatency { TranscribedClientLatency { output_throughput_milli_tok_per_s: throughput_milli_tok_per_s, - tpot_milli: tpot_milli, + tpot_milli: millisecond(count: tpot_milli), itl_milli: none, - ttft_milli: ttft_milli, + ttft_milli: millisecond(count: ttft_milli), standing: glm_native_contended_sweep_standing, } } @@ -1737,28 +1745,28 @@ fn elasticity_is_off_the_uncontrolled_series(s: UncontrolledSeriesElasticity) -> } fn glm_native_sweep_ttft_c8() -> Nat { - glm_native_contended_sweep_c8.latency.ttft_milli + millisecond_count(m: glm_native_contended_sweep_c8.latency.ttft_milli) } fn glm_native_sweep_ttft_c16() -> Nat { - glm_native_contended_sweep_c16.latency.ttft_milli + millisecond_count(m: glm_native_contended_sweep_c16.latency.ttft_milli) } type WindowStandingGapSpecimen { - quieter_engine_tpot_milli: Nat - contended_client_c1_tpot_milli: Nat + quieter_engine_tpot_milli: Millisecond + contended_client_c1_tpot_milli: Millisecond } data glm_native_window_standing_specimen: WindowStandingGapSpecimen = WindowStandingGapSpecimen { quieter_engine_tpot_milli: glm_native_single_stream_decode_bound_millis, - contended_client_c1_tpot_milli: 81, + contended_client_c1_tpot_milli: millisecond(count: 81), } // Same subject, same single-stream protocol shape, different window: quieter engine 48.9 ms vs // contended client c=1 TPOT 80.7 ms. The gap is observed; its cause is unestablished until an // overlapping lease or engine-population join attributes it. fn window_standing_gap_is_unattributed(s: WindowStandingGapSpecimen) -> Bool { - s.contended_client_c1_tpot_milli > s.quieter_engine_tpot_milli + millisecond_count(m: s.contended_client_c1_tpot_milli) > millisecond_count(m: s.quieter_engine_tpot_milli) } fn bench_output_len(req: VllmBenchServeRequest) -> Nat { @@ -1798,7 +1806,7 @@ data glm_native_holistic_execution: LongContextExecutionStanding = LongContextLo // floor from the checkpoint config (45 layers, hidden 4096, 288 routed experts, top-8 + 1 shared, fp8) // and measured 48.9 ms single-stream. Until those config rows are cited, the 49 ms figure stays // TranscribedUncited and is not consumed as a rate. -data glm_native_single_stream_decode_bound_millis: Nat = 49 +data glm_native_single_stream_decode_bound_millis: Millisecond = millisecond(count: 49) data glm_native_single_stream_decode_bound_standing: CitedFigureStanding = TranscribedUncited { read_obligation: "read the served GLM-5.3-Flash checkpoint config for layer count, hidden size, routed experts, top-k and shared expert, and the independent single-stream measurement this 49 ms/token bound was transcribed from; the 9-11 ms memory-bandwidth floor is a derived bound from that config, not a serving reading" as NonEmptyStr } diff --git a/dag/gunbc/spark/serving_load_probe_cli.dag b/dag/gunbc/spark/serving_load_probe_cli.dag index fd5b2d43bae..4e089bcedbd 100644 --- a/dag/gunbc/spark/serving_load_probe_cli.dag +++ b/dag/gunbc/spark/serving_load_probe_cli.dag @@ -1,6 +1,8 @@ module gunbc.spark.serving_load_probe_cli -import std.types { Bool, List, NonEmptyStr, String } +import std.types { Int, List, NonEmptyStr, String } +import std.measure { second } +import extdeps.tools.curl { curl_bounded_get_argv } import std.process { ProcessExit, ExitSuccess, exit_failure } import std.resources { Network } import extdeps.filesystem.filesystem_io { Filesystem } @@ -8,7 +10,7 @@ import extdeps.docker.cli { docker_exec_command } import extdeps.exec.command { argv_words } import extdeps.vllm.bench_serve { vllm_bench_serve_arguments } import gunbc.clock_read { clock_now_probed_at, probed_at_word } -import gunbc.fleet_intent_network { operator_host_srv9 } +import gunbc.fleet_intent_network { operator_host_srv9, srv9_host_lan_endpoint } import gunbc.spark.model_snapshot_materialize { SparkMaterializeContext, spark_remote_run, RemoteRan, RemoteUnreachable, } @@ -53,7 +55,7 @@ fn metrics_url() -> String { } fn curl_metrics_argv() -> List { - ["curl", "-fsS", "--max-time", "15", metrics_url()] + curl_bounded_get_argv(url: metrics_url(), connect_timeout: second(count: 2), max_time: second(count: 15)) } fn bench_exec_argv() -> List { @@ -64,20 +66,31 @@ fn bench_exec_argv() -> List { )) } -fn remote_or_fail(ctx: SparkMaterializeContext, argv: List, step: String) -> String { - match spark_remote_run(ctx: ctx, argv: argv) { - RemoteUnreachable { cause: c } => join(["UNREACHABLE ", step, " ", c], "") +// One metrics scrape keeps the remote run's arms: a refusal is never a body a parser can read. +type MetricsScrape + = ScrapeBody { body: String } + | ScrapeUnreachable { step: String, cause: String } + | ScrapeExitedNonZero { step: String, exit_code: Int, stdout: String, stderr: String } + +fn scrape_metrics(ctx: SparkMaterializeContext, step: String) -> MetricsScrape { + match spark_remote_run(ctx: ctx, argv: curl_metrics_argv()) { + RemoteUnreachable { cause: c } => ScrapeUnreachable { step: step, cause: c } RemoteRan { exit_code: code, stdout: out, stderr: err } => if code != 0 { - join(["FAILED ", step, " exit=", to_string(code), " stderr=", err], "") + ScrapeExitedNonZero { step: step, exit_code: code, stdout: out, stderr: err } } else { - out + ScrapeBody { body: out } } } } -fn body_is_failure(body: String) -> Bool { - starts_with(s: body, prefix: "UNREACHABLE ") || starts_with(s: body, prefix: "FAILED ") +fn scrape_refusal_text(s: MetricsScrape) -> String { + match s { + ScrapeBody { body: _ } => "scrape produced a body" + ScrapeUnreachable { step: st, cause: c } => join(["UNREACHABLE ", st, " ", c], "") + ScrapeExitedNonZero { step: st, exit_code: code, stdout: out, stderr: err } => + join(["FAILED ", st, " exit=", to_string(code), " stderr=", err, " stdout=", out], "") + } } fn inspect_incarnation(ctx: SparkMaterializeContext) -> ObservedRankIncarnation? @@ -101,10 +114,11 @@ fn glm_native_serving_load_run() -> ProcessExit { with_group_b_access(use: fn(trust, path, administrator, file) { let ctx = rank_context(host: operator_host_srv9, trust: trust, path: path, administrator: administrator, credential_file: file) - let before = remote_or_fail(ctx: ctx, argv: curl_metrics_argv(), step: "metrics-before") - if body_is_failure(body: before) { - exit_failure(reason: before) - } else { + let before_scrape = scrape_metrics(ctx: ctx, step: "metrics-before") + match before_scrape { + ScrapeUnreachable { step: _, cause: _ } => exit_failure(reason: scrape_refusal_text(s: before_scrape)) + ScrapeExitedNonZero { step: _, exit_code: _, stdout: _, stderr: _ } => exit_failure(reason: scrape_refusal_text(s: before_scrape)) + ScrapeBody { body: before } => { let drain = drain_from_queue(q: harness_queue_from_body(body: before)) let window = window_from_drain(drain: drain) match window { @@ -122,13 +136,14 @@ fn glm_native_serving_load_run() -> ProcessExit DrainObservedIdle => { let before_incarnation = inspect_incarnation(ctx: ctx) let bench = bench_serve_from_remote(protocol: glm_native_smoke_protocol, remote: spark_remote_run(ctx: ctx, argv: bench_exec_argv())) - let after = remote_or_fail(ctx: ctx, argv: curl_metrics_argv(), step: "metrics-after") - if body_is_failure(body: after) { - exit_failure(reason: after) - } else { + let after_scrape = scrape_metrics(ctx: ctx, step: "metrics-after") + match after_scrape { + ScrapeUnreachable { step: _, cause: _ } => exit_failure(reason: scrape_refusal_text(s: after_scrape)) + ScrapeExitedNonZero { step: _, exit_code: _, stdout: _, stderr: _ } => exit_failure(reason: scrape_refusal_text(s: after_scrape)) + ScrapeBody { body: after } => { let after_incarnation = inspect_incarnation(ctx: ctx) - let before_launch = harness_launch_from_body(group: FabricGroupB, address: "192.168.1.236", body: before) - let after_launch = harness_launch_from_body(group: FabricGroupB, address: "192.168.1.236", body: after) + let before_launch = harness_launch_from_body(group: FabricGroupB, address: srv9_host_lan_endpoint.address, body: before) + let after_launch = harness_launch_from_body(group: FabricGroupB, address: srv9_host_lan_endpoint.address, body: after) let occ = occupancy_trace_from_endpoint_scrapes(before_body: before, after_body: after) let bucket = bench_serve_bucket_peak(e: bench) let itl = bench_serve_itl(e: bench) @@ -155,10 +170,12 @@ fn glm_native_serving_load_run() -> ProcessExit } else { ExitSuccess } + } } } } } + } } }, attempt_raw: glm_native_serving_load_attempt_raw, credential_file_name: "gunbc-glm-native-serving-load-admin-password" as NonEmptyStr) } diff --git a/dag/test/claim/spark/serving_load_probe_witness_test.dag b/dag/test/claim/spark/serving_load_probe_witness_test.dag index 7db89ca63d0..3f8b292cdb1 100644 --- a/dag/test/claim/spark/serving_load_probe_witness_test.dag +++ b/dag/test/claim/spark/serving_load_probe_witness_test.dag @@ -4,7 +4,7 @@ import std.types { Bool, String, NonEmptyStr, EpochSecs, List } import std.nat { Nat } import v2.std.algebra { length, filter } import v2.std.optional { Present, Absent } -import std.measure { token_count, token_count_value } +import std.measure { token_count, millisecond, millisecond_count } import product.capacity.lease { LeaseGrant, lease_fence_of, lease_grant, LeasePolicy, FencedResource } import product.capacity.event_chain { EventId } import gunbc.fleet_intent_network { operator_host_srv9 } @@ -225,11 +225,11 @@ test fn engine_rate_comes_from_generation_tokens_not_iteration_or_itl() -> Bool t == 128 && match derive_rate_honest( ledger: closed_ok(), - scrape_millis: Present { value: 2000 }, + scrape_millis: Present { value: millisecond(count: 2000) }, client_output: ClientOutputTokensObserved { tokens: t }, ) { RateFromClientOutputTokens { tokens: tok, scrape_millis: ms } => - tok == 128 && ms == 2000 && + tok == 128 && millisecond_count(m: ms) == 2000 && match tokens_per_observation_second(r: RateFromClientOutputTokens { tokens: tok, scrape_millis: ms }) { Absent => false Present { value: rate } => rate == 64 @@ -292,7 +292,7 @@ test fn a_scoped_generation_delta_names_the_incarnation() -> Bool { after_body: fx_after, ) { TokenDeltaScoped { tokens: t, incarnation: i } => - t == 128 && (i.container.id as String) == "0f3a9c1d2e4b" && i.node_rank == token_count_value(t: token_count(count: 0)) + t == 128 && (i.container.id as String) == "0f3a9c1d2e4b" && i.node_rank == 0 TokenDeltaRead { tokens: _ } => false TokenDeltaUnread { cause: _ } => false TokenDeltaReset { cause: _ } => false @@ -303,7 +303,7 @@ fn fx_incarnation(id: String) -> ObservedRankIncarnation? { match container_incarnation_id(id: id) { Absent => none Present { value: cid } => - Present { value: ObservedRankIncarnation { host: operator_host_srv9, container: cid, node_rank: token_count_value(t: token_count(count: 0)) } } + Present { value: ObservedRankIncarnation { host: operator_host_srv9, container: cid, node_rank: 0 } } } } @@ -335,7 +335,7 @@ fn fx_obs() -> ServingLoadObservation { test fn generation_tokens_without_client_completions_is_foreign_load() -> Bool { match derive_rate_honest( ledger: LedgerClosed { offered: 4, completed: 0, failed: 4 }, - scrape_millis: Present { value: 2000 }, + scrape_millis: Present { value: millisecond(count: 2000) }, client_output: ClientOutputTokensUnread { cause: "none" as NonEmptyStr }, ) { RateUndenominable { because: _ } => true @@ -347,7 +347,7 @@ test fn generation_tokens_without_client_completions_is_foreign_load() -> Bool { test fn occupancy_above_declared_concurrency_does_not_refuse_the_client_rate() -> Bool { match derive_rate_honest( ledger: closed_ok(), - scrape_millis: Present { value: 2000 }, + scrape_millis: Present { value: millisecond(count: 2000) }, client_output: ClientOutputTokensObserved { tokens: 128 }, ) { RateFromClientOutputTokens { tokens: t, scrape_millis: _ } => t == 128 @@ -359,7 +359,7 @@ test fn occupancy_above_declared_concurrency_does_not_refuse_the_client_rate() - test fn unread_client_output_tokens_refuse_the_rate() -> Bool { match derive_rate_honest( ledger: closed_ok(), - scrape_millis: Present { value: 2000 }, + scrape_millis: Present { value: millisecond(count: 2000) }, client_output: ClientOutputTokensUnread { cause: "bench stdout not parsed" as NonEmptyStr }, ) { RateUnreadable { because: _ } => true @@ -371,7 +371,7 @@ test fn unread_client_output_tokens_refuse_the_rate() -> Bool { test fn extra_engine_tokens_bound_foreign_work_and_keep_the_client_rate() -> Bool { match derive_rate_honest( ledger: closed_ok(), - scrape_millis: Present { value: 2000 }, + scrape_millis: Present { value: millisecond(count: 2000) }, client_output: ClientOutputTokensObserved { tokens: 128 }, ) { RateFromClientOutputTokens { tokens: t, scrape_millis: _ } => @@ -389,7 +389,7 @@ test fn extra_engine_tokens_bound_foreign_work_and_keep_the_client_rate() -> Boo test fn unsampled_occupancy_does_not_refuse_the_client_rate() -> Bool { match derive_rate_honest( ledger: closed_ok(), - scrape_millis: Present { value: 2000 }, + scrape_millis: Present { value: millisecond(count: 2000) }, client_output: ClientOutputTokensObserved { tokens: 128 }, ) { RateFromClientOutputTokens { tokens: t, scrape_millis: _ } => t == 128 @@ -440,7 +440,7 @@ test fn an_itl_histogram_sum_with_sub_milli_digits_is_still_a_milli_reading() -> let before = metrics_body(running: "0.0", waiting: "0.0", capacity: "0.0", preempt: "0.0", itl_sum: "10.1234567", itl_count: "100.0", itok_sum: "1000.0", itok_count: "10.0", gen: "1000.0", start: "1789300000.12") let after = metrics_body(running: "0.0", waiting: "0.0", capacity: "0.0", preempt: "0.0", itl_sum: "12.1234567", itl_count: "200.0", itok_sum: "1000.0", itok_count: "10.0", gen: "1000.0", start: "1789300000.12") match histogram_delta(before_body: before, after_body: after, metric: InterTokenLatencySeconds) { - HistogramDeltaRead { sum_milli: ds, count: dc } => ds == 2000 && dc == 100 + HistogramDeltaRead { sum_milli: ds, count: dc } => millisecond_count(m: ds) == 2000 && dc == 100 HistogramDeltaUnread { cause: _ } => false HistogramCounterReset { cause: _ } => false } @@ -448,7 +448,7 @@ test fn an_itl_histogram_sum_with_sub_milli_digits_is_still_a_milli_reading() -> test fn a_sudo_password_prompt_line_does_not_spoil_the_bench_ledger() -> Bool { let body = join(["[sudo] password for briansrls:\n", fx_bench_stdout], "") - match ledger_from_bench_stdout(body: body, offered: token_count_value(t: token_count(count: 4))) { + match ledger_from_bench_stdout(body: body, offered: 4) { LedgerClosed { offered: o, completed: c, failed: f } => o == 4 && c == 4 && f == 0 && match client_output_from_bench_stdout(body: body) { @@ -462,7 +462,7 @@ test fn a_sudo_password_prompt_line_does_not_spoil_the_bench_ledger() -> Bool { test fn the_holistic_protocol_does_not_corroborate_the_single_stream_bound() -> Bool { match decode_corroboration_for_protocol(req: glm_native_holistic_protocol) { CorroborationNotApplicable { because: _ } => - glm_native_single_stream_decode_bound_millis == 49 + millisecond_count(m: glm_native_single_stream_decode_bound_millis) == 49 && match glm_native_single_stream_decode_bound_standing { TranscribedUncited { read_obligation: _ } => true CitedToAuthority { authority: _ } => false @@ -474,7 +474,7 @@ test fn the_holistic_protocol_does_not_corroborate_the_single_stream_bound() -> test fn the_smoke_protocol_is_not_the_holistic_envelope() -> Bool { !holistic_protocol_is_session_shaped(req: glm_native_smoke_protocol) && !vllm_bench_serve_uses_poisson_idle_gaps(req: glm_native_smoke_protocol) - && glm_native_smoke_client_latency.tpot_milli == 82 + && millisecond_count(m: glm_native_smoke_client_latency.tpot_milli) == 82 } test fn a_64_out_wiring_receipt_is_not_the_128_out_sweep_protocol() -> Bool { @@ -519,8 +519,8 @@ data fx_bench_stdout_short: String = join([ test fn a_cap_2_second_bucket_peak_4_does_not_establish_foreign_work() -> Bool { cap_2_bucket_peak_4_is_not_foreign_work(p: SuccessfulClientRequestSecondBucketPeak { - client_max_concurrency: token_count_value(t: token_count(count: 2)), - bucket_peak: token_count_value(t: token_count(count: 4)), + client_max_concurrency: 2, + bucket_peak: 4, }) } @@ -528,13 +528,13 @@ test fn parsed_itl_distribution_does_not_establish_a_cause() -> Bool { let d = client_itl_from_bench_stdout(body: fx_bench_stdout) match d { ClientItlDistributionObserved { mean_milli: mean_m, median_milli: med, p99_milli: p99, cause: _ } => - mean_m == 83 && med == 82 && p99 == 165 && itl_tail_cause_is_unestablished(d: d) + millisecond_count(m: mean_m) == 83 && millisecond_count(m: med) == 82 && millisecond_count(m: p99) == 165 && itl_tail_cause_is_unestablished(d: d) ClientItlDistributionUnread { cause: _ } => false } } test fn ledger_and_rate_come_from_bench_stdout_not_exit_ok() -> Bool { - match ledger_from_bench_stdout(body: fx_bench_stdout, offered: token_count_value(t: token_count(count: 4))) { + match ledger_from_bench_stdout(body: fx_bench_stdout, offered: 4) { LedgerClosed { offered: o, completed: c, failed: f } => o == 4 && c == 4 && f == 0 && match client_output_from_bench_stdout(body: fx_bench_stdout) { @@ -543,7 +543,7 @@ test fn ledger_and_rate_come_from_bench_stdout_not_exit_ok() -> Bool { n == 512 && match scrape_millis_from_bench_stdout(body: fx_bench_stdout) { Absent => false - Present { value: ms } => ms == 22750 + Present { value: ms } => millisecond_count(m: ms) == 22750 } } LedgerIncomplete { because: _ } => false @@ -564,8 +564,8 @@ test fn the_contended_sweep_is_five_shared_window_client_points() -> Bool { && glm_native_sweep_num_prompts(concurrency: 2) == 8 && glm_native_sweep_num_prompts(concurrency: 4) == 16 && glm_native_contended_sweep_c1.latency.output_throughput_milli_tok_per_s == 10860 - && glm_native_contended_sweep_c1.latency.tpot_milli == 81 - && glm_native_contended_sweep_c1.latency.ttft_milli == 1542 + && millisecond_count(m: glm_native_contended_sweep_c1.latency.tpot_milli) == 81 + && millisecond_count(m: glm_native_contended_sweep_c1.latency.ttft_milli) == 1542 && glm_native_contended_sweep_c1.concurrency == 1 } @@ -578,8 +578,8 @@ test fn ttft_c8_and_c16_remain_primitive_observations() -> Bool { } test fn the_49_vs_81_ms_gap_is_why_window_standing_is_a_field() -> Bool { - glm_native_window_standing_specimen.quieter_engine_tpot_milli == 49 - && glm_native_window_standing_specimen.contended_client_c1_tpot_milli == 81 + millisecond_count(m: glm_native_window_standing_specimen.quieter_engine_tpot_milli) == 49 + && millisecond_count(m: glm_native_window_standing_specimen.contended_client_c1_tpot_milli) == 81 && window_standing_gap_is_unattributed(s: glm_native_window_standing_specimen) } @@ -655,8 +655,8 @@ test fn mixing_two_bench_stdout_bodies_cannot_write_one_receipt() -> Bool { test fn send_all_at_cap_2_with_no_start_events_is_not_zero_skew() -> Bool { send_all_without_start_events_is_not_zero_skew( - num_prompts: token_count_value(t: token_count(count: 4)), - cap: token_count_value(t: token_count(count: 2)), + num_prompts: 4, + cap: 2, start_event_count: 0, ) } From 421df043866ca325ca1871e90b97fba2fe223c8f Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sat, 19 Sep 2026 04:05:03 +0000 Subject: [PATCH 25/43] HistogramDeltaRead sum stays Nat: the fold also carries booked-token sums, not only latency Co-Authored-By: Claude Opus 5 (1M context) --- dag/gunbc/spark/serving_load_probe.dag | 6 +++--- dag/test/claim/spark/serving_load_probe_witness_test.dag | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dag/gunbc/spark/serving_load_probe.dag b/dag/gunbc/spark/serving_load_probe.dag index 362d1625784..43d27433573 100644 --- a/dag/gunbc/spark/serving_load_probe.dag +++ b/dag/gunbc/spark/serving_load_probe.dag @@ -253,7 +253,7 @@ fn counter_continuity(before: VllmEndpointProcessLaunchObservation, after: VllmE } type HistogramDelta - = HistogramDeltaRead { sum_milli: Millisecond, count: Nat } + = HistogramDeltaRead { sum_milli: Nat, count: Nat } | HistogramDeltaUnread { cause: NonEmptyStr } | HistogramCounterReset { cause: NonEmptyStr } @@ -326,7 +326,7 @@ fn histogram_delta(before_body: String, after_body: String, metric: VllmServingM Present { value: ds } => match nat_delta(after: acn, before: bcn) { Absent => HistogramCounterReset { cause: "histogram count decreased across the window" as NonEmptyStr } - Present { value: dc } => HistogramDeltaRead { sum_milli: millisecond(count: ds), count: dc } + Present { value: dc } => HistogramDeltaRead { sum_milli: ds, count: dc } } } } @@ -1298,7 +1298,7 @@ fn backlog_text(b: BacklogStanding) -> String { fn histogram_text(d: HistogramDelta) -> String { match d { HistogramDeltaRead { sum_milli: s, count: n } => - join(["delta sum_milli=", to_string(millisecond_count(m: s)), " count=", to_string(n)], "") + join(["delta sum_milli=", to_string(s), " count=", to_string(n)], "") HistogramDeltaUnread { cause: c } => join(["unread ", c as String], "") HistogramCounterReset { cause: c } => join(["reset ", c as String], "") } diff --git a/dag/test/claim/spark/serving_load_probe_witness_test.dag b/dag/test/claim/spark/serving_load_probe_witness_test.dag index 3f8b292cdb1..df6f2e19d45 100644 --- a/dag/test/claim/spark/serving_load_probe_witness_test.dag +++ b/dag/test/claim/spark/serving_load_probe_witness_test.dag @@ -440,7 +440,7 @@ test fn an_itl_histogram_sum_with_sub_milli_digits_is_still_a_milli_reading() -> let before = metrics_body(running: "0.0", waiting: "0.0", capacity: "0.0", preempt: "0.0", itl_sum: "10.1234567", itl_count: "100.0", itok_sum: "1000.0", itok_count: "10.0", gen: "1000.0", start: "1789300000.12") let after = metrics_body(running: "0.0", waiting: "0.0", capacity: "0.0", preempt: "0.0", itl_sum: "12.1234567", itl_count: "200.0", itok_sum: "1000.0", itok_count: "10.0", gen: "1000.0", start: "1789300000.12") match histogram_delta(before_body: before, after_body: after, metric: InterTokenLatencySeconds) { - HistogramDeltaRead { sum_milli: ds, count: dc } => millisecond_count(m: ds) == 2000 && dc == 100 + HistogramDeltaRead { sum_milli: ds, count: dc } => ds == 2000 && dc == 100 HistogramDeltaUnread { cause: _ } => false HistogramCounterReset { cause: _ } => false } From 0cbec2699a76d6b8b50af06b9cc4d59da7e548a3 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sat, 19 Sep 2026 04:26:53 +0000 Subject: [PATCH 26/43] serving-load: histogram sums keep their metric's dimension; rates are Frequency measures ITL sums project to Millisecond and iteration-token sums to booked TokenCount over one shared raw histogram delta (a fractional token delta refuses). Client throughput is MilliTokensPerSecond, the Poisson request rate MilliRequestsPerSecond, burstiness Measure; the bench argv bytes are unchanged. Addresses the side-chat hold on bfb364f and review 68151. Co-Authored-By: Claude Opus 5 (1M context) --- dag/extdeps/vllm/bench_serve.dag | 27 ++-- dag/gunbc/spark/serving_load_probe.dag | 134 ++++++++++++------ dag/std/measure.dag | 27 ++++ .../spark/serving_load_probe_witness_test.dag | 52 ++++++- 4 files changed, 188 insertions(+), 52 deletions(-) diff --git a/dag/extdeps/vllm/bench_serve.dag b/dag/extdeps/vllm/bench_serve.dag index cb7a72b43d9..51bfe8ea9c3 100644 --- a/dag/extdeps/vllm/bench_serve.dag +++ b/dag/extdeps/vllm/bench_serve.dag @@ -3,7 +3,11 @@ module extdeps.vllm.bench_serve import std.types { Bool, List, NonEmptyStr, String, Int } import std.nat { Nat } import v2.std.optional { Present, Absent } -import std.measure { TokenCount, token_count, token_count_value } +import std.measure { + TokenCount, token_count, token_count_value, + Measure, Dimensionless, Milli, measure_count, + MilliRequestsPerSecond, milli_requests_per_second_count, +} import std.decl_ref { DeclarationRef, WholeDeclaration } import std.decimal { fixed_point_wire } import extdeps.external_authority { ExternalAuthority, ExternalModelScope, ExternalSubjectRef, CitedFigureStanding, TranscribedUncited } @@ -64,7 +68,7 @@ fn vllm_bench_backend_route(b: VllmBenchBackend) -> VllmRoute { // session simulation must not select it. type BenchArrival = SendAllImmediately - | PoissonProcess { millirequests_per_second: Nat, burstiness_milli: Nat } + | PoissonProcess { request_rate: MilliRequestsPerSecond, burstiness: Measure } type RandomDatasetSpec { input_len: TokenCount @@ -114,16 +118,16 @@ fn vllm_bench_serve_request( fn vllm_bench_arrival_rate_wire(a: BenchArrival) -> String { match a { SendAllImmediately => "inf" - PoissonProcess { millirequests_per_second: n, burstiness_milli: _ } => - fixed_point_wire(value: n as Int, decimals: 3) + PoissonProcess { request_rate: n, burstiness: _ } => + fixed_point_wire(value: milli_requests_per_second_count(r: n) as Int, decimals: 3) } } fn vllm_bench_burstiness_words(a: BenchArrival) -> List { match a { SendAllImmediately => [] - PoissonProcess { millirequests_per_second: _, burstiness_milli: b } => - ["--burstiness", fixed_point_wire(value: b as Int, decimals: 3)] + PoissonProcess { request_rate: _, burstiness: b } => + ["--burstiness", fixed_point_wire(value: measure_count(b) as Int, decimals: 3)] } } @@ -147,12 +151,14 @@ fn vllm_bench_arrival_eq(a: BenchArrival, b: BenchArrival) -> Bool { SendAllImmediately => match b { SendAllImmediately => true - PoissonProcess { millirequests_per_second: _, burstiness_milli: _ } => false + PoissonProcess { request_rate: _, burstiness: _ } => false } - PoissonProcess { millirequests_per_second: an, burstiness_milli: ab } => + PoissonProcess { request_rate: an, burstiness: ab } => match b { SendAllImmediately => false - PoissonProcess { millirequests_per_second: bn, burstiness_milli: bb } => an == bn && ab == bb + PoissonProcess { request_rate: bn, burstiness: bb } => + milli_requests_per_second_count(r: an) == milli_requests_per_second_count(r: bn) + && measure_count(ab) == measure_count(bb) } } } @@ -197,6 +203,7 @@ fn vllm_bench_serve_arguments(req: VllmBenchServeRequest) -> List { fn vllm_bench_serve_uses_poisson_idle_gaps(req: VllmBenchServeRequest) -> Bool { match req.arrival { SendAllImmediately => false - PoissonProcess { millirequests_per_second: n, burstiness_milli: b } => n > 0 && b == 1000 + PoissonProcess { request_rate: n, burstiness: b } => + milli_requests_per_second_count(r: n) > 0 && measure_count(b) == 1000 } } diff --git a/dag/gunbc/spark/serving_load_probe.dag b/dag/gunbc/spark/serving_load_probe.dag index 43d27433573..13628573a29 100644 --- a/dag/gunbc/spark/serving_load_probe.dag +++ b/dag/gunbc/spark/serving_load_probe.dag @@ -2,7 +2,13 @@ module gunbc.spark.serving_load_probe import std.types { Bool, String, NonEmptyStr, List, EpochSecs, Int } import std.nat { Nat } -import std.measure { Millisecond, millisecond, millisecond_count } +import std.measure { + Millisecond, millisecond, millisecond_count, + TokenCount, token_count, token_count_value, + Measure, Dimensionless, Milli, + MilliTokensPerSecond, milli_tokens_per_second, milli_tokens_per_second_count, + MilliRequestsPerSecond, milli_requests_per_second, +} import std.decimal { ExactDecimal, canonical_exact_decimal, decimal_pow10 } import std.checked_arithmetic { checked_int_magnitude, CheckedNatReady, CheckedNatOverflow } import v2.std.optional { Present, Absent } @@ -252,6 +258,11 @@ fn counter_continuity(before: VllmEndpointProcessLaunchObservation, after: VllmE } } +// THE RAW DELTA IS DIMENSION-AGNOSTIC ON PURPOSE. `histogram_delta` is the one shared parse and +// subtract for any vLLM histogram: `sum_milli` is thousandths of WHATEVER UNIT THAT METRIC'S SUM IS +// IN, and `count` is how many observations the histogram recorded. It is not a receipt field: the +// observation stores only the typed projections below, so a seconds sum and a booked-token sum can +// never be read through one carrier. type HistogramDelta = HistogramDeltaRead { sum_milli: Nat, count: Nat } | HistogramDeltaUnread { cause: NonEmptyStr } @@ -310,10 +321,10 @@ fn histogram_delta(before_body: String, after_body: String, metric: VllmServingM Absent => HistogramDeltaUnread { cause: "histogram count missing on the second body" as NonEmptyStr } Present { value: ac } => match field_to_milli(field: bs) { - Absent => HistogramDeltaUnread { cause: "histogram sum before was not an exact milli-second" as NonEmptyStr } + Absent => HistogramDeltaUnread { cause: "histogram sum before was not exact to three decimals" as NonEmptyStr } Present { value: bsm } => match field_to_milli(field: asv) { - Absent => HistogramDeltaUnread { cause: "histogram sum after was not an exact milli-second" as NonEmptyStr } + Absent => HistogramDeltaUnread { cause: "histogram sum after was not exact to three decimals" as NonEmptyStr } Present { value: asm } => match harness_gauge_count(text: bc) { Absent => HistogramDeltaUnread { cause: "histogram count before was not an exact count" as NonEmptyStr } @@ -340,6 +351,40 @@ fn histogram_delta(before_body: String, after_body: String, metric: VllmServingM } } +// vllm:inter_token_latency_seconds: the sum is SECONDS, so thousandths of it are milliseconds. +type LatencyHistogramDelta + = LatencyHistogramRead { sum: Millisecond, observations: Nat } + | LatencyHistogramUnread { cause: NonEmptyStr } + | LatencyHistogramReset { cause: NonEmptyStr } + +// vllm:iteration_tokens_total: the sum is TOKENS BOOKED across scheduler iterations, not a +// duration, and the count is histogram observations, not an engine-step count the probe may rely on. +type TokenHistogramDelta + = TokenHistogramRead { booked: TokenCount, observations: Nat } + | TokenHistogramUnread { cause: NonEmptyStr } + | TokenHistogramReset { cause: NonEmptyStr } + +fn itl_latency_delta(before_body: String, after_body: String) -> LatencyHistogramDelta { + match histogram_delta(before_body: before_body, after_body: after_body, metric: InterTokenLatencySeconds) { + HistogramDeltaRead { sum_milli: s, count: c } => LatencyHistogramRead { sum: millisecond(count: s), observations: c } + HistogramDeltaUnread { cause: x } => LatencyHistogramUnread { cause: x } + HistogramCounterReset { cause: x } => LatencyHistogramReset { cause: x } + } +} + +fn iteration_tokens_booked_delta(before_body: String, after_body: String) -> TokenHistogramDelta { + match histogram_delta(before_body: before_body, after_body: after_body, metric: IterationTokensTotal) { + HistogramDeltaRead { sum_milli: s, count: c } => + if s % 1000 == 0 { + TokenHistogramRead { booked: token_count(count: s / 1000), observations: c } + } else { + TokenHistogramUnread { cause: "iteration_tokens_total sum delta was not a whole token count" as NonEmptyStr } + } + HistogramDeltaUnread { cause: x } => TokenHistogramUnread { cause: x } + HistogramCounterReset { cause: x } => TokenHistogramReset { cause: x } + } +} + fn preemption_count(body: String) -> Nat? { match harness_gauge_value(body: body, metric: NumPreemptionsTotal) { Absent => none @@ -449,13 +494,13 @@ type ArrivalSkew type ArrivalPolicy = ArrivalPolicySendAll - | ArrivalPolicyPoisson { millirequests_per_second: Nat, burstiness_milli: Nat } + | ArrivalPolicyPoisson { request_rate: MilliRequestsPerSecond, burstiness: Measure } fn arrival_policy_from_request(req: VllmBenchServeRequest) -> ArrivalPolicy { match req.arrival { SendAllImmediately => ArrivalPolicySendAll - PoissonProcess { millirequests_per_second: n, burstiness_milli: b } => - ArrivalPolicyPoisson { millirequests_per_second: n, burstiness_milli: b } + PoissonProcess { request_rate: n, burstiness: b } => + ArrivalPolicyPoisson { request_rate: n, burstiness: b } } } @@ -463,7 +508,7 @@ fn arrival_from_protocol(req: VllmBenchServeRequest) -> ArrivalSkew { match arrival_policy_from_request(req: req) { ArrivalPolicySendAll => ArrivalSkewUnread { cause: "ArrivalPolicySendAll is input policy, not observed skew; vLLM's max_concurrency semaphore can run prompts in waves, and per-request start times were not retained" as NonEmptyStr } - ArrivalPolicyPoisson { millirequests_per_second: _, burstiness_milli: _ } => + ArrivalPolicyPoisson { request_rate: _, burstiness: _ } => ArrivalSkewUnread { cause: "Poisson starts are not parsed from vllm bench serve stdout until per-request start_times are retained" as NonEmptyStr } } } @@ -772,7 +817,7 @@ fn decode_corroboration_for_protocol(req: VllmBenchServeRequest) -> DecodeCorrob type ClientBenchLatency = ClientBenchLatencyUnread { cause: NonEmptyStr } | ClientBenchLatencyReported { - output_throughput_milli_tok_per_s: Nat + output_throughput: MilliTokensPerSecond tpot_milli: Millisecond itl_milli: Millisecond? ttft_milli: Millisecond @@ -1006,8 +1051,8 @@ type ServingLoadObservation sole_constructor { before_backlog: BacklogStanding after_backlog: BacklogStanding generation: TokenDelta - itl_latency: HistogramDelta - iteration_tokens_booked: HistogramDelta + itl_latency: LatencyHistogramDelta + iteration_tokens_booked: TokenHistogramDelta ledger: OperationLedger admission: AdmissionCost corroboration: DecodeCorroboration @@ -1064,8 +1109,8 @@ fn serving_load_observation( before_backlog: backlog_from_body(body: before_body, preemptions: before_p), after_backlog: backlog_from_body(body: after_body, preemptions: after_p), generation: generation, - itl_latency: histogram_delta(before_body: before_body, after_body: after_body, metric: InterTokenLatencySeconds), - iteration_tokens_booked: histogram_delta(before_body: before_body, after_body: after_body, metric: IterationTokensTotal), + itl_latency: itl_latency_delta(before_body: before_body, after_body: after_body), + iteration_tokens_booked: iteration_tokens_booked_delta(before_body: before_body, after_body: after_body), ledger: ledger, admission: glm_native_workload_admission, corroboration: decode_corroboration_for_protocol(req: protocol), @@ -1135,8 +1180,8 @@ fn serving_load_observation_text(o: ServingLoadObservation) -> String { "occupancy: ", occupancy_text(t: o.occupancy), "\n", "agreement: ", agreement_text(a: o.agreement), "\n", "generation: ", token_delta_text(d: o.generation), "\n", - "itl latency (not a rate): ", histogram_text(d: o.itl_latency), "\n", - "iteration_tokens booked (not occupancy): ", histogram_text(d: o.iteration_tokens_booked), "\n", + "itl latency (not a rate): ", latency_histogram_text(d: o.itl_latency), "\n", + "iteration_tokens booked (not occupancy): ", token_histogram_text(d: o.iteration_tokens_booked), "\n", "ledger: ", ledger_text(l: o.ledger), "\n", "admission: ", admission_text(a: o.admission), "\n", "corroboration: ", corroboration_text(c: o.corroboration), "\n", @@ -1177,9 +1222,9 @@ fn capacity_claim_text(c: CapacityClaim) -> String { fn client_latency_text(c: ClientBenchLatency) -> String { match c { ClientBenchLatencyUnread { cause: x } => join(["unread ", x as String], "") - ClientBenchLatencyReported { output_throughput_milli_tok_per_s: th, tpot_milli: tpot, itl_milli: itl, ttft_milli: ttft, window: w } => + ClientBenchLatencyReported { output_throughput: th, tpot_milli: tpot, itl_milli: itl, ttft_milli: ttft, window: w } => join([ - "bench-serve throughput_milli_tok_s=", to_string(th), + "bench-serve throughput_milli_tok_s=", to_string(milli_tokens_per_second_count(r: th)), " tpot_ms=", to_string(millisecond_count(m: tpot)), " itl_ms=", match itl { @@ -1295,12 +1340,21 @@ fn backlog_text(b: BacklogStanding) -> String { } } -fn histogram_text(d: HistogramDelta) -> String { +fn latency_histogram_text(d: LatencyHistogramDelta) -> String { + match d { + LatencyHistogramRead { sum: s, observations: n } => + join(["delta sum_ms=", to_string(millisecond_count(m: s)), " observations=", to_string(n)], "") + LatencyHistogramUnread { cause: c } => join(["unread ", c as String], "") + LatencyHistogramReset { cause: c } => join(["reset ", c as String], "") + } +} + +fn token_histogram_text(d: TokenHistogramDelta) -> String { match d { - HistogramDeltaRead { sum_milli: s, count: n } => - join(["delta sum_milli=", to_string(s), " count=", to_string(n)], "") - HistogramDeltaUnread { cause: c } => join(["unread ", c as String], "") - HistogramCounterReset { cause: c } => join(["reset ", c as String], "") + TokenHistogramRead { booked: t, observations: n } => + join(["delta booked_tokens=", to_string(token_count_value(t: t)), " observations=", to_string(n)], "") + TokenHistogramUnread { cause: c } => join(["unread ", c as String], "") + TokenHistogramReset { cause: c } => join(["reset ", c as String], "") } } @@ -1405,7 +1459,7 @@ data glm_native_holistic_protocol: VllmBenchServeRequest = vllm_bench_serve_requ tokenizer: glm_native_engine_tokenizer_path, dataset: glm_native_holistic_dataset, num_prompts: 4, - arrival: PoissonProcess { millirequests_per_second: 50, burstiness_milli: 1000 }, + arrival: PoissonProcess { request_rate: milli_requests_per_second(count: 50), burstiness: Measure { count: 1000 } }, max_concurrency: Present { value: 2 }, ignore_eos: true, seed: glm_native_bench_seed, @@ -1438,7 +1492,7 @@ data glm_native_wiring_smoke_protocol: VllmBenchServeRequest = vllm_bench_serve_ // Client TTFT/TPOT/ITL from vllm bench serve stdout, transcribed from the 2026-09-18 wiring // smoke (256/64, inf rate, c=2, 4/4 ok). Contended. Not the 256/128 sweep protocol. type TranscribedClientLatency { - output_throughput_milli_tok_per_s: Nat + output_throughput: MilliTokensPerSecond tpot_milli: Millisecond itl_milli: Millisecond? ttft_milli: Millisecond @@ -1446,7 +1500,7 @@ type TranscribedClientLatency { } data glm_native_smoke_client_latency: TranscribedClientLatency = TranscribedClientLatency { - output_throughput_milli_tok_per_s: 17390 + output_throughput: milli_tokens_per_second(count: 17390) tpot_milli: millisecond(count: 82) itl_milli: Present { value: millisecond(count: 82) } ttft_milli: millisecond(count: 2185) @@ -1460,7 +1514,7 @@ data glm_native_wet_smoke_standing: CitedFigureStanding = TranscribedUncited { } data glm_native_wet_smoke_client_latency: TranscribedClientLatency = TranscribedClientLatency { - output_throughput_milli_tok_per_s: 22510 + output_throughput: milli_tokens_per_second(count: 22510) tpot_milli: millisecond(count: 82) itl_milli: Present { value: millisecond(count: 83) } ttft_milli: millisecond(count: 996) @@ -1574,7 +1628,7 @@ fn client_latency_from_bench_stdout(body: String, window: ProbeWindowStanding) - Absent => ClientBenchLatencyUnread { cause: "vllm bench serve stdout carried no unique Mean TTFT (ms) line" as NonEmptyStr } Present { value: ttft } => ClientBenchLatencyReported { - output_throughput_milli_tok_per_s: th, + output_throughput: milli_tokens_per_second(count: th), tpot_milli: tpot, itl_milli: bench_labeled_whole_milli(body: body, label: "Mean ITL (ms)"), ttft_milli: ttft, @@ -1594,21 +1648,21 @@ data glm_native_client_rate_denomination: RateTokenDenomination = RateDenominate } type PrefillVersusDecodeThroughput { - output_milli_tok_per_s: Nat - total_milli_tok_per_s: Nat + output_throughput: MilliTokensPerSecond + total_throughput: MilliTokensPerSecond input_tokens: Nat output_tokens: Nat } data glm_native_wet_smoke_prefill_versus_decode: PrefillVersusDecodeThroughput = PrefillVersusDecodeThroughput { - output_milli_tok_per_s: 22510 - total_milli_tok_per_s: 69640 + output_throughput: milli_tokens_per_second(count: 22510) + total_throughput: milli_tokens_per_second(count: 69640) input_tokens: 1072 output_tokens: 512 } fn total_token_throughput_is_not_the_probe_rate(r: PrefillVersusDecodeThroughput) -> Bool { - r.total_milli_tok_per_s != r.output_milli_tok_per_s + milli_tokens_per_second_count(r: r.total_throughput) != milli_tokens_per_second_count(r: r.output_throughput) } data glm_native_wet_smoke_client_output: ClientOutputTokens = ClientOutputTokensObserved { tokens: 512 } @@ -1668,12 +1722,12 @@ fn glm_native_contended_sweep_protocol(concurrency: Nat) -> VllmBenchServeReques } fn glm_native_contended_client_latency( - throughput_milli_tok_per_s: Nat, + throughput: MilliTokensPerSecond, tpot_milli: Nat, ttft_milli: Nat, ) -> TranscribedClientLatency { TranscribedClientLatency { - output_throughput_milli_tok_per_s: throughput_milli_tok_per_s, + output_throughput: throughput, tpot_milli: millisecond(count: tpot_milli), itl_milli: none, ttft_milli: millisecond(count: ttft_milli), @@ -1689,7 +1743,7 @@ type ContendedSweepPoint { fn glm_native_contended_sweep_point( concurrency: Nat, - throughput_milli_tok_per_s: Nat, + throughput: MilliTokensPerSecond, tpot_milli: Nat, ttft_milli: Nat, ) -> ContendedSweepPoint { @@ -1697,7 +1751,7 @@ fn glm_native_contended_sweep_point( concurrency: concurrency, protocol: glm_native_contended_sweep_protocol(concurrency: concurrency), latency: glm_native_contended_client_latency( - throughput_milli_tok_per_s: throughput_milli_tok_per_s, + throughput: throughput, tpot_milli: tpot_milli, ttft_milli: ttft_milli, ), @@ -1705,19 +1759,19 @@ fn glm_native_contended_sweep_point( } data glm_native_contended_sweep_c1: ContendedSweepPoint = glm_native_contended_sweep_point( - concurrency: 1, throughput_milli_tok_per_s: 10860, tpot_milli: 81, ttft_milli: 1542, + concurrency: 1, throughput: milli_tokens_per_second(count: 10860), tpot_milli: 81, ttft_milli: 1542, ) data glm_native_contended_sweep_c2: ContendedSweepPoint = glm_native_contended_sweep_point( - concurrency: 2, throughput_milli_tok_per_s: 17220, tpot_milli: 109, ttft_milli: 994, + concurrency: 2, throughput: milli_tokens_per_second(count: 17220), tpot_milli: 109, ttft_milli: 994, ) data glm_native_contended_sweep_c4: ContendedSweepPoint = glm_native_contended_sweep_point( - concurrency: 4, throughput_milli_tok_per_s: 25490, tpot_milli: 140, ttft_milli: 2353, + concurrency: 4, throughput: milli_tokens_per_second(count: 25490), tpot_milli: 140, ttft_milli: 2353, ) data glm_native_contended_sweep_c8: ContendedSweepPoint = glm_native_contended_sweep_point( - concurrency: 8, throughput_milli_tok_per_s: 38360, tpot_milli: 190, ttft_milli: 2602, + concurrency: 8, throughput: milli_tokens_per_second(count: 38360), tpot_milli: 190, ttft_milli: 2602, ) data glm_native_contended_sweep_c16: ContendedSweepPoint = glm_native_contended_sweep_point( - concurrency: 16, throughput_milli_tok_per_s: 62530, tpot_milli: 198, ttft_milli: 5218, + concurrency: 16, throughput: milli_tokens_per_second(count: 62530), tpot_milli: 198, ttft_milli: 5218, ) data glm_native_contended_sweep_points: List = [ diff --git a/dag/std/measure.dag b/dag/std/measure.dag index 7465cad18da..60931232381 100644 --- a/dag/std/measure.dag +++ b/dag/std/measure.dag @@ -1303,6 +1303,33 @@ fn tokens_per_second_count(r: TokensPerSecond) -> Nat { measure_count(r) } +// The same token rate at Milli: a count of N is N/1000 tokens per second, so a client figure quoted +// to three decimals ("17.39 tok/s") is carried exactly as 17390 without a bare Nat whose scale lives +// only in its field name. Same Frequency axis as TokensPerSecond; the scale marker, not a suffix, +// says milli. First consumer: gunbc.spark.serving_load_probe client throughput. +type MilliTokensPerSecond = Measure + +fn milli_tokens_per_second(count: Nat) -> MilliTokensPerSecond { + Measure { count: count } +} + +fn milli_tokens_per_second_count(r: MilliTokensPerSecond) -> Nat { + measure_count(r) +} + +// An offered REQUEST arrival rate at Milli (vllm bench serve `--request-rate`). Frequency axis like +// its token sibling, a different thing counted: a request is not a token. First consumer: +// extdeps.vllm.bench_serve PoissonProcess. +type MilliRequestsPerSecond = Measure + +fn milli_requests_per_second(count: Nat) -> MilliRequestsPerSecond { + Measure { count: count } +} + +fn milli_requests_per_second_count(r: MilliRequestsPerSecond) -> Nat { + measure_count(r) +} + // EVAL STEPS PER MILLISECOND -- the conversion the required floor's claim ceiling is denominated // through. Frequency family, period marker in the type, exactly as `EventsPerMinute` and // `MegatransfersPerSecond` are. diff --git a/dag/test/claim/spark/serving_load_probe_witness_test.dag b/dag/test/claim/spark/serving_load_probe_witness_test.dag index df6f2e19d45..8e5e424502a 100644 --- a/dag/test/claim/spark/serving_load_probe_witness_test.dag +++ b/dag/test/claim/spark/serving_load_probe_witness_test.dag @@ -4,7 +4,7 @@ import std.types { Bool, String, NonEmptyStr, EpochSecs, List } import std.nat { Nat } import v2.std.algebra { length, filter } import v2.std.optional { Present, Absent } -import std.measure { token_count, millisecond, millisecond_count } +import std.measure { token_count, token_count_value, millisecond, millisecond_count, milli_tokens_per_second_count } import product.capacity.lease { LeaseGrant, lease_fence_of, lease_grant, LeasePolicy, FencedResource } import product.capacity.event_chain { EventId } import gunbc.fleet_intent_network { operator_host_srv9 } @@ -41,6 +41,9 @@ import gunbc.spark.serving_load_probe { foreign_work_bound, ForeignWorkBounded, ForeignWorkUnread, ForeignWorkContradiction, ClientRateUnqualified, occupancy_from_body, occupancy_trace_from_endpoint_scrapes, histogram_delta, HistogramDeltaRead, HistogramDeltaUnread, HistogramCounterReset, + itl_latency_delta, iteration_tokens_booked_delta, + LatencyHistogramRead, LatencyHistogramUnread, LatencyHistogramReset, + TokenHistogramRead, TokenHistogramUnread, TokenHistogramReset, CapacityClaimUnavailable, glm_native_holistic_protocol, holistic_protocol_is_session_shaped, glm_native_live_subject_standing, counter_continuity, SameExporter, ExporterChanged, ContinuityUnread, @@ -446,6 +449,51 @@ test fn an_itl_histogram_sum_with_sub_milli_digits_is_still_a_milli_reading() -> } } +test fn an_itl_histogram_sum_delta_of_half_a_second_is_500_milliseconds() -> Bool { + let before = metrics_body(running: "0.0", waiting: "0.0", capacity: "0.0", preempt: "0.0", itl_sum: "1.0", itl_count: "10.0", itok_sum: "100.0", itok_count: "10.0", gen: "1000.0", start: "1789300000.12") + let after = metrics_body(running: "0.0", waiting: "0.0", capacity: "0.0", preempt: "0.0", itl_sum: "1.5", itl_count: "15.0", itok_sum: "110.0", itok_count: "12.0", gen: "1000.0", start: "1789300000.12") + match itl_latency_delta(before_body: before, after_body: after) { + LatencyHistogramRead { sum: s, observations: n } => millisecond_count(m: s) == 500 && n == 5 + LatencyHistogramUnread { cause: _ } => false + LatencyHistogramReset { cause: _ } => false + } +} + +test fn an_iteration_tokens_sum_delta_is_booked_tokens_not_a_duration() -> Bool { + let before = metrics_body(running: "0.0", waiting: "0.0", capacity: "0.0", preempt: "0.0", itl_sum: "1.0", itl_count: "10.0", itok_sum: "100.0", itok_count: "10.0", gen: "1000.0", start: "1789300000.12") + let after = metrics_body(running: "0.0", waiting: "0.0", capacity: "0.0", preempt: "0.0", itl_sum: "1.5", itl_count: "15.0", itok_sum: "110.0", itok_count: "12.0", gen: "1000.0", start: "1789300000.12") + match iteration_tokens_booked_delta(before_body: before, after_body: after) { + TokenHistogramRead { booked: t, observations: n } => token_count_value(t: t) == 10 && n == 2 + TokenHistogramUnread { cause: _ } => false + TokenHistogramReset { cause: _ } => false + } +} + +test fn a_fractional_iteration_tokens_sum_delta_refuses_rather_than_rounding() -> Bool { + let before = metrics_body(running: "0.0", waiting: "0.0", capacity: "0.0", preempt: "0.0", itl_sum: "1.0", itl_count: "10.0", itok_sum: "100.0", itok_count: "10.0", gen: "1000.0", start: "1789300000.12") + let after = metrics_body(running: "0.0", waiting: "0.0", capacity: "0.0", preempt: "0.0", itl_sum: "1.5", itl_count: "15.0", itok_sum: "110.5", itok_count: "12.0", gen: "1000.0", start: "1789300000.12") + match iteration_tokens_booked_delta(before_body: before, after_body: after) { + TokenHistogramRead { booked: _, observations: _ } => false + TokenHistogramUnread { cause: _ } => true + TokenHistogramReset { cause: _ } => false + } +} + +test fn the_observation_keeps_itl_milliseconds_and_booked_tokens_distinct() -> Bool { + let obs = fx_obs() + match obs.itl_latency { + LatencyHistogramRead { sum: s, observations: n } => + millisecond_count(m: s) == 2000 && n == 100 + && match obs.iteration_tokens_booked { + TokenHistogramRead { booked: t, observations: k } => token_count_value(t: t) == 98999 && k == 10 + TokenHistogramUnread { cause: _ } => false + TokenHistogramReset { cause: _ } => false + } + LatencyHistogramUnread { cause: _ } => false + LatencyHistogramReset { cause: _ } => false + } +} + test fn a_sudo_password_prompt_line_does_not_spoil_the_bench_ledger() -> Bool { let body = join(["[sudo] password for briansrls:\n", fx_bench_stdout], "") match ledger_from_bench_stdout(body: body, offered: 4) { @@ -563,7 +611,7 @@ test fn the_contended_sweep_is_five_shared_window_client_points() -> Bool { && glm_native_sweep_num_prompts(concurrency: 1) == 8 && glm_native_sweep_num_prompts(concurrency: 2) == 8 && glm_native_sweep_num_prompts(concurrency: 4) == 16 - && glm_native_contended_sweep_c1.latency.output_throughput_milli_tok_per_s == 10860 + && milli_tokens_per_second_count(r: glm_native_contended_sweep_c1.latency.output_throughput) == 10860 && millisecond_count(m: glm_native_contended_sweep_c1.latency.tpot_milli) == 81 && millisecond_count(m: glm_native_contended_sweep_c1.latency.ttft_milli) == 1542 && glm_native_contended_sweep_c1.concurrency == 1 From db8c13c23c796beb424027b06105b6795c53782d Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sat, 19 Sep 2026 04:53:44 +0000 Subject: [PATCH 27/43] serving-load: subtract histogram sums exactly before projecting a unit histogram_delta now reads both cumulative sums as ExactDecimal and subtracts with a new std.decimal exact_decimal_sub, so a fraction or a decrease of any size reaches the check that must see it. Tokens then require an exact whole number (110.0005 refuses); latency floors the exact delta to milliseconds; a sub-millisecond decrease is a reset, not zero. Co-Authored-By: Claude Opus 5 (1M context) --- dag/gunbc/spark/serving_load_probe.dag | 56 ++++++++++++------ dag/std/decimal.dag | 9 +++ .../spark/serving_load_probe_witness_test.dag | 57 +++++++++++++++++-- 3 files changed, 100 insertions(+), 22 deletions(-) diff --git a/dag/gunbc/spark/serving_load_probe.dag b/dag/gunbc/spark/serving_load_probe.dag index 13628573a29..19e74cf6cf7 100644 --- a/dag/gunbc/spark/serving_load_probe.dag +++ b/dag/gunbc/spark/serving_load_probe.dag @@ -9,7 +9,7 @@ import std.measure { MilliTokensPerSecond, milli_tokens_per_second, milli_tokens_per_second_count, MilliRequestsPerSecond, milli_requests_per_second, } -import std.decimal { ExactDecimal, canonical_exact_decimal, decimal_pow10 } +import std.decimal { ExactDecimal, canonical_exact_decimal, decimal_pow10, exact_decimal_sub } import std.checked_arithmetic { checked_int_magnitude, CheckedNatReady, CheckedNatOverflow } import v2.std.optional { Present, Absent } import std.content_hash { ContentHash, content_hash_of_value, serialize_content_hash } @@ -259,12 +259,14 @@ fn counter_continuity(before: VllmEndpointProcessLaunchObservation, after: VllmE } // THE RAW DELTA IS DIMENSION-AGNOSTIC ON PURPOSE. `histogram_delta` is the one shared parse and -// subtract for any vLLM histogram: `sum_milli` is thousandths of WHATEVER UNIT THAT METRIC'S SUM IS -// IN, and `count` is how many observations the histogram recorded. It is not a receipt field: the +// subtract for any vLLM histogram. `sum` is the EXACT decimal difference of the two cumulative sums, +// so a decrease or a fraction of any size survives to the check that must see it; each projection +// then applies its own unit (latency floors seconds to whole milliseconds, tokens require an exact +// whole number and refuse any fraction). `count` is how many observations the histogram recorded. It is not a receipt field: the // observation stores only the typed projections below, so a seconds sum and a booked-token sum can // never be read through one carrier. type HistogramDelta - = HistogramDeltaRead { sum_milli: Nat, count: Nat } + = HistogramDeltaRead { sum: ExactDecimal, count: Nat } | HistogramDeltaUnread { cause: NonEmptyStr } | HistogramCounterReset { cause: NonEmptyStr } @@ -300,10 +302,20 @@ fn field_to_milli(field: String) -> Nat? { } } +// A sample read as its exact decimal; a non-finite or unreadable lexeme is absent, never rounded. +fn field_to_exact(field: String) -> ExactDecimal? { + match prometheus_sample_value_reading(field: field) { + SampleValueNotFinite { lexeme: _ } => none + SampleValueUnreadable { lexeme: _ } => none + SampleValueExact { value: d } => Present { value: d } + } +} + fn nat_delta(after: Nat, before: Nat) -> Nat? { if after < before { none } else { Present { value: after - before } } } +// The sum is read through the projection's own reader, so its unit is the caller's, never guessed here. fn histogram_delta(before_body: String, after_body: String, metric: VllmServingMetric) -> HistogramDelta { if !vllm_metric_exports_histogram_statistics(m: metric) { HistogramDeltaUnread { cause: "this metric does not export histogram sum/count" as NonEmptyStr } @@ -320,11 +332,11 @@ fn histogram_delta(before_body: String, after_body: String, metric: VllmServingM match harness_histogram_statistic_value(body: after_body, metric: metric, statistic: HistogramCount) { Absent => HistogramDeltaUnread { cause: "histogram count missing on the second body" as NonEmptyStr } Present { value: ac } => - match field_to_milli(field: bs) { - Absent => HistogramDeltaUnread { cause: "histogram sum before was not exact to three decimals" as NonEmptyStr } + match field_to_exact(field: bs) { + Absent => HistogramDeltaUnread { cause: "histogram sum before was not an exact decimal" as NonEmptyStr } Present { value: bsm } => - match field_to_milli(field: asv) { - Absent => HistogramDeltaUnread { cause: "histogram sum after was not exact to three decimals" as NonEmptyStr } + match field_to_exact(field: asv) { + Absent => HistogramDeltaUnread { cause: "histogram sum after was not an exact decimal" as NonEmptyStr } Present { value: asm } => match harness_gauge_count(text: bc) { Absent => HistogramDeltaUnread { cause: "histogram count before was not an exact count" as NonEmptyStr } @@ -332,12 +344,13 @@ fn histogram_delta(before_body: String, after_body: String, metric: VllmServingM match harness_gauge_count(text: ac) { Absent => HistogramDeltaUnread { cause: "histogram count after was not an exact count" as NonEmptyStr } Present { value: acn } => - match nat_delta(after: asm, before: bsm) { - Absent => HistogramCounterReset { cause: "histogram sum decreased across the window" as NonEmptyStr } - Present { value: ds } => + let ds = exact_decimal_sub(a: asm, b: bsm) + if ds.units < 0 { + HistogramCounterReset { cause: "histogram sum decreased across the window" as NonEmptyStr } + } else { match nat_delta(after: acn, before: bcn) { Absent => HistogramCounterReset { cause: "histogram count decreased across the window" as NonEmptyStr } - Present { value: dc } => HistogramDeltaRead { sum_milli: ds, count: dc } + Present { value: dc } => HistogramDeltaRead { sum: ds, count: dc } } } } @@ -366,7 +379,11 @@ type TokenHistogramDelta fn itl_latency_delta(before_body: String, after_body: String) -> LatencyHistogramDelta { match histogram_delta(before_body: before_body, after_body: after_body, metric: InterTokenLatencySeconds) { - HistogramDeltaRead { sum_milli: s, count: c } => LatencyHistogramRead { sum: millisecond(count: s), observations: c } + HistogramDeltaRead { sum: s, count: c } => + match milli_from_exact(d: s) { + Absent => LatencyHistogramUnread { cause: "inter-token latency sum delta did not project to milliseconds" as NonEmptyStr } + Present { value: ms } => LatencyHistogramRead { sum: millisecond(count: ms), observations: c } + } HistogramDeltaUnread { cause: x } => LatencyHistogramUnread { cause: x } HistogramCounterReset { cause: x } => LatencyHistogramReset { cause: x } } @@ -374,12 +391,17 @@ fn itl_latency_delta(before_body: String, after_body: String) -> LatencyHistogra fn iteration_tokens_booked_delta(before_body: String, after_body: String) -> TokenHistogramDelta { match histogram_delta(before_body: before_body, after_body: after_body, metric: IterationTokensTotal) { - HistogramDeltaRead { sum_milli: s, count: c } => - if s % 1000 == 0 { - TokenHistogramRead { booked: token_count(count: s / 1000), observations: c } - } else { + HistogramDeltaRead { sum: s, count: c } => { + let d = canonical_exact_decimal(d: s) + if d.fraction_digits != 0 { TokenHistogramUnread { cause: "iteration_tokens_total sum delta was not a whole token count" as NonEmptyStr } + } else { + match nat_from_nonneg_int(n: d.units) { + Absent => TokenHistogramUnread { cause: "iteration_tokens_total sum delta was negative" as NonEmptyStr } + Present { value: t } => TokenHistogramRead { booked: token_count(count: t), observations: c } + } } + } HistogramDeltaUnread { cause: x } => TokenHistogramUnread { cause: x } HistogramCounterReset { cause: x } => TokenHistogramReset { cause: x } } diff --git a/dag/std/decimal.dag b/dag/std/decimal.dag index e484a2830e6..c6eb2f556d4 100644 --- a/dag/std/decimal.dag +++ b/dag/std/decimal.dag @@ -127,6 +127,15 @@ fn exact_decimal_equal(a: ExactDecimal, b: ExactDecimal) -> Bool { ca.units == cb.units && ca.fraction_digits == cb.fraction_digits } +// EXACT DIFFERENCE: both operands are aligned to the larger scale before subtracting, so no digit is +// dropped and a decrease smaller than either operand's last shared digit still comes out negative. +fn exact_decimal_sub(a: ExactDecimal, b: ExactDecimal) -> ExactDecimal { + let digits = if a.fraction_digits > b.fraction_digits { a.fraction_digits } else { b.fraction_digits } + let au = a.units * decimal_pow10(exponent: digits - a.fraction_digits) + let bu = b.units * decimal_pow10(exponent: digits - b.fraction_digits) + canonical_exact_decimal(d: ExactDecimal { units: au - bu, fraction_digits: digits }) +} + // THE PROJECTION BACK TO A NUMERAL, WHICH IS NOT THE LEXEME IT WAS READ FROM AND DOES NOT CLAIM TO // BE. It renders the canonical form, so `30.0` reads in and `30` renders out. That is a round-trip // of the VALUE, never of the bytes; a consumer needing the authored bytes keeps the lexeme. diff --git a/dag/test/claim/spark/serving_load_probe_witness_test.dag b/dag/test/claim/spark/serving_load_probe_witness_test.dag index 8e5e424502a..64081e0d4b2 100644 --- a/dag/test/claim/spark/serving_load_probe_witness_test.dag +++ b/dag/test/claim/spark/serving_load_probe_witness_test.dag @@ -40,7 +40,7 @@ import gunbc.spark.serving_load_probe { saturation_from_one_run, observation_rate_is_stored_separately, foreign_work_bound, ForeignWorkBounded, ForeignWorkUnread, ForeignWorkContradiction, ClientRateUnqualified, - occupancy_from_body, occupancy_trace_from_endpoint_scrapes, histogram_delta, HistogramDeltaRead, HistogramDeltaUnread, HistogramCounterReset, + occupancy_from_body, occupancy_trace_from_endpoint_scrapes, itl_latency_delta, iteration_tokens_booked_delta, LatencyHistogramRead, LatencyHistogramUnread, LatencyHistogramReset, TokenHistogramRead, TokenHistogramUnread, TokenHistogramReset, @@ -442,10 +442,10 @@ test fn occupancy_reads_prompt_tokens_that_are_not_an_integer_lexeme() -> Bool { test fn an_itl_histogram_sum_with_sub_milli_digits_is_still_a_milli_reading() -> Bool { let before = metrics_body(running: "0.0", waiting: "0.0", capacity: "0.0", preempt: "0.0", itl_sum: "10.1234567", itl_count: "100.0", itok_sum: "1000.0", itok_count: "10.0", gen: "1000.0", start: "1789300000.12") let after = metrics_body(running: "0.0", waiting: "0.0", capacity: "0.0", preempt: "0.0", itl_sum: "12.1234567", itl_count: "200.0", itok_sum: "1000.0", itok_count: "10.0", gen: "1000.0", start: "1789300000.12") - match histogram_delta(before_body: before, after_body: after, metric: InterTokenLatencySeconds) { - HistogramDeltaRead { sum_milli: ds, count: dc } => ds == 2000 && dc == 100 - HistogramDeltaUnread { cause: _ } => false - HistogramCounterReset { cause: _ } => false + match itl_latency_delta(before_body: before, after_body: after) { + LatencyHistogramRead { sum: ds, observations: dc } => millisecond_count(m: ds) == 2000 && dc == 100 + LatencyHistogramUnread { cause: _ } => false + LatencyHistogramReset { cause: _ } => false } } @@ -479,6 +479,16 @@ test fn a_fractional_iteration_tokens_sum_delta_refuses_rather_than_rounding() - } } +test fn a_sub_milli_token_fraction_refuses_rather_than_truncating() -> Bool { + let before = metrics_body(running: "0.0", waiting: "0.0", capacity: "0.0", preempt: "0.0", itl_sum: "1.0", itl_count: "10.0", itok_sum: "100.0", itok_count: "10.0", gen: "1000.0", start: "1789300000.12") + let after = metrics_body(running: "0.0", waiting: "0.0", capacity: "0.0", preempt: "0.0", itl_sum: "1.5", itl_count: "15.0", itok_sum: "110.0005", itok_count: "12.0", gen: "1000.0", start: "1789300000.12") + match iteration_tokens_booked_delta(before_body: before, after_body: after) { + TokenHistogramRead { booked: _, observations: _ } => false + TokenHistogramUnread { cause: _ } => true + TokenHistogramReset { cause: _ } => false + } +} + test fn the_observation_keeps_itl_milliseconds_and_booked_tokens_distinct() -> Bool { let obs = fx_obs() match obs.itl_latency { @@ -760,3 +770,40 @@ test fn the_receipt_persists_raw_evidence_for_replay() -> Bool { test fn qualification_frontier_names_the_producers() -> Bool { qualification_frontier_requires_serve_py_digest(f: glm_native_qualification_frontier) } + +test fn a_latency_sum_decrease_within_one_millisecond_is_a_reset_not_zero() -> Bool { + let before = metrics_body(running: "0.0", waiting: "0.0", capacity: "0.0", preempt: "0.0", itl_sum: "100.0009", itl_count: "10.0", itok_sum: "100.0", itok_count: "10.0", gen: "1000.0", start: "1789300000.12") + let after = metrics_body(running: "0.0", waiting: "0.0", capacity: "0.0", preempt: "0.0", itl_sum: "100.0001", itl_count: "10.0", itok_sum: "100.0", itok_count: "10.0", gen: "1000.0", start: "1789300000.12") + match itl_latency_delta(before_body: before, after_body: after) { + LatencyHistogramReset { cause: _ } => true + LatencyHistogramRead { sum: _, observations: _ } => false + LatencyHistogramUnread { cause: _ } => false + } +} + +fn fx_obs_between(before: String, after: String) -> ServingLoadObservation { + serving_load_observation( + subject: glm_native_live_subject_standing(), + window: window_from_drain(drain: DrainObservedIdle), + continuity: counter_continuity(before: fx_launch(), after: fx_launch()), + occupancy: occupancy_trace_from_endpoint_scrapes(before_body: before, after_body: after), + before_body: before, + after_body: after, + before_incarnation: fx_same_incarnation(), + after_incarnation: fx_same_incarnation(), + bench: fx_bench_receipt(stdout: fx_bench_stdout), + ) +} + +test fn a_fractional_token_delta_reaches_the_receipt_as_unread_not_booked() -> Bool { + let before = metrics_body(running: "0.0", waiting: "0.0", capacity: "0.0", preempt: "0.0", itl_sum: "1.0", itl_count: "10.0", itok_sum: "100.0", itok_count: "10.0", gen: "1000.0", start: "1789300000.12") + let after = metrics_body(running: "0.0", waiting: "0.0", capacity: "0.0", preempt: "0.0", itl_sum: "1.5", itl_count: "15.0", itok_sum: "110.0005", itok_count: "12.0", gen: "1000.0", start: "1789300000.12") + let obs = fx_obs_between(before: before, after: after) + let text = serving_load_observation_text(o: obs) + match obs.iteration_tokens_booked { + TokenHistogramUnread { cause: _ } => + string_contains(s: text, pattern: "iteration_tokens booked (not occupancy): unread") && !string_contains(s: text, pattern: "booked_tokens=10 ") + TokenHistogramRead { booked: _, observations: _ } => false + TokenHistogramReset { cause: _ } => false + } +} From 63c8333f5d304d542ed713c62cd24bc280e3497b Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sat, 19 Sep 2026 05:23:01 +0000 Subject: [PATCH 28/43] serving-load: refuse negative cumulative sums; exact_decimal_sub is checked against i64 A negative before/after histogram sum is Unread before subtraction (a cumulative sum's domain), not a positive delta. std.decimal exact_decimal_sub now returns ExactDecimalDifference: scale alignment and subtraction go through std.checked_arithmetic, so an unrepresentable difference is ExactDifferenceUnrepresentable with its overflow, never a wrapped value. Addresses hold 5254701996. Co-Authored-By: Claude Opus 5 (1M context) --- dag/gunbc/spark/serving_load_probe.dag | 13 +++++- dag/std/decimal.dag | 42 +++++++++++++++++-- .../spark/serving_load_probe_witness_test.dag | 25 +++++++++++ 3 files changed, 74 insertions(+), 6 deletions(-) diff --git a/dag/gunbc/spark/serving_load_probe.dag b/dag/gunbc/spark/serving_load_probe.dag index 19e74cf6cf7..f0b99879d14 100644 --- a/dag/gunbc/spark/serving_load_probe.dag +++ b/dag/gunbc/spark/serving_load_probe.dag @@ -9,7 +9,7 @@ import std.measure { MilliTokensPerSecond, milli_tokens_per_second, milli_tokens_per_second_count, MilliRequestsPerSecond, milli_requests_per_second, } -import std.decimal { ExactDecimal, canonical_exact_decimal, decimal_pow10, exact_decimal_sub } +import std.decimal { ExactDecimal, canonical_exact_decimal, decimal_pow10, exact_decimal_sub, ExactDifference, ExactDifferenceUnrepresentable } import std.checked_arithmetic { checked_int_magnitude, CheckedNatReady, CheckedNatOverflow } import v2.std.optional { Present, Absent } import std.content_hash { ContentHash, content_hash_of_value, serialize_content_hash } @@ -344,7 +344,14 @@ fn histogram_delta(before_body: String, after_body: String, metric: VllmServingM match harness_gauge_count(text: ac) { Absent => HistogramDeltaUnread { cause: "histogram count after was not an exact count" as NonEmptyStr } Present { value: acn } => - let ds = exact_decimal_sub(a: asm, b: bsm) + if bsm.units < 0 { + HistogramDeltaUnread { cause: "histogram sum before was negative, outside a cumulative sum's domain" as NonEmptyStr } + } else if asm.units < 0 { + HistogramDeltaUnread { cause: "histogram sum after was negative, outside a cumulative sum's domain" as NonEmptyStr } + } else { + match exact_decimal_sub(a: asm, b: bsm) { + ExactDifferenceUnrepresentable { cause: _ } => HistogramDeltaUnread { cause: "histogram sum delta does not fit a 64-bit exact decimal" as NonEmptyStr } + ExactDifference { value: ds } => if ds.units < 0 { HistogramCounterReset { cause: "histogram sum decreased across the window" as NonEmptyStr } } else { @@ -353,6 +360,8 @@ fn histogram_delta(before_body: String, after_body: String, metric: VllmServingM Present { value: dc } => HistogramDeltaRead { sum: ds, count: dc } } } + } + } } } } diff --git a/dag/std/decimal.dag b/dag/std/decimal.dag index c6eb2f556d4..d992f307012 100644 --- a/dag/std/decimal.dag +++ b/dag/std/decimal.dag @@ -3,6 +3,7 @@ module std.decimal import std.types { String, Int, Bool } import std.render_repeat_string_bootstrap { repeat_string } import std.bytes { pure_dag_seam_unreachable } +import std.checked_arithmetic { CheckedInt, CheckedIntReady, CheckedIntOverflow, IntegerOverflow, checked_int_multiply, checked_int_subtract } data decimal_note: String = "Positional decimal notation for a FIXED-POINT magnitude: an integer paired with the power of ten it is scaled by. It exists because two unrelated boundaries needed the identical projection and neither is the right owner of it — WebAudio's gain and time arguments are decimal seconds and a linear amplitude in [0, 1], and CSS transform scale factors are decimal ratios. Each carried its magnitude integrally upstream (a fractional literal in a .dag row would be a second representation of the same number), so each needed to divide exactly once, at its own wire. Giving each boundary its own formatter would have put the same numeral logic in two places for no reason other than that the two consumers are far apart in the layer graph, which is the horizontal redundancy DESIGN section 2 names — the concept is one, so it is modeled once and both uses derive. @@ -129,11 +130,44 @@ fn exact_decimal_equal(a: ExactDecimal, b: ExactDecimal) -> Bool { // EXACT DIFFERENCE: both operands are aligned to the larger scale before subtracting, so no digit is // dropped and a decrease smaller than either operand's last shared digit still comes out negative. -fn exact_decimal_sub(a: ExactDecimal, b: ExactDecimal) -> ExactDecimal { +// Int is i64 in every realization, so alignment and subtraction are CHECKED: a difference that does +// not fit is ExactDifferenceUnrepresentable with the overflow that refused it, never a wrapped value. +type ExactDecimalDifference + = ExactDifference { value: ExactDecimal } + | ExactDifferenceUnrepresentable { cause: IntegerOverflow } + +fn checked_decimal_pow10(exponent: Int) -> CheckedInt { + if exponent <= 0 { + CheckedIntReady { value: 1 } + } else { + match checked_decimal_pow10(exponent: exponent - 1) { + CheckedIntReady { value: p } => checked_int_multiply(a: p, b: 10) + CheckedIntOverflow { cause: c } => CheckedIntOverflow { cause: c } + } + } +} + +fn checked_decimal_rescale(units: Int, by: Int) -> CheckedInt { + match checked_decimal_pow10(exponent: by) { + CheckedIntReady { value: p } => checked_int_multiply(a: units, b: p) + CheckedIntOverflow { cause: c } => CheckedIntOverflow { cause: c } + } +} + +fn exact_decimal_sub(a: ExactDecimal, b: ExactDecimal) -> ExactDecimalDifference { let digits = if a.fraction_digits > b.fraction_digits { a.fraction_digits } else { b.fraction_digits } - let au = a.units * decimal_pow10(exponent: digits - a.fraction_digits) - let bu = b.units * decimal_pow10(exponent: digits - b.fraction_digits) - canonical_exact_decimal(d: ExactDecimal { units: au - bu, fraction_digits: digits }) + match checked_decimal_rescale(units: a.units, by: digits - a.fraction_digits) { + CheckedIntOverflow { cause: c } => ExactDifferenceUnrepresentable { cause: c } + CheckedIntReady { value: au } => + match checked_decimal_rescale(units: b.units, by: digits - b.fraction_digits) { + CheckedIntOverflow { cause: c } => ExactDifferenceUnrepresentable { cause: c } + CheckedIntReady { value: bu } => + match checked_int_subtract(a: au, b: bu) { + CheckedIntOverflow { cause: c } => ExactDifferenceUnrepresentable { cause: c } + CheckedIntReady { value: d } => ExactDifference { value: canonical_exact_decimal(d: ExactDecimal { units: d, fraction_digits: digits }) } + } + } + } } // THE PROJECTION BACK TO A NUMERAL, WHICH IS NOT THE LEXEME IT WAS READ FROM AND DOES NOT CLAIM TO diff --git a/dag/test/claim/spark/serving_load_probe_witness_test.dag b/dag/test/claim/spark/serving_load_probe_witness_test.dag index 64081e0d4b2..4a1038e9bc0 100644 --- a/dag/test/claim/spark/serving_load_probe_witness_test.dag +++ b/dag/test/claim/spark/serving_load_probe_witness_test.dag @@ -807,3 +807,28 @@ test fn a_fractional_token_delta_reaches_the_receipt_as_unread_not_booked() -> B TokenHistogramReset { cause: _ } => false } } + +test fn a_negative_cumulative_sum_is_unread_not_a_positive_delta() -> Bool { + let before = metrics_body(running: "0.0", waiting: "0.0", capacity: "0.0", preempt: "0.0", itl_sum: "-1.0", itl_count: "10.0", itok_sum: "-1.0", itok_count: "10.0", gen: "1000.0", start: "1789300000.12") + let after = metrics_body(running: "0.0", waiting: "0.0", capacity: "0.0", preempt: "0.0", itl_sum: "0.0", itl_count: "11.0", itok_sum: "0.0", itok_count: "11.0", gen: "1000.0", start: "1789300000.12") + match iteration_tokens_booked_delta(before_body: before, after_body: after) { + TokenHistogramUnread { cause: _ } => + match itl_latency_delta(before_body: before, after_body: after) { + LatencyHistogramUnread { cause: _ } => true + LatencyHistogramRead { sum: _, observations: _ } => false + LatencyHistogramReset { cause: _ } => false + } + TokenHistogramRead { booked: _, observations: _ } => false + TokenHistogramReset { cause: _ } => false + } +} + +test fn an_alignment_that_overflows_i64_is_unread_not_wrapped() -> Bool { + let before = metrics_body(running: "0.0", waiting: "0.0", capacity: "0.0", preempt: "0.0", itl_sum: "10", itl_count: "10.0", itok_sum: "10", itok_count: "10.0", gen: "1000.0", start: "1789300000.12") + let after = metrics_body(running: "0.0", waiting: "0.0", capacity: "0.0", preempt: "0.0", itl_sum: "10.0000000000000000001", itl_count: "11.0", itok_sum: "10.0000000000000000001", itok_count: "11.0", gen: "1000.0", start: "1789300000.12") + match iteration_tokens_booked_delta(before_body: before, after_body: after) { + TokenHistogramUnread { cause: _ } => true + TokenHistogramRead { booked: _, observations: _ } => false + TokenHistogramReset { cause: _ } => false + } +} From 0515d2b63caa9d29b101ea921b3f0f04d16ea73a Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sat, 19 Sep 2026 06:10:09 +0000 Subject: [PATCH 29/43] serving-load: delete constant-valued predicates; print the parsed ITL and bucket peak; validate decimal operand scale Review 68222: itl_tail_cause_is_unestablished, client_second_bucket_peak_establishes_foreign_work, cap_2_bucket_peak_4_is_not_foreign_work and elasticity_is_off_the_uncontrolled_series (with its one-arm type) could not go red; they, their witnesses and the two fixed receipt lines are removed. The receipt now prints the parsed ITL distribution and successful-request bucket peak instead. Hold 5254814788: exact_decimal_sub refuses a negative operand scale before alignment (ExactDifferenceOperandScaleRefused); the overflow witness now uses 1e-18 -> 10, both of which parse, and asserts ExactDifferenceUnrepresentable. Co-Authored-By: Claude Opus 5 (1M context) --- dag/gunbc/spark/serving_load_probe.dag | 64 ++++++----------- dag/gunbc/spark/serving_load_probe_cli.dag | 9 +-- dag/std/decimal.dag | 14 ++++ .../spark/serving_load_probe_witness_test.dag | 71 +++++++++++++------ 4 files changed, 89 insertions(+), 69 deletions(-) diff --git a/dag/gunbc/spark/serving_load_probe.dag b/dag/gunbc/spark/serving_load_probe.dag index f0b99879d14..6fd4ca49c1d 100644 --- a/dag/gunbc/spark/serving_load_probe.dag +++ b/dag/gunbc/spark/serving_load_probe.dag @@ -9,7 +9,7 @@ import std.measure { MilliTokensPerSecond, milli_tokens_per_second, milli_tokens_per_second_count, MilliRequestsPerSecond, milli_requests_per_second, } -import std.decimal { ExactDecimal, canonical_exact_decimal, decimal_pow10, exact_decimal_sub, ExactDifference, ExactDifferenceUnrepresentable } +import std.decimal { ExactDecimal, canonical_exact_decimal, decimal_pow10, exact_decimal_sub, ExactDifference, ExactDifferenceUnrepresentable, ExactDifferenceOperandScaleRefused } import std.checked_arithmetic { checked_int_magnitude, CheckedNatReady, CheckedNatOverflow } import v2.std.optional { Present, Absent } import std.content_hash { ContentHash, content_hash_of_value, serialize_content_hash } @@ -351,6 +351,7 @@ fn histogram_delta(before_body: String, after_body: String, metric: VllmServingM } else { match exact_decimal_sub(a: asm, b: bsm) { ExactDifferenceUnrepresentable { cause: _ } => HistogramDeltaUnread { cause: "histogram sum delta does not fit a 64-bit exact decimal" as NonEmptyStr } + ExactDifferenceOperandScaleRefused { observed_fraction_digits: _ } => HistogramDeltaUnread { cause: "histogram sum carried a negative decimal scale" as NonEmptyStr } ExactDifference { value: ds } => if ds.units < 0 { HistogramCounterReset { cause: "histogram sum decreased across the window" as NonEmptyStr } @@ -950,6 +951,27 @@ fn bench_serve_latency(e: BenchServeExecution, window: ProbeWindowStanding) -> C } } +fn client_itl_text(d: ClientItlDistribution) -> String { + match d { + ClientItlDistributionUnread { cause: c } => join(["unread ", c as String], "") + ClientItlDistributionObserved { mean_milli: m, median_milli: md, p99_milli: p, cause: ItlTailCauseUnestablished { because: b } } => + join([ + "mean_ms=", to_string(millisecond_count(m: m)), + " median_ms=", to_string(millisecond_count(m: md)), + " p99_ms=", to_string(millisecond_count(m: p)), + " tail_cause=unestablished (", b as String, ")", + ], "") + } +} + +fn client_bucket_peak_text(p: ClientRequestConcurrencyStanding) -> String { + match p { + ClientConcurrencyUnread { cause: c } => join(["unread ", c as String], "") + SuccessfulClientRequestSecondBucketPeak { client_max_concurrency: c, bucket_peak: b } => + join(["client_max_concurrency=", to_string(c), " successful_request_second_bucket_peak=", to_string(b), " (a per-second completion bucket, not concurrent occupancy)"], "") + } +} + fn bench_serve_itl(e: BenchServeExecution) -> ClientItlDistribution { match bench_summary_stdout(e: e) { Absent => ClientItlDistributionUnread { cause: bench_summary_unread_cause(e: e) } @@ -1552,30 +1574,6 @@ data glm_native_wet_smoke_client_latency: TranscribedClientLatency = Transcribed standing: glm_native_wet_smoke_standing } -fn itl_tail_cause_is_unestablished(d: ClientItlDistribution) -> Bool { - match d { - ClientItlDistributionUnread { cause: _ } => true - ClientItlDistributionObserved { mean_milli: _, median_milli: _, p99_milli: _, cause: ItlTailCauseUnestablished { because: _ } } => true - } -} - -fn client_second_bucket_peak_establishes_foreign_work(p: ClientRequestConcurrencyStanding) -> Bool { - match p { - ClientConcurrencyUnread { cause: _ } => false - SuccessfulClientRequestSecondBucketPeak { client_max_concurrency: _, bucket_peak: _ } => false - } -} - -fn cap_2_bucket_peak_4_is_not_foreign_work(p: ClientRequestConcurrencyStanding) -> Bool { - match p { - ClientConcurrencyUnread { cause: _ } => false - SuccessfulClientRequestSecondBucketPeak { client_max_concurrency: c, bucket_peak: b } => - c == 2 - && b == 4 - && !client_second_bucket_peak_establishes_foreign_work(p: p) - } -} - fn bench_labeled_nat(body: String, label: String) -> Nat? { text_labeled_count(body: text_without_sudo_prompt(body: body), label: label) } @@ -1813,22 +1811,6 @@ data glm_native_contended_sweep_points: List = [ glm_native_contended_sweep_c16, ] -// ABSOLUTE tok/s ARE NOT A CAPACITY without an exclusive window. Elasticity -// log(throughput ratio)/log(concurrency ratio) is a SHAPE that requires a controlled series. -// The five contended points are shared-window client latency; they are not that series. -type UncontrolledSeriesElasticity - = ElasticityNotOnUncontrolledSeries { because: NonEmptyStr } - -data glm_native_contended_sweep_elasticity: UncontrolledSeriesElasticity = ElasticityNotOnUncontrolledSeries { - because: "glm_native_contended_sweep_points were taken without an exclusive window; log(throughput ratio)/log(concurrency ratio) on that series is not a scaling elasticity" as NonEmptyStr -} - -fn elasticity_is_off_the_uncontrolled_series(s: UncontrolledSeriesElasticity) -> Bool { - match s { - ElasticityNotOnUncontrolledSeries { because: _ } => true - } -} - fn glm_native_sweep_ttft_c8() -> Nat { millisecond_count(m: glm_native_contended_sweep_c8.latency.ttft_milli) } diff --git a/dag/gunbc/spark/serving_load_probe_cli.dag b/dag/gunbc/spark/serving_load_probe_cli.dag index 4e089bcedbd..2b627bda707 100644 --- a/dag/gunbc/spark/serving_load_probe_cli.dag +++ b/dag/gunbc/spark/serving_load_probe_cli.dag @@ -29,8 +29,7 @@ import gunbc.spark.serving_load_probe { serving_load_observation, serving_load_observation_text, drain_from_queue, window_from_drain, counter_continuity, occupancy_trace_from_endpoint_scrapes, - bench_serve_from_remote, bench_serve_bucket_peak, bench_serve_itl, - client_second_bucket_peak_establishes_foreign_work, itl_tail_cause_is_unestablished, + bench_serve_from_remote, bench_serve_bucket_peak, bench_serve_itl, client_itl_text, client_bucket_peak_text, WindowIsolated, WindowIsolationNotEstablished, ForeignTrafficObserved, ForeignTrafficNotObserved, ForeignTrafficUnread, DrainObservedIdle, DrainNotIdle, DrainUnread, @@ -145,8 +144,6 @@ fn glm_native_serving_load_run() -> ProcessExit let before_launch = harness_launch_from_body(group: FabricGroupB, address: srv9_host_lan_endpoint.address, body: before) let after_launch = harness_launch_from_body(group: FabricGroupB, address: srv9_host_lan_endpoint.address, body: after) let occ = occupancy_trace_from_endpoint_scrapes(before_body: before, after_body: after) - let bucket = bench_serve_bucket_peak(e: bench) - let itl = bench_serve_itl(e: bench) let obs = serving_load_observation( subject: glm_native_live_subject_standing(), window: window, @@ -161,8 +158,8 @@ fn glm_native_serving_load_run() -> ProcessExit let body = join([ "glm native serving-load wet at ", probed_at_word(reading: clock_now_probed_at()) as String, "\n", serving_load_observation_text(o: obs), - "bucket_peak_establishes_foreign_work=", if client_second_bucket_peak_establishes_foreign_work(p: bucket) { "yes" } else { "no" }, "\n", - "itl_tail_cause_unestablished=", if itl_tail_cause_is_unestablished(d: itl) { "yes" } else { "no" }, "\n", + "client itl (bench stdout): ", client_itl_text(d: bench_serve_itl(e: bench)), "\n", + "client bucket peak (bench stdout): ", client_bucket_peak_text(p: bench_serve_bucket_peak(e: bench)), "\n", ], "") let w = Filesystem.Write(path: glm_native_serving_load_receipt_path, content: body) if !w.success { diff --git a/dag/std/decimal.dag b/dag/std/decimal.dag index d992f307012..62f6a08675a 100644 --- a/dag/std/decimal.dag +++ b/dag/std/decimal.dag @@ -132,9 +132,12 @@ fn exact_decimal_equal(a: ExactDecimal, b: ExactDecimal) -> Bool { // dropped and a decrease smaller than either operand's last shared digit still comes out negative. // Int is i64 in every realization, so alignment and subtraction are CHECKED: a difference that does // not fit is ExactDifferenceUnrepresentable with the overflow that refused it, never a wrapped value. +// An operand whose scale is negative (a computed value the refinement cannot stop) is refused BEFORE +// any alignment: checking arithmetic overflow does not validate the decimal's domain. type ExactDecimalDifference = ExactDifference { value: ExactDecimal } | ExactDifferenceUnrepresentable { cause: IntegerOverflow } + | ExactDifferenceOperandScaleRefused { observed_fraction_digits: Int } fn checked_decimal_pow10(exponent: Int) -> CheckedInt { if exponent <= 0 { @@ -155,6 +158,17 @@ fn checked_decimal_rescale(units: Int, by: Int) -> CheckedInt { } fn exact_decimal_sub(a: ExactDecimal, b: ExactDecimal) -> ExactDecimalDifference { + if a.fraction_digits < 0 { + ExactDifferenceOperandScaleRefused { observed_fraction_digits: a.fraction_digits } + } else if b.fraction_digits < 0 { + ExactDifferenceOperandScaleRefused { observed_fraction_digits: b.fraction_digits } + } else { + exact_decimal_sub_admitted(a: canonical_exact_decimal(d: a), b: canonical_exact_decimal(d: b)) + } +} + +// Both operands have a nonnegative, canonical scale here; only the i64 bound remains to check. +fn exact_decimal_sub_admitted(a: ExactDecimal, b: ExactDecimal) -> ExactDecimalDifference { let digits = if a.fraction_digits > b.fraction_digits { a.fraction_digits } else { b.fraction_digits } match checked_decimal_rescale(units: a.units, by: digits - a.fraction_digits) { CheckedIntOverflow { cause: c } => ExactDifferenceUnrepresentable { cause: c } diff --git a/dag/test/claim/spark/serving_load_probe_witness_test.dag b/dag/test/claim/spark/serving_load_probe_witness_test.dag index 4a1038e9bc0..0234e7d5140 100644 --- a/dag/test/claim/spark/serving_load_probe_witness_test.dag +++ b/dag/test/claim/spark/serving_load_probe_witness_test.dag @@ -4,6 +4,8 @@ import std.types { Bool, String, NonEmptyStr, EpochSecs, List } import std.nat { Nat } import v2.std.algebra { length, filter } import v2.std.optional { Present, Absent } +import std.decimal { ExactDecimal, exact_decimal_sub, ExactDifference, ExactDifferenceUnrepresentable, ExactDifferenceOperandScaleRefused } +import extdeps.prometheus.client { prometheus_sample_value_reading, SampleValueExact, SampleValueNotFinite, SampleValueUnreadable } import std.measure { token_count, token_count_value, millisecond, millisecond_count, milli_tokens_per_second_count } import product.capacity.lease { LeaseGrant, lease_fence_of, lease_grant, LeasePolicy, FencedResource } import product.capacity.event_chain { EventId } @@ -65,11 +67,11 @@ import gunbc.spark.serving_load_probe { decode_corroboration_for_protocol, CorroborationNotApplicable, CorroborationUnread, glm_native_wiring_smoke_protocol, glm_native_contended_sweep_c1, glm_native_contended_sweep_c2, glm_native_contended_sweep_c16, glm_native_contended_sweep_points, - glm_native_contended_sweep_elasticity, elasticity_is_off_the_uncontrolled_series, + glm_native_wet_smoke_is_not_sweep_c1_protocol, glm_native_wet_smoke_rate_is_output_tokens, glm_native_window_standing_specimen, window_standing_gap_is_unattributed, - cap_2_bucket_peak_4_is_not_foreign_work, SuccessfulClientRequestSecondBucketPeak, - ClientItlDistributionObserved, ClientItlDistributionUnread, itl_tail_cause_is_unestablished, + SuccessfulClientRequestSecondBucketPeak, + ClientItlDistributionObserved, ClientItlDistributionUnread, client_itl_text, client_bucket_peak_text, ledger_from_bench_stdout, client_output_from_bench_stdout, scrape_millis_from_bench_stdout, client_itl_from_bench_stdout, client_bucket_peak_from_bench_stdout, ClientOutputTokensObserved, @@ -575,18 +577,11 @@ data fx_bench_stdout_short: String = join([ "Total generated tokens: 512\n", ], "") -test fn a_cap_2_second_bucket_peak_4_does_not_establish_foreign_work() -> Bool { - cap_2_bucket_peak_4_is_not_foreign_work(p: SuccessfulClientRequestSecondBucketPeak { - client_max_concurrency: 2, - bucket_peak: 4, - }) -} - test fn parsed_itl_distribution_does_not_establish_a_cause() -> Bool { let d = client_itl_from_bench_stdout(body: fx_bench_stdout) match d { ClientItlDistributionObserved { mean_milli: mean_m, median_milli: med, p99_milli: p99, cause: _ } => - millisecond_count(m: mean_m) == 83 && millisecond_count(m: med) == 82 && millisecond_count(m: p99) == 165 && itl_tail_cause_is_unestablished(d: d) + millisecond_count(m: mean_m) == 83 && millisecond_count(m: med) == 82 && millisecond_count(m: p99) == 165 ClientItlDistributionUnread { cause: _ } => false } } @@ -627,10 +622,6 @@ test fn the_contended_sweep_is_five_shared_window_client_points() -> Bool { && glm_native_contended_sweep_c1.concurrency == 1 } -test fn scaling_elasticity_is_off_the_uncontrolled_series() -> Bool { - elasticity_is_off_the_uncontrolled_series(s: glm_native_contended_sweep_elasticity) -} - test fn ttft_c8_and_c16_remain_primitive_observations() -> Bool { glm_native_sweep_ttft_c8() == 2602 && glm_native_sweep_ttft_c16() == 5218 } @@ -823,12 +814,48 @@ test fn a_negative_cumulative_sum_is_unread_not_a_positive_delta() -> Bool { } } -test fn an_alignment_that_overflows_i64_is_unread_not_wrapped() -> Bool { - let before = metrics_body(running: "0.0", waiting: "0.0", capacity: "0.0", preempt: "0.0", itl_sum: "10", itl_count: "10.0", itok_sum: "10", itok_count: "10.0", gen: "1000.0", start: "1789300000.12") - let after = metrics_body(running: "0.0", waiting: "0.0", capacity: "0.0", preempt: "0.0", itl_sum: "10.0000000000000000001", itl_count: "11.0", itok_sum: "10.0000000000000000001", itok_count: "11.0", gen: "1000.0", start: "1789300000.12") - match iteration_tokens_booked_delta(before_body: before, after_body: after) { - TokenHistogramUnread { cause: _ } => true - TokenHistogramRead { booked: _, observations: _ } => false - TokenHistogramReset { cause: _ } => false +test fn an_alignment_that_overflows_i64_is_unrepresentable_after_both_samples_parse() -> Bool { + match prometheus_sample_value_reading(field: "1e-18") { + SampleValueExact { value: small } => + match prometheus_sample_value_reading(field: "10") { + SampleValueExact { value: ten } => + match exact_decimal_sub(a: ten, b: small) { + ExactDifferenceUnrepresentable { cause: _ } => { + let before = metrics_body(running: "0.0", waiting: "0.0", capacity: "0.0", preempt: "0.0", itl_sum: "1e-18", itl_count: "10.0", itok_sum: "1e-18", itok_count: "10.0", gen: "1000.0", start: "1789300000.12") + let after = metrics_body(running: "0.0", waiting: "0.0", capacity: "0.0", preempt: "0.0", itl_sum: "10", itl_count: "11.0", itok_sum: "10", itok_count: "11.0", gen: "1000.0", start: "1789300000.12") + match iteration_tokens_booked_delta(before_body: before, after_body: after) { + TokenHistogramUnread { cause: c } => string_contains(s: c as String, pattern: "does not fit a 64-bit") + TokenHistogramRead { booked: _, observations: _ } => false + TokenHistogramReset { cause: _ } => false + } + } + ExactDifference { value: _ } => false + ExactDifferenceOperandScaleRefused { observed_fraction_digits: _ } => false + } + SampleValueNotFinite { lexeme: _ } => false + SampleValueUnreadable { lexeme: _ } => false + } + SampleValueNotFinite { lexeme: _ } => false + SampleValueUnreadable { lexeme: _ } => false + } +} + +test fn a_computed_negative_operand_scale_is_refused_not_rescaled() -> Bool { + let bad = 0 - 1 + match exact_decimal_sub(a: ExactDecimal { units: 1, fraction_digits: bad }, b: ExactDecimal { units: 0, fraction_digits: 0 }) { + ExactDifferenceOperandScaleRefused { observed_fraction_digits: d } => d == bad + ExactDifference { value: _ } => false + ExactDifferenceUnrepresentable { cause: _ } => false } } + +test fn the_receipt_itl_line_prints_the_parsed_distribution() -> Bool { + let t = client_itl_text(d: client_itl_from_bench_stdout(body: fx_bench_stdout)) + string_contains(s: t, pattern: "mean_ms=83 median_ms=82 p99_ms=165") && string_contains(s: t, pattern: "tail_cause=unestablished") +} + +test fn the_receipt_bucket_line_prints_the_parsed_peak_not_a_verdict() -> Bool { + let t = client_bucket_peak_text(p: client_bucket_peak_from_bench_stdout(body: fx_bench_stdout, client_max_concurrency: 2)) + string_contains(s: t, pattern: "client_max_concurrency=2 successful_request_second_bucket_peak=") + && !string_contains(s: t, pattern: "foreign") +} From 98923562c1e32584a85cc820e7eaa49187454884 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sat, 19 Sep 2026 06:57:32 +0000 Subject: [PATCH 30/43] serving-load: the foreign-actor roster is an annotation, not a String row; pin the bucket peak value Review 68247: glm_native_exclusion_warning was commentary in a data row with only grep consumers. It becomes a // annotation on glm_native_arm_service, whose ArmInService standing is the typed fact it explains; the string_contains witness is removed. The bucket-line witness now asserts the parsed peak (4) and discriminates a different supplied value (7), per the side chat's non-blocking note. Co-Authored-By: Claude Opus 5 (1M context) --- dag/gunbc/spark/serving_load_probe.dag | 8 +++++--- dag/gunbc/spark/serving_load_probe_cli.dag | 2 +- .../claim/spark/serving_load_probe_witness_test.dag | 12 ++---------- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/dag/gunbc/spark/serving_load_probe.dag b/dag/gunbc/spark/serving_load_probe.dag index 6fd4ca49c1d..e72ac0204e0 100644 --- a/dag/gunbc/spark/serving_load_probe.dag +++ b/dag/gunbc/spark/serving_load_probe.dag @@ -151,7 +151,7 @@ type ArmServiceStanding // A ZERO RUNNING GAUGE IS A DRAIN SNAPSHOT, not exclusion. The probe still refuses to START on a // non-idle queue: that would mix already-running foreign requests into the client window without a // join. An idle start without lease/exclusion/protected subject is WindowIsolationNotEstablished. -// A prose list of actors who might arrive is glm_native_exclusion_warning, not a traffic observation. +// Actors who might arrive are named beside glm_native_arm_service; naming them is not a traffic observation. fn window_from_drain(drain: DrainReceipt) -> ProbeWindowStanding { match drain { DrainUnread { cause: c } => WindowIsolationNotEstablished { cause: c, drain: drain } @@ -1523,8 +1523,10 @@ data glm_native_live_probe_provenance: ProbeProvenance = DriverObserverSplit { observer: "deep-otter-201 HTTP scrape of 192.168.1.236:30000/metrics" as NonEmptyStr, } -data glm_native_exclusion_warning: NonEmptyStr = "operator interactive long-context sessions (70-110k prompt jumps) share Group B as production traffic with no exclusive window; gunbc.harness.harness_cli harness_probe_cli may POST a turn; proud-boar-181 nccl-tests all_reduce_perf may allocate GPU buffers; a drain snapshot is not exclusion and is not out-of-service" as NonEmptyStr - +// Actors who may share Group B during a capture, none of which a drain snapshot excludes: operator +// interactive long-context sessions (70-110k prompt jumps), gunbc.harness.harness_cli +// harness_probe_cli turns, and proud-boar-181's nccl-tests all_reduce_perf buffers. That is why this +// arm is ArmInService and every window here is WindowIsolationNotEstablished. data glm_native_arm_service: ArmServiceStanding = ArmInService { because: "the operator serves interactive work on this arm; WindowIsolated requires an out-of-service receipt that has not been issued" as NonEmptyStr } diff --git a/dag/gunbc/spark/serving_load_probe_cli.dag b/dag/gunbc/spark/serving_load_probe_cli.dag index 2b627bda707..73b811626d8 100644 --- a/dag/gunbc/spark/serving_load_probe_cli.dag +++ b/dag/gunbc/spark/serving_load_probe_cli.dag @@ -37,7 +37,7 @@ import gunbc.spark.serving_load_probe { // // Witnesses supply metric bodies. This function drives `vllm bench serve` against the live native // GLM head. A non-idle drain REFUSES the start. An idle start is WindowIsolationNotEstablished: -// glm_native_exclusion_warning names actors who might arrive, and is not a traffic observation. +// glm_native_arm_service's annotation names actors who might arrive; that is not a traffic observation. // Client facts are derived from one BenchServeExecution minted from the remote operation. // glm_native_serving_load_wet exits 0 when the observation is captured. Qualification is a // declared frontier (request start events, reserved-window lease/exclusion, interval occupancy, diff --git a/dag/test/claim/spark/serving_load_probe_witness_test.dag b/dag/test/claim/spark/serving_load_probe_witness_test.dag index 0234e7d5140..daaf6d82f41 100644 --- a/dag/test/claim/spark/serving_load_probe_witness_test.dag +++ b/dag/test/claim/spark/serving_load_probe_witness_test.dag @@ -52,12 +52,10 @@ import gunbc.spark.serving_load_probe { OccupancyBoundariesRead, OccupancyBoundariesUnread, OccupancySample, occupancy_does_not_count_positively, qualify_client_rate, send_all_without_start_events_is_not_zero_skew, - glm_native_exclusion_warning, glm_native_sweep_ttft_c8, glm_native_sweep_ttft_c16, ClientOutputTokensUnread, ClientOutputTokensObserved, ClientBenchLatencyUnread, ClientBenchLatencyReported, glm_native_workload_admission, - glm_native_exclusion_warning, glm_native_single_stream_decode_bound_millis, glm_native_single_stream_decode_bound_standing, glm_native_engine_tokenizer_path, @@ -150,13 +148,6 @@ test fn a_quiet_drain_is_not_an_isolated_window() -> Bool { } } -test fn exclusion_warning_names_actors_who_might_arrive() -> Bool { - string_contains(s: glm_native_exclusion_warning as String, pattern: "harness_probe_cli") - && string_contains(s: glm_native_exclusion_warning as String, pattern: "nccl-tests") - && string_contains(s: glm_native_exclusion_warning as String, pattern: "operator") - && string_contains(s: glm_native_exclusion_warning as String, pattern: "70-110k") -} - test fn isolated_window_requires_exclusion_and_idle_drain() -> Bool { let grant = lease_grant( reference: protected_subject_key(p: glm_native_protected_subject), @@ -856,6 +847,7 @@ test fn the_receipt_itl_line_prints_the_parsed_distribution() -> Bool { test fn the_receipt_bucket_line_prints_the_parsed_peak_not_a_verdict() -> Bool { let t = client_bucket_peak_text(p: client_bucket_peak_from_bench_stdout(body: fx_bench_stdout, client_max_concurrency: 2)) - string_contains(s: t, pattern: "client_max_concurrency=2 successful_request_second_bucket_peak=") + string_contains(s: t, pattern: "client_max_concurrency=2 successful_request_second_bucket_peak=4 ") && !string_contains(s: t, pattern: "foreign") + && string_contains(s: client_bucket_peak_text(p: SuccessfulClientRequestSecondBucketPeak { client_max_concurrency: 2, bucket_peak: 7 }), pattern: "successful_request_second_bucket_peak=7 ") } From ac17446211e571c03d2e28bde92c9ae4448c6a95 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sat, 19 Sep 2026 07:15:20 +0000 Subject: [PATCH 31/43] Regenerate the std_measure bootstrap mirror for MilliTokensPerSecond and MilliRequestsPerSecond Produced by claim_executor --required-regen from std.measure; additive only. Co-Authored-By: Claude Opus 5 (1M context) --- src/v1/stage0/src/std_measure.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/v1/stage0/src/std_measure.rs b/src/v1/stage0/src/std_measure.rs index 49566539010..4aa1d33f1c3 100644 --- a/src/v1/stage0/src/std_measure.rs +++ b/src/v1/stage0/src/std_measure.rs @@ -1320,6 +1320,32 @@ pub fn tokens_per_second_count(r: TokensPerSecond) -> Nat { measure_count(r.clone()) } +pub type MilliTokensPerSecond = Rc>; + +pub fn milli_tokens_per_second(count: Nat) -> MilliTokensPerSecond { + Rc::new(Measure { + count: count.clone(), + _phantom: std::marker::PhantomData, + }) +} + +pub fn milli_tokens_per_second_count(r: MilliTokensPerSecond) -> Nat { + measure_count(r.clone()) +} + +pub type MilliRequestsPerSecond = Rc>; + +pub fn milli_requests_per_second(count: Nat) -> MilliRequestsPerSecond { + Rc::new(Measure { + count: count.clone(), + _phantom: std::marker::PhantomData, + }) +} + +pub fn milli_requests_per_second_count(r: MilliRequestsPerSecond) -> Nat { + measure_count(r.clone()) +} + pub type EvalStepsPerMillisecond = Rc>; pub fn eval_steps_per_millisecond(count: Nat) -> EvalStepsPerMillisecond { From 29c0529590403f3850805e93451025ce4c4ab93e Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sat, 19 Sep 2026 08:03:21 +0000 Subject: [PATCH 32/43] serving-load: delete the constant-valued qualification and capacity folds and remaining dead declarations Review 68279: QualifiedClientRate and CapacityClaim had one arm each, so qualify_client_rate, occupancy_does_not_count_positively and capacity_claim_for_window could only return that arm and their witnesses could not go red. They, the observation fields, their receipt lines and witnesses are removed; glm_native_qualification_frontier remains the typed statement of what qualification still needs. Also removed: saturation_from_one_run and observation_rate_is_stored_separately (literal false), send_all_without_start_events_is_not_zero_skew (its arrival arm is constant), and four declarations with no consumer (window_isolated_requires_exclusion, scrape_interval_millis, metric_count, glm_native_wet_smoke_client_latency). Co-Authored-By: Claude Opus 5 (1M context) --- dag/gunbc/spark/serving_load_probe.dag | 164 ------------------ .../spark/serving_load_probe_witness_test.dag | 34 ---- 2 files changed, 198 deletions(-) diff --git a/dag/gunbc/spark/serving_load_probe.dag b/dag/gunbc/spark/serving_load_probe.dag index e72ac0204e0..277cb7530ff 100644 --- a/dag/gunbc/spark/serving_load_probe.dag +++ b/dag/gunbc/spark/serving_load_probe.dag @@ -122,20 +122,6 @@ type ProbeWindowStanding | ForeignTrafficNotObserved { drain: DrainReceipt } | ForeignTrafficUnread { cause: NonEmptyStr, drain: DrainReceipt } -fn window_isolated_requires_exclusion(s: ProbeWindowStanding) -> Bool { - match s { - WindowIsolated { grant: _, protected: _, deadline: _, drain: _, exclusion: e } => - match e { - ExclusionEstablished { how: _, protected: _ } => true - ExclusionNotEstablished { cause: _ } => false - } - WindowIsolationNotEstablished { cause: _, drain: _ } => false - ForeignTrafficObserved { attributed_receipt: _, drain: _ } => false - ForeignTrafficNotObserved { drain: _ } => false - ForeignTrafficUnread { cause: _, drain: _ } => false - } -} - fn drain_from_queue(q: ServingQueueReading) -> DrainReceipt { match q { QueueDepthUnread { obligation: o } => DrainUnread { cause: o } @@ -512,14 +498,6 @@ fn generation_token_delta_scoped( } } -fn scrape_interval_millis(before_at: EpochSecs, after_at: EpochSecs) -> Nat? { - if after_at <= before_at { - none - } else { - nat_from_nonneg_int(n: (after_at - before_at) * 1000) - } -} - type ArrivalSkew = ArrivalSkewObserved { max_stagger_millis: Millisecond } | ArrivalSkewUnread { cause: NonEmptyStr } @@ -545,16 +523,6 @@ fn arrival_from_protocol(req: VllmBenchServeRequest) -> ArrivalSkew { } } -fn send_all_without_start_events_is_not_zero_skew(num_prompts: Nat, cap: Nat, start_event_count: Nat) -> Bool { - num_prompts == 4 - && cap == 2 - && start_event_count == 0 - && match arrival_from_protocol(req: glm_native_smoke_protocol) { - ArrivalSkewUnread { cause: _ } => true - ArrivalSkewObserved { max_stagger_millis: _ } => false - } -} - data arrival_skew_comparison_bound_millis: Millisecond = millisecond(count: 250) fn arrival_admits_rate_comparison(s: ArrivalSkew) -> Bool { @@ -608,13 +576,6 @@ fn occupancy_from_body(body: String) -> OccupancySample? { } } -fn metric_count(body: String, metric: VllmServingMetric) -> Nat? { - match harness_gauge_value(body: body, metric: metric) { - Absent => none - Present { value: t } => harness_gauge_count(text: t) - } -} - fn occupancy_trace_from_endpoint_scrapes(before_body: String, after_body: String) -> BoundaryOccupancyReceipt { match occupancy_from_body(body: before_body) { Absent => OccupancyBoundariesUnread { cause: "a bound scrape could not yield running/waiting/prompt_tokens on the before body" as NonEmptyStr } @@ -703,24 +664,6 @@ fn foreign_work_bound(generation: TokenDelta, client_output: ClientOutputTokens) } } -type CapacityClaim - = CapacityClaimUnavailable { because: NonEmptyStr } - -fn capacity_claim_for_window(window: ProbeWindowStanding) -> CapacityClaim { - match window { - WindowIsolated { grant: _, protected: _, deadline: _, drain: _, exclusion: _ } => - CapacityClaimUnavailable { because: "one run does not decide saturation even under isolation" as NonEmptyStr } - WindowIsolationNotEstablished { cause: _, drain: _ } => - CapacityClaimUnavailable { because: "this arm has no exclusive window; a latency distribution beside unattributed load is real, an aggregate capacity claim is not" as NonEmptyStr } - ForeignTrafficObserved { attributed_receipt: _, drain: _ } => - CapacityClaimUnavailable { because: "foreign traffic was attributed on this window, so an aggregate capacity claim is not available" as NonEmptyStr } - ForeignTrafficNotObserved { drain: _ } => - CapacityClaimUnavailable { because: "one run does not decide saturation even when foreign traffic was not observed" as NonEmptyStr } - ForeignTrafficUnread { cause: _, drain: _ } => - CapacityClaimUnavailable { because: "foreign-traffic standing is unread, so no capacity claim is available" as NonEmptyStr } - } -} - type DerivedRate = RateFromClientOutputTokens { tokens: Nat, scrape_millis: Millisecond } | RateUndenominable { because: NonEmptyStr } @@ -754,9 +697,6 @@ fn derive_rate_honest( } } -type QualifiedClientRate - = ClientRateUnqualified { because: NonEmptyStr } - type ClientRateQualificationFrontier sole_constructor { request_start_events: NonEmptyStr reserved_window: NonEmptyStr @@ -771,66 +711,6 @@ data glm_native_qualification_frontier: ClientRateQualificationFrontier = Client serve_py_digest: "bind vllm_bench_serve_source_standing to the serve.py file or package digest inside the running image, or an explicit policy that admits TranscribedUncited" as NonEmptyStr, } -fn occupancy_does_not_count_positively(occupancy: BoundaryOccupancyReceipt) -> QualifiedClientRate { - match occupancy { - OccupancyBoundariesUnread { cause: c } => ClientRateUnqualified { because: c } - OccupancyBoundariesRead { before: _, after: _ } => - ClientRateUnqualified { because: "boundary occupancy is two scrapes, not a time-series over the interval; it cannot count positively toward a qualified rate" as NonEmptyStr } - } -} - -fn qualify_client_rate( - subject: ServingPerformanceSubjectStanding, - continuity: CounterContinuity, - arrival: ArrivalSkew, - window: ProbeWindowStanding, - agreement: LedgerCounterAgreement, - occupancy: BoundaryOccupancyReceipt, - foreign_work: ForeignWorkBound, - rate: DerivedRate, -) -> QualifiedClientRate { - match rate { - RateUndenominable { because: b } => ClientRateUnqualified { because: b } - RateUnreadable { because: b } => ClientRateUnqualified { because: b } - RateFromClientOutputTokens { tokens: _, scrape_millis: _ } => - match subject { - SubjectPartial { subject: _, unknown_axes: _, believed: _, would_settle: s } => - ClientRateUnqualified { because: s } - SubjectEstablished { subject: _ } => - match continuity { - ContinuityUnread { cause: c } => ClientRateUnqualified { because: c } - ExporterChanged { before: _, after: _ } => - ClientRateUnqualified { because: "the exporter changed across the window, so the rate is not a single-incarnation observation" as NonEmptyStr } - SameExporter { start_field: _ } => - if !arrival_admits_rate_comparison(s: arrival) { - ClientRateUnqualified { because: "arrival standing does not admit a rate comparison" as NonEmptyStr } - } else { - match window { - WindowIsolationNotEstablished { cause: c, drain: _ } => ClientRateUnqualified { because: c } - ForeignTrafficObserved { attributed_receipt: _, drain: _ } => - ClientRateUnqualified { because: "foreign traffic was attributed on this window, so the client rate is not a qualified comparable observation" as NonEmptyStr } - ForeignTrafficUnread { cause: c, drain: _ } => ClientRateUnqualified { because: c } - ForeignTrafficNotObserved { drain: _ } => - match agreement { - AgreementUnread { because: c } => ClientRateUnqualified { because: c } - LedgerCounterDisagree { because: c } => ClientRateUnqualified { because: c } - LedgerAndCounterAgree { generation_tokens: _, completed_requests: _ } => - occupancy_does_not_count_positively(occupancy: occupancy) - } - WindowIsolated { grant: _, protected: _, deadline: _, drain: _, exclusion: _ } => - match agreement { - AgreementUnread { because: c } => ClientRateUnqualified { because: c } - LedgerCounterDisagree { because: c } => ClientRateUnqualified { because: c } - LedgerAndCounterAgree { generation_tokens: _, completed_requests: _ } => - occupancy_does_not_count_positively(occupancy: occupancy) - } - } - } - } - } - } -} - type DecodeCorroboration = CorroborationNotApplicable { because: NonEmptyStr } | CorroborationUnread { because: NonEmptyStr } @@ -1112,9 +992,7 @@ type ServingLoadObservation sole_constructor { provenance: ProbeProvenance client_latency: ClientBenchLatency foreign_work: ForeignWorkBound - capacity_claim: CapacityClaim rate: DerivedRate - qualified_rate: QualifiedClientRate qualification_frontier: ClientRateQualificationFrontier evidence: ServingLoadEvidence } @@ -1170,31 +1048,12 @@ fn serving_load_observation( provenance: glm_native_live_probe_provenance, client_latency: bench_serve_latency(e: bench, window: window), foreign_work: foreign, - capacity_claim: capacity_claim_for_window(window: window), rate: rate, - qualified_rate: qualify_client_rate( - subject: subject, - continuity: continuity, - arrival: arrival, - window: window, - agreement: agreement, - occupancy: occupancy, - foreign_work: foreign, - rate: rate, - ), qualification_frontier: glm_native_qualification_frontier, evidence: serving_load_evidence(before_body: before_body, after_body: after_body, bench: bench), } } -fn observation_rate_is_stored_separately(_: ServingLoadObservation) -> Bool { - false -} - -fn saturation_from_one_run(_: ServingLoadObservation) -> Bool { - false -} - fn observation_evidence_replays_client_facts(o: ServingLoadObservation) -> Bool { captured_text_digest_matches(c: o.evidence.metrics_before) && captured_text_digest_matches(c: o.evidence.metrics_after) @@ -1241,11 +1100,8 @@ fn serving_load_observation_text(o: ServingLoadObservation) -> String { "provenance: ", provenance_text(p: o.provenance), "\n", "client latency: ", client_latency_text(c: o.client_latency), "\n", "foreign work: ", foreign_work_text(f: o.foreign_work), "\n", - "capacity claim: ", capacity_claim_text(c: o.capacity_claim), "\n", "rate: ", rate_text(r: o.rate), "\n", - "qualified rate: ", qualified_rate_text(q: o.qualified_rate), "\n", "qualification frontier: ", qualification_frontier_text(f: o.qualification_frontier), "\n", - "saturation decided from this run: ", if saturation_from_one_run(obs: o) { "yes" } else { "no" }, "\n", serving_load_evidence_text(ev: o.evidence), ], "") } @@ -1260,18 +1116,6 @@ fn foreign_work_text(f: ForeignWorkBound) -> String { } } -fn qualified_rate_text(q: QualifiedClientRate) -> String { - match q { - ClientRateUnqualified { because: b } => join(["unqualified ", b as String], "") - } -} - -fn capacity_claim_text(c: CapacityClaim) -> String { - match c { - CapacityClaimUnavailable { because: b } => join(["unavailable ", b as String], "") - } -} - fn client_latency_text(c: ClientBenchLatency) -> String { match c { ClientBenchLatencyUnread { cause: x } => join(["unread ", x as String], "") @@ -1568,14 +1412,6 @@ data glm_native_wet_smoke_standing: CitedFigureStanding = TranscribedUncited { read_obligation: "re-read calm-bat-65 docker-exec stdout for glm_native_smoke_protocol (256-in/128-out/prefix 0/4 prompts/inf/c=2/ignore-eos) on 192.168.1.236" as NonEmptyStr } -data glm_native_wet_smoke_client_latency: TranscribedClientLatency = TranscribedClientLatency { - output_throughput: milli_tokens_per_second(count: 22510) - tpot_milli: millisecond(count: 82) - itl_milli: Present { value: millisecond(count: 83) } - ttft_milli: millisecond(count: 996) - standing: glm_native_wet_smoke_standing -} - fn bench_labeled_nat(body: String, label: String) -> Nat? { text_labeled_count(body: text_without_sudo_prompt(body: body), label: label) } diff --git a/dag/test/claim/spark/serving_load_probe_witness_test.dag b/dag/test/claim/spark/serving_load_probe_witness_test.dag index daaf6d82f41..01a7e49a8ec 100644 --- a/dag/test/claim/spark/serving_load_probe_witness_test.dag +++ b/dag/test/claim/spark/serving_load_probe_witness_test.dag @@ -39,19 +39,14 @@ import gunbc.spark.serving_load_probe { ArrivalSkewObserved, ArrivalSkewUnread, arrival_admits_rate_comparison, TokenDeltaRead, TokenDeltaReset, TokenDeltaUnread, TokenDeltaScoped, generation_token_delta, generation_token_delta_scoped, derive_rate_honest, serving_load_observation, serving_load_observation_text, ServingLoadObservation, tokens_per_observation_second, - saturation_from_one_run, observation_rate_is_stored_separately, foreign_work_bound, ForeignWorkBounded, ForeignWorkUnread, ForeignWorkContradiction, - ClientRateUnqualified, occupancy_from_body, occupancy_trace_from_endpoint_scrapes, itl_latency_delta, iteration_tokens_booked_delta, LatencyHistogramRead, LatencyHistogramUnread, LatencyHistogramReset, TokenHistogramRead, TokenHistogramUnread, TokenHistogramReset, - CapacityClaimUnavailable, glm_native_holistic_protocol, holistic_protocol_is_session_shaped, glm_native_live_subject_standing, counter_continuity, SameExporter, ExporterChanged, ContinuityUnread, OccupancyBoundariesRead, OccupancyBoundariesUnread, OccupancySample, - occupancy_does_not_count_positively, qualify_client_rate, - send_all_without_start_events_is_not_zero_skew, glm_native_sweep_ttft_c8, glm_native_sweep_ttft_c16, ClientOutputTokensUnread, ClientOutputTokensObserved, ClientBenchLatencyUnread, ClientBenchLatencyReported, @@ -405,18 +400,6 @@ test fn a_long_context_protocol_does_not_mint_an_admission_ceiling() -> Bool { } } -test fn one_run_does_not_decide_saturation() -> Bool { - let obs = fx_obs() - !saturation_from_one_run(obs: obs) - && !observation_rate_is_stored_separately(obs: obs) - && match obs.capacity_claim { - CapacityClaimUnavailable { because: _ } => true - } - && match obs.qualified_rate { - ClientRateUnqualified { because: _ } => true - } -} - test fn client_output_exceeding_engine_generation_is_a_contradiction() -> Bool { match foreign_work_bound(generation: TokenDeltaRead { tokens: 100 }, client_output: ClientOutputTokensObserved { tokens: 512 }) { ForeignWorkContradiction { engine_generation: g, client_output: c, because: _ } => g == 100 && c == 512 @@ -693,23 +676,6 @@ test fn mixing_two_bench_stdout_bodies_cannot_write_one_receipt() -> Bool { ) } -test fn send_all_at_cap_2_with_no_start_events_is_not_zero_skew() -> Bool { - send_all_without_start_events_is_not_zero_skew( - num_prompts: 4, - cap: 2, - start_event_count: 0, - ) -} - -test fn qualify_client_rate_refuses_two_boundary_occupancy() -> Bool { - match occupancy_does_not_count_positively(occupancy: OccupancyBoundariesRead { - before: OccupancySample { running: 0, waiting: 0, capacity_waiting: 0, preemptions: 0, prompt_tokens: 0 }, - after: OccupancySample { running: 0, waiting: 0, capacity_waiting: 0, preemptions: 0, prompt_tokens: 1 }, - }) { - ClientRateUnqualified { because: _ } => true - } -} - test fn live_subject_consumes_the_derived_gb10_runtime_row() -> Bool { glm_native_live_runtime_is_derived_gb10_row() } From c08291431b79f5e1b544b5c9efe793ac4255dd5a Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sat, 19 Sep 2026 09:23:41 +0000 Subject: [PATCH 33/43] serving-load: remove every non-discriminating witness and the declarations only they consumed; render subject and arrival Review 68295 and side-chat hold 5255113139, done as one audit instead of another partial round. Deleted 19 witnesses (literal echoes of rows authored here, prose greps, constants, duplicates) and 55 declarations consumed only by them (transcribed sweep/smoke/latency rows, the holistic and wiring protocols, witness-shaped Bool helpers in production, the frontier grep). Prose worth keeping moved to leading annotations on surviving declarations. The receipt now prints the observation's subject standing (wire, unknown axes, unverified belief, would_settle) and arrival standing directly, without restoring any qualification assessment; three witnesses drive the real constructor and renderer and were checked red with the lines removed. 42/42 pass; wet capture exit 0. Co-Authored-By: Claude Opus 5 (1M context) --- dag/gunbc/spark/serving_load_probe.dag | 458 ++---------------- dag/gunbc/spark/serving_load_probe_cli.dag | 2 +- .../spark/serving_load_probe_witness_test.dag | 311 +++--------- 3 files changed, 121 insertions(+), 650 deletions(-) diff --git a/dag/gunbc/spark/serving_load_probe.dag b/dag/gunbc/spark/serving_load_probe.dag index 277cb7530ff..5e7d1de864e 100644 --- a/dag/gunbc/spark/serving_load_probe.dag +++ b/dag/gunbc/spark/serving_load_probe.dag @@ -1,57 +1,42 @@ module gunbc.spark.serving_load_probe -import std.types { Bool, String, NonEmptyStr, List, EpochSecs, Int } +import std.types { Bool, String, NonEmptyStr, EpochSecs, Int } import std.nat { Nat } import std.measure { - Millisecond, millisecond, millisecond_count, - TokenCount, token_count, token_count_value, - Measure, Dimensionless, Milli, - MilliTokensPerSecond, milli_tokens_per_second, milli_tokens_per_second_count, - MilliRequestsPerSecond, milli_requests_per_second, + Millisecond, millisecond, millisecond_count, TokenCount, token_count, token_count_value, Measure, Dimensionless, Milli, MilliTokensPerSecond, milli_tokens_per_second, milli_tokens_per_second_count, MilliRequestsPerSecond, } import std.decimal { ExactDecimal, canonical_exact_decimal, decimal_pow10, exact_decimal_sub, ExactDifference, ExactDifferenceUnrepresentable, ExactDifferenceOperandScaleRefused } import std.checked_arithmetic { checked_int_magnitude, CheckedNatReady, CheckedNatOverflow } import v2.std.optional { Present, Absent } import std.content_hash { ContentHash, content_hash_of_value, serialize_content_hash } import product.capacity.lease { LeaseGrant } -import product.fabric.demand { ObservationReceiptRef } import extdeps.prometheus.client { SampleValueExact, SampleValueNotFinite, SampleValueUnreadable, prometheus_sample_value_reading, } import extdeps.vllm.metrics { - VllmServingMetric, InterTokenLatencySeconds, IterationTokensTotal, NumPreemptionsTotal, GenerationTokensTotal, PromptTokensTotal, - HistogramStatistic, HistogramSum, HistogramCount, - vllm_metric_exports_histogram_statistics, + VllmServingMetric, InterTokenLatencySeconds, IterationTokensTotal, NumPreemptionsTotal, GenerationTokensTotal, PromptTokensTotal, HistogramSum, HistogramCount, vllm_metric_exports_histogram_statistics, } import extdeps.vllm.bench_serve { - VllmBenchServeRequest, PoissonProcess, SendAllImmediately, - RandomDatasetSpec, OpenaiChat, vllm_bench_serve_request, vllm_bench_serve_uses_poisson_idle_gaps, - vllm_bench_serve_identity_matches, vllm_bench_serve_source_standing, vllm_bench_backend_route, + VllmBenchServeRequest, PoissonProcess, SendAllImmediately, RandomDatasetSpec, OpenaiChat, vllm_bench_serve_request, vllm_bench_serve_source_standing, vllm_bench_backend_route, } import extdeps.vllm.server { vllm_route_path } import gunbc.spark.model_snapshot_materialize { SparkRemoteRun, RemoteRan, RemoteUnreachable } import gunbc.harness.harness_backend { - harness_gauge_value, harness_labelled_gauge_value, harness_gauge_count, - harness_histogram_statistic_value, harness_launch_from_body, harness_queue_from_body, - text_labeled_count, text_labeled_head_count, text_field_last_word, text_without_sudo_prompt, + harness_gauge_value, harness_gauge_count, harness_histogram_statistic_value, harness_queue_from_body, text_labeled_count, text_labeled_head_count, text_field_last_word, text_without_sudo_prompt, } import gunbc.serving.turn_admission { - ServingQueueReading, QueueDepthRead, QueueDepthUnread, - ServingCapacityPressure, RouteAdmittingMore, RouteHoldingForCapacity, CapacityPressureUnread, + ServingQueueReading, QueueDepthRead, QueueDepthUnread, ServingCapacityPressure, RouteAdmittingMore, RouteHoldingForCapacity, CapacityPressureUnread, } import gunbc.spark.vllm_endpoint_process_launch { VllmEndpointProcessLaunchObservation, LaunchObserved, LaunchUnobserved, } import gunbc.spark.serving_arm { - Glm53NativeFp8, GunbcGlm53DerivedGb10, FourSparkTp4, glm_native_concurrent_profile, - glm53_native_fp8_row, glm53_derived_row, runtime_artifact_wire, serving_runtime_wire, + Glm53NativeFp8, GunbcGlm53DerivedGb10, FourSparkTp4, glm_native_concurrent_profile, glm53_native_fp8_row, glm53_derived_row, runtime_artifact_wire, } import gunbc.spark.serving_arm_launch { glm_native_weights_container_dir } import gunbc.spark.model_snapshot_acquisition { snapshot_install_path, HubCachePlacement } import gunbc.spark.serving_performance_subject { - ServingPerformanceSubject, serving_performance_subject, serving_subject_standing, - ServingPerformanceSubjectStanding, SubjectEstablished, SubjectPartial, - serving_performance_subject_wire, + ServingPerformanceSubject, serving_performance_subject, serving_subject_standing, ServingPerformanceSubjectStanding, SubjectEstablished, SubjectPartial, serving_performance_subject_wire, serving_subject_axes_wire, } import gunbc.spark.serving_rank_observe { ObservedRankIncarnation, observed_rank_incarnations_agree, observed_rank_incarnation_text, @@ -130,14 +115,12 @@ fn drain_from_queue(q: ServingQueueReading) -> DrainReceipt { } } -type ArmServiceStanding - = ArmInService { because: NonEmptyStr } - | ArmOutOfService { how: NonEmptyStr } - // A ZERO RUNNING GAUGE IS A DRAIN SNAPSHOT, not exclusion. The probe still refuses to START on a // non-idle queue: that would mix already-running foreign requests into the client window without a // join. An idle start without lease/exclusion/protected subject is WindowIsolationNotEstablished. -// Actors who might arrive are named beside glm_native_arm_service; naming them is not a traffic observation. +// Actors who may share Group B during a capture, none of which a drain snapshot excludes: operator +// interactive long-context sessions, gunbc.harness.harness_cli harness_probe_cli turns, and nccl-tests +// all_reduce_perf buffers. Naming them is not a traffic observation. fn window_from_drain(drain: DrainReceipt) -> ProbeWindowStanding { match drain { DrainUnread { cause: c } => WindowIsolationNotEstablished { cause: c, drain: drain } @@ -715,6 +698,9 @@ type DecodeCorroboration = CorroborationNotApplicable { because: NonEmptyStr } | CorroborationUnread { because: NonEmptyStr } +// The 49 ms/token single-stream bound is TRANSCRIBED, NOT A READING: parent measured 48.9 ms +// single-stream in a quieter window, against a contended client c=1 TPOT of ~81 ms. The gap is +// observed; its cause is unestablished until an overlapping lease or engine-population join attributes it. fn decode_corroboration_for_protocol(req: VllmBenchServeRequest) -> DecodeCorroboration { match req.max_concurrency { Present { value: 1 } => @@ -870,47 +856,6 @@ fn bench_serve_bucket_peak(e: BenchServeExecution) -> ClientRequestConcurrencySt } } -fn mixed_run_client_facts_cannot_be_written(a: BenchServeExecution, b: BenchServeExecution) -> Bool { - match bench_serve_interval(e: a) { - Absent => false - Present { value: ia } => - match bench_serve_interval(e: b) { - Absent => false - Present { value: ib } => ia != ib - } - } -} - -fn nonzero_exit_does_not_yield_client_facts(e: BenchServeExecution) -> Bool { - match e { - BenchServeUnreachable { protocol: _, cause: _ } => false - BenchServeRan { protocol: _, exit_code: code, stdout: _, stderr: _ } => - code != 0 - && match bench_serve_completed_output(e: e) { - ClientOutputTokensUnread { cause: _ } => true - ClientOutputTokensObserved { tokens: _ } => false - } - } -} - -fn unreachable_does_not_yield_client_facts(e: BenchServeExecution) -> Bool { - match e { - BenchServeRan { protocol: _, exit_code: _, stdout: _, stderr: _ } => false - BenchServeUnreachable { protocol: _, cause: _ } => - match bench_serve_completed_output(e: e) { - ClientOutputTokensUnread { cause: _ } => true - ClientOutputTokensObserved { tokens: _ } => false - } - } -} - -fn stderr_is_not_the_client_summary(e: BenchServeExecution) -> Bool { - match bench_serve_completed_output(e: e) { - ClientOutputTokensUnread { cause: _ } => true - ClientOutputTokensObserved { tokens: _ } => false - } -} - type CapturedText sole_constructor { kind: NonEmptyStr digest: ContentHash @@ -925,10 +870,6 @@ fn captured_text(kind: NonEmptyStr, body: String) -> CapturedText { } } -fn captured_text_digest_matches(c: CapturedText) -> Bool { - (serialize_content_hash(hash: c.digest) as String) == (serialize_content_hash(hash: captured_text(kind: c.kind, body: c.body).digest) as String) -} - type ServingLoadEvidence sole_constructor { metrics_before: CapturedText metrics_after: CapturedText @@ -1054,36 +995,12 @@ fn serving_load_observation( } } -fn observation_evidence_replays_client_facts(o: ServingLoadObservation) -> Bool { - captured_text_digest_matches(c: o.evidence.metrics_before) - && captured_text_digest_matches(c: o.evidence.metrics_after) - && captured_text_digest_matches(c: o.evidence.bench_stdout) - && captured_text_digest_matches(c: o.evidence.bench_stderr) - && match bench_serve_interval(e: o.execution) { - Absent => - match scrape_millis_from_bench_stdout(body: o.evidence.bench_stdout.body) { - Absent => true - Present { value: _ } => false - } - Present { value: ia } => - match scrape_millis_from_bench_stdout(body: o.evidence.bench_stdout.body) { - Absent => false - Present { value: ib } => ia == ib - } - } -} - -fn qualification_frontier_requires_serve_py_digest(f: ClientRateQualificationFrontier) -> Bool { - string_contains(s: f.serve_py_digest as String, pattern: "serve.py") - && string_contains(s: f.request_start_events as String, pattern: "start") - && string_contains(s: f.reserved_window as String, pattern: "exclusive") - && string_contains(s: f.interval_occupancy as String, pattern: "time-series") -} - fn serving_load_observation_text(o: ServingLoadObservation) -> String { join([ "serving-load observation\n", "execution: ", bench_execution_text(e: o.execution), "\n", + "subject: ", subject_standing_text(s: o.subject), "\n", + "arrival: ", arrival_text(a: o.arrival), "\n", "bench source standing: ", cited_standing_text(s: o.bench_source_standing), "\n", "window: ", window_text(s: o.window), "\n", "continuity: ", continuity_text(c: o.continuity), "\n", @@ -1106,6 +1023,30 @@ fn serving_load_observation_text(o: ServingLoadObservation) -> String { ], "") } +// The standing is rendered as the subject authority states it: a Partial's belief is printed as a +// belief and its settling obligation as an obligation, never as a reading of the unknown axes. +fn subject_standing_text(s: ServingPerformanceSubjectStanding) -> String { + match s { + SubjectEstablished { subject: sub } => + join(["established ", serving_performance_subject_wire(s: sub) as String], "") + SubjectPartial { subject: sub, unknown_axes: axes, believed: b, would_settle: w } => + join([ + "partial ", serving_performance_subject_wire(s: sub) as String, + " unknown_axes=", serving_subject_axes_wire(axes: axes), + " believed (unverified)=", b as String, + " would_settle=", w as String, + ], "") + } +} + +fn arrival_text(a: ArrivalSkew) -> String { + match a { + ArrivalSkewUnread { cause: c } => join(["unread ", c as String], "") + ArrivalSkewObserved { max_stagger_millis: m } => + join(["observed max_stagger_ms=", to_string(millisecond_count(m: m))], "") + } +} + fn foreign_work_text(f: ForeignWorkBound) -> String { match f { ForeignWorkUnread { because: c } => join(["unread ", c as String], "") @@ -1291,11 +1232,13 @@ fn rate_text(r: DerivedRate) -> String { } } -// ── THE HOLISTIC GLM PROTOCOL THIS FLEET'S SESSIONS ACTUALLY LOOK LIKE ──────────────────────── +// ── ADMISSION FOR THE SESSIONS THIS FLEET ACTUALLY SERVES ───────────────────────────────────── // // Real sessions sit at ~100k-130k tokens of context after compacting a 262k window. They idle // between turns. Each turn is a separate request whose KV frees on completion while the prefix -// stays in the prefix cache. A long-context point is how that envelope is exercised. +// stays in the prefix cache. A 100k-prefix load protocol is not modeled here: it is the heaviest +// prefill this arm can construct, and it waits on the qualification window (exact lease and +// exclusion, idle drain, protected subject). // // THAT IS NOT AN ADMISSION CAPACITY. vLLM's printed token pool is floor(max_concurrency × // max_model_len) — the same fact twice — and GLM's hybrid KV (full / sliding-window / Mamba) does @@ -1307,27 +1250,12 @@ data glm_native_workload_admission: AdmissionCost = AdmissionCostUnestablished { cause: "the live cache-group roster is unobserved, so cold_admission_blocks cannot establish per-request cost; a token-pool divided by request length is not an admission capacity" as NonEmptyStr } -data glm_native_holistic_dataset: RandomDatasetSpec = RandomDatasetSpec { - input_len: token_count(count: 20000), - output_len: token_count(count: 128), - prefix_len: token_count(count: 100000), -} - data glm_native_engine_tokenizer_path: NonEmptyStr = snapshot_install_path( placement: HubCachePlacement { cache_root: glm_native_weights_container_dir }, repo: glm53_native_fp8_row.repo, revision: glm53_native_fp8_row.revision, ) -// WIRING IS PROVEN AT A FEW HUNDRED TOKENS. A 100k-prefix protocol is not a smoke test: it is the -// heaviest prefill this arm can construct and it starves operator interactive traffic. SendAllImmediately -// is the validated wiring argv; it is not a comparable rate protocol (arrival skew). -data glm_native_wiring_smoke_dataset: RandomDatasetSpec = RandomDatasetSpec { - input_len: token_count(count: 256), - output_len: token_count(count: 64), - prefix_len: token_count(count: 0), -} - data glm_native_sweep_dataset: RandomDatasetSpec = RandomDatasetSpec { input_len: token_count(count: 256), output_len: token_count(count: 128), @@ -1336,6 +1264,9 @@ data glm_native_sweep_dataset: RandomDatasetSpec = RandomDatasetSpec { data glm_native_bench_seed: Nat = 20260918 +// The live probe's protocol: 256-in/128-out, SendAllImmediately, c=2. SendAllImmediately is wiring, +// not a comparable rate protocol (arrival skew is unread). The derived rate counts completed output +// tokens; bench-serve's total token throughput also counts prefill and answers a different question. data glm_native_smoke_protocol: VllmBenchServeRequest = vllm_bench_serve_request( backend: OpenaiChat, base_url: "http://127.0.0.1:30000" as NonEmptyStr, @@ -1349,69 +1280,11 @@ data glm_native_smoke_protocol: VllmBenchServeRequest = vllm_bench_serve_request seed: glm_native_bench_seed, ) -data glm_native_holistic_protocol: VllmBenchServeRequest = vllm_bench_serve_request( - backend: OpenaiChat, - base_url: "http://127.0.0.1:30000" as NonEmptyStr, - model: glm_native_concurrent_profile.served_alias, - tokenizer: glm_native_engine_tokenizer_path, - dataset: glm_native_holistic_dataset, - num_prompts: 4, - arrival: PoissonProcess { request_rate: milli_requests_per_second(count: 50), burstiness: Measure { count: 1000 } }, - max_concurrency: Present { value: 2 }, - ignore_eos: true, - seed: glm_native_bench_seed, -) - data glm_native_live_probe_provenance: ProbeProvenance = DriverObserverSplit { driver: "calm-bat-65 via srv1 docker exec of vllm bench serve" as NonEmptyStr, observer: "deep-otter-201 HTTP scrape of 192.168.1.236:30000/metrics" as NonEmptyStr, } -// Actors who may share Group B during a capture, none of which a drain snapshot excludes: operator -// interactive long-context sessions (70-110k prompt jumps), gunbc.harness.harness_cli -// harness_probe_cli turns, and proud-boar-181's nccl-tests all_reduce_perf buffers. That is why this -// arm is ArmInService and every window here is WindowIsolationNotEstablished. -data glm_native_arm_service: ArmServiceStanding = ArmInService { - because: "the operator serves interactive work on this arm; WindowIsolated requires an out-of-service receipt that has not been issued" as NonEmptyStr -} - -data glm_native_wiring_smoke_protocol: VllmBenchServeRequest = vllm_bench_serve_request( - backend: OpenaiChat, - base_url: "http://127.0.0.1:30000" as NonEmptyStr, - model: glm_native_concurrent_profile.served_alias, - tokenizer: glm_native_engine_tokenizer_path, - dataset: glm_native_wiring_smoke_dataset, - num_prompts: 4, - arrival: SendAllImmediately, - max_concurrency: Present { value: 2 }, - ignore_eos: true, - seed: glm_native_bench_seed, -) - -// Client TTFT/TPOT/ITL from vllm bench serve stdout, transcribed from the 2026-09-18 wiring -// smoke (256/64, inf rate, c=2, 4/4 ok). Contended. Not the 256/128 sweep protocol. -type TranscribedClientLatency { - output_throughput: MilliTokensPerSecond - tpot_milli: Millisecond - itl_milli: Millisecond? - ttft_milli: Millisecond - standing: CitedFigureStanding -} - -data glm_native_smoke_client_latency: TranscribedClientLatency = TranscribedClientLatency { - output_throughput: milli_tokens_per_second(count: 17390) - tpot_milli: millisecond(count: 82) - itl_milli: Present { value: millisecond(count: 82) } - ttft_milli: millisecond(count: 2185) - standing: TranscribedUncited { - read_obligation: "re-read vllm bench serve stdout for the 256-in/64-out wiring argv; the 17.39 tok/s / 82.1 ms TPOT / 81.8 ms ITL / 2185 ms TTFT figures were transcribed from calm-bat-65's docker-exec receipt" as NonEmptyStr - } -} - -data glm_native_wet_smoke_standing: CitedFigureStanding = TranscribedUncited { - read_obligation: "re-read calm-bat-65 docker-exec stdout for glm_native_smoke_protocol (256-in/128-out/prefix 0/4 prompts/inf/c=2/ignore-eos) on 192.168.1.236" as NonEmptyStr -} - fn bench_labeled_nat(body: String, label: String) -> Nat? { text_labeled_count(body: text_without_sudo_prompt(body: body), label: label) } @@ -1506,216 +1379,6 @@ fn client_latency_from_bench_stdout(body: String, window: ProbeWindowStanding) - } } -type RateTokenDenomination - = RateDenominatedInCompletedOutputTokens { because: NonEmptyStr } - | RateDenominatedInTotalTokensIncludingPrefill { because: NonEmptyStr } - -data glm_native_client_rate_denomination: RateTokenDenomination = RateDenominatedInCompletedOutputTokens { - because: "vllm bench serve output token throughput and the probe rate both count completed decode tokens; total token throughput also counts prefill of the same requests and is a different question" as NonEmptyStr -} - -type PrefillVersusDecodeThroughput { - output_throughput: MilliTokensPerSecond - total_throughput: MilliTokensPerSecond - input_tokens: Nat - output_tokens: Nat -} - -data glm_native_wet_smoke_prefill_versus_decode: PrefillVersusDecodeThroughput = PrefillVersusDecodeThroughput { - output_throughput: milli_tokens_per_second(count: 22510) - total_throughput: milli_tokens_per_second(count: 69640) - input_tokens: 1072 - output_tokens: 512 -} - -fn total_token_throughput_is_not_the_probe_rate(r: PrefillVersusDecodeThroughput) -> Bool { - milli_tokens_per_second_count(r: r.total_throughput) != milli_tokens_per_second_count(r: r.output_throughput) -} - -data glm_native_wet_smoke_client_output: ClientOutputTokens = ClientOutputTokensObserved { tokens: 512 } -data glm_native_wet_smoke_duration_millis: Millisecond = millisecond(count: 22750) - -fn glm_native_wet_smoke_rate() -> DerivedRate { - derive_rate_honest( - ledger: LedgerClosed { offered: 4, completed: 4, failed: 0 }, - scrape_millis: Present { value: glm_native_wet_smoke_duration_millis }, - client_output: glm_native_wet_smoke_client_output, - ) -} - -fn glm_native_wet_smoke_is_not_sweep_c1_protocol() -> Bool { - !pinned_load_protocol_matches(a: glm_native_smoke_protocol, b: glm_native_contended_sweep_c1.protocol) -} - -fn glm_native_wet_smoke_rate_is_output_tokens() -> Bool { - match glm_native_client_rate_denomination { - RateDenominatedInTotalTokensIncludingPrefill { because: _ } => false - RateDenominatedInCompletedOutputTokens { because: _ } => - total_token_throughput_is_not_the_probe_rate(r: glm_native_wet_smoke_prefill_versus_decode) - && glm_native_wet_smoke_prefill_versus_decode.output_tokens == 512 - && glm_native_wet_smoke_prefill_versus_decode.input_tokens == 1072 - && match glm_native_wet_smoke_rate() { - RateFromClientOutputTokens { tokens: t, scrape_millis: ms } => t == 512 && millisecond_count(m: ms) == 22750 - RateUndenominable { because: _ } => false - RateUnreadable { because: _ } => false - } - } -} - -data glm_native_contended_sweep_standing: CitedFigureStanding = TranscribedUncited { - read_obligation: "re-read calm-bat-65's vllm bench serve stdout for the 256-in/128-out inf-rate ignore-eos sweep (num-prompts 4×concurrency, min 8) taken while operator long-context traffic shared Group B" as NonEmptyStr -} - -data glm_native_sweep_min_prompts: Nat = 8 - -fn glm_native_sweep_num_prompts(concurrency: Nat) -> Nat { - let fourfold = concurrency * 4 - if fourfold < glm_native_sweep_min_prompts { glm_native_sweep_min_prompts } else { fourfold } -} - -fn glm_native_contended_sweep_protocol(concurrency: Nat) -> VllmBenchServeRequest { - vllm_bench_serve_request( - backend: OpenaiChat, - base_url: "http://127.0.0.1:30000" as NonEmptyStr, - model: glm_native_concurrent_profile.served_alias, - tokenizer: glm_native_engine_tokenizer_path, - dataset: glm_native_sweep_dataset, - num_prompts: glm_native_sweep_num_prompts(concurrency: concurrency), - arrival: SendAllImmediately, - max_concurrency: Present { value: concurrency }, - ignore_eos: true, - seed: glm_native_bench_seed, - ) -} - -fn glm_native_contended_client_latency( - throughput: MilliTokensPerSecond, - tpot_milli: Nat, - ttft_milli: Nat, -) -> TranscribedClientLatency { - TranscribedClientLatency { - output_throughput: throughput, - tpot_milli: millisecond(count: tpot_milli), - itl_milli: none, - ttft_milli: millisecond(count: ttft_milli), - standing: glm_native_contended_sweep_standing, - } -} - -type ContendedSweepPoint { - concurrency: Nat - protocol: VllmBenchServeRequest - latency: TranscribedClientLatency -} - -fn glm_native_contended_sweep_point( - concurrency: Nat, - throughput: MilliTokensPerSecond, - tpot_milli: Nat, - ttft_milli: Nat, -) -> ContendedSweepPoint { - ContendedSweepPoint { - concurrency: concurrency, - protocol: glm_native_contended_sweep_protocol(concurrency: concurrency), - latency: glm_native_contended_client_latency( - throughput: throughput, - tpot_milli: tpot_milli, - ttft_milli: ttft_milli, - ), - } -} - -data glm_native_contended_sweep_c1: ContendedSweepPoint = glm_native_contended_sweep_point( - concurrency: 1, throughput: milli_tokens_per_second(count: 10860), tpot_milli: 81, ttft_milli: 1542, -) -data glm_native_contended_sweep_c2: ContendedSweepPoint = glm_native_contended_sweep_point( - concurrency: 2, throughput: milli_tokens_per_second(count: 17220), tpot_milli: 109, ttft_milli: 994, -) -data glm_native_contended_sweep_c4: ContendedSweepPoint = glm_native_contended_sweep_point( - concurrency: 4, throughput: milli_tokens_per_second(count: 25490), tpot_milli: 140, ttft_milli: 2353, -) -data glm_native_contended_sweep_c8: ContendedSweepPoint = glm_native_contended_sweep_point( - concurrency: 8, throughput: milli_tokens_per_second(count: 38360), tpot_milli: 190, ttft_milli: 2602, -) -data glm_native_contended_sweep_c16: ContendedSweepPoint = glm_native_contended_sweep_point( - concurrency: 16, throughput: milli_tokens_per_second(count: 62530), tpot_milli: 198, ttft_milli: 5218, -) - -data glm_native_contended_sweep_points: List = [ - glm_native_contended_sweep_c1, - glm_native_contended_sweep_c2, - glm_native_contended_sweep_c4, - glm_native_contended_sweep_c8, - glm_native_contended_sweep_c16, -] - -fn glm_native_sweep_ttft_c8() -> Nat { - millisecond_count(m: glm_native_contended_sweep_c8.latency.ttft_milli) -} - -fn glm_native_sweep_ttft_c16() -> Nat { - millisecond_count(m: glm_native_contended_sweep_c16.latency.ttft_milli) -} - -type WindowStandingGapSpecimen { - quieter_engine_tpot_milli: Millisecond - contended_client_c1_tpot_milli: Millisecond -} - -data glm_native_window_standing_specimen: WindowStandingGapSpecimen = WindowStandingGapSpecimen { - quieter_engine_tpot_milli: glm_native_single_stream_decode_bound_millis, - contended_client_c1_tpot_milli: millisecond(count: 81), -} - -// Same subject, same single-stream protocol shape, different window: quieter engine 48.9 ms vs -// contended client c=1 TPOT 80.7 ms. The gap is observed; its cause is unestablished until an -// overlapping lease or engine-population join attributes it. -fn window_standing_gap_is_unattributed(s: WindowStandingGapSpecimen) -> Bool { - millisecond_count(m: s.contended_client_c1_tpot_milli) > millisecond_count(m: s.quieter_engine_tpot_milli) -} - -fn bench_output_len(req: VllmBenchServeRequest) -> Nat { - token_count_value(t: req.dataset.output_len) -} - -fn pinned_load_protocol_matches(a: VllmBenchServeRequest, b: VllmBenchServeRequest) -> Bool { - vllm_bench_serve_identity_matches(a: a, b: b) - && token_count_value(t: a.dataset.input_len) == token_count_value(t: b.dataset.input_len) - && bench_output_len(req: a) == bench_output_len(req: b) - && token_count_value(t: a.dataset.prefix_len) == token_count_value(t: b.dataset.prefix_len) - && a.ignore_eos == b.ignore_eos - && a.num_prompts == b.num_prompts - && match a.max_concurrency { - Absent => - match b.max_concurrency { - Absent => true - Present { value: _ } => false - } - Present { value: ac } => - match b.max_concurrency { - Absent => false - Present { value: bc } => ac == bc - } - } -} - -type LongContextExecutionStanding - = LongContextLoadProtocolPrototype { until: NonEmptyStr } - | LongContextRunnable { because: NonEmptyStr } - -data glm_native_holistic_execution: LongContextExecutionStanding = LongContextLoadProtocolPrototype { - until: "the qualification-window law holds: exact lease and exclusion, idle drain, and a protected subject; a 100k-prefix protocol stays a prototype until that window can be established" as NonEmptyStr -} - -// TRANSCRIBED BOUND, NOT A READING. Parent derived ~10.7 GB active weights / ~9-11 ms memory-bandwidth -// floor from the checkpoint config (45 layers, hidden 4096, 288 routed experts, top-8 + 1 shared, fp8) -// and measured 48.9 ms single-stream. Until those config rows are cited, the 49 ms figure stays -// TranscribedUncited and is not consumed as a rate. -data glm_native_single_stream_decode_bound_millis: Millisecond = millisecond(count: 49) -data glm_native_single_stream_decode_bound_standing: CitedFigureStanding = TranscribedUncited { - read_obligation: "read the served GLM-5.3-Flash checkpoint config for layer count, hidden size, routed experts, top-k and shared expert, and the independent single-stream measurement this 49 ms/token bound was transcribed from; the 9-11 ms memory-bandwidth floor is a derived bound from that config, not a serving reading" as NonEmptyStr -} - // max_num_seqs is 16 on the live units (parent reverted the out-of-band 64 edit). // Runtime is glm53_derived_row (GunbcGlm53DerivedGb10); checkpoint revision is the native Flash row. data glm_native_live_subject: ServingPerformanceSubject = serving_performance_subject( @@ -1741,35 +1404,8 @@ fn glm_native_live_subject_standing() -> ServingPerformanceSubjectStanding { ) } -fn glm_native_live_runtime_is_derived_gb10_row() -> Bool { - (serving_runtime_wire(r: glm_native_live_subject.runtime) as String) == (serving_runtime_wire(r: GunbcGlm53DerivedGb10) as String) - && (glm_native_live_subject.runtime_image_reference as String) == (runtime_artifact_wire(a: glm53_derived_row.artifact) as String) -} - data glm_native_protected_subject: ProtectedSubjectField = protected_subject_field( subject: glm_native_live_subject, served_alias: glm_native_concurrent_profile.served_alias, route: vllm_route_path(r: vllm_bench_backend_route(b: glm_native_smoke_protocol.backend)), ) - -fn glm_native_observation_carries_bench_source_standing(o: ServingLoadObservation) -> Bool { - match o.bench_source_standing { - TranscribedUncited { read_obligation: a } => - match vllm_bench_serve_source_standing { - TranscribedUncited { read_obligation: b } => (a as String) == (b as String) - CitedToAuthority { authority: _ } => false - } - CitedToAuthority { authority: _ } => false - } -} - -fn holistic_protocol_is_session_shaped(req: VllmBenchServeRequest) -> Bool { - vllm_bench_serve_uses_poisson_idle_gaps(req: req) - && token_count_at_least(t: req.dataset.prefix_len, n: 100000) - && token_count_at_least(t: req.dataset.input_len, n: 10000) - && (req.model as String) != (req.tokenizer as String) -} - -fn token_count_at_least(t: TokenCount, n: Nat) -> Bool { - token_count_value(t: t) >= n -} diff --git a/dag/gunbc/spark/serving_load_probe_cli.dag b/dag/gunbc/spark/serving_load_probe_cli.dag index 73b811626d8..8647cea976b 100644 --- a/dag/gunbc/spark/serving_load_probe_cli.dag +++ b/dag/gunbc/spark/serving_load_probe_cli.dag @@ -37,7 +37,7 @@ import gunbc.spark.serving_load_probe { // // Witnesses supply metric bodies. This function drives `vllm bench serve` against the live native // GLM head. A non-idle drain REFUSES the start. An idle start is WindowIsolationNotEstablished: -// glm_native_arm_service's annotation names actors who might arrive; that is not a traffic observation. +// naming actors who might arrive (window_from_drain's annotation) is not a traffic observation. // Client facts are derived from one BenchServeExecution minted from the remote operation. // glm_native_serving_load_wet exits 0 when the observation is captured. Qualification is a // declared frontier (request start events, reserved-window lease/exclusion, interval occupancy, diff --git a/dag/test/claim/spark/serving_load_probe_witness_test.dag b/dag/test/claim/spark/serving_load_probe_witness_test.dag index 01a7e49a8ec..6391ba737ac 100644 --- a/dag/test/claim/spark/serving_load_probe_witness_test.dag +++ b/dag/test/claim/spark/serving_load_probe_witness_test.dag @@ -1,13 +1,11 @@ module test.claim.spark.serving_load_probe_witness -import std.types { Bool, String, NonEmptyStr, EpochSecs, List } -import std.nat { Nat } -import v2.std.algebra { length, filter } +import std.types { Bool, String, NonEmptyStr } import v2.std.optional { Present, Absent } import std.decimal { ExactDecimal, exact_decimal_sub, ExactDifference, ExactDifferenceUnrepresentable, ExactDifferenceOperandScaleRefused } import extdeps.prometheus.client { prometheus_sample_value_reading, SampleValueExact, SampleValueNotFinite, SampleValueUnreadable } -import std.measure { token_count, token_count_value, millisecond, millisecond_count, milli_tokens_per_second_count } -import product.capacity.lease { LeaseGrant, lease_fence_of, lease_grant, LeasePolicy, FencedResource } +import std.measure { token_count_value, millisecond, millisecond_count } +import product.capacity.lease { lease_fence_of, lease_grant, LeasePolicy, FencedResource } import product.capacity.event_chain { EventId } import gunbc.fleet_intent_network { operator_host_srv9 } import gunbc.spark.serving_rank_observe { @@ -16,69 +14,28 @@ import gunbc.spark.serving_rank_observe { import product.fabric.demand { ObservationReceiptRef } import gunbc.spark.model_snapshot_materialize { RemoteRan, RemoteUnreachable } import gunbc.spark.vllm_endpoint_process_launch { - vllm_endpoint_process_launch, VllmEndpointProcessLaunchObservation, LaunchObserved, LaunchUnobserved, + vllm_endpoint_process_launch, VllmEndpointProcessLaunchObservation, LaunchObserved, } import gunbc.harness.harness_backend { harness_queue_from_body } -import extdeps.vllm.metrics { InterTokenLatencySeconds } -import extdeps.vllm.bench_serve { - VllmBenchServeRequest, RandomDatasetSpec, OpenaiChat, SendAllImmediately, PoissonProcess, - vllm_bench_serve_request, vllm_bench_serve_arguments, vllm_bench_serve_uses_poisson_idle_gaps, - vllm_bench_serve_identity_matches, -} -import extdeps.vllm.kv_layout { AdmissionCostUnestablished, AdmissionCostBlocks } -import extdeps.external_authority { TranscribedUncited, CitedToAuthority } import gunbc.spark.serving_load_probe { - DrainObservedIdle, DrainNotIdle, - ExclusionNotEstablished, ExclusionEstablished, - WindowIsolated, WindowIsolationNotEstablished, - ForeignTrafficObserved, ForeignTrafficNotObserved, ForeignTrafficUnread, - window_from_drain, isolated_window, drain_from_queue, - ArmInService, ArmOutOfService, - OperationLedger, LedgerClosed, LedgerIncomplete, ledger_admits_token_denomination, - RateFromClientOutputTokens, RateUndenominable, RateUnreadable, - ArrivalSkewObserved, ArrivalSkewUnread, arrival_admits_rate_comparison, - TokenDeltaRead, TokenDeltaReset, TokenDeltaUnread, TokenDeltaScoped, generation_token_delta, generation_token_delta_scoped, - derive_rate_honest, serving_load_observation, serving_load_observation_text, ServingLoadObservation, tokens_per_observation_second, - foreign_work_bound, ForeignWorkBounded, ForeignWorkUnread, ForeignWorkContradiction, - occupancy_from_body, occupancy_trace_from_endpoint_scrapes, - itl_latency_delta, iteration_tokens_booked_delta, - LatencyHistogramRead, LatencyHistogramUnread, LatencyHistogramReset, - TokenHistogramRead, TokenHistogramUnread, TokenHistogramReset, - glm_native_holistic_protocol, holistic_protocol_is_session_shaped, - glm_native_live_subject_standing, counter_continuity, SameExporter, ExporterChanged, ContinuityUnread, - OccupancyBoundariesRead, OccupancyBoundariesUnread, OccupancySample, - glm_native_sweep_ttft_c8, glm_native_sweep_ttft_c16, - ClientOutputTokensUnread, ClientOutputTokensObserved, - ClientBenchLatencyUnread, ClientBenchLatencyReported, - glm_native_workload_admission, - glm_native_single_stream_decode_bound_millis, - glm_native_single_stream_decode_bound_standing, - glm_native_engine_tokenizer_path, - glm_native_live_probe_provenance, DriverObserverSplit, SamePrincipal, - glm_native_smoke_protocol, glm_native_smoke_client_latency, - glm_native_arm_service, - decode_corroboration_for_protocol, CorroborationNotApplicable, CorroborationUnread, - glm_native_wiring_smoke_protocol, glm_native_contended_sweep_c1, glm_native_contended_sweep_c2, - glm_native_contended_sweep_c16, glm_native_contended_sweep_points, - - glm_native_wet_smoke_is_not_sweep_c1_protocol, glm_native_wet_smoke_rate_is_output_tokens, - glm_native_window_standing_specimen, window_standing_gap_is_unattributed, - SuccessfulClientRequestSecondBucketPeak, - ClientItlDistributionObserved, ClientItlDistributionUnread, client_itl_text, client_bucket_peak_text, - ledger_from_bench_stdout, client_output_from_bench_stdout, scrape_millis_from_bench_stdout, - client_itl_from_bench_stdout, client_bucket_peak_from_bench_stdout, - ClientOutputTokensObserved, - pinned_load_protocol_matches, bench_output_len, glm_native_sweep_num_prompts, - glm_native_holistic_execution, LongContextLoadProtocolPrototype, LongContextRunnable, - glm_native_live_runtime_is_derived_gb10_row, - glm_native_protected_subject, protected_subject_key, - bench_serve_from_remote, BenchServeRan, BenchServeUnreachable, BenchServeExecution, - mixed_run_client_facts_cannot_be_written, nonzero_exit_does_not_yield_client_facts, - unreachable_does_not_yield_client_facts, stderr_is_not_the_client_summary, - glm_native_observation_carries_bench_source_standing, - observation_evidence_replays_client_facts, glm_native_qualification_frontier, - qualification_frontier_requires_serve_py_digest, -} + DrainObservedIdle, DrainNotIdle, ExclusionNotEstablished, ExclusionEstablished, WindowIsolated, + WindowIsolationNotEstablished, ForeignTrafficObserved, ForeignTrafficNotObserved, ForeignTrafficUnread, window_from_drain, + isolated_window, drain_from_queue, OperationLedger, LedgerClosed, LedgerIncomplete, + ledger_admits_token_denomination, RateFromClientOutputTokens, RateUndenominable, RateUnreadable, ArrivalSkewUnread, + arrival_admits_rate_comparison, TokenDeltaRead, TokenDeltaReset, TokenDeltaUnread, TokenDeltaScoped, + generation_token_delta, generation_token_delta_scoped, derive_rate_honest, serving_load_observation, serving_load_observation_text, + ServingLoadObservation, tokens_per_observation_second, foreign_work_bound, ForeignWorkBounded, ForeignWorkUnread, + ForeignWorkContradiction, occupancy_from_body, occupancy_trace_from_endpoint_scrapes, itl_latency_delta, iteration_tokens_booked_delta, + LatencyHistogramRead, LatencyHistogramUnread, LatencyHistogramReset, TokenHistogramRead, TokenHistogramUnread, + TokenHistogramReset, glm_native_live_subject_standing, counter_continuity, SameExporter, ExporterChanged, + ContinuityUnread, ClientOutputTokensUnread, ClientOutputTokensObserved, glm_native_smoke_protocol, decode_corroboration_for_protocol, + CorroborationNotApplicable, CorroborationUnread, SuccessfulClientRequestSecondBucketPeak, ClientItlDistributionObserved, ClientItlDistributionUnread, + client_itl_text, client_bucket_peak_text, ledger_from_bench_stdout, client_output_from_bench_stdout, scrape_millis_from_bench_stdout, + client_itl_from_bench_stdout, client_bucket_peak_from_bench_stdout, glm_native_protected_subject, protected_subject_key, bench_serve_from_remote, + BenchServeExecution, bench_serve_completed_output, glm_native_live_subject, arrival_text, + ArrivalSkewObserved, +} +import gunbc.spark.serving_performance_subject { serving_subject_standing, ServingPerformanceSubjectStanding } data start_field: NonEmptyStr = "1789300000.12" as NonEmptyStr @@ -310,8 +267,12 @@ fn fx_bench_receipt(stdout: String) -> BenchServeExecution { } fn fx_obs() -> ServingLoadObservation { + fx_obs_for(subject: glm_native_live_subject_standing()) +} + +fn fx_obs_for(subject: ServingPerformanceSubjectStanding) -> ServingLoadObservation { serving_load_observation( - subject: glm_native_live_subject_standing(), + subject: subject, window: window_from_drain(drain: DrainObservedIdle), continuity: counter_continuity(before: fx_launch(), after: fx_launch()), occupancy: occupancy_trace_from_endpoint_scrapes(before_body: fx_idle, after_body: fx_after), @@ -335,18 +296,6 @@ test fn generation_tokens_without_client_completions_is_foreign_load() -> Bool { } } -test fn occupancy_above_declared_concurrency_does_not_refuse_the_client_rate() -> Bool { - match derive_rate_honest( - ledger: closed_ok(), - scrape_millis: Present { value: millisecond(count: 2000) }, - client_output: ClientOutputTokensObserved { tokens: 128 }, - ) { - RateFromClientOutputTokens { tokens: t, scrape_millis: _ } => t == 128 - RateUnreadable { because: _ } => false - RateUndenominable { because: _ } => false - } -} - test fn unread_client_output_tokens_refuse_the_rate() -> Bool { match derive_rate_honest( ledger: closed_ok(), @@ -377,29 +326,6 @@ test fn extra_engine_tokens_bound_foreign_work_and_keep_the_client_rate() -> Boo } } -test fn unsampled_occupancy_does_not_refuse_the_client_rate() -> Bool { - match derive_rate_honest( - ledger: closed_ok(), - scrape_millis: Present { value: millisecond(count: 2000) }, - client_output: ClientOutputTokensObserved { tokens: 128 }, - ) { - RateFromClientOutputTokens { tokens: t, scrape_millis: _ } => t == 128 - RateUnreadable { because: _ } => false - RateUndenominable { because: _ } => false - } -} - -test fn a_long_context_protocol_does_not_mint_an_admission_ceiling() -> Bool { - match glm_native_workload_admission { - AdmissionCostUnestablished { cause: _ } => - match fx_obs().admission { - AdmissionCostUnestablished { cause: _ } => true - AdmissionCostBlocks { blocks: _ } => false - } - AdmissionCostBlocks { blocks: _ } => false - } -} - test fn client_output_exceeding_engine_generation_is_a_contradiction() -> Bool { match foreign_work_bound(generation: TokenDeltaRead { tokens: 100 }, client_output: ClientOutputTokensObserved { tokens: 512 }) { ForeignWorkContradiction { engine_generation: g, client_output: c, because: _ } => g == 100 && c == 512 @@ -493,35 +419,13 @@ test fn a_sudo_password_prompt_line_does_not_spoil_the_bench_ledger() -> Bool { } } -test fn the_holistic_protocol_does_not_corroborate_the_single_stream_bound() -> Bool { - match decode_corroboration_for_protocol(req: glm_native_holistic_protocol) { - CorroborationNotApplicable { because: _ } => - millisecond_count(m: glm_native_single_stream_decode_bound_millis) == 49 - && match glm_native_single_stream_decode_bound_standing { - TranscribedUncited { read_obligation: _ } => true - CitedToAuthority { authority: _ } => false - } +test fn a_multi_stream_protocol_does_not_corroborate_the_single_stream_bound() -> Bool { + match decode_corroboration_for_protocol(req: glm_native_smoke_protocol) { + CorroborationNotApplicable { because: _ } => true CorroborationUnread { because: _ } => false } } -test fn the_smoke_protocol_is_not_the_holistic_envelope() -> Bool { - !holistic_protocol_is_session_shaped(req: glm_native_smoke_protocol) - && !vllm_bench_serve_uses_poisson_idle_gaps(req: glm_native_smoke_protocol) - && millisecond_count(m: glm_native_smoke_client_latency.tpot_milli) == 82 -} - -test fn a_64_out_wiring_receipt_is_not_the_128_out_sweep_protocol() -> Bool { - bench_output_len(req: glm_native_wiring_smoke_protocol) == 64 - && bench_output_len(req: glm_native_contended_sweep_c2.protocol) == 128 - && !pinned_load_protocol_matches(a: glm_native_wiring_smoke_protocol, b: glm_native_contended_sweep_c2.protocol) -} - -test fn protocol_identity_includes_backend_model_tokenizer_and_arrival() -> Bool { - vllm_bench_serve_identity_matches(a: glm_native_smoke_protocol, b: glm_native_wiring_smoke_protocol) - && !vllm_bench_serve_identity_matches(a: glm_native_smoke_protocol, b: glm_native_holistic_protocol) -} - data fx_bench_stdout: String = join([ "============ Serving Benchmark Result ============\n", "Successful requests: 4\n", @@ -543,14 +447,6 @@ data fx_bench_stdout: String = join([ "P99 ITL (ms): 165.00\n", ], "") -data fx_bench_stdout_short: String = join([ - "============ Serving Benchmark Result ============\n", - "Successful requests: 4\n", - "Failed requests: 0\n", - "Benchmark duration (s): 10.00\n", - "Total generated tokens: 512\n", -], "") - test fn parsed_itl_distribution_does_not_establish_a_cause() -> Bool { let d = client_itl_from_bench_stdout(body: fx_bench_stdout) match d { @@ -577,86 +473,6 @@ test fn ledger_and_rate_come_from_bench_stdout_not_exit_ok() -> Bool { } } -test fn wet_smoke_tpot_is_not_a_protocol_match_to_sweep_c1() -> Bool { - glm_native_wet_smoke_is_not_sweep_c1_protocol() -} - -test fn the_probe_rate_is_completed_output_tokens_not_total_including_prefill() -> Bool { - glm_native_wet_smoke_rate_is_output_tokens() -} - -test fn the_contended_sweep_is_five_shared_window_client_points() -> Bool { - length(glm_native_contended_sweep_points) == 5 - && glm_native_sweep_num_prompts(concurrency: 1) == 8 - && glm_native_sweep_num_prompts(concurrency: 2) == 8 - && glm_native_sweep_num_prompts(concurrency: 4) == 16 - && milli_tokens_per_second_count(r: glm_native_contended_sweep_c1.latency.output_throughput) == 10860 - && millisecond_count(m: glm_native_contended_sweep_c1.latency.tpot_milli) == 81 - && millisecond_count(m: glm_native_contended_sweep_c1.latency.ttft_milli) == 1542 - && glm_native_contended_sweep_c1.concurrency == 1 -} - -test fn ttft_c8_and_c16_remain_primitive_observations() -> Bool { - glm_native_sweep_ttft_c8() == 2602 && glm_native_sweep_ttft_c16() == 5218 -} - -test fn the_49_vs_81_ms_gap_is_why_window_standing_is_a_field() -> Bool { - millisecond_count(m: glm_native_window_standing_specimen.quieter_engine_tpot_milli) == 49 - && millisecond_count(m: glm_native_window_standing_specimen.contended_client_c1_tpot_milli) == 81 - && window_standing_gap_is_unattributed(s: glm_native_window_standing_specimen) -} - -test fn long_context_stays_a_prototype_until_the_qualification_window() -> Bool { - match glm_native_holistic_execution { - LongContextLoadProtocolPrototype { until: u } => - string_contains(s: u as String, pattern: "qualification-window") - LongContextRunnable { because: _ } => false - } -} - -test fn the_holistic_protocol_is_poisson_with_session_context_and_prefix() -> Bool { - holistic_protocol_is_session_shaped(req: glm_native_holistic_protocol) - && vllm_bench_serve_uses_poisson_idle_gaps(req: glm_native_holistic_protocol) - && !vllm_bench_serve_uses_poisson_idle_gaps(req: vllm_bench_serve_request( - backend: OpenaiChat, - base_url: "http://127.0.0.1:30000" as NonEmptyStr, - model: "m" as NonEmptyStr, - tokenizer: "m" as NonEmptyStr, - dataset: RandomDatasetSpec { input_len: token_count(count: 128), output_len: token_count(count: 128), prefix_len: token_count(count: 0) }, - num_prompts: 4, - arrival: SendAllImmediately, - max_concurrency: Absent, - ignore_eos: true, - seed: 20260918, - )) -} - -fn words_contain(words: List, needle: String) -> Bool { - count(filter(words, w => w == needle)) > 0 -} - -test fn the_rendered_argv_carries_the_prefix_and_a_finite_rate() -> Bool { - let words = vllm_bench_serve_arguments(req: glm_native_holistic_protocol) - words_contain(words: words, needle: "--random-prefix-len") - && words_contain(words: words, needle: "100000") - && words_contain(words: words, needle: "--request-rate") - && words_contain(words: words, needle: "0.050") - && !words_contain(words: words, needle: "inf") - && words_contain(words: words, needle: "--tokenizer") - && words_contain(words: words, needle: glm_native_engine_tokenizer_path as String) - && words_contain(words: words, needle: "--model") - && words_contain(words: words, needle: "--seed") - && words_contain(words: words, needle: "20260918") - && (glm_native_holistic_protocol.model as String) != (glm_native_holistic_protocol.tokenizer as String) -} - -test fn this_reading_names_a_split_driver_and_observer() -> Bool { - match glm_native_live_probe_provenance { - DriverObserverSplit { driver: _, observer: _ } => true - SamePrincipal { principal: _ } => false - } -} - test fn exporter_restart_breaks_counter_continuity() -> Bool { let after: VllmEndpointProcessLaunchObservation = LaunchObserved { launch: vllm_endpoint_process_launch(group: FabricGroupB, endpoint: "192.168.1.236:30000" as NonEmptyStr, process_start_field: "1789300999.00" as NonEmptyStr), @@ -669,56 +485,43 @@ test fn exporter_restart_breaks_counter_continuity() -> Bool { } } -test fn mixing_two_bench_stdout_bodies_cannot_write_one_receipt() -> Bool { - mixed_run_client_facts_cannot_be_written( - a: fx_bench_receipt(stdout: fx_bench_stdout), - b: fx_bench_receipt(stdout: fx_bench_stdout_short), - ) -} - -test fn live_subject_consumes_the_derived_gb10_runtime_row() -> Bool { - glm_native_live_runtime_is_derived_gb10_row() +fn client_output_is_unread(e: BenchServeExecution) -> Bool { + match bench_serve_completed_output(e: e) { + ClientOutputTokensUnread { cause: _ } => true + ClientOutputTokensObserved { tokens: _ } => false + } } test fn a_nonzero_bench_exit_does_not_parse_stdout() -> Bool { - nonzero_exit_does_not_yield_client_facts(e: bench_serve_from_remote( + client_output_is_unread(e: bench_serve_from_remote( protocol: glm_native_smoke_protocol, remote: RemoteRan { exit_code: 1, stdout: fx_bench_stdout, stderr: "" }, )) + && !client_output_is_unread(e: fx_bench_receipt(stdout: fx_bench_stdout)) } test fn an_unreachable_bench_does_not_parse_stdout() -> Bool { - unreachable_does_not_yield_client_facts(e: bench_serve_from_remote( + client_output_is_unread(e: bench_serve_from_remote( protocol: glm_native_smoke_protocol, remote: RemoteUnreachable { cause: "ssh refused" }, )) } test fn stderr_carrying_the_summary_is_not_parsed() -> Bool { - stderr_is_not_the_client_summary(e: bench_serve_from_remote( + client_output_is_unread(e: bench_serve_from_remote( protocol: glm_native_smoke_protocol, remote: RemoteRan { exit_code: 0, stdout: "", stderr: fx_bench_stdout }, )) } -test fn the_observation_carries_bench_source_standing() -> Bool { - glm_native_observation_carries_bench_source_standing(o: fx_obs()) -} - test fn the_receipt_persists_raw_evidence_for_replay() -> Bool { - let obs = fx_obs() - let text = serving_load_observation_text(o: obs) - observation_evidence_replays_client_facts(o: obs) - && string_contains(s: text, pattern: "--- metrics-before digest=") + let text = serving_load_observation_text(o: fx_obs()) + string_contains(s: text, pattern: "--- metrics-before digest=") && string_contains(s: text, pattern: "--- bench-stdout digest=") && string_contains(s: text, pattern: "vllm:num_requests_running") && string_contains(s: text, pattern: "Total generated tokens") } -test fn qualification_frontier_names_the_producers() -> Bool { - qualification_frontier_requires_serve_py_digest(f: glm_native_qualification_frontier) -} - test fn a_latency_sum_decrease_within_one_millisecond_is_a_reset_not_zero() -> Bool { let before = metrics_body(running: "0.0", waiting: "0.0", capacity: "0.0", preempt: "0.0", itl_sum: "100.0009", itl_count: "10.0", itok_sum: "100.0", itok_count: "10.0", gen: "1000.0", start: "1789300000.12") let after = metrics_body(running: "0.0", waiting: "0.0", capacity: "0.0", preempt: "0.0", itl_sum: "100.0001", itl_count: "10.0", itok_sum: "100.0", itok_count: "10.0", gen: "1000.0", start: "1789300000.12") @@ -817,3 +620,35 @@ test fn the_receipt_bucket_line_prints_the_parsed_peak_not_a_verdict() -> Bool { && !string_contains(s: t, pattern: "foreign") && string_contains(s: client_bucket_peak_text(p: SuccessfulClientRequestSecondBucketPeak { client_max_concurrency: 2, bucket_peak: 7 }), pattern: "successful_request_second_bucket_peak=7 ") } + +fn fx_partial_subject(would_settle: String) -> ServingPerformanceSubjectStanding { + serving_subject_standing( + subject: glm_native_live_subject, + believed: "transport is probably NCCL over RoCE" as NonEmptyStr, + would_settle: would_settle as NonEmptyStr, + ) +} + +test fn receipts_differing_only_in_the_settling_obligation_differ() -> Bool { + let a = serving_load_observation_text(o: fx_obs_for(subject: fx_partial_subject(would_settle: "read obligation alpha"))) + let b = serving_load_observation_text(o: fx_obs_for(subject: fx_partial_subject(would_settle: "read obligation beta"))) + a != b + && string_contains(s: a, pattern: "would_settle=read obligation alpha") + && !string_contains(s: a, pattern: "read obligation beta") + && string_contains(s: b, pattern: "would_settle=read obligation beta") + && !string_contains(s: b, pattern: "read obligation alpha") +} + +test fn the_live_subject_receipt_carries_the_nccl_announcement_obligation() -> Bool { + let t = serving_load_observation_text(o: fx_obs()) + string_contains(s: t, pattern: "subject: partial ") + && string_contains(s: t, pattern: "would_settle=read the running launch's NCCL transport announcement on this incarnation") +} + +test fn arrival_unread_and_observed_render_distinguishably() -> Bool { + let t = serving_load_observation_text(o: fx_obs()) + let observed = arrival_text(a: ArrivalSkewObserved { max_stagger_millis: millisecond(count: 250) }) + string_contains(s: t, pattern: "arrival: unread ") + && string_contains(s: observed, pattern: "observed max_stagger_ms=250") + && !string_contains(s: observed, pattern: "unread") +} From 0f6205fbccd6579c52954964f08fd901b7285d3c Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sat, 19 Sep 2026 09:57:21 +0000 Subject: [PATCH 34/43] serving-load: replay the retained stdout against its execution at the witness boundary; delete callerless bench_serve helpers Side-chat hold 5255233165. The audit deleted observation_evidence_replays_client_facts, the one control relating retained bench stdout to the execution it came from. It returns as witnesses, not a production Bool: distinct before/after/stdout/stderr bodies land in their own sections with digests from std.content_hash, the retained stdout replays the execution's interval and output tokens, and a truncated retained stdout does not. extdeps.vllm.bench_serve vllm_bench_serve_identity_matches, vllm_bench_backend_eq, vllm_bench_arrival_eq and vllm_bench_serve_uses_poisson_idle_gaps lost their only consumers in the audit and are deleted. Co-Authored-By: Claude Opus 5 (1M context) --- dag/extdeps/vllm/bench_serve.dag | 36 ------------ .../spark/serving_load_probe_witness_test.dag | 57 ++++++++++++++++++- 2 files changed, 56 insertions(+), 37 deletions(-) diff --git a/dag/extdeps/vllm/bench_serve.dag b/dag/extdeps/vllm/bench_serve.dag index 51bfe8ea9c3..47503dfcb86 100644 --- a/dag/extdeps/vllm/bench_serve.dag +++ b/dag/extdeps/vllm/bench_serve.dag @@ -142,35 +142,6 @@ fn vllm_bench_eos_words(ignore: Bool) -> List { if ignore { ["--ignore-eos"] } else { [] } } -fn vllm_bench_backend_eq(a: VllmBenchBackend, b: VllmBenchBackend) -> Bool { - (vllm_bench_backend_wire(b: a) as String) == (vllm_bench_backend_wire(b: b) as String) -} - -fn vllm_bench_arrival_eq(a: BenchArrival, b: BenchArrival) -> Bool { - match a { - SendAllImmediately => - match b { - SendAllImmediately => true - PoissonProcess { request_rate: _, burstiness: _ } => false - } - PoissonProcess { request_rate: an, burstiness: ab } => - match b { - SendAllImmediately => false - PoissonProcess { request_rate: bn, burstiness: bb } => - milli_requests_per_second_count(r: an) == milli_requests_per_second_count(r: bn) - && measure_count(ab) == measure_count(bb) - } - } -} - -fn vllm_bench_serve_identity_matches(a: VllmBenchServeRequest, b: VllmBenchServeRequest) -> Bool { - vllm_bench_backend_eq(a: a.backend, b: b.backend) - && (a.model as String) == (b.model as String) - && (a.tokenizer as String) == (b.tokenizer as String) - && vllm_bench_arrival_eq(a: a.arrival, b: b.arrival) - && a.seed == b.seed -} - // THE ARGV IS DERIVED FROM THE REQUEST, so a protocol that asked for Poisson arrivals cannot // silently render `inf`, and a protocol that named a shared prefix cannot drop `--random-prefix-len`. // SERVED NAME AND TOKENIZER IDENTITY ARE DIFFERENT FACTS. --model is what the OpenAI route answers; @@ -200,10 +171,3 @@ fn vllm_bench_serve_arguments(req: VllmBenchServeRequest) -> List { ) } -fn vllm_bench_serve_uses_poisson_idle_gaps(req: VllmBenchServeRequest) -> Bool { - match req.arrival { - SendAllImmediately => false - PoissonProcess { request_rate: n, burstiness: b } => - milli_requests_per_second_count(r: n) > 0 && measure_count(b) == 1000 - } -} diff --git a/dag/test/claim/spark/serving_load_probe_witness_test.dag b/dag/test/claim/spark/serving_load_probe_witness_test.dag index 6391ba737ac..91e435c9a0e 100644 --- a/dag/test/claim/spark/serving_load_probe_witness_test.dag +++ b/dag/test/claim/spark/serving_load_probe_witness_test.dag @@ -2,6 +2,7 @@ module test.claim.spark.serving_load_probe_witness import std.types { Bool, String, NonEmptyStr } import v2.std.optional { Present, Absent } +import std.content_hash { content_hash_of_value, serialize_content_hash } import std.decimal { ExactDecimal, exact_decimal_sub, ExactDifference, ExactDifferenceUnrepresentable, ExactDifferenceOperandScaleRefused } import extdeps.prometheus.client { prometheus_sample_value_reading, SampleValueExact, SampleValueNotFinite, SampleValueUnreadable } import std.measure { token_count_value, millisecond, millisecond_count } @@ -32,7 +33,7 @@ import gunbc.spark.serving_load_probe { CorroborationNotApplicable, CorroborationUnread, SuccessfulClientRequestSecondBucketPeak, ClientItlDistributionObserved, ClientItlDistributionUnread, client_itl_text, client_bucket_peak_text, ledger_from_bench_stdout, client_output_from_bench_stdout, scrape_millis_from_bench_stdout, client_itl_from_bench_stdout, client_bucket_peak_from_bench_stdout, glm_native_protected_subject, protected_subject_key, bench_serve_from_remote, - BenchServeExecution, bench_serve_completed_output, glm_native_live_subject, arrival_text, + BenchServeExecution, bench_serve_interval, bench_serve_completed_output, glm_native_live_subject, arrival_text, ArrivalSkewObserved, } import gunbc.spark.serving_performance_subject { serving_subject_standing, ServingPerformanceSubjectStanding } @@ -652,3 +653,57 @@ test fn arrival_unread_and_observed_render_distinguishably() -> Bool { && string_contains(s: observed, pattern: "observed max_stagger_ms=250") && !string_contains(s: observed, pattern: "unread") } + +fn retained_stdout_replays_the_execution(e: BenchServeExecution, retained: String) -> Bool { + match bench_serve_interval(e: e) { + Absent => false + Present { value: ia } => + match scrape_millis_from_bench_stdout(body: retained) { + Absent => false + Present { value: ib } => + millisecond_count(m: ia) == millisecond_count(m: ib) + && match bench_serve_completed_output(e: e) { + ClientOutputTokensUnread { cause: _ } => false + ClientOutputTokensObserved { tokens: a } => + match client_output_from_bench_stdout(body: retained) { + ClientOutputTokensUnread { cause: _ } => false + ClientOutputTokensObserved { tokens: b } => a == b + } + } + } + } +} + +fn digest_of(kind: String, body: String) -> String { + serialize_content_hash(hash: content_hash_of_value(value: join([kind, "\n", body], "") as NonEmptyStr)) as String +} + +test fn the_retained_evidence_is_the_execution_it_was_captured_from() -> Bool { + let stderr = "fixture stderr diagnostic" + let bench = bench_serve_from_remote(protocol: glm_native_smoke_protocol, remote: RemoteRan { exit_code: 0, stdout: fx_bench_stdout, stderr: stderr }) + let obs = serving_load_observation( + subject: glm_native_live_subject_standing(), + window: window_from_drain(drain: DrainObservedIdle), + continuity: counter_continuity(before: fx_launch(), after: fx_launch()), + occupancy: occupancy_trace_from_endpoint_scrapes(before_body: fx_idle, after_body: fx_after), + before_body: fx_idle, + after_body: fx_after, + before_incarnation: fx_same_incarnation(), + after_incarnation: fx_same_incarnation(), + bench: bench, + ) + let ev = obs.evidence + ev.metrics_before.body == fx_idle + && ev.metrics_after.body == fx_after + && ev.bench_stdout.body == fx_bench_stdout + && ev.bench_stderr.body == stderr + && (serialize_content_hash(hash: ev.bench_stdout.digest) as String) == digest_of(kind: "bench-stdout", body: fx_bench_stdout) + && (serialize_content_hash(hash: ev.metrics_before.digest) as String) == digest_of(kind: "metrics-before", body: fx_idle) + && retained_stdout_replays_the_execution(e: obs.execution, retained: ev.bench_stdout.body) +} + +test fn a_truncated_retained_stdout_does_not_replay_the_execution() -> Bool { + let bench = fx_bench_receipt(stdout: fx_bench_stdout) + retained_stdout_replays_the_execution(e: bench, retained: fx_bench_stdout) + && !retained_stdout_replays_the_execution(e: bench, retained: "Total generated tokens: 512\n") +} From d775e07a638bdb9710945f0b50361c43b148e1cb Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sat, 19 Sep 2026 10:08:30 +0000 Subject: [PATCH 35/43] serving-load: milli projections are checked and exact; ArrivalSkew reads BenchArrival directly Review 68341. milli_from_exact now rescales through std.decimal checked_decimal_rescale and refuses a nonzero digit past the third decimal instead of truncating, so a counter like generation_tokens_total cannot be understated into the foreign-work bound. The one intentional floor, the ITL latency sum, is its own named milli_floor_from_exact (scaling up still checked). ArrivalPolicy duplicated extdeps.vllm.bench_serve BenchArrival; it is deleted and arrival_from_protocol matches req.arrival. Co-Authored-By: Claude Opus 5 (1M context) --- dag/gunbc/spark/serving_load_probe.dag | 56 +++++++++++-------- .../spark/serving_load_probe_witness_test.dag | 22 ++++++++ 2 files changed, 54 insertions(+), 24 deletions(-) diff --git a/dag/gunbc/spark/serving_load_probe.dag b/dag/gunbc/spark/serving_load_probe.dag index 5e7d1de864e..fdba81ec501 100644 --- a/dag/gunbc/spark/serving_load_probe.dag +++ b/dag/gunbc/spark/serving_load_probe.dag @@ -3,10 +3,10 @@ module gunbc.spark.serving_load_probe import std.types { Bool, String, NonEmptyStr, EpochSecs, Int } import std.nat { Nat } import std.measure { - Millisecond, millisecond, millisecond_count, TokenCount, token_count, token_count_value, Measure, Dimensionless, Milli, MilliTokensPerSecond, milli_tokens_per_second, milli_tokens_per_second_count, MilliRequestsPerSecond, + Millisecond, millisecond, millisecond_count, TokenCount, token_count, token_count_value, MilliTokensPerSecond, milli_tokens_per_second, milli_tokens_per_second_count, } -import std.decimal { ExactDecimal, canonical_exact_decimal, decimal_pow10, exact_decimal_sub, ExactDifference, ExactDifferenceUnrepresentable, ExactDifferenceOperandScaleRefused } -import std.checked_arithmetic { checked_int_magnitude, CheckedNatReady, CheckedNatOverflow } +import std.decimal { ExactDecimal, canonical_exact_decimal, decimal_pow10, checked_decimal_rescale, exact_decimal_sub, ExactDifference, ExactDifferenceUnrepresentable, ExactDifferenceOperandScaleRefused } +import std.checked_arithmetic { checked_int_magnitude, CheckedNatReady, CheckedNatOverflow, CheckedIntReady, CheckedIntOverflow } import v2.std.optional { Present, Absent } import std.content_hash { ContentHash, content_hash_of_value, serialize_content_hash } import product.capacity.lease { LeaseGrant } @@ -250,16 +250,36 @@ fn nat_from_nonneg_int(n: Int) -> Nat? { } } +// EXACT THOUSANDTHS OR NOTHING. Scaling up goes through std.decimal checked_decimal_rescale, so an +// overflow refuses rather than wrapping; a value with a nonzero digit past the third decimal refuses +// rather than truncating. Counters and bench figures read through this may not lose precision. fn milli_from_exact(d: ExactDecimal) -> Nat? { let c = canonical_exact_decimal(d: d) if c.units < 0 { none } else if c.fraction_digits > 3 { - let extra = c.fraction_digits - 3 - nat_from_nonneg_int(n: c.units / decimal_pow10(exponent: extra)) + none } else { - let scaled = c.units * decimal_pow10(exponent: 3 - c.fraction_digits) - nat_from_nonneg_int(n: scaled) + match checked_decimal_rescale(units: c.units, by: 3 - c.fraction_digits) { + CheckedIntReady { value: scaled } => nat_from_nonneg_int(n: scaled) + CheckedIntOverflow { cause: _ } => none + } + } +} + +// WHOLE MILLISECONDS, FLOORED ON PURPOSE. A latency sum carries sub-millisecond digits the receipt +// does not keep; flooring is the declared projection here, and only here. Scaling up is still checked. +fn milli_floor_from_exact(d: ExactDecimal) -> Nat? { + let c = canonical_exact_decimal(d: d) + if c.units < 0 { + none + } else if c.fraction_digits > 3 { + nat_from_nonneg_int(n: c.units / decimal_pow10(exponent: c.fraction_digits - 3)) + } else { + match checked_decimal_rescale(units: c.units, by: 3 - c.fraction_digits) { + CheckedIntReady { value: scaled } => nat_from_nonneg_int(n: scaled) + CheckedIntOverflow { cause: _ } => none + } } } @@ -359,7 +379,7 @@ type TokenHistogramDelta fn itl_latency_delta(before_body: String, after_body: String) -> LatencyHistogramDelta { match histogram_delta(before_body: before_body, after_body: after_body, metric: InterTokenLatencySeconds) { HistogramDeltaRead { sum: s, count: c } => - match milli_from_exact(d: s) { + match milli_floor_from_exact(d: s) { Absent => LatencyHistogramUnread { cause: "inter-token latency sum delta did not project to milliseconds" as NonEmptyStr } Present { value: ms } => LatencyHistogramRead { sum: millisecond(count: ms), observations: c } } @@ -485,23 +505,11 @@ type ArrivalSkew = ArrivalSkewObserved { max_stagger_millis: Millisecond } | ArrivalSkewUnread { cause: NonEmptyStr } -type ArrivalPolicy - = ArrivalPolicySendAll - | ArrivalPolicyPoisson { request_rate: MilliRequestsPerSecond, burstiness: Measure } - -fn arrival_policy_from_request(req: VllmBenchServeRequest) -> ArrivalPolicy { - match req.arrival { - SendAllImmediately => ArrivalPolicySendAll - PoissonProcess { request_rate: n, burstiness: b } => - ArrivalPolicyPoisson { request_rate: n, burstiness: b } - } -} - fn arrival_from_protocol(req: VllmBenchServeRequest) -> ArrivalSkew { - match arrival_policy_from_request(req: req) { - ArrivalPolicySendAll => - ArrivalSkewUnread { cause: "ArrivalPolicySendAll is input policy, not observed skew; vLLM's max_concurrency semaphore can run prompts in waves, and per-request start times were not retained" as NonEmptyStr } - ArrivalPolicyPoisson { request_rate: _, burstiness: _ } => + match req.arrival { + SendAllImmediately => + ArrivalSkewUnread { cause: "SendAllImmediately is input policy, not observed skew; vLLM's max_concurrency semaphore can run prompts in waves, and per-request start times were not retained" as NonEmptyStr } + PoissonProcess { request_rate: _, burstiness: _ } => ArrivalSkewUnread { cause: "Poisson starts are not parsed from vllm bench serve stdout until per-request start_times are retained" as NonEmptyStr } } } diff --git a/dag/test/claim/spark/serving_load_probe_witness_test.dag b/dag/test/claim/spark/serving_load_probe_witness_test.dag index 91e435c9a0e..47a4bbd42a4 100644 --- a/dag/test/claim/spark/serving_load_probe_witness_test.dag +++ b/dag/test/claim/spark/serving_load_probe_witness_test.dag @@ -707,3 +707,25 @@ test fn a_truncated_retained_stdout_does_not_replay_the_execution() -> Bool { retained_stdout_replays_the_execution(e: bench, retained: fx_bench_stdout) && !retained_stdout_replays_the_execution(e: bench, retained: "Total generated tokens: 512\n") } + +test fn a_counter_with_a_fourth_decimal_digit_is_unread_not_truncated() -> Bool { + let before = metrics_body(running: "0.0", waiting: "0.0", capacity: "0.0", preempt: "0.0", itl_sum: "1.0", itl_count: "10.0", itok_sum: "100.0", itok_count: "10.0", gen: "1000.0", start: "1789300000.12") + let after = metrics_body(running: "0.0", waiting: "0.0", capacity: "0.0", preempt: "0.0", itl_sum: "1.5", itl_count: "15.0", itok_sum: "110.0", itok_count: "12.0", gen: "1512.0005", start: "1789300000.12") + match generation_token_delta(before_body: before, after_body: after) { + TokenDeltaUnread { cause: _ } => true + TokenDeltaRead { tokens: _ } => false + TokenDeltaScoped { tokens: _, incarnation: _ } => false + TokenDeltaReset { cause: _ } => false + } +} + +test fn a_whole_counter_delta_still_reads_after_the_exactness_change() -> Bool { + let before = metrics_body(running: "0.0", waiting: "0.0", capacity: "0.0", preempt: "0.0", itl_sum: "1.0", itl_count: "10.0", itok_sum: "100.0", itok_count: "10.0", gen: "1000.0", start: "1789300000.12") + let after = metrics_body(running: "0.0", waiting: "0.0", capacity: "0.0", preempt: "0.0", itl_sum: "1.5", itl_count: "15.0", itok_sum: "110.0", itok_count: "12.0", gen: "1512.0", start: "1789300000.12") + match generation_token_delta(before_body: before, after_body: after) { + TokenDeltaRead { tokens: t } => t == 512 + TokenDeltaUnread { cause: _ } => false + TokenDeltaScoped { tokens: _, incarnation: _ } => false + TokenDeltaReset { cause: _ } => false + } +} From 135306060caac73463d645ee707313e1c83dc4d7 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sat, 19 Sep 2026 10:48:18 +0000 Subject: [PATCH 36/43] serving-load: delete the dead arrival comparison gate; name the producer instead of transcribing decode figures Review 68367. arrival_admits_rate_comparison and its 250 ms bound had no production consumer and could only ever see ArrivalSkewUnread; they and their witness are removed. The decode-corroboration annotation and refusal strings quoted 49 / 48.9 / 81 ms; they now name glm_native_serving_load_wet at max_concurrency=1 as the producer of a single-stream decode figure (DESIGN section 6). Co-Authored-By: Claude Opus 5 (1M context) --- dag/gunbc/spark/serving_load_probe.dag | 19 +++++-------------- .../spark/serving_load_probe_witness_test.dag | 6 +----- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/dag/gunbc/spark/serving_load_probe.dag b/dag/gunbc/spark/serving_load_probe.dag index fdba81ec501..79dd06706d5 100644 --- a/dag/gunbc/spark/serving_load_probe.dag +++ b/dag/gunbc/spark/serving_load_probe.dag @@ -514,15 +514,6 @@ fn arrival_from_protocol(req: VllmBenchServeRequest) -> ArrivalSkew { } } -data arrival_skew_comparison_bound_millis: Millisecond = millisecond(count: 250) - -fn arrival_admits_rate_comparison(s: ArrivalSkew) -> Bool { - match s { - ArrivalSkewUnread { cause: _ } => false - ArrivalSkewObserved { max_stagger_millis: n } => millisecond_count(m: n) <= millisecond_count(m: arrival_skew_comparison_bound_millis) - } -} - type OccupancySample { running: Nat waiting: Nat @@ -706,15 +697,15 @@ type DecodeCorroboration = CorroborationNotApplicable { because: NonEmptyStr } | CorroborationUnread { because: NonEmptyStr } -// The 49 ms/token single-stream bound is TRANSCRIBED, NOT A READING: parent measured 48.9 ms -// single-stream in a quieter window, against a contended client c=1 TPOT of ~81 ms. The gap is -// observed; its cause is unestablished until an overlapping lease or engine-population join attributes it. +// A single-stream decode figure is produced by glm_native_serving_load_wet run with a +// max_concurrency=1 protocol; this module holds no such figure. A multi-stream observation can +// neither corroborate nor falsify one, and a single-stream observation has not yet been captured here. fn decode_corroboration_for_protocol(req: VllmBenchServeRequest) -> DecodeCorroboration { match req.max_concurrency { Present { value: 1 } => - CorroborationUnread { because: "a single-stream run can be compared to the transcribed 49 ms/token bound; this observation has not yet produced that figure" as NonEmptyStr } + CorroborationUnread { because: "a single-stream run is the producer of a decode figure; this observation has not yet produced one" as NonEmptyStr } Present { value: _ } => - CorroborationNotApplicable { because: "the holistic protocol is not a single-stream measurement, so it cannot corroborate or falsify the 49 ms/token bound" as NonEmptyStr } + CorroborationNotApplicable { because: "a multi-stream protocol is not a single-stream measurement, so it cannot corroborate or falsify a single-stream decode figure" as NonEmptyStr } Absent => CorroborationNotApplicable { because: "unbounded concurrency is not a single-stream measurement" as NonEmptyStr } } diff --git a/dag/test/claim/spark/serving_load_probe_witness_test.dag b/dag/test/claim/spark/serving_load_probe_witness_test.dag index 47a4bbd42a4..1508808bd31 100644 --- a/dag/test/claim/spark/serving_load_probe_witness_test.dag +++ b/dag/test/claim/spark/serving_load_probe_witness_test.dag @@ -23,7 +23,7 @@ import gunbc.spark.serving_load_probe { WindowIsolationNotEstablished, ForeignTrafficObserved, ForeignTrafficNotObserved, ForeignTrafficUnread, window_from_drain, isolated_window, drain_from_queue, OperationLedger, LedgerClosed, LedgerIncomplete, ledger_admits_token_denomination, RateFromClientOutputTokens, RateUndenominable, RateUnreadable, ArrivalSkewUnread, - arrival_admits_rate_comparison, TokenDeltaRead, TokenDeltaReset, TokenDeltaUnread, TokenDeltaScoped, + TokenDeltaRead, TokenDeltaReset, TokenDeltaUnread, TokenDeltaScoped, generation_token_delta, generation_token_delta_scoped, derive_rate_honest, serving_load_observation, serving_load_observation_text, ServingLoadObservation, tokens_per_observation_second, foreign_work_bound, ForeignWorkBounded, ForeignWorkUnread, ForeignWorkContradiction, occupancy_from_body, occupancy_trace_from_endpoint_scrapes, itl_latency_delta, iteration_tokens_booked_delta, @@ -192,10 +192,6 @@ test fn engine_rate_comes_from_generation_tokens_not_iteration_or_itl() -> Bool } } -test fn unread_arrival_skew_refuses_a_rate_comparison() -> Bool { - !arrival_admits_rate_comparison(s: ArrivalSkewUnread { cause: "bench stdout not parsed" as NonEmptyStr }) -} - test fn a_generation_counter_reset_is_not_a_rate() -> Bool { match generation_token_delta(before_body: fx_idle, after_body: fx_reset) { TokenDeltaReset { cause: _ } => true From 7e9854b087dfbbba3fb729b2095c3212de138f50 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sat, 19 Sep 2026 11:38:03 +0000 Subject: [PATCH 37/43] serving-load: provenance is supplied by the caller that ran the operations; checked scale-down Review 68379. serving_load_observation stamped every observation with an authored DriverObserverSplit naming two principals and endpoints the production route does not use; the CLI runs the bench and the metrics scrape through one srv9 context. Provenance is now a parameter, the CLI supplies SamePrincipal describing that session, the authored row is deleted, and a witness shows the receipt prints what the caller supplied. milli_floor_from_exact's scale-down divisor now comes from checked_decimal_pow10. Co-Authored-By: Claude Opus 5 (1M context) --- dag/gunbc/spark/serving_load_probe.dag | 15 +++++++-------- dag/gunbc/spark/serving_load_probe_cli.dag | 2 ++ .../spark/serving_load_probe_witness_test.dag | 13 +++++++++++++ 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/dag/gunbc/spark/serving_load_probe.dag b/dag/gunbc/spark/serving_load_probe.dag index 79dd06706d5..70e44635a5d 100644 --- a/dag/gunbc/spark/serving_load_probe.dag +++ b/dag/gunbc/spark/serving_load_probe.dag @@ -5,7 +5,7 @@ import std.nat { Nat } import std.measure { Millisecond, millisecond, millisecond_count, TokenCount, token_count, token_count_value, MilliTokensPerSecond, milli_tokens_per_second, milli_tokens_per_second_count, } -import std.decimal { ExactDecimal, canonical_exact_decimal, decimal_pow10, checked_decimal_rescale, exact_decimal_sub, ExactDifference, ExactDifferenceUnrepresentable, ExactDifferenceOperandScaleRefused } +import std.decimal { ExactDecimal, canonical_exact_decimal, checked_decimal_rescale, checked_decimal_pow10, exact_decimal_sub, ExactDifference, ExactDifferenceUnrepresentable, ExactDifferenceOperandScaleRefused } import std.checked_arithmetic { checked_int_magnitude, CheckedNatReady, CheckedNatOverflow, CheckedIntReady, CheckedIntOverflow } import v2.std.optional { Present, Absent } import std.content_hash { ContentHash, content_hash_of_value, serialize_content_hash } @@ -274,7 +274,10 @@ fn milli_floor_from_exact(d: ExactDecimal) -> Nat? { if c.units < 0 { none } else if c.fraction_digits > 3 { - nat_from_nonneg_int(n: c.units / decimal_pow10(exponent: c.fraction_digits - 3)) + match checked_decimal_pow10(exponent: c.fraction_digits - 3) { + CheckedIntReady { value: p } => nat_from_nonneg_int(n: c.units / p) + CheckedIntOverflow { cause: _ } => none + } } else { match checked_decimal_rescale(units: c.units, by: 3 - c.fraction_digits) { CheckedIntReady { value: scaled } => nat_from_nonneg_int(n: scaled) @@ -947,6 +950,7 @@ fn serving_load_observation( before_incarnation: ObservedRankIncarnation?, after_incarnation: ObservedRankIncarnation?, bench: BenchServeExecution, + provenance: ProbeProvenance, ) -> ServingLoadObservation { let protocol = bench_execution_protocol(e: bench) let before_p = preemption_count(body: before_body) @@ -985,7 +989,7 @@ fn serving_load_observation( ledger: ledger, admission: glm_native_workload_admission, corroboration: decode_corroboration_for_protocol(req: protocol), - provenance: glm_native_live_probe_provenance, + provenance: provenance, client_latency: bench_serve_latency(e: bench, window: window), foreign_work: foreign, rate: rate, @@ -1279,11 +1283,6 @@ data glm_native_smoke_protocol: VllmBenchServeRequest = vllm_bench_serve_request seed: glm_native_bench_seed, ) -data glm_native_live_probe_provenance: ProbeProvenance = DriverObserverSplit { - driver: "calm-bat-65 via srv1 docker exec of vllm bench serve" as NonEmptyStr, - observer: "deep-otter-201 HTTP scrape of 192.168.1.236:30000/metrics" as NonEmptyStr, -} - fn bench_labeled_nat(body: String, label: String) -> Nat? { text_labeled_count(body: text_without_sudo_prompt(body: body), label: label) } diff --git a/dag/gunbc/spark/serving_load_probe_cli.dag b/dag/gunbc/spark/serving_load_probe_cli.dag index 8647cea976b..aaad56f8bbd 100644 --- a/dag/gunbc/spark/serving_load_probe_cli.dag +++ b/dag/gunbc/spark/serving_load_probe_cli.dag @@ -24,6 +24,7 @@ import gunbc.spark.serving_arm { glm_native_concurrent_profile } import gunbc.harness.harness_backend { harness_launch_from_body, harness_queue_from_body } import gunbc.spark.fabric_switch_observed { FabricGroupB } import gunbc.spark.serving_load_probe { + SamePrincipal, glm_native_live_subject_standing, glm_native_smoke_protocol, serving_load_observation, serving_load_observation_text, @@ -154,6 +155,7 @@ fn glm_native_serving_load_run() -> ProcessExit before_incarnation: before_incarnation, after_incarnation: after_incarnation, bench: bench, + provenance: SamePrincipal { principal: join(["group-B administrator ssh session on ", operator_host_srv9 as String, " (bench by docker exec, metrics by 127.0.0.1 scrape, same context)"], "") as NonEmptyStr }, ) let body = join([ "glm native serving-load wet at ", probed_at_word(reading: clock_now_probed_at()) as String, "\n", diff --git a/dag/test/claim/spark/serving_load_probe_witness_test.dag b/dag/test/claim/spark/serving_load_probe_witness_test.dag index 1508808bd31..f5439e7f1f9 100644 --- a/dag/test/claim/spark/serving_load_probe_witness_test.dag +++ b/dag/test/claim/spark/serving_load_probe_witness_test.dag @@ -19,6 +19,7 @@ import gunbc.spark.vllm_endpoint_process_launch { } import gunbc.harness.harness_backend { harness_queue_from_body } import gunbc.spark.serving_load_probe { + SamePrincipal, DriverObserverSplit, provenance_text, ProbeProvenance, DrainObservedIdle, DrainNotIdle, ExclusionNotEstablished, ExclusionEstablished, WindowIsolated, WindowIsolationNotEstablished, ForeignTrafficObserved, ForeignTrafficNotObserved, ForeignTrafficUnread, window_from_drain, isolated_window, drain_from_queue, OperationLedger, LedgerClosed, LedgerIncomplete, @@ -278,6 +279,7 @@ fn fx_obs_for(subject: ServingPerformanceSubjectStanding) -> ServingLoadObservat before_incarnation: fx_same_incarnation(), after_incarnation: fx_same_incarnation(), bench: fx_bench_receipt(stdout: fx_bench_stdout), + provenance: fx_provenance, ) } @@ -540,6 +542,7 @@ fn fx_obs_between(before: String, after: String) -> ServingLoadObservation { before_incarnation: fx_same_incarnation(), after_incarnation: fx_same_incarnation(), bench: fx_bench_receipt(stdout: fx_bench_stdout), + provenance: fx_provenance, ) } @@ -687,6 +690,7 @@ test fn the_retained_evidence_is_the_execution_it_was_captured_from() -> Bool { before_incarnation: fx_same_incarnation(), after_incarnation: fx_same_incarnation(), bench: bench, + provenance: fx_provenance, ) let ev = obs.evidence ev.metrics_before.body == fx_idle @@ -725,3 +729,12 @@ test fn a_whole_counter_delta_still_reads_after_the_exactness_change() -> Bool { TokenDeltaReset { cause: _ } => false } } + +data fx_provenance: ProbeProvenance = SamePrincipal { principal: "fixture principal" as NonEmptyStr } + +test fn the_receipt_prints_the_provenance_its_caller_supplied() -> Bool { + let same = serving_load_observation_text(o: fx_obs()) + string_contains(s: same, pattern: "same-principal fixture principal") + && !string_contains(s: same, pattern: "driver-observer-split") + && string_contains(s: provenance_text(p: DriverObserverSplit { driver: "d" as NonEmptyStr, observer: "o" as NonEmptyStr }), pattern: "driver-observer-split driver=d observer=o") +} From 749bad695b8062b31fbab0f1fd551755bd26fb42 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sat, 19 Sep 2026 12:36:45 +0000 Subject: [PATCH 38/43] serving-load: token counts are TokenCount and the derived rate is TokensPerSecond Review 68402. OccupancySample.prompt_tokens, TokenDeltaRead/Scoped.tokens, ClientOutputTokensObserved.tokens, LedgerAndCounterAgree.generation_tokens, ForeignWorkBounded and ForeignWorkContradiction's token fields, and RateFromClientOutputTokens.tokens carried a token count as bare Nat beside TokenCount in the same module; tokens_per_observation_second returned bare Nat beside TokensPerSecond. Request, observation, queue and preemption counts stay Nat. The decode-corroboration annotation no longer names a max_concurrency=1 invocation the wet entry cannot select. Co-Authored-By: Claude Opus 5 (1M context) --- dag/gunbc/spark/serving_load_probe.dag | 65 ++++++++++--------- .../spark/serving_load_probe_witness_test.dag | 32 ++++----- 2 files changed, 49 insertions(+), 48 deletions(-) diff --git a/dag/gunbc/spark/serving_load_probe.dag b/dag/gunbc/spark/serving_load_probe.dag index 70e44635a5d..624300d17e1 100644 --- a/dag/gunbc/spark/serving_load_probe.dag +++ b/dag/gunbc/spark/serving_load_probe.dag @@ -3,7 +3,7 @@ module gunbc.spark.serving_load_probe import std.types { Bool, String, NonEmptyStr, EpochSecs, Int } import std.nat { Nat } import std.measure { - Millisecond, millisecond, millisecond_count, TokenCount, token_count, token_count_value, MilliTokensPerSecond, milli_tokens_per_second, milli_tokens_per_second_count, + Millisecond, millisecond, millisecond_count, TokenCount, token_count, token_count_value, MilliTokensPerSecond, milli_tokens_per_second, milli_tokens_per_second_count, TokensPerSecond, tokens_per_second, tokens_per_second_count, } import std.decimal { ExactDecimal, canonical_exact_decimal, checked_decimal_rescale, checked_decimal_pow10, exact_decimal_sub, ExactDifference, ExactDifferenceUnrepresentable, ExactDifferenceOperandScaleRefused } import std.checked_arithmetic { checked_int_magnitude, CheckedNatReady, CheckedNatOverflow, CheckedIntReady, CheckedIntOverflow } @@ -429,12 +429,12 @@ fn ledger_admits_token_denomination(l: OperationLedger) -> Bool { } type TokenDelta - = TokenDeltaRead { tokens: Nat } - | TokenDeltaScoped { tokens: Nat, incarnation: ObservedRankIncarnation } + = TokenDeltaRead { tokens: TokenCount } + | TokenDeltaScoped { tokens: TokenCount, incarnation: ObservedRankIncarnation } | TokenDeltaUnread { cause: NonEmptyStr } | TokenDeltaReset { cause: NonEmptyStr } -fn token_delta_tokens(d: TokenDelta) -> Nat? { +fn token_delta_tokens(d: TokenDelta) -> TokenCount? { match d { TokenDeltaRead { tokens: t } => Present { value: t } TokenDeltaScoped { tokens: t, incarnation: _ } => Present { value: t } @@ -460,7 +460,7 @@ fn generation_token_delta(before_body: String, after_body: String) -> TokenDelta Absent => TokenDeltaReset { cause: "generation_tokens_total decreased; the exporter likely restarted" as NonEmptyStr } Present { value: d } => if d % 1000 == 0 { - TokenDeltaRead { tokens: d / 1000 } + TokenDeltaRead { tokens: token_count(count: d / 1000) } } else { TokenDeltaUnread { cause: "generation_tokens_total delta was not a whole token count" as NonEmptyStr } } @@ -522,21 +522,21 @@ type OccupancySample { waiting: Nat capacity_waiting: Nat preemptions: Nat - prompt_tokens: Nat + prompt_tokens: TokenCount } type BoundaryOccupancyReceipt = OccupancyBoundariesUnread { cause: NonEmptyStr } | OccupancyBoundariesRead { before: OccupancySample, after: OccupancySample } -fn metric_token_count(body: String, metric: VllmServingMetric) -> Nat? { +fn metric_token_count(body: String, metric: VllmServingMetric) -> TokenCount? { match harness_gauge_value(body: body, metric: metric) { Absent => none Present { value: t } => match field_to_milli(field: t) { Absent => none Present { value: m } => - if m % 1000 == 0 { Present { value: m / 1000 } } else { none } + if m % 1000 == 0 { Present { value: token_count(count: m / 1000) } } else { none } } } } @@ -573,11 +573,11 @@ fn occupancy_trace_from_endpoint_scrapes(before_body: String, after_body: String } type ClientOutputTokens - = ClientOutputTokensObserved { tokens: Nat } + = ClientOutputTokensObserved { tokens: TokenCount } | ClientOutputTokensUnread { cause: NonEmptyStr } type LedgerCounterAgreement - = LedgerAndCounterAgree { generation_tokens: Nat, completed_requests: Nat } + = LedgerAndCounterAgree { generation_tokens: TokenCount, completed_requests: Nat } | LedgerCounterDisagree { because: NonEmptyStr } | AgreementUnread { because: NonEmptyStr } @@ -600,14 +600,14 @@ fn ledger_counter_agreement(ledger: OperationLedger, generation: TokenDelta, cli match ledger { LedgerIncomplete { because: c } => AgreementUnread { because: c } LedgerClosed { offered: _, completed: n, failed: _ } => - if g > 0 && n == 0 { + if token_count_value(t: g) > 0 && n == 0 { LedgerCounterDisagree { because: "generation_tokens_total advanced while the client ledger completed zero requests; foreign load is the remaining explanation" as NonEmptyStr } } else { match client_output { ClientOutputTokensUnread { cause: c } => AgreementUnread { because: c } ClientOutputTokensObserved { tokens: c } => - if nat_abs_diff(a: c, b: g) <= generation_client_token_agreement_bound { + if nat_abs_diff(a: token_count_value(t: c), b: token_count_value(t: g)) <= generation_client_token_agreement_bound { LedgerAndCounterAgree { generation_tokens: g, completed_requests: n } } else { LedgerCounterDisagree { because: "generation_tokens_total includes foreign decode beside this client ledger; surplus bounds shared work and is not a refuse of the client rate" as NonEmptyStr } @@ -620,8 +620,8 @@ fn ledger_counter_agreement(ledger: OperationLedger, generation: TokenDelta, cli type ForeignWorkBound = ForeignWorkUnread { because: NonEmptyStr } - | ForeignWorkBounded { engine_generation: Nat, client_output: Nat, surplus: Nat } - | ForeignWorkContradiction { engine_generation: Nat, client_output: Nat, because: NonEmptyStr } + | ForeignWorkBounded { engine_generation: TokenCount, client_output: TokenCount, surplus: TokenCount } + | ForeignWorkContradiction { engine_generation: TokenCount, client_output: TokenCount, because: NonEmptyStr } fn foreign_work_bound(generation: TokenDelta, client_output: ClientOutputTokens) -> ForeignWorkBound { match token_delta_tokens(d: generation) { @@ -636,8 +636,8 @@ fn foreign_work_bound(generation: TokenDelta, client_output: ClientOutputTokens) match client_output { ClientOutputTokensUnread { cause: c } => ForeignWorkUnread { because: c } ClientOutputTokensObserved { tokens: c } => - if g >= c { - ForeignWorkBounded { engine_generation: g, client_output: c, surplus: g - c } + if token_count_value(t: g) >= token_count_value(t: c) { + ForeignWorkBounded { engine_generation: g, client_output: c, surplus: token_count(count: token_count_value(t: g) - token_count_value(t: c)) } } else { ForeignWorkContradiction { engine_generation: g, @@ -650,16 +650,16 @@ fn foreign_work_bound(generation: TokenDelta, client_output: ClientOutputTokens) } type DerivedRate - = RateFromClientOutputTokens { tokens: Nat, scrape_millis: Millisecond } + = RateFromClientOutputTokens { tokens: TokenCount, scrape_millis: Millisecond } | RateUndenominable { because: NonEmptyStr } | RateUnreadable { because: NonEmptyStr } -fn tokens_per_observation_second(r: DerivedRate) -> Nat? { +fn tokens_per_observation_second(r: DerivedRate) -> TokensPerSecond? { match r { RateUndenominable { because: _ } => none RateUnreadable { because: _ } => none RateFromClientOutputTokens { tokens: t, scrape_millis: ms } => - if millisecond_count(m: ms) == 0 { none } else { Present { value: (t * 1000) / millisecond_count(m: ms) } } + if millisecond_count(m: ms) == 0 { none } else { Present { value: tokens_per_second(count: (token_count_value(t: t) * 1000) / millisecond_count(m: ms)) } } } } @@ -700,13 +700,14 @@ type DecodeCorroboration = CorroborationNotApplicable { because: NonEmptyStr } | CorroborationUnread { because: NonEmptyStr } -// A single-stream decode figure is produced by glm_native_serving_load_wet run with a -// max_concurrency=1 protocol; this module holds no such figure. A multi-stream observation can -// neither corroborate nor falsify one, and a single-stream observation has not yet been captured here. +// A single-stream decode figure would need a future single-stream protocol variant of the +// serving-load capture; glm_native_serving_load_wet today runs only the c=2 smoke protocol, and +// this module holds no such figure. A multi-stream observation can neither corroborate nor +// falsify one, and a single-stream observation has not yet been captured here. fn decode_corroboration_for_protocol(req: VllmBenchServeRequest) -> DecodeCorroboration { match req.max_concurrency { Present { value: 1 } => - CorroborationUnread { because: "a single-stream run is the producer of a decode figure; this observation has not yet produced one" as NonEmptyStr } + CorroborationUnread { because: "a single-stream decode figure would need a future single-stream protocol variant of the serving-load capture, which today runs only the c=2 smoke protocol; this observation holds no such figure" as NonEmptyStr } Present { value: _ } => CorroborationNotApplicable { because: "a multi-stream protocol is not a single-stream measurement, so it cannot corroborate or falsify a single-stream decode figure" as NonEmptyStr } Absent => @@ -1054,9 +1055,9 @@ fn foreign_work_text(f: ForeignWorkBound) -> String { match f { ForeignWorkUnread { because: c } => join(["unread ", c as String], "") ForeignWorkBounded { engine_generation: g, client_output: c, surplus: s } => - join(["engine=", to_string(g), " client=", to_string(c), " surplus=", to_string(s)], "") + join(["engine=", to_string(token_count_value(t: g)), " client=", to_string(token_count_value(t: c)), " surplus=", to_string(token_count_value(t: s))], "") ForeignWorkContradiction { engine_generation: g, client_output: c, because: b } => - join(["contradiction engine=", to_string(g), " client=", to_string(c), " ", b as String], "") + join(["contradiction engine=", to_string(token_count_value(t: g)), " client=", to_string(token_count_value(t: c)), " ", b as String], "") } } @@ -1112,7 +1113,7 @@ fn occupancy_sample_text(s: OccupancySample) -> String { join([ "running=", to_string(s.running), " waiting=", to_string(s.waiting), - " prompt_tokens=", to_string(s.prompt_tokens), + " prompt_tokens=", to_string(token_count_value(t: s.prompt_tokens)), " preemptions=", to_string(s.preemptions), ], "") } @@ -1128,7 +1129,7 @@ fn occupancy_text(t: BoundaryOccupancyReceipt) -> String { fn agreement_text(a: LedgerCounterAgreement) -> String { match a { LedgerAndCounterAgree { generation_tokens: g, completed_requests: n } => - join(["agree generation=", to_string(g), " completed=", to_string(n)], "") + join(["agree generation=", to_string(token_count_value(t: g)), " completed=", to_string(n)], "") LedgerCounterDisagree { because: c } => join(["disagree ", c as String], "") AgreementUnread { because: c } => join(["unread ", c as String], "") } @@ -1210,9 +1211,9 @@ fn ledger_text(l: OperationLedger) -> String { fn token_delta_text(d: TokenDelta) -> String { match d { TokenDeltaRead { tokens: n } => - join(["delta tokens=", to_string(n), " incarnation=unscoped — generation_token_delta_scoped did not bind this reading"], "") + join(["delta tokens=", to_string(token_count_value(t: n)), " incarnation=unscoped — generation_token_delta_scoped did not bind this reading"], "") TokenDeltaScoped { tokens: n, incarnation: i } => - join(["delta tokens=", to_string(n), " incarnation=", observed_rank_incarnation_text(i: i)], "") + join(["delta tokens=", to_string(token_count_value(t: n)), " incarnation=", observed_rank_incarnation_text(i: i)], "") TokenDeltaUnread { cause: c } => join(["unread ", c as String], "") TokenDeltaReset { cause: c } => join(["reset ", c as String], "") } @@ -1224,12 +1225,12 @@ fn rate_text(r: DerivedRate) -> String { RateUnreadable { because: c } => join(["unreadable ", c as String], "") RateFromClientOutputTokens { tokens: t, scrape_millis: ms } => join([ - "completed_output_tokens=", to_string(t), + "completed_output_tokens=", to_string(token_count_value(t: t)), " scrape_millis=", to_string(millisecond_count(m: ms)), " output_tokens_per_s=", match tokens_per_observation_second(r: r) { Absent => "none" - Present { value: v } => to_string(v) + Present { value: v } => to_string(tokens_per_second_count(r: v)) }, ], "") } @@ -1320,7 +1321,7 @@ fn ledger_from_bench_stdout(body: String, offered: Nat) -> OperationLedger { fn client_output_from_bench_stdout(body: String) -> ClientOutputTokens { match bench_labeled_nat(body: body, label: "Total generated tokens") { Absent => ClientOutputTokensUnread { cause: "vllm bench serve stdout carried no unique Total generated tokens line" as NonEmptyStr } - Present { value: t } => ClientOutputTokensObserved { tokens: t } + Present { value: t } => ClientOutputTokensObserved { tokens: token_count(count: t) } } } diff --git a/dag/test/claim/spark/serving_load_probe_witness_test.dag b/dag/test/claim/spark/serving_load_probe_witness_test.dag index f5439e7f1f9..e4df9db8807 100644 --- a/dag/test/claim/spark/serving_load_probe_witness_test.dag +++ b/dag/test/claim/spark/serving_load_probe_witness_test.dag @@ -5,7 +5,7 @@ import v2.std.optional { Present, Absent } import std.content_hash { content_hash_of_value, serialize_content_hash } import std.decimal { ExactDecimal, exact_decimal_sub, ExactDifference, ExactDifferenceUnrepresentable, ExactDifferenceOperandScaleRefused } import extdeps.prometheus.client { prometheus_sample_value_reading, SampleValueExact, SampleValueNotFinite, SampleValueUnreadable } -import std.measure { token_count_value, millisecond, millisecond_count } +import std.measure { token_count, token_count_value, tokens_per_second_count, millisecond, millisecond_count } import product.capacity.lease { lease_fence_of, lease_grant, LeasePolicy, FencedResource } import product.capacity.event_chain { EventId } import gunbc.fleet_intent_network { operator_host_srv9 } @@ -172,17 +172,17 @@ test fn a_request_that_emitted_then_failed_cannot_be_denominated_in_tokens() -> test fn engine_rate_comes_from_generation_tokens_not_iteration_or_itl() -> Bool { match generation_token_delta(before_body: fx_idle, after_body: fx_after) { TokenDeltaRead { tokens: t } => - t == 128 && + token_count_value(t: t) == 128 && match derive_rate_honest( ledger: closed_ok(), scrape_millis: Present { value: millisecond(count: 2000) }, client_output: ClientOutputTokensObserved { tokens: t }, ) { RateFromClientOutputTokens { tokens: tok, scrape_millis: ms } => - tok == 128 && millisecond_count(m: ms) == 2000 && + token_count_value(t: tok) == 128 && millisecond_count(m: ms) == 2000 && match tokens_per_observation_second(r: RateFromClientOutputTokens { tokens: tok, scrape_millis: ms }) { Absent => false - Present { value: rate } => rate == 64 + Present { value: rate } => tokens_per_second_count(r: rate) == 64 } RateUndenominable { because: _ } => false RateUnreadable { because: _ } => false @@ -238,7 +238,7 @@ test fn a_scoped_generation_delta_names_the_incarnation() -> Bool { after_body: fx_after, ) { TokenDeltaScoped { tokens: t, incarnation: i } => - t == 128 && (i.container.id as String) == "0f3a9c1d2e4b" && i.node_rank == 0 + token_count_value(t: t) == 128 && (i.container.id as String) == "0f3a9c1d2e4b" && i.node_rank == 0 TokenDeltaRead { tokens: _ } => false TokenDeltaUnread { cause: _ } => false TokenDeltaReset { cause: _ } => false @@ -311,12 +311,12 @@ test fn extra_engine_tokens_bound_foreign_work_and_keep_the_client_rate() -> Boo match derive_rate_honest( ledger: closed_ok(), scrape_millis: Present { value: millisecond(count: 2000) }, - client_output: ClientOutputTokensObserved { tokens: 128 }, + client_output: ClientOutputTokensObserved { tokens: token_count(count: 128) }, ) { RateFromClientOutputTokens { tokens: t, scrape_millis: _ } => - t == 128 && - match foreign_work_bound(generation: TokenDeltaRead { tokens: 200 }, client_output: ClientOutputTokensObserved { tokens: 128 }) { - ForeignWorkBounded { engine_generation: g, client_output: c, surplus: s } => g == 200 && c == 128 && s == 72 + token_count_value(t: t) == 128 && + match foreign_work_bound(generation: TokenDeltaRead { tokens: token_count(count: 200) }, client_output: ClientOutputTokensObserved { tokens: token_count(count: 128) }) { + ForeignWorkBounded { engine_generation: g, client_output: c, surplus: s } => token_count_value(t: g) == 200 && token_count_value(t: c) == 128 && token_count_value(t: s) == 72 ForeignWorkUnread { because: _ } => false ForeignWorkContradiction { engine_generation: _, client_output: _, because: _ } => false } @@ -326,8 +326,8 @@ test fn extra_engine_tokens_bound_foreign_work_and_keep_the_client_rate() -> Boo } test fn client_output_exceeding_engine_generation_is_a_contradiction() -> Bool { - match foreign_work_bound(generation: TokenDeltaRead { tokens: 100 }, client_output: ClientOutputTokensObserved { tokens: 512 }) { - ForeignWorkContradiction { engine_generation: g, client_output: c, because: _ } => g == 100 && c == 512 + match foreign_work_bound(generation: TokenDeltaRead { tokens: token_count(count: 100) }, client_output: ClientOutputTokensObserved { tokens: token_count(count: 512) }) { + ForeignWorkContradiction { engine_generation: g, client_output: c, because: _ } => token_count_value(t: g) == 100 && token_count_value(t: c) == 512 ForeignWorkBounded { engine_generation: _, client_output: _, surplus: _ } => false ForeignWorkUnread { because: _ } => false } @@ -336,7 +336,7 @@ test fn client_output_exceeding_engine_generation_is_a_contradiction() -> Bool { test fn occupancy_reads_prompt_tokens_that_are_not_an_integer_lexeme() -> Bool { match occupancy_from_body(body: fx_idle) { Absent => false - Present { value: s } => s.running == 0 && s.prompt_tokens == 0 + Present { value: s } => s.running == 0 && token_count_value(t: s.prompt_tokens) == 0 } } @@ -411,7 +411,7 @@ test fn a_sudo_password_prompt_line_does_not_spoil_the_bench_ledger() -> Bool { LedgerClosed { offered: o, completed: c, failed: f } => o == 4 && c == 4 && f == 0 && match client_output_from_bench_stdout(body: body) { - ClientOutputTokensObserved { tokens: n } => n == 512 + ClientOutputTokensObserved { tokens: n } => token_count_value(t: n) == 512 ClientOutputTokensUnread { cause: _ } => false } LedgerIncomplete { because: _ } => false @@ -462,7 +462,7 @@ test fn ledger_and_rate_come_from_bench_stdout_not_exit_ok() -> Bool { && match client_output_from_bench_stdout(body: fx_bench_stdout) { ClientOutputTokensUnread { cause: _ } => false ClientOutputTokensObserved { tokens: n } => - n == 512 + token_count_value(t: n) == 512 && match scrape_millis_from_bench_stdout(body: fx_bench_stdout) { Absent => false Present { value: ms } => millisecond_count(m: ms) == 22750 @@ -666,7 +666,7 @@ fn retained_stdout_replays_the_execution(e: BenchServeExecution, retained: Strin ClientOutputTokensObserved { tokens: a } => match client_output_from_bench_stdout(body: retained) { ClientOutputTokensUnread { cause: _ } => false - ClientOutputTokensObserved { tokens: b } => a == b + ClientOutputTokensObserved { tokens: b } => token_count_value(t: a) == token_count_value(t: b) } } } @@ -723,7 +723,7 @@ test fn a_whole_counter_delta_still_reads_after_the_exactness_change() -> Bool { let before = metrics_body(running: "0.0", waiting: "0.0", capacity: "0.0", preempt: "0.0", itl_sum: "1.0", itl_count: "10.0", itok_sum: "100.0", itok_count: "10.0", gen: "1000.0", start: "1789300000.12") let after = metrics_body(running: "0.0", waiting: "0.0", capacity: "0.0", preempt: "0.0", itl_sum: "1.5", itl_count: "15.0", itok_sum: "110.0", itok_count: "12.0", gen: "1512.0", start: "1789300000.12") match generation_token_delta(before_body: before, after_body: after) { - TokenDeltaRead { tokens: t } => t == 512 + TokenDeltaRead { tokens: t } => token_count_value(t: t) == 512 TokenDeltaUnread { cause: _ } => false TokenDeltaScoped { tokens: _, incarnation: _ } => false TokenDeltaReset { cause: _ } => false From 765b9599f259a9cdec7fd89d5518245000b91d0d Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sat, 19 Sep 2026 13:31:50 +0000 Subject: [PATCH 39/43] serving-load: bench URL from the profile's port; name the thousandths helper; model the Prometheus family type Review 68425. glm_native_smoke_protocol.base_url hard-coded :30000 while metrics_url derives the port from glm_native_concurrent_profile; both derive now. bench_labeled_milli_from_seconds also scaled tok/s, so it is renamed bench_labeled_thousandths for the one contract it has. The Bool vllm_metric_exports_histogram_statistics is replaced by extdeps.vllm.metrics vllm_metric_type returning a new extdeps.prometheus.client PrometheusMetricType (the exposition format's # TYPE), and histogram_delta refuses by the family's type. Co-Authored-By: Claude Opus 5 (1M context) --- dag/extdeps/prometheus/client.dag | 18 ++++++++++++ dag/extdeps/vllm/metrics.dag | 28 ++++++++++--------- dag/gunbc/spark/serving_load_probe.dag | 20 +++++++------ .../spark/serving_load_probe_witness_test.dag | 10 +++++++ 4 files changed, 55 insertions(+), 21 deletions(-) diff --git a/dag/extdeps/prometheus/client.dag b/dag/extdeps/prometheus/client.dag index 6609ff94c9e..fdef46c0d3d 100644 --- a/dag/extdeps/prometheus/client.dag +++ b/dag/extdeps/prometheus/client.dag @@ -27,6 +27,24 @@ data extdeps_model_scope: ExternalModelScope = ExternalModelScope { further_citations: [] } +// THE METRIC FAMILY TYPE, as the text exposition format declares it on each family's `# TYPE` line +// (prometheus.io/docs/instrumenting/exposition_formats). Only a histogram family exports the +// `_sum` and `_count` series a histogram delta reads; a counter or gauge of the same name does not. +type PrometheusMetricType + = PrometheusCounter + | PrometheusGauge + | PrometheusHistogram + | PrometheusSummary + +fn prometheus_metric_type_word(t: PrometheusMetricType) -> String { + match t { + PrometheusCounter => "counter" + PrometheusGauge => "gauge" + PrometheusHistogram => "histogram" + PrometheusSummary => "summary" + } +} + // THE PROCESS COLLECTOR IS THE CLIENT LIBRARY'S, NOT THE SERVING ENGINE'S. // // Anything exporting through prometheus_client on Linux also exports a small population of series diff --git a/dag/extdeps/vllm/metrics.dag b/dag/extdeps/vllm/metrics.dag index 592d9516df9..83ca32f5fee 100644 --- a/dag/extdeps/vllm/metrics.dag +++ b/dag/extdeps/vllm/metrics.dag @@ -4,6 +4,7 @@ import std.types { Bool, String, NonEmptyStr, List } import std.decl_ref { DeclarationRef, WholeDeclaration } import extdeps.external_authority { ExternalAuthority, ExternalModelScope, ExternalSubjectRef } import extdeps.uri { Uri, Https } +import extdeps.prometheus.client { PrometheusMetricType, PrometheusCounter, PrometheusGauge, PrometheusHistogram } import extdeps.vllm.server { VllmSourceRevision, vllm_source_revision_read } data extdeps_external_authority_anchor: ExternalAuthority = ExternalAuthority { @@ -469,19 +470,20 @@ fn vllm_histogram_series_name(m: VllmServingMetric, s: HistogramStatistic) -> No } } -fn vllm_metric_exports_histogram_statistics(m: VllmServingMetric) -> Bool { +// Each family's Prometheus type as vLLM's metrics module registers it (Histogram, Counter or Gauge). +fn vllm_metric_type(m: VllmServingMetric) -> PrometheusMetricType { match m { - InterTokenLatencySeconds => true - IterationTokensTotal => true - KvCacheUsagePerc => false - NumRequestsRunning => false - NumRequestsWaiting => false - NumRequestsWaitingByReason => false - PrefixCacheQueries => false - PrefixCacheHits => false - PromptTokensTotal => false - GenerationTokensTotal => false - NumPreemptionsTotal => false - EstimatedFlopsPerGpuTotal => false + InterTokenLatencySeconds => PrometheusHistogram + IterationTokensTotal => PrometheusHistogram + KvCacheUsagePerc => PrometheusGauge + NumRequestsRunning => PrometheusGauge + NumRequestsWaiting => PrometheusGauge + NumRequestsWaitingByReason => PrometheusGauge + PrefixCacheQueries => PrometheusCounter + PrefixCacheHits => PrometheusCounter + PromptTokensTotal => PrometheusCounter + GenerationTokensTotal => PrometheusCounter + NumPreemptionsTotal => PrometheusCounter + EstimatedFlopsPerGpuTotal => PrometheusCounter } } diff --git a/dag/gunbc/spark/serving_load_probe.dag b/dag/gunbc/spark/serving_load_probe.dag index 624300d17e1..87306ab07e5 100644 --- a/dag/gunbc/spark/serving_load_probe.dag +++ b/dag/gunbc/spark/serving_load_probe.dag @@ -11,10 +11,11 @@ import v2.std.optional { Present, Absent } import std.content_hash { ContentHash, content_hash_of_value, serialize_content_hash } import product.capacity.lease { LeaseGrant } import extdeps.prometheus.client { + PrometheusCounter, PrometheusGauge, PrometheusHistogram, PrometheusSummary, SampleValueExact, SampleValueNotFinite, SampleValueUnreadable, prometheus_sample_value_reading, } import extdeps.vllm.metrics { - VllmServingMetric, InterTokenLatencySeconds, IterationTokensTotal, NumPreemptionsTotal, GenerationTokensTotal, PromptTokensTotal, HistogramSum, HistogramCount, vllm_metric_exports_histogram_statistics, + VllmServingMetric, InterTokenLatencySeconds, IterationTokensTotal, NumPreemptionsTotal, GenerationTokensTotal, PromptTokensTotal, HistogramSum, HistogramCount, vllm_metric_type, } import extdeps.vllm.bench_serve { VllmBenchServeRequest, PoissonProcess, SendAllImmediately, RandomDatasetSpec, OpenaiChat, vllm_bench_serve_request, vllm_bench_serve_source_standing, vllm_bench_backend_route, @@ -309,9 +310,11 @@ fn nat_delta(after: Nat, before: Nat) -> Nat? { // The sum is read through the projection's own reader, so its unit is the caller's, never guessed here. fn histogram_delta(before_body: String, after_body: String, metric: VllmServingMetric) -> HistogramDelta { - if !vllm_metric_exports_histogram_statistics(m: metric) { - HistogramDeltaUnread { cause: "this metric does not export histogram sum/count" as NonEmptyStr } - } else { + match vllm_metric_type(m: metric) { + PrometheusCounter => HistogramDeltaUnread { cause: "this metric is a counter family, which exports no histogram sum/count" as NonEmptyStr } + PrometheusGauge => HistogramDeltaUnread { cause: "this metric is a gauge family, which exports no histogram sum/count" as NonEmptyStr } + PrometheusSummary => HistogramDeltaUnread { cause: "this metric is a summary family; its sum/count are not read as a histogram delta here" as NonEmptyStr } + PrometheusHistogram => { match harness_histogram_statistic_value(body: before_body, metric: metric, statistic: HistogramSum) { Absent => HistogramDeltaUnread { cause: "histogram sum missing on the first body" as NonEmptyStr } Present { value: bs } => @@ -364,6 +367,7 @@ fn histogram_delta(before_body: String, after_body: String, metric: VllmServingM } } } + } } // vllm:inter_token_latency_seconds: the sum is SECONDS, so thousandths of it are milliseconds. @@ -1273,7 +1277,7 @@ data glm_native_bench_seed: Nat = 20260918 // tokens; bench-serve's total token throughput also counts prefill and answers a different question. data glm_native_smoke_protocol: VllmBenchServeRequest = vllm_bench_serve_request( backend: OpenaiChat, - base_url: "http://127.0.0.1:30000" as NonEmptyStr, + base_url: join(["http://127.0.0.1:", to_string(glm_native_concurrent_profile.serve_port)], "") as NonEmptyStr, model: glm_native_concurrent_profile.served_alias, tokenizer: glm_native_engine_tokenizer_path, dataset: glm_native_sweep_dataset, @@ -1288,7 +1292,7 @@ fn bench_labeled_nat(body: String, label: String) -> Nat? { text_labeled_count(body: text_without_sudo_prompt(body: body), label: label) } -fn bench_labeled_milli_from_seconds(body: String, label: String) -> Nat? { +fn bench_labeled_thousandths(body: String, label: String) -> Nat? { match text_field_last_word(body: text_without_sudo_prompt(body: body), label: label) { Absent => none Present { value: last_word } => field_to_milli(field: last_word) @@ -1326,7 +1330,7 @@ fn client_output_from_bench_stdout(body: String) -> ClientOutputTokens { } fn scrape_millis_from_bench_stdout(body: String) -> Millisecond? { - match bench_labeled_milli_from_seconds(body: body, label: "Benchmark duration (s)") { + match bench_labeled_thousandths(body: body, label: "Benchmark duration (s)") { Absent => none Present { value: n } => Present { value: millisecond(count: n) } } @@ -1357,7 +1361,7 @@ fn client_bucket_peak_from_bench_stdout(body: String, client_max_concurrency: Na } fn client_latency_from_bench_stdout(body: String, window: ProbeWindowStanding) -> ClientBenchLatency { - match bench_labeled_milli_from_seconds(body: body, label: "Output token throughput (tok/s)") { + match bench_labeled_thousandths(body: body, label: "Output token throughput (tok/s)") { Absent => ClientBenchLatencyUnread { cause: "vllm bench serve stdout carried no unique Output token throughput (tok/s) line" as NonEmptyStr } Present { value: th } => match bench_labeled_whole_milli(body: body, label: "Mean TPOT (ms)") { diff --git a/dag/test/claim/spark/serving_load_probe_witness_test.dag b/dag/test/claim/spark/serving_load_probe_witness_test.dag index e4df9db8807..c6b4a66ae91 100644 --- a/dag/test/claim/spark/serving_load_probe_witness_test.dag +++ b/dag/test/claim/spark/serving_load_probe_witness_test.dag @@ -3,6 +3,7 @@ module test.claim.spark.serving_load_probe_witness import std.types { Bool, String, NonEmptyStr } import v2.std.optional { Present, Absent } import std.content_hash { content_hash_of_value, serialize_content_hash } +import extdeps.vllm.metrics { GenerationTokensTotal } import std.decimal { ExactDecimal, exact_decimal_sub, ExactDifference, ExactDifferenceUnrepresentable, ExactDifferenceOperandScaleRefused } import extdeps.prometheus.client { prometheus_sample_value_reading, SampleValueExact, SampleValueNotFinite, SampleValueUnreadable } import std.measure { token_count, token_count_value, tokens_per_second_count, millisecond, millisecond_count } @@ -19,6 +20,7 @@ import gunbc.spark.vllm_endpoint_process_launch { } import gunbc.harness.harness_backend { harness_queue_from_body } import gunbc.spark.serving_load_probe { + histogram_delta, HistogramDeltaRead, HistogramDeltaUnread, HistogramCounterReset, SamePrincipal, DriverObserverSplit, provenance_text, ProbeProvenance, DrainObservedIdle, DrainNotIdle, ExclusionNotEstablished, ExclusionEstablished, WindowIsolated, WindowIsolationNotEstablished, ForeignTrafficObserved, ForeignTrafficNotObserved, ForeignTrafficUnread, window_from_drain, @@ -738,3 +740,11 @@ test fn the_receipt_prints_the_provenance_its_caller_supplied() -> Bool { && !string_contains(s: same, pattern: "driver-observer-split") && string_contains(s: provenance_text(p: DriverObserverSplit { driver: "d" as NonEmptyStr, observer: "o" as NonEmptyStr }), pattern: "driver-observer-split driver=d observer=o") } + +test fn a_histogram_delta_on_a_counter_family_is_refused_by_its_type() -> Bool { + match histogram_delta(before_body: fx_idle, after_body: fx_after, metric: GenerationTokensTotal) { + HistogramDeltaUnread { cause: c } => string_contains(s: c as String, pattern: "counter family") + HistogramDeltaRead { sum: _, count: _ } => false + HistogramCounterReset { cause: _ } => false + } +} From 98e4421a06fcc1a34184920ea16b0d436d9b5ec7 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sat, 19 Sep 2026 14:17:32 +0000 Subject: [PATCH 40/43] serving-load: the metrics route comes from extdeps.vllm.server; the family word renders refusals Review 68450. metrics_url spelled /metrics beside vllm_route_metrics; it now reads vllm_route_path(vllm_route_metrics) (bytes unchanged). prometheus_metric_type_word had no consumer; histogram_delta's family refusal is now built from it instead of three hand-written arms. Co-Authored-By: Claude Opus 5 (1M context) --- dag/gunbc/spark/serving_load_probe.dag | 12 ++++++++---- dag/gunbc/spark/serving_load_probe_cli.dag | 3 ++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/dag/gunbc/spark/serving_load_probe.dag b/dag/gunbc/spark/serving_load_probe.dag index 87306ab07e5..71fdf03f377 100644 --- a/dag/gunbc/spark/serving_load_probe.dag +++ b/dag/gunbc/spark/serving_load_probe.dag @@ -11,7 +11,7 @@ import v2.std.optional { Present, Absent } import std.content_hash { ContentHash, content_hash_of_value, serialize_content_hash } import product.capacity.lease { LeaseGrant } import extdeps.prometheus.client { - PrometheusCounter, PrometheusGauge, PrometheusHistogram, PrometheusSummary, + PrometheusMetricType, PrometheusCounter, PrometheusGauge, PrometheusHistogram, PrometheusSummary, prometheus_metric_type_word, SampleValueExact, SampleValueNotFinite, SampleValueUnreadable, prometheus_sample_value_reading, } import extdeps.vllm.metrics { @@ -308,12 +308,16 @@ fn nat_delta(after: Nat, before: Nat) -> Nat? { if after < before { none } else { Present { value: after - before } } } +fn histogram_family_refused(t: PrometheusMetricType) -> HistogramDelta { + HistogramDeltaUnread { cause: join(["this metric is a ", prometheus_metric_type_word(t: t), " family; only a histogram family's sum/count are read as a histogram delta"], "") as NonEmptyStr } +} + // The sum is read through the projection's own reader, so its unit is the caller's, never guessed here. fn histogram_delta(before_body: String, after_body: String, metric: VllmServingMetric) -> HistogramDelta { match vllm_metric_type(m: metric) { - PrometheusCounter => HistogramDeltaUnread { cause: "this metric is a counter family, which exports no histogram sum/count" as NonEmptyStr } - PrometheusGauge => HistogramDeltaUnread { cause: "this metric is a gauge family, which exports no histogram sum/count" as NonEmptyStr } - PrometheusSummary => HistogramDeltaUnread { cause: "this metric is a summary family; its sum/count are not read as a histogram delta here" as NonEmptyStr } + PrometheusCounter => histogram_family_refused(t: PrometheusCounter) + PrometheusGauge => histogram_family_refused(t: PrometheusGauge) + PrometheusSummary => histogram_family_refused(t: PrometheusSummary) PrometheusHistogram => { match harness_histogram_statistic_value(body: before_body, metric: metric, statistic: HistogramSum) { Absent => HistogramDeltaUnread { cause: "histogram sum missing on the first body" as NonEmptyStr } diff --git a/dag/gunbc/spark/serving_load_probe_cli.dag b/dag/gunbc/spark/serving_load_probe_cli.dag index aaad56f8bbd..5743a38b419 100644 --- a/dag/gunbc/spark/serving_load_probe_cli.dag +++ b/dag/gunbc/spark/serving_load_probe_cli.dag @@ -8,6 +8,7 @@ import std.resources { Network } import extdeps.filesystem.filesystem_io { Filesystem } import extdeps.docker.cli { docker_exec_command } import extdeps.exec.command { argv_words } +import extdeps.vllm.server { vllm_route_path, vllm_route_metrics } import extdeps.vllm.bench_serve { vllm_bench_serve_arguments } import gunbc.clock_read { clock_now_probed_at, probed_at_word } import gunbc.fleet_intent_network { operator_host_srv9, srv9_host_lan_endpoint } @@ -51,7 +52,7 @@ data glm_native_serving_load_receipt_path: String = "target/glm-native-serving-l data glm_native_serving_load_attempt_raw: String = "glm-native-serving-load" fn metrics_url() -> String { - join(["http://127.0.0.1:", to_string(glm_native_concurrent_profile.serve_port), "/metrics"], "") + join(["http://127.0.0.1:", to_string(glm_native_concurrent_profile.serve_port), vllm_route_path(r: vllm_route_metrics) as String], "") } fn curl_metrics_argv() -> List { From 4654dd66710d3e6f3c561e27a51b4f7c40493c52 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sat, 19 Sep 2026 14:25:41 +0000 Subject: [PATCH 41/43] prometheus: carry the full classic # TYPE vocabulary and state which families export sum/count Side-chat hold 5255922595. PrometheusMetricType gains PrometheusUntyped (the format's default when TYPE is absent); the annotation now says histograms AND summaries export _sum/_count, and histogram_delta's refusal says this reader only takes a histogram family, not that upstream exports nothing. vllm_metric_type is annotated as a catalog projection, not a reading of the live TYPE line. Co-Authored-By: Claude Opus 5 (1M context) --- dag/extdeps/prometheus/client.dag | 9 ++++++--- dag/extdeps/vllm/metrics.dag | 3 ++- dag/gunbc/spark/serving_load_probe.dag | 5 +++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/dag/extdeps/prometheus/client.dag b/dag/extdeps/prometheus/client.dag index fdef46c0d3d..79c7b177c61 100644 --- a/dag/extdeps/prometheus/client.dag +++ b/dag/extdeps/prometheus/client.dag @@ -27,14 +27,16 @@ data extdeps_model_scope: ExternalModelScope = ExternalModelScope { further_citations: [] } -// THE METRIC FAMILY TYPE, as the text exposition format declares it on each family's `# TYPE` line -// (prometheus.io/docs/instrumenting/exposition_formats). Only a histogram family exports the -// `_sum` and `_count` series a histogram delta reads; a counter or gauge of the same name does not. +// THE METRIC FAMILY TYPE of the classic text exposition format's `# TYPE` line +// (prometheus.io/docs/instrumenting/exposition_formats): counter, gauge, histogram, summary, and +// untyped, which is also the default when no TYPE line is given. Both histogram and summary families +// export `_sum` and `_count` series; counters, gauges and untyped families do not. type PrometheusMetricType = PrometheusCounter | PrometheusGauge | PrometheusHistogram | PrometheusSummary + | PrometheusUntyped fn prometheus_metric_type_word(t: PrometheusMetricType) -> String { match t { @@ -42,6 +44,7 @@ fn prometheus_metric_type_word(t: PrometheusMetricType) -> String { PrometheusGauge => "gauge" PrometheusHistogram => "histogram" PrometheusSummary => "summary" + PrometheusUntyped => "untyped" } } diff --git a/dag/extdeps/vllm/metrics.dag b/dag/extdeps/vllm/metrics.dag index 83ca32f5fee..900b9d32c4c 100644 --- a/dag/extdeps/vllm/metrics.dag +++ b/dag/extdeps/vllm/metrics.dag @@ -470,7 +470,8 @@ fn vllm_histogram_series_name(m: VllmServingMetric, s: HistogramStatistic) -> No } } -// Each family's Prometheus type as vLLM's metrics module registers it (Histogram, Counter or Gauge). +// Each family's Prometheus type as vLLM's metrics module REGISTERS it (Histogram, Counter or Gauge). +// A projection from the catalog, not a reading of the running exporter's `# TYPE` line. fn vllm_metric_type(m: VllmServingMetric) -> PrometheusMetricType { match m { InterTokenLatencySeconds => PrometheusHistogram diff --git a/dag/gunbc/spark/serving_load_probe.dag b/dag/gunbc/spark/serving_load_probe.dag index 71fdf03f377..88b989556ce 100644 --- a/dag/gunbc/spark/serving_load_probe.dag +++ b/dag/gunbc/spark/serving_load_probe.dag @@ -11,7 +11,7 @@ import v2.std.optional { Present, Absent } import std.content_hash { ContentHash, content_hash_of_value, serialize_content_hash } import product.capacity.lease { LeaseGrant } import extdeps.prometheus.client { - PrometheusMetricType, PrometheusCounter, PrometheusGauge, PrometheusHistogram, PrometheusSummary, prometheus_metric_type_word, + PrometheusMetricType, PrometheusCounter, PrometheusGauge, PrometheusHistogram, PrometheusSummary, PrometheusUntyped, prometheus_metric_type_word, SampleValueExact, SampleValueNotFinite, SampleValueUnreadable, prometheus_sample_value_reading, } import extdeps.vllm.metrics { @@ -309,7 +309,7 @@ fn nat_delta(after: Nat, before: Nat) -> Nat? { } fn histogram_family_refused(t: PrometheusMetricType) -> HistogramDelta { - HistogramDeltaUnread { cause: join(["this metric is a ", prometheus_metric_type_word(t: t), " family; only a histogram family's sum/count are read as a histogram delta"], "") as NonEmptyStr } + HistogramDeltaUnread { cause: join(["this metric is a ", prometheus_metric_type_word(t: t), " family; this reader takes sum/count as a histogram delta only from a histogram family"], "") as NonEmptyStr } } // The sum is read through the projection's own reader, so its unit is the caller's, never guessed here. @@ -318,6 +318,7 @@ fn histogram_delta(before_body: String, after_body: String, metric: VllmServingM PrometheusCounter => histogram_family_refused(t: PrometheusCounter) PrometheusGauge => histogram_family_refused(t: PrometheusGauge) PrometheusSummary => histogram_family_refused(t: PrometheusSummary) + PrometheusUntyped => histogram_family_refused(t: PrometheusUntyped) PrometheusHistogram => { match harness_histogram_statistic_value(body: before_body, metric: metric, statistic: HistogramSum) { Absent => HistogramDeltaUnread { cause: "histogram sum missing on the first body" as NonEmptyStr } From a546ec68a9ef60a3f1b4116c80a78faeb6d4a22f Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sat, 19 Sep 2026 14:58:25 +0000 Subject: [PATCH 42/43] serving-load: the live subject reads max_num_seqs from its profile and leaves KV dtype unread Review 68463. max_num_seqs was transcribed beside glm_native_concurrent_profile, which owns it; it is read from the profile now. kv_cache_dtype asserted KvFp8 as established while the profile declares auto and the running unit was launched from a different plan; the axis is now unread, the believed text names the disagreement, and would_settle asks for the running --kv-cache-dtype. Co-Authored-By: Claude Opus 5 (1M context) --- dag/gunbc/spark/serving_load_probe.dag | 12 ++++++------ .../claim/spark/serving_load_probe_witness_test.dag | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/dag/gunbc/spark/serving_load_probe.dag b/dag/gunbc/spark/serving_load_probe.dag index 88b989556ce..9e7299d59c4 100644 --- a/dag/gunbc/spark/serving_load_probe.dag +++ b/dag/gunbc/spark/serving_load_probe.dag @@ -42,7 +42,7 @@ import gunbc.spark.serving_performance_subject { import gunbc.spark.serving_rank_observe { ObservedRankIncarnation, observed_rank_incarnations_agree, observed_rank_incarnation_text, } -import extdeps.vllm.engine_args { KvFp8, SpeculativeDecodingOff } +import extdeps.vllm.engine_args { SpeculativeDecodingOff } import extdeps.vllm.kv_layout { AdmissionCost, AdmissionCostUnestablished, AdmissionCostBlocks } import extdeps.external_authority { CitedFigureStanding, TranscribedUncited, CitedToAuthority } @@ -1387,7 +1387,7 @@ fn client_latency_from_bench_stdout(body: String, window: ProbeWindowStanding) - } } -// max_num_seqs is 16 on the live units (parent reverted the out-of-band 64 edit). +// max_num_seqs and the other launch figures are read from glm_native_concurrent_profile, the one row that owns them. // Runtime is glm53_derived_row (GunbcGlm53DerivedGb10); checkpoint revision is the native Flash row. data glm_native_live_subject: ServingPerformanceSubject = serving_performance_subject( checkpoint: Glm53NativeFp8, @@ -1398,8 +1398,8 @@ data glm_native_live_subject: ServingPerformanceSubject = serving_performance_su rank_population: Present { value: 4 }, context_ceiling: Present { value: glm_native_concurrent_profile.max_model_len }, max_num_batched_tokens: glm_native_concurrent_profile.max_num_batched_tokens, - max_num_seqs: Present { value: 16 }, - kv_cache_dtype: Present { value: KvFp8 }, + max_num_seqs: Present { value: glm_native_concurrent_profile.max_num_seqs }, + kv_cache_dtype: none, speculative: Present { value: SpeculativeDecodingOff }, collective_transport: none, ) @@ -1407,8 +1407,8 @@ data glm_native_live_subject: ServingPerformanceSubject = serving_performance_su fn glm_native_live_subject_standing() -> ServingPerformanceSubjectStanding { serving_subject_standing( subject: glm_native_live_subject, - believed: "collective transport was unread; the runtime is glm53_derived_row and the checkpoint revision is glm53_native_fp8_row.revision" as NonEmptyStr, - would_settle: "read the running launch's NCCL transport announcement on this incarnation" as NonEmptyStr, + believed: "collective transport was unread; the KV cache dtype is unread because glm_native_concurrent_profile declares kv_cache_dtype_wire auto while the running group B unit was launched from a different plan; the runtime is glm53_derived_row and the checkpoint revision is glm53_native_fp8_row.revision" as NonEmptyStr, + would_settle: "read the running launch's NCCL transport announcement and its --kv-cache-dtype on this incarnation" as NonEmptyStr, ) } diff --git a/dag/test/claim/spark/serving_load_probe_witness_test.dag b/dag/test/claim/spark/serving_load_probe_witness_test.dag index c6b4a66ae91..373ec3da4ff 100644 --- a/dag/test/claim/spark/serving_load_probe_witness_test.dag +++ b/dag/test/claim/spark/serving_load_probe_witness_test.dag @@ -644,7 +644,7 @@ test fn receipts_differing_only_in_the_settling_obligation_differ() -> Bool { test fn the_live_subject_receipt_carries_the_nccl_announcement_obligation() -> Bool { let t = serving_load_observation_text(o: fx_obs()) string_contains(s: t, pattern: "subject: partial ") - && string_contains(s: t, pattern: "would_settle=read the running launch's NCCL transport announcement on this incarnation") + && string_contains(s: t, pattern: "would_settle=read the running launch's NCCL transport announcement and its --kv-cache-dtype on this incarnation") } test fn arrival_unread_and_observed_render_distinguishably() -> Bool { From d5e2bcc9537e6434174a539c948102866d16dc26 Mon Sep 17 00:00:00 2001 From: gunbc-ci-auto-heal Date: Sat, 19 Sep 2026 15:47:46 +0000 Subject: [PATCH 43/43] serving-load: drop the unenforced sole_constructor on a coproduct; one loopback base URL Review 68481. sole_constructor on the BenchServeExecution sum parses and enforces nothing on this compiler (gunbc.recurring_failure_mode modifier_accepted_on_a_shape_its_check_cannot_see); the real wall is the bench_serve_from_remote mint, so the modifier is removed. The bench base_url and the CLI's metrics_url each minted http://127.0.0.1:; both use glm_native_serve_base_url. Co-Authored-By: Claude Opus 5 (1M context) --- dag/gunbc/spark/serving_load_probe.dag | 9 +++++++-- dag/gunbc/spark/serving_load_probe_cli.dag | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/dag/gunbc/spark/serving_load_probe.dag b/dag/gunbc/spark/serving_load_probe.dag index 9e7299d59c4..e8f5e43ec23 100644 --- a/dag/gunbc/spark/serving_load_probe.dag +++ b/dag/gunbc/spark/serving_load_probe.dag @@ -751,7 +751,7 @@ type ProbeProvenance // ONE REMOTE OPERATION IS ONE EXECUTION. The mint takes SparkRemoteRun whole, so an exit from // run A cannot be paired with stdout from run B at this interface. -type BenchServeExecution sole_constructor +type BenchServeExecution = BenchServeRan { protocol: VllmBenchServeRequest, exit_code: Int, stdout: String, stderr: String } | BenchServeUnreachable { protocol: VllmBenchServeRequest, cause: NonEmptyStr } @@ -1277,12 +1277,17 @@ data glm_native_sweep_dataset: RandomDatasetSpec = RandomDatasetSpec { data glm_native_bench_seed: Nat = 20260918 +// The loopback base URL both the bench client and the metrics scrape address, from the profile's port. +fn glm_native_serve_base_url() -> NonEmptyStr { + join(["http://127.0.0.1:", to_string(glm_native_concurrent_profile.serve_port)], "") as NonEmptyStr +} + // The live probe's protocol: 256-in/128-out, SendAllImmediately, c=2. SendAllImmediately is wiring, // not a comparable rate protocol (arrival skew is unread). The derived rate counts completed output // tokens; bench-serve's total token throughput also counts prefill and answers a different question. data glm_native_smoke_protocol: VllmBenchServeRequest = vllm_bench_serve_request( backend: OpenaiChat, - base_url: join(["http://127.0.0.1:", to_string(glm_native_concurrent_profile.serve_port)], "") as NonEmptyStr, + base_url: glm_native_serve_base_url(), model: glm_native_concurrent_profile.served_alias, tokenizer: glm_native_engine_tokenizer_path, dataset: glm_native_sweep_dataset, diff --git a/dag/gunbc/spark/serving_load_probe_cli.dag b/dag/gunbc/spark/serving_load_probe_cli.dag index 5743a38b419..4beee8a9015 100644 --- a/dag/gunbc/spark/serving_load_probe_cli.dag +++ b/dag/gunbc/spark/serving_load_probe_cli.dag @@ -21,10 +21,10 @@ import gunbc.spark.serving_rank_observe { observed_rank_incarnation, ObservedRankIncarnation, } import gunbc.spark.glm_group_b_relaunch_cli { with_group_b_access, rank_context } -import gunbc.spark.serving_arm { glm_native_concurrent_profile } import gunbc.harness.harness_backend { harness_launch_from_body, harness_queue_from_body } import gunbc.spark.fabric_switch_observed { FabricGroupB } import gunbc.spark.serving_load_probe { + glm_native_serve_base_url, SamePrincipal, glm_native_live_subject_standing, glm_native_smoke_protocol, @@ -52,7 +52,7 @@ data glm_native_serving_load_receipt_path: String = "target/glm-native-serving-l data glm_native_serving_load_attempt_raw: String = "glm-native-serving-load" fn metrics_url() -> String { - join(["http://127.0.0.1:", to_string(glm_native_concurrent_profile.serve_port), vllm_route_path(r: vllm_route_metrics) as String], "") + join([glm_native_serve_base_url() as String, vllm_route_path(r: vllm_route_metrics) as String], "") } fn curl_metrics_argv() -> List {