Skip to content

Latest commit

 

History

History
644 lines (554 loc) · 38.6 KB

benchmark-methodology.md

File metadata and controls

644 lines (554 loc) · 38.6 KB
myst
html_meta
description keywords
How AgentKernelArena measures GPU kernels with CUDA or HIP Graph replay, records event fallbacks, and compares matched benchmark cases.
AgentKernelArena, benchmark, CUDA Graph, HIP Graph, CUDA event, HIP event, Triton, FlyDSL, kernel timing, speedup

Performance measurement methodology in AgentKernelArena

AgentKernelArena uses graph-first device timing for Python-callable GPU kernels, regardless of whether the kernel is implemented in Triton, HIP, FlyDSL, or PyTorch. The canonical implementation is src/tools/perf/aka_benchmark.py. PyTorch exposes CUDA and ROCm through the same torch.cuda namespace, so benchmark_method: cuda_graph means CUDA Graph on a CUDA build and HIP Graph on a ROCm build.

Schema-v3 kernel tasks

Single-GPU kernel tasks (see the task contract) use one timing method in every language: amortized cold-cache CUDA-graph timing (benchmark_method: cuda_graph_cold_cache_amortized, 10 warmups, 100 samples, median). Every call starts with its caches evicted by a 1 GiB read sweep, and the fixed cost of launching and timing a graph is subtracted instead of being charged to the call. There is no Event fallback for these tasks: a baseline that cannot be captured on the current stream fails the QA audit (QA-TIMING-METHOD), and each performance case must take the baseline at least 4 us of amortized time (QA-TIMING-FLOOR). The performance cases span at least 100x in var-axis size, except for model-specialized tasks with an evidenced production-range span exemption, whose cases cover the part of the observed production range above the floor at both ends; the floor and the timing method are the same for them. The final evaluation remeasures the baseline interleaved with the candidate, and the task's speedup is the geometric mean of the per-case speedups (baseline time over candidate time). A task with case weights uses the serving-weighted speedup, the ratio of total times Σ wᵢ·t_baselineᵢ / Σ wᵢ·t_candidateᵢ, where a case's weight is how often it runs in the recorded workload. The remaining sections of this page describe the shared helper and the older fallback and cold-weight policies, which apply to the end-to-end and legacy helper paths.

Why the replay cost is subtracted

Cold-cache timing needs every call to start with evicted caches, so the earlier single-call method (cuda_graph_cold_cache) timed one call per graph replay: preparation, eviction, start Event, a replay of a one-call graph, end Event. That span also contains the Event pair and the graph launch, about 7 us on MI355X. An empty Triton kernel scored 9.1 to 9.5 us although it adds about 1.6 us inside a graph. The constant compresses the speedups of short operators and let cases pass the earlier 10 us floor on overhead alone. Cold caches stay: with warm caches a decode-size weight remains in the 256 MB MALL between samples.

The amortized method

For each performance case, performance_action in src/tools/arena_eval/evaluate.py times K calls per sample with benchmark_cuda_graph_cold_cache_amortized_samples. Every call i is captured into two graphs of its own:

  • an operator graph: restore call i's mutable inputs, poison call i's outputs, evict the caches, call the implementation;
  • a reference graph: the same without the call.

A sample replays the K operator graphs back to back between one Event pair, followed by one more eviction, and then the K reference graphs the same way, and reports (operator span - reference span) / K. The order of the two groups alternates between samples (reference first, then operator first) so drift cancels. Preparation, the evictions, the graph launches and the Events are in both spans, so their average cost cancels; their replay-to-replay variation does not, and is the noise of a sample. What remains is each call's time from evicted caches, including the write-back of its outputs: every call's falls into the next call's eviction, and the trailing eviction takes the last call's. Each sample's two raw spans are kept in benchmark_operator_graph_ms and benchmark_reference_graph_ms.

Each call has a graph of its own so that it must join any stream it forks before its capture ends: in one graph holding all calls, a call could fork its work to another stream and join it only at the last call, so that the work overlapped the next calls' preparation and eviction and was subtracted with them.

