Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .buildkite/gpu_benchmark_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ def render(root, url, commit, section, limit=100):
if shards or vendor in expected:
groups.append((f"{label} {topology}", shards, vendor_suites))
lines = [f"<!-- dagger-gpu-benchmarks:{section}:{commit} -->", "## GPU benchmarks", "",
"Timing regressions require five samples per revision and independent confirmation.", "",
"| Backend | Regressions | Improvements | Within noise | Inconclusive time | Suites |",
"Timing regressions require five samples per revision and independent confirmation. Allocation changes explicitly contradicted by that existing repeat are inconclusive; missing or neutral repeats retain the original allocation gate.", "",
"| Backend | Regressions | Improvements | Within noise | Inconclusive metrics | Suites |",
"|:---|---:|---:|---:|---:|:---|"]
totals = {key: [] for key in CATEGORIES}
for label, shards, vendor_suites in groups:
Expand All @@ -74,7 +74,7 @@ def changes(entries):
lines.extend(["", f"### GPU {category} across all backends", "", *changes(totals[category])])
for label, shards, vendor_suites in groups:
lines.extend(["", "<details>", f"<summary>{label}</summary>", "",
"| Suite | Regressions | Improvements | Within noise | Inconclusive time |",
"| Suite | Regressions | Improvements | Within noise | Inconclusive metrics |",
"|:---|---:|---:|---:|---:|"])
by_suite = dict(shards)
for suite in vendor_suites:
Expand All @@ -83,10 +83,10 @@ def changes(entries):
lines.append(f"| {suite} (missing or invalid report) | — | — | — | — |")
else:
lines.append(f"| {suite} | " + " | ".join(str(len(data[key])) for key in CATEGORIES) + " |")
for category in ("regressions", "improvements"):
for category in ("regressions", "improvements", "insufficient"):
entries = [(label, entry) for _, data in shards if "error" not in data for entry in data[category]]
if entries:
lines.extend(["", f"#### {category.capitalize()}", "", *changes(entries)])
lines.extend(["", f"#### {'Inconclusive metric changes' if category == 'insufficient' else category.capitalize()}", "", *changes(entries)])
lines.extend(["", "</details>"])
lines.extend(["", f"[GPU results and plots on Buildkite]({url})", f"<!-- /dagger-gpu-benchmarks:{section} -->"])
return "\n".join(lines)
Expand Down
15 changes: 15 additions & 0 deletions .buildkite/test_gpu_benchmark_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,21 @@ def test_summary_and_missing_suites(self):
body = report.render(root, "build", "abc", "pipeline")
self.assertIn("| CUDA GPU+MPI | — | — | — | — | 0/4 |", body)

def test_inconclusive_allocation_is_visible(self):
with tempfile.TemporaryDirectory() as directory, patch.dict(os.environ, {"BENCHMARK_GPU_VENDORS": "cuda"}):
root = Path(directory)
shard = root / "benchmark-results-cuda-gpu-array"
shard.mkdir()
data = {"schema_version": 1, "jobs": [{}], "regressions": [],
"improvements": [], "within_noise": [],
"insufficient": [{"name": "svd", "ratio": 1.3715477533805658, "metric": "allocs"}]}
(shard / "summary.json").write_text(json.dumps(data))
body = report.render(root, "build", "abc", "pipeline")
self.assertIn("Inconclusive metrics", body)
self.assertIn("Inconclusive metric changes", body)
self.assertIn("| CUDA GPU | 0 | 0 | 0 | 1 | 1/4 |", body)
self.assertIn("| CUDA GPU | `svd` | allocs | +37.2% |", body)

