[MUH] Fix three-layer disconnect — C++ headers are now the single source of truth

Problems fixed:
  1. gen_patch.py was reading .muh YAML (all nulls) instead of C++ headers.
     Now it parses bi100_* structs directly from tuning_*.cuh via regex,
     extracts constexpr values, and maps them to vllm injection points.
     Verified: 11 patches generated from 6 algorithms.

  2. C++ headers had no build system or tests.
     Added CMakeLists.txt (header-only library target) and compile_test.cpp.
     Verified: g++ -std=c++17 compiles all headers, 17/17 runtime checks pass.
     Also added cuda_compile_test.cu for when nvcc is available.

  3. baseline.muh had a tuning section full of nulls duplicating C++ values.
     Stripped to vllm launch config only. Tuning values live exclusively
     in muh/include/muh/tuning/tuning_*.cuh bi100_* structs.

  4. Fixed constexpr goto in tuning_scan.cuh (C++17 doesn't allow goto in
     constexpr; replaced with early-return + default: break pattern).

Data flow is now:
  tuning_*.cuh (bi100_* constexpr) ──→ gen_patch.py ──→ vllm patches
  baseline.muh (launch config)     ──→ gen_yaml.py  ──→ computility-run.yaml
  compile_test.cpp                 ──→ g++/nvcc     ──→ verify values are real
This commit is contained in:
dylanyunlon
2026-07-30 14:12:33 +00:00
parent 5f880bb279
commit 57e222b99d
6 changed files with 402 additions and 286 deletions

View File

@@ -0,0 +1,40 @@
cmake_minimum_required(VERSION 3.18)
project(muh LANGUAGES CXX)
# muh is a header-only library
add_library(muh INTERFACE)
target_include_directories(muh INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
target_compile_features(muh INTERFACE cxx_std_17)
# If CCCL is available, link it
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../../cccl_upstream/cub/cub/config.cuh")
target_include_directories(muh INTERFACE
${CMAKE_CURRENT_SOURCE_DIR}/../../cccl_upstream/cub
${CMAKE_CURRENT_SOURCE_DIR}/../../cccl_upstream/thrust
${CMAKE_CURRENT_SOURCE_DIR}/../../cccl_upstream/libcudacxx/include
)
target_compile_definitions(muh INTERFACE MUH_HAS_CCCL=1)
endif()
# Compile test — verifies all headers parse without errors
# This is a host-only test (no GPU needed)
option(MUH_BUILD_TESTS "Build muh compile tests" ON)
if(MUH_BUILD_TESTS)
add_executable(muh_compile_test
${CMAKE_CURRENT_SOURCE_DIR}/../test/compile_test.cpp
)
target_link_libraries(muh_compile_test PRIVATE muh)
# If we have a CUDA compiler, also test .cu compilation
include(CheckLanguage)
check_language(CUDA)
if(CMAKE_CUDA_COMPILER)
enable_language(CUDA)
add_executable(muh_cuda_compile_test
${CMAKE_CURRENT_SOURCE_DIR}/../test/cuda_compile_test.cu
)
target_link_libraries(muh_cuda_compile_test PRIVATE muh)
set_target_properties(muh_cuda_compile_test PROPERTIES CUDA_STANDARD 17)
endif()
endif()

View File

@@ -200,10 +200,8 @@ struct policy_selector {
/// Get the best lookback policy for BI-V100
constexpr ScanLookbackPolicy get_lookback(const hardware_capability& hw) const {
if (!hw.at_least(hardware_capability::vendor_t::iluvatar, 100))
goto fallback;
if (operation_t == op_kind_t::plus && is_primitive_accum) {
if (hw.at_least(hardware_capability::vendor_t::iluvatar, 100)
&& operation_t == op_kind_t::plus && is_primitive_accum) {
if (offset_size == 4) {
switch (input_value_size) {
case 1: return {bi100_lookback_1B_o4::threads, bi100_lookback_1B_o4::items,
@@ -222,6 +220,7 @@ struct policy_selector {
bi100_lookback_8B_o4::load_algo, bi100_lookback_8B_o4::load_mod,
bi100_lookback_8B_o4::store_algo, BLOCK_SCAN_WARP_SCANS,
bi100_lookback_8B_o4::delay};
default: break;
}
} else if (offset_size == 8) {
switch (input_value_size) {
@@ -233,11 +232,12 @@ struct policy_selector {
bi100_lookback_8B_o8::load_algo, bi100_lookback_8B_o8::load_mod,
bi100_lookback_8B_o8::store_algo, BLOCK_SCAN_WARP_SCANS,
bi100_lookback_8B_o8::delay};
default: break;
}
}
}
fallback:
// Fallback
return {bi100_lookback_default::threads, bi100_lookback_default::items,
bi100_lookback_default::load_algo, bi100_lookback_default::load_mod,
bi100_lookback_default::store_algo, BLOCK_SCAN_WARP_SCANS,