What the time includes

The amortized time is a call's time from evicted caches until what it wrote has left the caches. It includes the write-back of the output lines that are still dirty when the kernel returns, which the following eviction forces. The evictions are inside both Event spans (benchmark_cache_flush_in_timing: true) and the reference group's are subtracted (benchmark_cache_flush_subtracted: true), so the sweep itself is not charged, only what the call adds to it.

The single-call method ended its span when the kernel returned. It charged the write-back only as far as an output did not fit in the caches, and left out the lines still dirty at that point. Charging it is part of the metric:

  • The roofline floors count every output byte as written to HBM once where rule G1 applies (src/roofline/bytes_model.py), so a time that leaves the write-back out can fall below its own floor.
  • The cost is charged in the same way whether or not an output fits in the caches, and whether an implementation writes with non-temporal stores or leaves the lines to the caches.
  • Inputs are read cold because other work between two calls replaces the cache contents. The same work evicts the call's outputs.

An amortized time is therefore not the single-call time minus the fixed replay cost. A case that writes much, with an output that fits in the caches, can take longer than that difference, and the ratio of two implementations can change when their dirty footprints differ: an implementation that also writes intermediates is charged for them.

Calls per sample

K is 4 GiB / (memory of one call), clamped to 4..32 (amortized_calls_per_replay). When 4 calls would hold more than 48 GiB (a call of more than 12 GiB), K is 48 GiB / (memory of one call) instead, but at least 2. On MI355X four calls of the largest cases (22 to 28 GiB each) ran out of the device's 288 GB, and a candidate, which also holds the baseline outputs of every draw, ran out where its baseline fit. The cases with such calls take hundreds of microseconds or more, so the larger noise of a two-call sample is a small share of their time, and with two calls the per-sample permutation still changes which draw a call gets. The memory of one call is its input draw (twice: stored and staged), its reference outputs, three copies of its checked values (its output and mutable-input buffers, their first checked copy and the baseline's outputs) and the poison patterns. It depends only on the case, never on a measured time or on the role, so baseline and candidate always use the same K. More calls make a sample less noisy (about +-0.6 us p10 to p90 at 32 calls) and shrink any per-sample cost the reference does not cancel. The per-call median can still depend slightly on K, so K is recorded as benchmark_calls_per_replay and is part of the comparison identity. At 4 calls the budget, and at 2 calls the 48 GiB bound, can be exceeded, and an allocation that does not fit fails the case instead of weakening the measurement. The budget does not cover memory the implementation allocates itself; the operator graphs share one memory pool, and a workspace that does not fit fails the case the same way. To leave room for the float64 temporaries of a full check, the references and baseline outputs of the draws wait in host memory and are copied to the device for each full check (the bitwise comparisons use the device-resident first checked copy), and the correctness draws' references and baseline outputs are released once the single-call samples on them are done. The evaluator also returns the allocator's cached memory after it has drawn the inputs and after every case. K still counts the references as one call's memory, so it stays a function of the case's sizes.

Draws and checks

The case has K input draws: seeds derived from the case's two framework seeds (draw_seed), each with its own reference outputs and, when a bound is baseline-relative, its own baseline outputs. Every call has its own input, output and mutable-input buffers, so every call's result is still there after a sample. Before every sample a fresh random permutation from the operating system's entropy (os.urandom) assigns the draws to the calls, and the draws are copied into the calls' input buffers then, outside both Event spans; the captured preparation of a call restores its mutable inputs from that copy and poisons its outputs. The permutation is drawn after the candidate's last Python call and is held only in local variables. Warm-up runs on the two correctness draws, never on a timed draw. Poison is captured too: NaN fills of floating-point outputs capture directly, and for other outputs K distinct random patterns are drawn before capture and copied in, because a device generator cannot be created during capture.

