Archived
engine: host-domain binding for weightless host-only ops
bind_ops falls back to the host domain when an op is host-only and carries no weight tensors: a plugin declaring host-only math gets the same binding path as device ops, with no model-specific quirk. Adds the R4D_DIAG kernel-selection trace in plugin selection (default off).
This commit is contained in:
1 parent
73bfc310aa
commit
61cf8b7b1a
2 files changed
+17
-1
No files matched your search
@@ -11,6 +11,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
@@ -139,6 +140,13 @@ const KernelRow* Registry::select(std::string_view op, const Geometry& g, int do
|
||||
}
|
||||
}
|
||||
|
||||
static const int seldbg = std::getenv("R4D_DIAG") ? 1 : 0; /* kernel-selection trace; R4D_DIAG=1 */
|
||||
if (seldbg && std::string(op) == "attn_paged" && domain == RAD_DOMAIN_DEVICE) {
|
||||
std::fprintf(stderr, "[SELDBG] %s | best=%s\n", t.query.c_str(), best ? best->info->name : "(none)");
|
||||
for (const auto& c : t.candidates)
|
||||
std::fprintf(stderr, " %-28s prio=%-3d ok=%d why=%s\n", c.kernel.c_str(),
|
||||
c.priority, (int)c.ok, c.why.c_str());
|
||||
}
|
||||
if (best) {
|
||||
t.kernel = best->info->name;
|
||||
t.plugin = best->plugin;
|
||||
|
||||
@@ -401,7 +401,10 @@ int Ctx::bind_ops() {
|
||||
/* Execution site. Site is a property of the weights (spec §5.1), so an op whose every
|
||||
* weight operand was placed on the host runs its host kernel and everything else runs on
|
||||
* the device. An op with no weights stays on the device; the planner overrides through
|
||||
* set_op_domain, which is where the "contiguous host runs" objective actually lands.
|
||||
* set_op_domain, which is where the "contiguous host runs" objective actually lands. A
|
||||
* weightless op with no device kernel in any band (host-only: rmsnorm_p / gelu_mul /
|
||||
* logit_softcap / attn_paged) falls back to the band resolution and runs on the host --
|
||||
* the device is not a correct answer for a kernel that exists only on the host.
|
||||
*
|
||||
* ON THE HOST BACKEND (no card visible: CPU-only serving) the device domain is the host's
|
||||
* own memory and an op with no device kernel in any band runs its host kernel -- the
|
||||
@@ -431,6 +434,11 @@ int Ctx::bind_ops() {
|
||||
all_host = false;
|
||||
}
|
||||
if (all_host) dom = RAD_DOMAIN_HOST;
|
||||
} else {
|
||||
bool any_dev = false;
|
||||
for (const Band& b : oi.bands)
|
||||
if (b.dom[RAD_DOMAIN_DEVICE]) { any_dev = true; break; }
|
||||
if (!any_dev) dom = RAD_DOMAIN_HOST;
|
||||
}
|
||||
op_domain_[i].store((uint8_t)dom, std::memory_order_relaxed);
|
||||
|
||||
|
||||
Reference in new issue
Block a user