Skip to content

Commit b74eed8

Browse files
Make analysis tools robust to NaN values from timeouts
- Filter out NaN values when computing mean, max, and std statistics - Exclude NaN values from plots to avoid visualization errors - Report number of timed-out tests in summary output - Ensure categorize_results excludes NaN values when selecting best algorithms - All aggregation functions now properly handle NaN values that indicate timeouts This ensures the autotuning system works correctly even when some tests timeout, which is expected behavior for large matrix sizes or slow algorithms.
1 parent ef0db19 commit b74eed8

File tree

4 files changed

+30
-16
lines changed

4 files changed

+30
-16
lines changed

lib/LinearSolveAutotune/src/LinearSolveAutotune.jl

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,13 @@ function Base.show(io::IO, results::AutotuneResults)
7878
println(io, " • Julia: ", get(results.sysinfo, "julia_version", "Unknown"))
7979
println(io, " • Threads: ", get(results.sysinfo, "num_threads", "Unknown"), " (BLAS: ", get(results.sysinfo, "blas_num_threads", "Unknown"), ")")
8080

81-
# Results summary
82-
successful_results = filter(row -> row.success, results.results_df)
81+
# Results summary - filter out NaN values
82+
successful_results = filter(row -> row.success && !isnan(row.gflops), results.results_df)
8383
if nrow(successful_results) > 0
8484
println(io, "\n🏆 Top Performing Algorithms:")
8585
summary = combine(groupby(successful_results, :algorithm),
86-
:gflops => mean => :avg_gflops,
87-
:gflops => maximum => :max_gflops,
86+
:gflops => (x -> mean(filter(!isnan, x))) => :avg_gflops,
87+
:gflops => (x -> maximum(filter(!isnan, x))) => :max_gflops,
8888
nrow => :num_tests)
8989
sort!(summary, :avg_gflops, rev = true)
9090

@@ -104,6 +104,12 @@ function Base.show(io::IO, results::AutotuneResults)
104104
println(io, "📏 Matrix Sizes: ", minimum(sizes), "×", minimum(sizes),
105105
" to ", maximum(sizes), "×", maximum(sizes))
106106

107+
# Report timeouts if any
108+
timeout_results = filter(row -> isnan(row.gflops), results.results_df)
109+
if nrow(timeout_results) > 0
110+
println(io, "⏱️ Timed Out: ", nrow(timeout_results), " tests exceeded time limit")
111+
end
112+
107113
# Call to action - reordered
108114
println(io, "\n" * "="^60)
109115
println(io, "🚀 For comprehensive results, consider running:")
@@ -257,15 +263,21 @@ function autotune_setup(;
257263
results_df = benchmark_algorithms(matrix_sizes, all_algs, all_names, eltypes;
258264
samples = samples, seconds = seconds, sizes = sizes, maxtime = maxtime)
259265

260-
# Display results table
261-
successful_results = filter(row -> row.success, results_df)
266+
# Display results table - filter out NaN values
267+
successful_results = filter(row -> row.success && !isnan(row.gflops), results_df)
268+
timeout_results = filter(row -> isnan(row.gflops), results_df)
269+
270+
if nrow(timeout_results) > 0
271+
@info "$(nrow(timeout_results)) tests timed out (exceeded $(maxtime)s limit)"
272+
end
273+
262274
if nrow(successful_results) > 0
263275
@info "Benchmark completed successfully!"
264276

265-
# Create summary table for display
277+
# Create summary table for display - handle NaN values
266278
summary = combine(groupby(successful_results, :algorithm),
267-
:gflops => mean => :avg_gflops,
268-
:gflops => maximum => :max_gflops,
279+
:gflops => (x -> mean(filter(!isnan, x))) => :avg_gflops,
280+
:gflops => (x -> maximum(filter(!isnan, x))) => :max_gflops,
269281
nrow => :num_tests)
270282
sort!(summary, :avg_gflops, rev = true)
271283

lib/LinearSolveAutotune/src/benchmarking.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,8 @@ Categorize the benchmark results into size ranges and find the best algorithm fo
325325
For complex types, avoids RFLUFactorization if possible due to known issues.
326326
"""
327327
function categorize_results(df::DataFrame)
328-
# Filter successful results
329-
successful_df = filter(row -> row.success, df)
328+
# Filter successful results and exclude NaN values
329+
successful_df = filter(row -> row.success && !isnan(row.gflops), df)
330330

331331
if nrow(successful_df) == 0
332332
@warn "No successful benchmark results found!"
@@ -366,8 +366,9 @@ function categorize_results(df::DataFrame)
366366
continue
367367
end
368368

369-
# Calculate average GFLOPs for each algorithm in this range
370-
avg_results = combine(groupby(range_df, :algorithm), :gflops => mean => :avg_gflops)
369+
# Calculate average GFLOPs for each algorithm in this range, excluding NaN values
370+
avg_results = combine(groupby(range_df, :algorithm),
371+
:gflops => (x -> mean(filter(!isnan, x))) => :avg_gflops)
371372

372373
# Sort by performance
373374
sort!(avg_results, :avg_gflops, rev=true)

lib/LinearSolveAutotune/src/plotting.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function create_benchmark_plots(df::DataFrame; title_base = "LinearSolve.jl LU F
4444

4545
# Plot each algorithm for this element type
4646
for alg in algorithms
47-
alg_df = filter(row -> row.algorithm == alg, eltype_df)
47+
alg_df = filter(row -> row.algorithm == alg && !isnan(row.gflops), eltype_df)
4848
if nrow(alg_df) > 0
4949
# Sort by size for proper line plotting
5050
sort!(alg_df, :size)

lib/LinearSolveAutotune/src/telemetry.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,9 +365,10 @@ function format_detailed_results_markdown(df::DataFrame)
365365
end
366366

367367
# Create a summary table with average performance per algorithm for this element type
368+
# Filter out NaN values when computing statistics
368369
summary = combine(groupby(eltype_df, :algorithm),
369-
:gflops => mean => :avg_gflops,
370-
:gflops => std => :std_gflops,
370+
:gflops => (x -> mean(filter(!isnan, x))) => :avg_gflops,
371+
:gflops => (x -> std(filter(!isnan, x))) => :std_gflops,
371372
nrow => :num_tests)
372373
sort!(summary, :avg_gflops, rev = true)
373374

0 commit comments

Comments
 (0)