The candidate's Python runs once per call while the graphs are captured, so it can tell the calls apart. With one shared output buffer it could work on the last call only; with repeated inputs it could copy an earlier call's result; and if a graph saw the same draw in every sample, a call could keep device state of its own, compute in the first sample and restore the stored result in every later one, without reading its inputs. Distinct draws, per-call buffers and the per-sample permutation close these: after every sample the evaluator checks every call against the reference of the draw it had in that sample, with the same bounds as correctness (baseline-relative bounds included). The first check of each draw is the full check; later results for that draw are compared bitwise with the first checked one, and a difference is checked fully again.

After the samples the reference group is replayed once more, and the checks of every call must reject what it leaves. A candidate whose checks accept a call that never ran the operator fails the case with failure_kind: unverifiable_measurement; for the baseline the count is recorded as reference_control_undetected_calls and fails the QA audit (QA-TIMING-CONTROL).

A case also fails as unverifiable_measurement, in both roles, when its amortized median is below 0.8 x single-call time - 10 us (CONSISTENCY_RATIO, CONSISTENCY_SLACK_MS), where the single-call time is measured on the same K timed draws, after the amortized samples: every draw is timed equally often, at least three times (and at least 10 samples in all), and the reference is the mean over the draws of each draw's median (single_call_timed_draws_ms), which is what one amortized sample averages. With one sample per draw a single slow sample moved the mean: an honest copy of a GEMM baseline measured 109 us amortized against a 163 us reference in one process, while its baseline measured 107 us single-call on the same draws. Removing the replay's fixed cost (about 7 us) cannot account for that much: the timed calls did less work than the single-call samples. The correctness draws are no reference for this. When an operator's work depends on its inputs, it takes different times on different draws: ssd_state_passing splits its chunks into sequences at random cut points and its time follows the longest sequence, and its baseline measured 343 us single-call on the correctness draws but 240 us amortized on the timed draws of the c128_s4 case, which failed the bound although honest. Before a case fails the bound, the reference is measured once more on the same draws and the lower of the two decides (single_call_timed_draws_first_ms, single_call_timed_draws_retry_ms). A case that still fails keeps the amortized median and both references in its measured_output_failures record. A slowdown of a whole reference stage once raised the references of honest cases to 25 and 99 us on MI355X, where three other runs of the same cases measured 14 and 66 us. A case fails only when its amortized median is below the bound for both references: the re-measurement lets a case through only when its median clears the bound of the lower reference. The bound limits a cheat confined to the timed stage: a review of this method estimated that such a cheat can stay under it with at most about 1.3 to 1.9x fake speedup. It does not stop an implementation that cheats the same way in both stages (below).

Copying each call's outputs into a snapshot after the call, in both graphs, would not cancel: in the operator graph the copy reads values the call has just left in the caches, in the reference graph it reads poison that the eviction has removed from them. On MI355X, add with 8M float16 elements measured 10.6 us with such copies and 14.0 to 15.3 us without them.

Short cases also vary from process to process more than within a process. On MI355X, add with 8M float16 elements measured 12.3 to 13.5 us across ten fresh processes on two GPUs (coefficient of variation 3%), while one process's samples spread about +-1.2 us around their median and the single-call medians of the same processes varied by 2%. The cause is not identified; the final evaluation therefore averages several processes per arm and flags cases whose spread is high (below).

Implementation code that fingerprints its inputs on the device (reads a few elements) and returns a result stored for that fingerprint in an earlier replay is not ruled out by these checks or by the consistency bound, because it can do so in the single-call samples and the amortized samples alike. A review verified that such a cheat passes with this method and with the earlier single-call method, so the gap predates it. Timing samples on secret fresh draws, never seen before by the implementation, are the planned follow-up.

A capture that fails (for example because a call left a forked stream unjoined) fails its case, and the remaining cases of the action are reported as not measured: the process's capture state is no longer usable. PyTorch aborts the process when such a graph is destroyed, so the timing helper keeps it alive (failed_captures()), and a process that holds one, such as the evaluator, ends with os._exit after reporting its result. A tampering error raised during capture keeps its label even when ending the capture raises another error.

The evaluator's binding integrity check (see What happens during a run) runs after every candidate call, including the captured ones, after every sample and after timing.

Final evaluation

