core: an architecture plugin can decline imported checkpoints

An imported quantisation names its tool, which no plugin claims, so the family's one quantised
plugin serves it and two are refused. rad_arch_serves_imports(), optional and absent = yes, lets a
second quantised plugin that reads only its own containers return 0: the import pick then leaves
it out of the family, neither counted nor picked as the only plugin. Its own descriptor still
selects it. Additive export; RAD_ABI_VERSION does not move.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
eddie168168andClaude Opus 5.5 authored and StillDeadcode committed 2026-10-19 10:42:13 +02:00
1 parent f706caecec
commit 0b0403603b
10 files changed
+55 -5

No files matched your search

+4 -2
View File
@@ -173,11 +173,13 @@ int rad_tools_load_plugins(const std::string& home, const std::vector<std::strin
}
}
/* An imported quantisation is served by the family's quantised plugin (startup.h). */
/* An imported quantisation is served by the family's quantised plugin (startup.h). A plugin
* that declines imports (rad_arch_serves_imports) is left out of the family here: neither
* counted as a second quantised plugin nor picked as the only one. */
if (imported && !arch_id.empty() && out->arch_plugin.empty()) {
std::vector<const Plugin*> fam, quantised;
for (const Plugin& p : r.plugins())
if (p.kind == RAD_PLUGIN_ARCH && p.arch_id == arch_id) {
if (p.kind == RAD_PLUGIN_ARCH && p.arch_id == arch_id && p.arch_serves_imports) {
fam.push_back(&p);
if (!p.arch_quant.empty()) quantised.push_back(&p);
}
+2 -1
View File
@@ -67,7 +67,8 @@ std::string rad_home_file(const std::string& home, const std::string& rel);
* `imported`: the checkpoint's quantisation is imported weight by weight (Checkpoint::imports), so
* its descriptor names the producing tool and no plugin claims it. The family's quantised plugin
* serves it: the one plugin claiming a descriptor, or the only plugin if none does. Two quantised
* plugins are refused by name. `out->arch_quant` is the chosen descriptor, which a container
* plugins are refused by name. A plugin whose rad_arch_serves_imports returns 0 is left out of
* both counts. `out->arch_quant` is the chosen descriptor, which a container
* converted from it records. */
int rad_tools_load_plugins(const std::string& radiance_home,
const std::vector<std::string>& hierarchy,
+3
View File
@@ -208,6 +208,9 @@ int Registry::commit_(Staged& s, int order) {
* container, which "" means. */
if (auto q_fn = dl_fn<const char* (*)(void)>(s.handle, "rad_arch_quant"))
p.arch_quant = or_empty(q_fn());
/* Optional: absent means the plugin may serve an imported quantisation (startup.h). */
if (auto i_fn = dl_fn<int (*)(void)>(s.handle, "rad_arch_serves_imports"))
p.arch_serves_imports = i_fn() != 0;
/* Optional: answers what the core needs before it builds the RadBuildCtx for declare.
* Absent means every answer is zero (rad_builder.h). */
+3
View File
@@ -94,6 +94,9 @@ struct Plugin {
int64_t (*arch_text_prepare)(int, const char*, char*, int64_t) = nullptr;
/* Required of a video generator (rad_builder.h); null for every other plugin. */
int64_t (*arch_video_positions)(int, const RadVideoGeom*, float*, int64_t) = nullptr;
/* Optional (rad_builder.h, rad_arch_serves_imports); absent is true. False keeps the plugin
* out of the pick for an imported checkpoint (startup.h). */
bool arch_serves_imports = true;
RadPluginCloseFn close = nullptr;
};
+5
View File
@@ -60,6 +60,11 @@ foreach(q plain fp8 w4)
RADTEST_ARCHQ_NAME="radtest_archq_${q}"
RADTEST_ARCHQ_QUANT="${_rad_q}")
endforeach()
# A fourth member, quantised but declining imported checkpoints (rad_arch_serves_imports).
rad_add_plugin(radtest_archq_w8 testarchq SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/testplugin.cc)
target_compile_definitions(radtest_archq_w8 PRIVATE RADTEST_ARCHQ=1
RADTEST_ARCHQ_NAME="radtest_archq_w8" RADTEST_ARCHQ_QUANT="w8"
RADTEST_ARCHQ_NO_IMPORTS=1)
# KV tier transfer test plugin. Unlike the others it computes (byte-row gather and scatter in the
# device domain, on host backend memory), so only tests/mem_test.cpp loads it, by path. It calls
+4
View File
@@ -623,6 +623,10 @@ const RadPluginInfo* rad_plugin_info(void) { return &kInfo; }
const char* rad_arch_id(void) { return RADTEST_ARCH_ID; }
/* The other half of the selection key (spec §2.4); "" is an unquantised container. */
const char* rad_arch_quant(void) { return RADTEST_ARCH_QUANT; }
#if defined(RADTEST_ARCHQ_NO_IMPORTS)
/* Quantised, but never the plugin an imported checkpoint is handed to. */
int rad_arch_serves_imports(void) { return 0; }
#endif
/* The core loads and identifies architecture plugins; the build component drives them. Neither
* hook is called by anything this test exercises, and declare refuses rather than pretending. */
int rad_arch_declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* ctx) {