From be4ebdc3afcdcf0215e8b023fbb9828f8b3ba647 Mon Sep 17 00:00:00 2001 From: baKon Date: Fri, 16 Oct 2026 10:13:26 -0500 Subject: [PATCH] build: a LoRA-declined fused GEMM owns no weight and is not a reference-kernel op Found on Qwen3.8-27B fp8: the 64 declined gemm_nt_q_gated folds tripped the reference-kernel gate, and as unresolved readers of gate_up they would have told the planner the weight cannot live on the card. --- core/build/rad_builder.cpp | 7 +++++++ core/build/startup.cpp | 1 + core/rad_core.h | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/core/build/rad_builder.cpp b/core/build/rad_builder.cpp index fd02703a..abb0144e 100644 --- a/core/build/rad_builder.cpp +++ b/core/build/rad_builder.cpp @@ -725,6 +725,13 @@ rad_op Builder::decl_op(const char* opname, const RadParam* p, int n_p, none.miss[d] = "declined: its weight is a runtime-LoRA target, and a fused GEMM has no " "output for the adapter's delta (the plugin runs the unfused chain)"; oi.bands.assign(1, none); + oi.lora_declined = true; + /* AND IT OWNS NO WEIGHT. The planner, the layout pass and the weight-use bookkeeping all + * read an op's weights, and an op with no kernel anywhere would tell the planner the weight + * cannot be read on the card -- moving the gate_up the unfused chain multiplies on the card + * off it. The op stays in the list, by name, so the sizing declare lines up. */ + oi.weights.clear(); + oi.weight_opd.clear(); prog_.ops.push_back(std::move(oi)); op_bufs_.emplace_back(); return RAD_NULL_HANDLE; diff --git a/core/build/startup.cpp b/core/build/startup.cpp index 98bf6dd0..63ef7a10 100644 --- a/core/build/startup.cpp +++ b/core/build/startup.cpp @@ -38,6 +38,7 @@ int rad_reference_ops(const Program& p, std::vector* out) { int n = 0; for (size_t i = 1; i < p.ops.size(); ++i) { const OpInfo& oi = p.ops[i]; + if (oi.lora_declined) continue; /* never handed out, so never issued (rad_builder.cpp) */ bool real = false; for (const Band& b : oi.bands) for (int d = 0; d < RAD_N_DOMAINS && !real; ++d) diff --git a/core/rad_core.h b/core/rad_core.h index e962d5b6..02b43458 100644 --- a/core/rad_core.h +++ b/core/rad_core.h @@ -271,6 +271,10 @@ struct OpInfo { * plugin op. `lora_site`: on a targeted gemm, its row in Program::lora_sites; -1 otherwise. */ int32_t anchor = -1; int32_t lora_site = -1; + /* Declined at declare because runtime LoRA targets its weight (a fused GEMM no delta can follow): + * recorded unresolved on purpose, its handle never handed to the plugin, so it is never issued + * and the reference-kernel gate does not count it. */ + bool lora_declined = false; }; struct KVGroupInfo {