The final evaluation measures each arm of a single-GPU task in four fresh processes, interleaved in balanced blocks (baseline, candidate, candidate, baseline, twice), and scores the per-case mean of each arm. interleaved_statistics in the result records, per case, each arm's coefficient of variation over its processes, a high_variance flag above 5%, and a paired 95% interval of the speedup (the k-th baseline process paired with the k-th candidate process). With a performance action of about 10 to 35 s on the tasks measured, the four extra processes cost a few minutes per task. A multi-GPU task keeps two processes per arm (baseline, candidate, baseline, candidate): it holds a node's GPU group, and its evaluation must fit the QA auditor's 600 s budget (QA-EVAL-BUDGET).

Single-call time

Before the amortized measurement each case is also timed with the single-call method on the two correctness draws (benchmark_cuda_graph_cold_cache_samples, 10 samples, every sample checked). Its median is recorded as single_call_cold_ms in the case metadata for continuity with earlier results; it is not scored and does not choose K. The single-call samples on the timed draws, which the consistency bound uses, are recorded as single_call_timed_draws_ms and single_call_timed_draws_samples. Times, speedups and floor checks from the single-call method are not comparable with amortized ones: the method names differ, and the evaluator never pairs the two.

Multi-GPU kernel tasks

A multi-GPU task does not use the amortized method: it keeps the single-call cold-cache protocol on every rank, reports benchmark_method: cuda_graph_cold_cache, keeps the 10 us floor of that method (QA-TIMING-FLOOR) and adds a synchronized release (benchmark_distributed_cold_cache_samples). Per sample, every rank prepares its inputs and zeroes its symmetric buffer, sweeps its own device's caches, synchronizes and meets a host barrier; rank 0 then broadcasts a CLOCK_MONOTONIC deadline 2 ms ahead, every rank spins until it, enqueues a device start barrier and times one replay of its own captured graph with GPU events, and a second barrier ends the sample. The host release aligns only the hosts; without more, the devices start the replay tens of microseconds apart and an early rank's span includes waiting in the collective for its peers. The device start barrier, a one-thread kernel on the sample's stream right before the start event, holds the stream for 200 µs (so the host has queued the timed replay behind it), then exchanges an epoch with every rank through uncached peer-mapped flags and spins until all ranks have arrived, so every rank's start event fires together. A barrier that does not complete within 5 s fails every rank. The sample's time is the maximum over ranks of the per-rank event spans (benchmark_rank_aggregation: max_over_ranks); the case's time is the median of those maxima. The method, metric, eviction policy and byte count are those of cuda_graph_cold_cache, so the protocol checks and comparison rules above apply unchanged; baseline and candidate of one task always use the same rule. The metadata adds benchmark_world_size, every rank's raw samples (benchmark_rank_samples_ms), the per-sample spread between the slowest and fastest rank (benchmark_rank_spread_us, with its median and maximum), the device start barrier (benchmark_start_alignment, benchmark_start_barrier_delay_us, and per sample the longest wait for the last rank, benchmark_start_barrier_wait_us: the device start skew it removed), the host's queueing of the timed replay (benchmark_host_enqueue_us_max; per rank, benchmark_late_enqueue_samples counts samples whose queueing outlasted the barrier's hold), the per-sample spread of host release times (benchmark_release_skew_us), the latest release after a deadline (benchmark_release_late_us_max) and how often each rank was the slowest. A collective finishes when its slowest rank does, so the maximum is the conservative per-call time. The pure aggregation (max_over_ranks, rank_spread_us, release_skew_us, summarize_rank_samples, summarize_start_alignment) and the release loop (synchronized_release_samples) take the communication object and the start barrier as arguments, so the helper still depends only on the standard library and PyTorch; the evaluator's DeviceStartBarrier (src/tools/arena_eval/distributed.py) compiles the barrier kernel with the HIP runtime compiler.

Canonical Python API

The canonical implementation is src/tools/perf/aka_benchmark.py, which the schema-v3 evaluator uses for kernel tasks. Its ReadOnlyCacheFlush uses a reusable initialized 1 GiB read sweep, after input preparation and before every timed call. The single-call cuda_graph_cold_cache metric is an Event graph span with eviction excluded; the amortized cuda_graph_cold_cache_amortized metric is the per-call difference of two such spans, described above. Both are distinct from the legacy warm cuda_graph method below, profiler kernel-duration sums and cuda_graph_cold_weights rotation.

Cold-cache performance case rows must put the returned timing metadata under metadata, with benchmark_method and execution_time_ms on the case row. The protocol checks the cache policy, metric and eviction byte count, and one invocation per replay with the eviction outside the span (single-call) or the graph layout, trailing eviction, alternating order, evictions inside the spans and subtracted, and a positive call count (amortized); comparison rejects differing or missing cache identities. The reference's paired utility preserves raw samples and reports a geometric mean speedup with a paired-round 95% percentile-bootstrap interval. It is a diagnostic comparison, not a replacement for task correctness or Arena scoring.

The common mean-time interface is:

mean_ms, metadata = benchmark_cuda_graph_or_events(
    fn,
    prepare_fn=None,
    warmup=10,
    repetition=100,
    target_ms=1.0,
    estimate_reps=5,
    max_graph_repeats=1000,
)

mean_ms is device milliseconds per invocation of fn. Suites whose scoring contract uses a median or percentile call benchmark_cuda_graph_or_events_samples() instead. It returns the same metadata and a list of per-invocation millisecond samples.

The callable must launch already-compiled device work. JIT compilation, module construction, and scratch/workspace sizing belong before the benchmark call. If the public operation returns newly allocated outputs, both sides must retain that same contract; otherwise both sides use caller-owned output buffers.

Stateful in-place kernels may provide prepare_fn. It runs on the active benchmark stream before each warmup and measured sample, but before the start event, so input restoration is ordered correctly and excluded from the kernel time. In this mode each graph replay contains one logical fn call; this prevents a later captured call from consuming state mutated by an earlier one. Output resets follow the same rule: they belong in prepare_fn, not in the captured/timed callable.

Graph-first measurement

For each fixed test case, the helper:

  1. Refuses to score when torch.cuda.is_available() is false. CPU wall-clock time is never substituted for kernel device time.
  2. Runs the requested warmup calls and synchronizes them.
  3. Captures and primes a small estimate graph, then measures one replay with GPU events.
  4. Rejects PyTorch's explicit empty-graph warning and independently rejects an effectively empty replay rather than reporting a fabricated near-zero time.
  5. Selects a bounded number of calls per graph so one replay targets roughly target_ms. This amortizes host launch overhead for short kernels.
  6. Captures and primes the final graph outside the reported sample set, replays it repetition times, and divides each replay's event time by the calls captured in that graph.
  7. For tasks that request a timed-run handle, exposes the exact captured output buffers and an additional replay of the same graph executable. Correctness checks poison or perturb those buffers, replay, and compare them with the eager/reference result. Automatic graph-to-Event fallback with a collector fails closed. Explicit Event observation is described below.

The start event, graph replay, and end event all run on the same side stream. This ordering is important: recording events on one stream while replaying on another can appear to time an empty stream.

Successful samples record at least:

benchmark_method: cuda_graph
benchmark_samples: 100
benchmark_effective_repeats: 80
benchmark_target_ms: 1.0
benchmark_max_repeats: 1000
benchmark_warmup: 10

GPU-event fallback

Some callables cannot be captured, for example because they synchronize the device, read a device scalar on the host, allocate capture-unsafe memory, or launch work on an incompatible stream. Capture failure, empty capture, and invalid replay timing fall back explicitly to eager GPU-event measurement:

benchmark_method: cuda_event_fallback
benchmark_fallback_reason: "cuda_graph_failed: RuntimeError: ..."
benchmark_effective_repeats: 1

Tasks may select Event timing for a known graph-capture incompatibility, or when the declared measured unit requires a fresh invocation of the public Python callable on every sample (for example, a wrapper that allocates and returns a new output). Pass use_cuda_graph=False with a stable fallback_reason, document why graph replay is not equivalent, and apply the same method and callable to baseline and candidate. A result is never silently changed to Event timing merely because graph timing is slower.

Graph after_sample receives the captured output after each reported replay. When one graph contains multiple calls, capture retains only the last returned output; graph replay also does not rerun Python dispatch or allocation. A single-call graph can make every replay's captured output observable, but it still measures graph replay rather than a fresh public call. Choose the method from the task contract, not from the apparent speedup. Disclose a method change and compare its before/after device times only under matched hardware, image, runtime, inputs and sampling settings. Device Events report GPU elapsed time; they do not turn host allocation or dispatch into CPU wall-clock timing.

Before accepting fallback, task harnesses should hoist host-side shape work, pointer-table creation, temporary allocation, and JIT setup out of fn, then directly launch the underlying kernel where that is part of the task's stable API. Do not remove a public wrapper's required allocation or dispatch merely to make its declared measured unit graph-capturable. A legacy HIP extension that hard-codes stream 0 is a legitimate example of an incompatible launch: CUDA/HIP Graph capture begins on a non-default side stream, while capturable PyTorch allocation/fill nodes can otherwise make a graph look non-empty even when the target kernel escaped to stream zero. HIP task harnesses therefore run a conservative source preflight. Every visible launch must use a stream obtained from PyTorch's current CUDA/HIP stream; a literal legacy stream, capture-unsafe synchronization/allocation, or an unverifiable launch construct classifies the baseline case as Event-only. For comparisons against a HIP reference, the reference source fixes this policy; candidate source cannot downgrade a graph-capable reference to Events.

Fallback still uses device events; it does not use Python, subprocess, or CPU wall-clock timing. Host and wall-time-only fields are rejected by the central performance parser.

For an explicit Event path, timed_run=TimedRun() exposes the return value from the last measured sample, after its ending GPU Event completes. It does not run a new untimed invocation to obtain that value. Its rerun() invokes the same eager callable on the measured stream, with prepare_fn before the call. This can allocate a new output and execute different Python dispatch decisions; it is not captured graph replay. The task must validate the measured output first and then validate the returned re-invocation output. Output observation alone is not a correctness verdict.

Collector metadata records benchmark_timed_run_kind: eager_callable for explicit Events and captured_graph for graph replay. The existing benchmark_method: cuda_event_fallback and fallback reason are unchanged. Automatic fallback from a failed/empty/invalid graph still rejects a requested collector; it does not silently switch the validation contract. Event timing must be selected explicitly when that is the task's declared methodology.

Cold-weight timing

benchmark_cuda_graph_cold_weights_samples() is an opt-in method for operators whose cost in a decode step comes from reading a weight from HBM. Under the default timing every sample reads the same weight, so after the first sample the weight sits in the L2 and the MALL. When prepare_fn restores or rotates inputs, each replay also holds a single call, so a decode-size operator that runs for a few microseconds is charged the whole fixed cost of a graph replay.

The task passes one zero-argument callable per weight copy. cold_weight_copy_count(weight_bytes) gives enough copies to pass 1 GiB in total, and at least 8:

from _aka_benchmark import (
    TimedRun, benchmark_cuda_graph_cold_weights_samples, cold_weight_copy_count,
)

copies = cold_weight_copy_count(weight_bytes, rotate_bytes=1 << 30, min_copies=8)
calls = [make_call(weights[i]) for i in range(copies)]
samples, metadata = benchmark_cuda_graph_cold_weights_samples(
    calls, warmup=20, repetition=100, prepare_fn=rotation, timed_run=TimedRun())

One CUDA graph calls every callable once, in order. Each sample is the replay time divided by the number of calls, so every call reads its weight from HBM and the fixed replay cost is shared by all calls. TimedRun.outputs is the list of per-call outputs, after_sample receives that list, and rerun_ms() returns the per-call time of one more replay. The metadata reports benchmark_method: cuda_graph_cold_weights, benchmark_calls_per_replay and benchmark_cold_weight_copies. The method has no event fallback, and AKA_BENCHMARK_FORCE_EVENT=1 makes it raise.

Every call needs its own weight copy and its own input buffer. Each weight copy is a separate draw from the task's initializer and stays fixed. prepare_fn runs once before the start event of each replay and draws a fresh, independent input into every call's buffer. With identical copies an implementation could read one copy for every call, so the weight stays in the caches. With identical copies and one shared input it could also compute one result and copy it to the other outputs. Both shortcuts pass the output checks.

A task that uses this method keeps the integrity checks of its default timing. It checks the output of every call against a reference for that call's input and weight copy, in the timed replays and in replays with fresh unseen inputs for every call. It also holds the reported time to the cost of the unseen inputs and checks that no weight copy changed.

Independent task workspaces

Task sources do not import AgentKernelArena's src package and do not carry copies of the canonical helper. For a schema-v3 kernel task, src/task_contract.py::render_workspace writes the evaluator and the timing helper into the run workspace as _aka_eval/_aka_benchmark.py, beside the resolved contract; solution/ is the only editable tree. The end-to-end serving tasks receive their serving client helpers from src/perf_helper_materialization.py. The materialized workspace is self-contained: the Python timing helper depends only on the standard library and PyTorch.

Generated helpers and protected evaluation inputs are covered by the harness integrity guard. A kernel task's candidate is the solution/ tree; every other file, including _aka_eval/, the contract, baseline and reference, is protected. See the task guide for the exact rules.

Normal optimization runs and quality_loop also snapshot the original task package's non-editable inputs before launching the optimizer. This includes case data such as session_cases.json, reference implementations, and helper files outside test directories. The snapshot is kept in framework memory and checked before evaluation and again before writing the final result. Editing, deleting, or renaming an original input rejects the run for every agent. The candidate boundary (solution/ for kernel tasks) identifies the implementation. Runtime outputs under build/, logs/, and perf/, environment caches, and generated result reports are not task inputs. New preparation files are allowed unless they match protected harness patterns, in which case the existing scratch-file removal policy applies. Cloned or image-seeded dependency trees retain the existing harness-pattern protection; this input snapshot is not a blanket source allowlist for those repositories.

Baseline and optimized fairness

The evaluator matches baseline and optimized cases by unique explicit ID first, then by unique parameters or shape. An ID establishes a pair but does not prove equal work: each pair must also have identical reported shape, params, and dtype fields. Changing or removing any of those fields prevents performance scoring, including for singleton/index-matched cases. Fields absent on both sides remain supported for legacy producers, with task inputs protected by the snapshot above. Nested metadata.params and metadata.dtype are normalized and these fields survive performance YAML round trips. Other diagnostic fields and adaptive timing repeat counts are not workload identity.

Workload mismatches retain measured timings, produce zero speedup, suppress comparison plots, and are recorded in workload_consistent and workload_mismatches in task_result.yaml.

Benchmark methods are then compared per matched case:

  • graph versus graph is comparable;
  • event fallback versus event fallback is comparable;
  • graph versus event fallback is retained as timing data but produces no speedup;
  • cold-weight graph (cuda_graph_cold_weights) is comparable only with cold-weight graph;
  • cold-cache graph (cuda_graph_cold_cache or cuda_graph_cold_cache_amortized) is comparable only with the same cold-cache method, metric, eviction policy and eviction byte count (and, for the amortized method, the same calls per sample); the two cold-cache methods are never compared with each other;
  • different shapes may use different methods, provided each matched baseline/optimized pair uses the same exact method.

The baseline result fixes the timing policy before candidate measurement. If a baseline case succeeds with Graph but the candidate falls back to Events, the candidate timing remains visible for diagnosis but earns no performance score. Only a case that the baseline itself classified as Event-only can be scored as Event versus Event. The evaluator never collects or selects a candidate-driven alternate Event baseline.

Missing or unknown method metadata is not comparable and produces no speedup; every scored case must explicitly identify cuda_graph, cuda_event_fallback, cuda_graph_cold_weights, cuda_graph_cold_cache or cuda_graph_cold_cache_amortized.

An aggregate mixed:... method string is never scored, even when the baseline and optimized strings are identical. It records only a set of methods and loses the shape-to-method mapping, so equality cannot prove that the same shapes used the same timer. The timing is retained with an ambiguous_mixed_aggregate mismatch reason.

This means a task can legitimately use graph timing for one shape and event fallback for another. The evaluator records method sets, per-case mismatch details, and benchmark_method_consistent in task_result.yaml. All benchmark_* metadata survives the baseline/optimized YAML round trip.

Serving wall-clock measurement

Tasks that declare evaluation.measurement.kind: serving do not time a kernel. Their unit of work is a fixed request set completed by a pinned benchmark client against a freshly started model server; the reported benchmark_method is serving_wall_clock, execution_time_ms is the client's wall duration, and metrics.output_tokens_per_s is the scored quantity. The protocol rejects a case whose completed requests, output tokens or input tokens differ from the manifest, or whose throughput does not equal tokens divided by duration. Graph-replay checks do not apply to this timer.

Final evaluation alternates baseline and candidate for at least three fresh pairs, each in its own clean container from the trusted task template. The per-case ratio is the median of the paired throughput ratios; several cases combine by geometric mean. serving_measurement.uncertainty keeps the ratio range and each side's repeat variation so a small median is not read as a gain. Before each performance action the container verifies the device is idle, and before final evaluation the worker container is swept of agent leftovers; both records are part of the result. Kernel tasks keep the device-timing rules above; mixed runs report the two groups separately with no combined average. See the e2e guide for the task-side contract.

Maintenance checks

Run:

make check-perf-helpers

src/tools/sync_perf_helpers.py audits committed task sources; it is not a GPU qualification. Schema-v3 kernel tasks (task.yaml) carry no benchmark code and are only counted. Every remaining schema-v2 task (config.yaml) must be a serving recipe (the exact bootstrap stub plus a hash-pinned workload) or a serving client whose scripts/evaluate.py imports _aka_serving; anything else fails the check instead of quietly using an undocumented timer. The check also fails when a generated helper copy (_aka_benchmark.py, _aka_serving*.py, _aka_eval/) is committed under tasks/.

Pull requests also run the CPU/mock unit suite and Python compilation audit in CI.

Event output-observation qualification

On 2026-09-15, Slurm job 139392 ran the three tests/test_gpu_graph_smoke.py checks on an MI355X (gfx950) with the pinned SGLang 0.5.19 qualification image on node crsuse2-m2m-001: all three passed, none skipped. Before qualification, the allocated device had 99.8% of its memory free and AMD-SMI reported no running processes. The previous helper rejected an explicit Event collector on the same GPU; the updated helper observed the actual measured output and validated eager re-invocation. See the runtime qualification record for image identities.

The HGEMM task also exercised all five original cases with the existing pinned SGLang 0.5.14 runtime (FlyDSL 0.2.2). Original and updated harnesses both passed baseline compile, correctness and performance actions using the same canonical helper. Each retained 100 Event samples, one call per sample and the original capture-unsafe reference reason. Updated results additionally recorded eager_callable, timed_output_correctness: PASS and replay_correctness: PASS for all five cases. These sequential runs verify timing boundaries and output checks; they do not establish a performance improvement. Action-level evidence is distinct from a full validator report (the predecessor of the QA auditor's qa_report.yaml). That separate HGEMM report was subsequently framework-finalized as PASS in the same job, with an implemented frozen initial candidate and no baseline diagnostic exemption.

Earlier job 139346 on node crsuse2-m2m-217 also produced successful functional reports, but a subsequent audit found external process/memory occupancy and other tasks failed with allocation/launch resource errors. Preserve those reports as historical functional evidence; all performance from that node is unqualified. Job 139392 explicitly excluded node217 and repeated the smoke, HGEMM boundary checks and the full task validator run (the predecessor of the QA audit) on the available-memory allocation described above. Neither sequential run establishes an optimization gain.