Repository source · complete snapshot
View docs/architecture/MODEL_RUNNERS.md at 140f6f7 ↗
SHA-256 0b4165b68170e48f1f150757cccb50687b353fd664071655cf7240cdf8245ffa
On this page
Model Architecture Runners
Phase 3 specialized operations
SDK 1.5 exposes guild_operation_api_v1_t through the optional operations tail
of the plugin host API. Runners can copy that table during init, resolve named
operation/version/capability requirements, and retain opaque bindings for their
execution resources. See GKMODULE.md for tensor, scratch, device,
stream and unloading contracts. This service is available to .gkernel runners
and .gkmodule operation providers. It does not change the existing RMD1 model
description layout or claim support for arbitrary execution topologies.
SDK 1.1+ supplies the RMD1 model-description extension in
include/guild/abi/runner_abi.h. The independent
guild-runners-qwen
repository (v1.1.0) owns the Qwen-family architecture runners (qwen35moe,
qwen4exp, qwen2moe, and ornith), using typed metadata/tensor callbacks,
copied C geometry values (guild_runner_model_v1_t), PLE metadata/tensor contract
validation, and vectorized check_finite instead of C++ runner subclasses inside
Core. When GUILD_BUILTIN_QWEN_RUNNERS=ON (default), cmake/QwenRunnersBackend.cmake
compiles guild-runners-qwen with GUILD_BUNDLED_QWEN_RUNNERS=1 and registers
runner.qwen4exp.v1 and runner.qwen35moe.v1 through AbiModelRunnerAdapter.
When GUILD_BUILTIN_QWEN_RUNNERS=OFF, Core contains no built-in Qwen runners and
loads the signed org.guild.runners.qwen .gkernel package at runtime.
Ornith-1.5-35B passed bundled/external parity. Qwen3.8-Flash-Next (UD-IQ4_XS)
passed bundled-runner parity against the preserved engine; that test did not
establish external-only Qwen4Exp execution.
Headers & Implementation:
include/guild/model/runner.hppsrc/model/runner.cppinclude/guild/model/model_descriptor.hpp- External Runner Plugin Example:
plugins/runner_smoke_ext/runner_smoke_plugin.cpp
Model Architecture Runners decouple model-family topology, GGUF metadata validation, and kernel requirements from Guild Core’s memory management, scheduler, and server.
1. Built-In Runners
| Runner ID | Package ID | Architecture ID | Family | Key Architectural Features |
|---|---|---|---|---|
runner.qwen4exp.v1 | builtin.guild-kernels-qwen | qwen4exp | ModelFamily::Qwen4Exp | 48 layers (36 Gated DeltaNet + 12 Quad-Sparse Attention, interval 4), 4-stream Hyper-Connections (hc=4), 512 routed experts (top_k=10) + 1 shared expert, mandatory Per-Layer Embeddings (ple_compute), Coupled-Draft MTP |
runner.qwen35moe.v1 | builtin.guild-kernels-ornith | qwen35moe | ModelFamily::Qwen35MoE | 40 layers (30 Gated DeltaNet + 10 Full GQA Attention, interval 4), single-stream residual (hc=1), 256 routed experts (top_k=8) + 1 shared expert, no PLE, native layer-wise batched prefill (BatchedPrefill) |
2. IModelRunner Interface & AbiModelRunnerAdapter
Every model runner implements guild::model::IModelRunner (either directly in C++ for built-in runners or via AbiModelRunnerAdapter, which wraps an external C ABI guild_runner_desc_v1_t registered from a .gkernel plugin):
runner_id(): Stable versioned identifier (e.g.,"runner.qwen35moe.v1").arch_id(): Canonical architecture identifier ("qwen4exp","qwen35moe", or custom architecture ID).package_id(): Owning.gkernelor built-in package identifier.family():ModelFamilyenum tag.capabilities(): Runner capability bitmask (GUILD_RUNNER_CAP_*).matches_gguf(const GgufMetadata&): Inspects GGUF header keys (general.architecture, tensor names, layer counts) to determine if this runner supports the artifact.validate_and_describe(const GgufModel&, ModelDescriptor&, std::string& err): Populates and validatesModelDescriptorfrom GGUF metadata and tensor headers.configure_geometry(const ModelDescriptor&, core::ModelGeometry&, int64_t& top_k, std::string& err): Populates runtime geometry and enforces architectural invariants before device memory allocation.required_operations(const ModelDescriptor&, const core::ModelGeometry&, const memory::ExecutionPlan&): Returns the list ofRunnerOpRequiremententries (op_name,category,backend,weight_dtype,activation_dtype,mandatory) validated byModelRunnerRegistry::validate_runner_requirements().
3. Lifecycle & Per-Package Lease Safety
ModelRunnerRegistry::register_abi_runner(const guild_runner_desc_v1_t&, std::string& err)validatesstruct_size,abi_versioncompatibility (guild_abi_is_compatible), and non-emptyrunner_id/arch_id, and deep-copies strings intoAbiModelRunnerAdapter.- When
GuildModel::load()resolves a runner, it acquires a per-packageSessionRunnerLease(&ModelRunnerRegistry::instance(), runner->package_id())and stores all resolved kernelpackage_ids inRunnerExecutionPlan::resolved_package_ids(held bySessionKernelLease). - While any
GuildModelorGuildSessionholds a lease on a runner’spackage_id,ModelRunnerRegistry::unregister_package()andGKernelPackageManager::disable_package()/remove_package()refuse to unload the package withGUILD_STATUS_ERR_ACTIVE_SESSION_BUSY.
4. Building an External Runner .gkernel Plugin
See plugins/runner_smoke_ext/runner_smoke_plugin.cpp for a complete external runner plugin compiled against Guild::KernelSDK:
- Include
"guild/abi/kernel_abi.h". - Define a
guild_runner_desc_v1_twithstruct_size = sizeof(guild_runner_desc_v1_t),abi_version = GUILD_KERNEL_ABI_VERSION_V1,runner_id,arch_id,package_id, andprobe_gguf/validate_model/build_execution_plancallbacks. - Export
GUILD_PLUGIN_EXPORT guild_status_t guild_plugin_entry_v1(...)and callhost_api->register_runner(host, &runner_desc, out_error)inside the plugin’sinitcallback. - Package with a
.gkmetadatamanifest declaring"scope": "runner"(or"hybrid") and"provided_runners": ["<runner_id>"], sign withguild kernel sign, and install withguild kernel install.