Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
b77f65d
[MIOpen] Add cross-architecture LGBM-based solver picker
jdcampbe Jun 8, 2026
b0a828d
[MIOpen] Fix LGBM model link errors: rename all generated C symbols
jdcampbe Jun 8, 2026
59fbdbf
[MIOpen] Fix stack-buffer overflow in LGBM feature row construction
jdcampbe Jun 8, 2026
d2d456b
[MIOpen] Refresh LGBM per-spec thresholds (v2-margin-off, 2026-06-08)
jdcampbe Jun 9, 2026
d24abed
[MIOpen] Update LGBM picker to v5 (rank-only, 59-feature pruned model)
jdcampbe Jun 11, 2026
dd68cc8
[MIOpen] Add gtest coverage for the LGBM solver picker
jdcampbe Jun 11, 2026
d1fa2cb
[MIOpen] Update LGBM picker to v10 (runtime-pure, no GPU JSON)
jdcampbe Jun 12, 2026
74b01fb
[MIOpen] Retrain LGBM picker to v11 (corrected unfiltered data)
jdcampbe Jun 12, 2026
1d7dc21
[MIOpen] Fix -Wswitch-enum build error in LGBM picker
jdcampbe Jun 15, 2026
47cf542
[MIOpen] Update LGBM picker to v16 (HIP-only, no embedded GPU data)
jdcampbe Jun 15, 2026
1d3441b
[MIOpen] Add per-solver LGBM perf-config picker (immediate mode)
jdcampbe Jun 16, 2026
6f7795f
[MIOpen] Fix lgbm_pcfg hook namespace resolution in find_solution.hpp
jdcampbe Jun 16, 2026
69ebee5
[MIOpen] Update lgbm_pcfg models to retrained boosters
jdcampbe Jun 16, 2026
ee4511a
[MIOpen] Retrain LGBM picker to v17 (delta data, larger solver vocab)
jdcampbe Jun 16, 2026
e63182d
Merge branch 'users/jascampb/cross-architecture-solver-selection' int…
jdcampbe Jun 16, 2026
6fe85bf
[MIOpen] Retrain lgbm_pcfg picker to v17 (delta data, larger solver v…
jdcampbe Jun 19, 2026
465aa6c
Merge branch 'develop' into users/jascampb/cross-architecture-solver-…
jdcampbe Jun 25, 2026
27b1d26
[MIOpen] Update LGBM picker to v18 TunaNet+Align (61 features, ranked…
jdcampbe Jun 30, 2026
da578ca
Merge branch 'users/jascampb/cross-architecture-solver-selection' int…
jdcampbe Jun 30, 2026
f99c74c
Merge remote-tracking branch 'origin/develop' into users/jascampb/cro…
jdcampbe Jul 1, 2026
b88bc1d
[MIOpen] Refresh lgbm_pcfg models to latest retrain (roofline removed)
jdcampbe Jul 1, 2026
7c073d3
[MIOpen] lgbm_pcfg: first-valid ranked walk instead of single argmax
jdcampbe Jul 9, 2026
19ebf29
[MIOpen] Demote naive fallbacks in LGBM rank order to fix perf regres…
jdcampbe Jul 10, 2026
07a518b
Merge branch 'users/jascampb/cross-architecture-solver-selection' int…
jdcampbe Jul 10, 2026
0d88a7a
[MIOpen] Make LGBM naive-fallback demotion group-count-aware
jdcampbe Jul 12, 2026
1dc07b9
Merge branch 'users/jascampb/cross-architecture-solver-selection' int…
jdcampbe Jul 12, 2026
54a78d8
[MIOpen] Add diagnostic logs for AI/lgbm solver-selection path
jdcampbe Jul 12, 2026
0b4d92e
[MIOpen] Fix -Werror,-Wmissing-noreturn in pooling/solvers.hpp
jdcampbe Jul 20, 2026
9794897
Merge remote-tracking branch 'origin/develop' into users/jascampb/cro…
jdcampbe Jul 20, 2026
d3be31b
[MIOpen] Retrain LGBM picker on expanded data (72 solvers)
jdcampbe Jul 22, 2026
adfc013
Merge branch 'users/jascampb/cross-architecture-solver-selection' int…
jdcampbe Jul 22, 2026
a3a059b
[MIOpen] Conform LGBM gtest fixture names to MIOpen naming convention
jdcampbe Jul 22, 2026
6c054f8
[MIOpen] Make CK grouped-conv applicability probes non-fatal
jdcampbe Jul 22, 2026
b3f915a
Merge remote-tracking branch 'origin/users/jascampb/ck-rdna-applicabi…
jdcampbe Jul 22, 2026
5093ba0
[MIOpen] Add SPDX license headers to new LGBM files; guard pcfg catal…
jdcampbe Jul 22, 2026
78c903b
[MIOpen] clang-format the LGBM picker sources (fix pre-commit CI)
jdcampbe Jul 22, 2026
ba2588d
[MIOpen] Export LGBM symbols so miopen_gtest links against libMIOpen.so
jdcampbe Jul 22, 2026
6e79867
[MIOpen] Fix clang-tidy failures + exclude generated LGBM artifacts
jdcampbe Jul 22, 2026
fb327b2
[MIOpen] Add trailing newline to LGBM JSON assets (fix pre-commit eof…
jdcampbe Jul 22, 2026
8ea0fe8
[MIOpen] Remove redundant nested #if in PredictSolver (clang-tidy)
jdcampbe Jul 23, 2026
1817f4c
[MIOpen] Fix lgbm_pcfg gtest crash on null inputs (json type_error.302)
jdcampbe Jul 23, 2026
58d5c49
[MIOpen] Make LGBM gtests self-contained (drop Python parity fixtures)
jdcampbe Jul 23, 2026
70e35d1
[MIOpen] Exclude gfx942/gfx950 from LGBM pickers (defer to existing h…
jdcampbe Jul 23, 2026
d6d9d10
Revert CK grouped-conv non-fatal applicability probes
jdcampbe Jul 23, 2026
6972cd4
[MIOpen] Drop dev-only LGBM regen script and unused tl2cgen Makefile
jdcampbe Jul 23, 2026
cb8e048
Merge branch 'develop' into users/jascampb/cross-architecture-perf-co…
jdcampbe Jul 23, 2026
ef34b9d
[MIOpen] Replace generated Treelite rank C with LightGBM .txt + in-ho…
jdcampbe Jul 23, 2026
6b4982d
[MIOpen] Replace generated Treelite pcfg C with LightGBM .txt + walker
jdcampbe Jul 23, 2026
faee22d
[MIOpen] Fix clang-tidy + pre-commit CI for the LGBM text-model walker
jdcampbe Jul 24, 2026
ae50f74
[MIOpen] Export LgbmForest so miopen_gtest links on Windows
jdcampbe Jul 24, 2026
ce53746
[MIOpen] Exclude gfx908/gfx90a from the LGBM pickers
jdcampbe Jul 24, 2026
2fb57cf
[MIOpen] Suppress spurious cppcheck syntaxError on the LGBM picker gt…
jdcampbe Jul 24, 2026
6779600
[MIOpen] Revert dead MIOPEN_SKIP_TIDY clang-tidy exclusion
jdcampbe Jul 24, 2026
0b0ee35
[MIOpen] Make LGBM selector a TunaNet fallback, active on all archs
jdcampbe Jul 24, 2026
2ed2581
[MIOpen] Remove arch exclusion from the LGBM perf-config picker
jdcampbe Jul 24, 2026
25edea7
[MIOpen] Defer LGBM perf-config to the two-tower KTN where it applies
jdcampbe Jul 24, 2026
a629357
[MIOpen] Drop C language from project(): no C sources remain
jdcampbe Jul 24, 2026
cc0d6d1
[MIOpen] Suppress cppcheck duplicateBreak on pooling not-implemented …
jdcampbe Jul 26, 2026
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: 10 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,16 @@ exclude: |
projects/miopen/.*\.s$|
projects/miopen/.*\.inc$|
projects/miopen/.*\.model$|
# Machine-generated LGBM assets: native LightGBM text models + baked
# catalog/metadata + golden parity fixtures (large, not human-authored;
# exceed check-added-large-files and are not lintable/end-of-file-fixable).
projects/miopen/src/conv/heuristics/lgbm_models/.*|
projects/miopen/src/conv/heuristics/lgbm_pcfg_models/.*|
projects/miopen/src/kernels/lgbm_pcfg_catalog\.json|
projects/miopen/src/kernels/lgbm_rank_model\.txt|
projects/miopen/src/kernels/lgbm_pcfg_.*_model\.txt|
projects/miopen/src/kernels/lgbm_rank_golden\.json|
projects/miopen/src/kernels/lgbm_pcfg_golden\.json|
# RPP exclusion list
projects/rpp/utilities/test_suite/TEST_IMAGES/three_images_yuv/.*|
projects/rpp/utilities/test_suite/REFERENCE_OUTPUT/yuv_to_rgb/.*|
Expand Down
6 changes: 6 additions & 0 deletions projects/miopen/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,12 @@ enable_cppcheck(
SUPPRESS
ConfigurationNotChecked
constStatement
# cppcheck cannot resolve a transitive header for the LGBM picker gtests
# in project mode, so it aborts parsing the whole TU with a spurious
# syntaxError at the first TEST_F. The files compile fine with the real
# toolchain; suppress the parse-abort for just these two.
syntaxError:*test/gtest/lgbm_picker.cpp
syntaxError:*test/gtest/lgbm_pcfg_picker.cpp
# There is no ODR violation because of using separate executables,
# but cppcheck doesn't understand that as it assumes everything
# will be compiled together in one binary.
Expand Down
37 changes: 36 additions & 1 deletion projects/miopen/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,25 @@ if(MIOPEN_ENABLE_AI_KERNEL_TUNING OR MIOPEN_ENABLE_AI_IMMED_MODE_FALLBACK)
list(APPEND MIOpen_Source anyramdb.cpp)
endif()

if(MIOPEN_ENABLE_AI_IMMED_MODE_FALLBACK)
list(APPEND MIOpen_Source
conv/heuristics/lgbm_pick.cpp
conv/heuristics/lgbm_metadata.cpp
conv/heuristics/lgbm_forest.cpp)
# The rank model ships as its native LightGBM text dump
# (kernels/lgbm_rank_model.txt, installed with the other model assets
# below) and is walked at runtime by lgbm_forest.cpp -- no generated C.

# Perf-config picker: one LightGBM lambdarank model PER tuneable solver.
# Each model ships as its native text dump (kernels/lgbm_pcfg_<solver>_
# model.txt, installed with the other model assets below) and is loaded +
# walked at runtime by lgbm_forest.cpp via the pcfg metadata loader. No
# generated C, so no per-solver symbol-rename / ODR machinery is needed.
list(APPEND MIOpen_Source
conv/heuristics/lgbm_pcfg_pick.cpp
conv/heuristics/lgbm_pcfg_metadata.cpp)
endif()

list(APPEND MIOpen_Source tmp_dir.cpp binary_cache.cpp md5.cpp)
if(MIOPEN_ENABLE_SQLITE)
list(APPEND MIOpen_Source sqlite_db.cpp)
Expand Down Expand Up @@ -948,10 +967,26 @@ if(MIOPEN_ENABLE_AI_KERNEL_TUNING OR MIOPEN_ENABLE_AI_IMMED_MODE_FALLBACK)
add_library(nlohmann_json INTERFACE IMPORTED GLOBAL)
target_link_libraries(nlohmann_json INTERFACE nlohmann_json::nlohmann_json)
endif()
file(GLOB MODEL_FILES CONFIGURE_DEPENDS kernels/*.model)
file(GLOB MODEL_FILES CONFIGURE_DEPENDS
kernels/*.model
kernels/lgbm_model_meta.json
kernels/lgbm_pcfg_model_meta.json
kernels/lgbm_pcfg_catalog.json
kernels/lgbm_rank_model.txt
kernels/lgbm_pcfg_*_model.txt)
if(NOT ENABLE_ASAN_PACKAGING )
install(FILES ${MODEL_FILES} DESTINATION ${DATABASE_INSTALL_DIR})
endif()
# Test-only golden-vector fixtures for the LGBM forest walker parity gates
# (test/gtest/lgbm_picker.cpp, lgbm_pcfg_picker.cpp). Copied next to the
# model assets so the tests find them via GetSystemDbPath(), but NOT
# installed into the package.
if(BUILD_TESTING)
configure_file("kernels/lgbm_rank_golden.json"
"${KERNELS_BINARY_DIR}/lgbm_rank_golden.json" COPYONLY)
configure_file("kernels/lgbm_pcfg_golden.json"
"${KERNELS_BINARY_DIR}/lgbm_pcfg_golden.json" COPYONLY)
endif()
foreach(MODEL_FILE ${MODEL_FILES})
get_filename_component(MODEL_FILE_FILENAME "${MODEL_FILE}" NAME)
configure_file("${MODEL_FILE}" "${KERNELS_BINARY_DIR}/${MODEL_FILE_FILENAME}" COPYONLY)
Expand Down
80 changes: 57 additions & 23 deletions projects/miopen/src/conv/heuristics/ai_heuristics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
// 4. Kernel tuning AI models (sequential prediction of kernel parameters)

#include <miopen/conv/heuristics/ai_heuristics.hpp>
#if MIOPEN_ENABLE_AI_IMMED_MODE_FALLBACK
#include <miopen/conv/heuristics/lgbm_pick.hpp>
#include <miopen/any_solver.hpp>
#endif
#if MIOPEN_ENABLE_AI_IMMED_MODE_FALLBACK || MIOPEN_ENABLE_AI_KERNEL_TUNING
#include <fdeep/fdeep.hpp>
#include <miopen/filesystem.hpp>
Expand All @@ -41,6 +45,7 @@
#include <mutex>

MIOPEN_DECLARE_ENV_VAR_BOOL(MIOPEN_AI_FDEEP_USE_SINGLE_THREAD_PREDICT)
MIOPEN_DECLARE_ENV_VAR_BOOL(MIOPEN_ENABLE_LGBM_SELECTOR)

// 3D AI heuristics - now declared properly in header
// No need for local forward declarations since we include the header
Expand Down Expand Up @@ -879,22 +884,32 @@ std::vector<uint64_t> PredictSolver(const conv::ProblemDescription& problem,
{
auto cached_result = GetCachedPrediction(problem, device, is3d);
if(!cached_result.empty())
{
// A cache hit short-circuits BEFORE the TunaNet/lgbm blocks, so this
// run shows no model log lines even though either could have produced
// the cached entry on an earlier call for this problem+device.
MIOPEN_LOG_I2("AI predict: cache hit for " << device << " (" << cached_result.size()
<< " solvers); TunaNet/lgbm not re-run");
return cached_result;
}
}

// Strategy:
// 1. Try ND model first (for gfx942/gfx950, supports both 2D and 3D)
// 2. Fall back to legacy model (for gfx908/gfx90a, 2D only)
// 3. Return empty vector to trigger WTI fallback for unsupported architectures
//
// Selection order: TunaNet -> LGBM -> WTI.
// TunaNet (the mature per-arch fdeep models) is preferred where it has a model
// that supports the problem. The cross-arch LGBM selector is the fallback: it
// covers architectures/problems TunaNet cannot serve (no per-arch model, or the
// problem is outside the model's supported set). Only if neither produces a
// prediction do we fall back to the non-AI WTI heuristic.

// 1. TunaNet.
// Any failure inside this block (including a model that fdeep cannot load -- e.g. a
// model exported in an incompatible format, which throws a non-miopen std::exception)
// is swallowed and turned into an empty result, so the caller degrades to the non-AI
// heuristic instead of failing the convolution. This is the predictor's contract: it
// returns a prediction or nothing, but never throws.
// is swallowed so we fall through to the LGBM selector instead of failing the
// convolution. This is the predictor's contract: it returns a prediction or nothing,
// but never throws.
try
{
// Try ND model first (preferred for gfx942/gfx950)
// ND model (for gfx942/gfx950, supports both 2D and 3D).
if((is2d || is3d) && HasNDTunaNetSupport(device))
{
int dim = is3d ? 3 : 2;
Expand All @@ -907,13 +922,11 @@ std::vector<uint64_t> PredictSolver(const conv::ProblemDescription& problem,
return ProcessAndCachePredictions(
problem, device, true, predictions, model->GetSolverMap());
}
// If ND model failed for this architecture, don't try legacy - go to WTI
MIOPEN_LOG_I2("ND TunaNet not applicable for this problem on " << device);
return {};
MIOPEN_LOG_I2("ND TunaNet not applicable for this problem on " << device
<< "; trying LGBM");
}

// Fall back to legacy 2D model (for gfx908/gfx90a only)
if(is2d && HasLegacyTunaNetSupport(device))
// Legacy 2D model (for gfx908/gfx90a only).
else if(is2d && HasLegacyTunaNetSupport(device))
{
std::unique_ptr<Model> model = GetModel(device);

Expand All @@ -924,20 +937,41 @@ std::vector<uint64_t> PredictSolver(const conv::ProblemDescription& problem,
return ProcessAndCachePredictions(
problem, device, false, predictions, model->metadata.solver_map);
}
MIOPEN_LOG_I2("Legacy TunaNet not applicable for this problem on " << device);
return {};
MIOPEN_LOG_I2("Legacy TunaNet not applicable for this problem on " << device
<< "; trying LGBM");
}
}
catch(const std::exception& e)
{
MIOPEN_LOG_W("TunaNet prediction failed (" << e.what()
<< "); falling back to non-AI heuristic");
return {};
MIOPEN_LOG_W("TunaNet prediction failed (" << e.what() << "); trying LGBM selector");
}

// 2. LGBM selector fallback: cross-arch dispatcher trained on perf-DB data.
// Returns the full solver vocabulary ranked by predicted speed; the caller
// (GetSolutionsFallback) walks this list and applies IsApplicable lazily, exactly
// like the TunaNet path -- so no applicability check is done here. Enabled by
// default (active for all architectures the model covers); set
// MIOPEN_ENABLE_LGBM_SELECTOR=0 to force selection straight to WTI.
if(!env::disabled(MIOPEN_ENABLE_LGBM_SELECTOR))
{
const auto ranked = ai::lgbm::PickSolverRanked(problem, ctx.GetStream());
if(!ranked.empty())
{
MIOPEN_LOG_I2("lgbm: returning " << ranked.size() << " ranked solvers");
std::vector<std::any> any_sol(ranked.begin(), ranked.end());
StorePredictionCache(problem, device, any_sol);
return ranked;
}
MIOPEN_LOG_I2("lgbm: abstained for " << device << ", falling back to WTI");
}
else
{
MIOPEN_LOG_I2("lgbm: disabled via MIOPEN_ENABLE_LGBM_SELECTOR=0 for " << device
<< ", using WTI");
}

// No TunaNet model available for this device/problem combination
// Return empty vector to trigger WTI fallback
MIOPEN_LOG_I2("No TunaNet model available for " << device << ", falling back to WTI");
// 3. WTI last: no AI prediction available, trigger the non-AI heuristic fallback.
MIOPEN_LOG_I2("No AI prediction for " << device << ", falling back to WTI");
return {};
}

Expand Down
Loading
Loading