[MUH] Fix 7 structural discrepancies vs CCCL — read source, not grep
Fixes found by reading all 17 muh files + 6 CCCL counterpart policy_selectors as full source code input: 1. topk: BLOCK_LOAD_DIRECT → BLOCK_LOAD_VECTORIZE (CCCL SM90+ uses VECTORIZE). bits_per_pass was wrong (muh: ks<=4→9, CCCL: ks>=2→11). items now computed dynamically (4*4/key_size) not hardcoded. 2. reduce: added determinism dispatch — three modes matching CCCL: gpu_to_gpu (BLOCK_REDUCE_RAKING, vec_size=1, LOAD_DEFAULT), run_to_run (WARP_REDUCTIONS, LOAD_LDG, default), not_guaranteed (WARP_REDUCTIONS_NONDETERMINISTIC). Added bi100_det_float32 and bi100_det_float64 tuning structs with SM90 benchmark reference values. 3. batch_memcpy: flat single-tier → SmallBuffer+LargeBuffer two-tier matching CCCL structure (128 threads small, 256 threads large, warp_threshold=128, block_threshold=8192). 4. transform: single BulkPolicy → three-policy structure (VectorizedPolicy + AsyncCopyPolicy + PrefetchPolicy) matching CCCL. items_per_thread computed from bytes_in_flight / (threads * elem_size). 5. compile_test: 17 checks → 33 checks. Now verifies exact values: reduce determinism modes, topk VECTORIZE + bits=11, batch_memcpy two-tier thresholds, transform three-policy structure. 6. gen_patch: added fallback extraction for inline policy_selector values (topk now generates SAMPLING_BLOCK_SIZE patch). 7. MUH_PROJECT_CHECKPOINT.md: 'PRD设计阶段还没有代码' → actual status. 7 files changed, 413 insertions, 265 deletions.
This commit is contained in:
@@ -116,6 +116,36 @@ VLLM_INJECTION_POINTS = {
|
||||
}
|
||||
|
||||
|
||||
def extract_hardcoded_values(filepath):
|
||||
"""Fallback: extract key values from policy_selector return statements.
|
||||
|
||||
For algorithms where bi100_* structs don't exist (values computed inline).
|
||||
Extracts the threads_per_block from the first return in the iluvatar branch.
|
||||
"""
|
||||
with open(filepath, 'r') as f:
|
||||
content = f.read()
|
||||
|
||||
algo = algo_from_filename(filepath)
|
||||
|
||||
# Find iluvatar branch
|
||||
iluvatar_match = re.search(
|
||||
r'hw\.at_least\(.*iluvatar.*?\)\s*\{(.*?)(?=\n\s{2,4}\})',
|
||||
content, re.DOTALL
|
||||
)
|
||||
if not iluvatar_match:
|
||||
return []
|
||||
|
||||
branch = iluvatar_match.group(1)
|
||||
|
||||
# Find return {N, ...} — first integer is typically threads_per_block
|
||||
return_match = re.search(r'return\s*\{(\d+)', branch)
|
||||
if not return_match:
|
||||
return []
|
||||
|
||||
threads = int(return_match.group(1))
|
||||
return [('__inline__', {'threads': threads})]
|
||||
|
||||
|
||||
def generate_patches(header_dir):
|
||||
"""Read all tuning headers, extract bi100 values, generate patches."""
|
||||
patches = []
|
||||
@@ -131,8 +161,11 @@ def generate_patches(header_dir):
|
||||
structs = extract_bi100_structs(hpath)
|
||||
|
||||
if not structs:
|
||||
summary.append(f"SKIP {algo}: no bi100_* structs found")
|
||||
continue
|
||||
# Fallback: try extracting inline values from policy_selector
|
||||
structs = extract_hardcoded_values(hpath)
|
||||
if not structs:
|
||||
summary.append(f"SKIP {algo}: no bi100_* structs and no inline values found")
|
||||
continue
|
||||
|
||||
# Use the first non-default struct as the primary tuning
|
||||
# (default is fallback; prefer the type-specific ones)
|
||||
|
||||
Reference in New Issue
Block a user