def test_preserves_current_cpu_and_other_pipeline(self):
cpu = "<!-- dagger-benchmarks -->\n<!-- dagger-benchmark-head:abc -->\nCPU results"
other = "<!-- dagger-gpu-benchmarks:other:abc -->\nOther GPU\n<!-- /dagger-gpu-benchmarks:other -->"
Expand Down
8 changes: 4 additions & 4 deletions .github/scripts/benchmark-report.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ function sortChanges(entries, improvement = false) {

function renderReport(results, runUrl, limit) {
const parts = [marker, '## Dagger benchmarks: `dirty` vs `master`', '',
'Counts are benchmark metrics (time, allocations, bytes). Timing changes require non-overlapping median ± IQR bands; both revisions need at least five timed samples, and timing regressions need an independent confirmation run.', '',
'| Backend | Regressions | Improvements | Within noise | Inconclusive time | Suites |',
'Counts are benchmark metrics (time, allocations, bytes). Timing changes require non-overlapping median ± IQR bands; both revisions need at least five timed samples, and timing regressions need an independent confirmation run. Allocation changes explicitly contradicted by that existing repeat are inconclusive; missing or neutral repeats retain the original allocation gate.', '',
'| Backend | Regressions | Improvements | Within noise | Inconclusive metrics | Suites |',
'|:---|---:|---:|---:|---:|:---|'];
for (const backend of results) {
parts.push(`| ${backend.label} | ${countCells(backend.available ? backend : null)} | ${backend.available}/${suites.length} |`);
Expand All @@ -92,13 +92,13 @@ function renderReport(results, runUrl, limit) {

for (const backend of results) {
parts.push('', '<details>', `<summary>${backend.label} (${backend.topology}) — ${backend.available ? `${backend.regressions.length} regressions, ${backend.improvements.length} improvements` : 'results unavailable'}</summary>`, '',
'| Suite | Regressions | Improvements | Within noise | Inconclusive time |',
'| Suite | Regressions | Improvements | Within noise | Inconclusive metrics |',
'|:---|---:|---:|---:|---:|');
for (const shard of backend.shards) {
parts.push(`| ${shard.suite}${shard.error ? ` (${shard.error})` : ''} | ${countCells(shard.data)} |`);
}
for (const [key, title] of [['regressions', 'Regressions'], ['improvements', 'Improvements'],
['within_noise', 'Within noise'], ['insufficient', 'Inconclusive timing changes']]) {
['within_noise', 'Within noise'], ['insufficient', 'Inconclusive metric changes']]) {
if (!backend[key].length) continue;
parts.push('', `#### ${title}`, '', changesTable(sortChanges(backend[key], key === 'improvements'), limit, false));
}
Expand Down
11 changes: 11 additions & 0 deletions .github/scripts/benchmark-report.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,14 @@ test('escapes benchmark names and bounds oversized comments without losing total
assert.equal(body.match(/<details>/g).length, backends.length);
assert.equal(body.match(/<\/details>/g).length, backends.length);
});

test('contradictory allocation metrics stay visible as inconclusive', t => {
const root = fixture(t);
write(root, 'default', 'linalg', { insufficient: [entry('linalg/dagger/svd', 1.3715477533805658, 'allocs')] });
const body = buildReport(root, 'https://example.com/run');
assert.match(body, /Inconclusive metrics/);
assert.match(body, /Inconclusive metric changes/);
assert.match(body, /Allocation changes explicitly contradicted/);
assert.match(body, /\| `linalg\/dagger\/svd` \| allocs \| \+37\.2% \|/);
assert.match(body, /\| Threads \| 0 \| 0 \| 0 \| 1 \| 1\/4 \|/);
});
14 changes: 9 additions & 5 deletions benchmark/ci.jl
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ job_summary_rows = [(j, get(job_regression_counts, j, 0), get(job_improvement_co
sort!(job_summary_rows; by = r -> (-r[2], -r[3], r[1]))

function job_summary_table(io, rows)
println(io, "| Job | Regressions | Improvements | Within noise | Inconclusive time | Advisory allocations |")
println(io, "| Job | Regressions | Improvements | Within noise | Inconclusive metrics | Advisory allocations |")
println(io, "|:---|---:|---:|---:|---:|---:|")
for (job, nreg, nimp, nnoise, ninsufficient, nadvisory) in rows
marker = nreg > 0 ? " ⚠️" : (nimp > 0 ? " ✅" : "")
Expand Down Expand Up @@ -289,9 +289,9 @@ open(joinpath(OUTPUT_DIR, "report.md"), "w") do io
end
println(io)
if !isempty(insufficient)
println(io, "#### Inconclusive timing changes")
println(io, "#### Inconclusive metric changes")
println(io)
println(io, "These changes had fewer than five timed samples in at least one revision, lacked a measured spread, or were not confirmed by the independent run; they are not counted as improvements or regressions.")
println(io, "Timing changes lacked five samples, a measured spread, or independent confirmation. Allocation changes listed here crossed opposite thresholds in the original and existing reversed-order comparisons. They are not counted as improvements or regressions.")
println(io)
for (name, metric, r) in insufficient
println(io, "- `", name, "` (", metric, "): ", pct(r))
Expand All @@ -301,10 +301,14 @@ open(joinpath(OUTPUT_DIR, "report.md"), "w") do io
if confirmation !== nothing
println(io, "#### Independent confirmation (reversed revision order)")
println(io)
println(io, "Timing regressions are counted only when both comparisons agree, with at least five samples per revision.")
println(io, "Timing regressions are counted only when both comparisons agree, with at least five samples per revision. Explicitly opposite allocation/memory classifications are inconclusive; missing or neutral repeat data leaves the original allocation gate unchanged.")
println(io)
println(io, create_table(confirmation; key="median", add_ratio_col=true))
println(io)
println(io, "Reversed-order allocations / memory:")
println(io)
println(io, create_table(confirmation; key="memory", add_ratio_col=true))
println(io)
end
println(io, "#### Median time")
println(io)
Expand Down Expand Up @@ -338,7 +342,7 @@ if !isempty(within_noise)
end

if !isempty(insufficient)
println("\n$(length(insufficient)) timing change(s) are inconclusive: fewer than five samples, missing spread, or no independent confirmation.")
println("\n$(length(insufficient)) metric change(s) are inconclusive: timing lacks samples/spread/confirmation, or allocation comparisons disagree.")
end

if !isempty(advisory_allocations)
Expand Down
28 changes: 20 additions & 8 deletions benchmark/compare.jl
Original file line number Diff line number Diff line change
Expand Up @@ -114,18 +114,30 @@ function attach_sample_counts!(flat, raw, prefix="")
return flat
end

# Only timing regressions require a second independent comparison. Allocation
# metrics retain their existing gates; unconfirmed timing flags stay visible.
# Only timing regressions trigger a second independent comparison. Allocation
# gates still stand alone, but an already available repeat must not explicitly
# contradict a claimed allocation regression or improvement. Missing/neutral
# repeat allocation data leaves the original gate unchanged.
function confirm_timing_regressions(first, second)
confirmed = Set((name, metric) for (name, metric, _) in second.regressions if metric == "time")
regressions = filter(first.regressions) do (name, metric, _)
metric != "time" || (name, metric) in confirmed
end
reversed_regressions = Set((name, metric) for (name, metric, _) in second.regressions
if metric in ("allocs", "memory"))
reversed_improvements = Set((name, metric) for (name, metric, _) in second.improvements
if metric in ("allocs", "memory"))
insufficient = copy(first.insufficient)
for entry in first.regressions
regressions = filter(first.regressions) do entry
name, metric, _ = entry
keep = metric == "time" ? (name, metric) in confirmed :
!((name, metric) in reversed_improvements)
keep || push!(insufficient, entry)
keep
end
improvements = filter(first.improvements) do entry
name, metric, _ = entry
metric == "time" && !((name, metric) in confirmed) && push!(insufficient, entry)
keep = !((name, metric) in reversed_regressions)
keep || push!(insufficient, entry)
keep
end
sort!(insufficient; by=last, rev=true)
return (; first..., regressions, insufficient)
return (; first..., regressions, improvements, insufficient)
end
33 changes: 33 additions & 0 deletions benchmark/compare_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,36 @@ end
attach_sample_counts!(flat, raw)
@test flat["suite/op"]["samples"] == 4
end

@testset "Existing confirmation reconciles explicit allocation conflicts" begin
stats(; allocs=100, memory=1000, samples=2) =
Dict("allocs"=>allocs, "memory"=>memory, "samples"=>samples)
baseline = Dict("op"=>stats())
first = compare_benchmarks(baseline, Dict("op"=>stats(; allocs=150, memory=500)))
opposite = compare_benchmarks(baseline, Dict("op"=>stats(; allocs=50, memory=1500)))
result = confirm_timing_regressions(first, opposite)
@test isempty(result.regressions)
@test isempty(result.improvements)
@test Set(result.insufficient) == Set([("op", "allocs", 1.5), ("op", "memory", 0.5)])
@test first.regressions == [("op", "allocs", 1.5)]
@test first.improvements == [("op", "memory", 0.5)]
@test isempty(first.insufficient)
@test opposite.regressions == [("op", "memory", 1.5)]
@test opposite.improvements == [("op", "allocs", 0.5)]

# Preserve standalone allocation policy for neutral/missing repeat data,
# agreement, and changes on another benchmark or another metric.
for repeat in (compare_benchmarks(baseline, baseline),
compare_benchmarks(baseline, Dict()), first,
compare_benchmarks(Dict("other"=>stats()), Dict("other"=>stats(; allocs=50))))
unchanged = confirm_timing_regressions(first, repeat)
@test unchanged.regressions == first.regressions
@test unchanged.improvements == first.improvements
@test isempty(unchanged.insufficient)
end
only_memory = compare_benchmarks(baseline, Dict("op"=>stats(; memory=1500)))
unchanged_count = confirm_timing_regressions((; first..., improvements=Tuple{String,String,Float64}[]), only_memory)
@test unchanged_count.regressions == first.regressions
@test isempty(unchanged_count.insufficient)
@test isempty(result.advisory_allocations)
end
Loading