77 "\\.ffn_(up|down|gate|gate_up)_(ch|)exps";
120 std::vector<std::string> patterns;
121 if (cpu_moe_layers <= 0) {
return patterns; }
122 patterns.reserve(
static_cast<std::size_t
>(cpu_moe_layers));
123 for (
int i = 0;
i < cpu_moe_layers; ++
i) {
156 const int n =
cfg.cpu_moe_layers;
159 reason =
"cpu_moe_layers must be >= 0 (0 = off), got "
161 +
". There is no 'all layers' sentinel — name the layer "
162 "count you want host-side.";
163 }
else if (
n > 0 &&
cfg.gpu_layers == 0) {
164 reason =
"cpu_moe_layers=" + std::to_string(
n)
165 +
" with gpu_layers: 0 — the whole model is already on the "
166 "host, so there are no expert tensors on the card to move "
167 "off it. Raise gpu_layers, or drop cpu_moe_layers.";
168 }
else if (
n > 0 &&
cfg.gpu_layers_auto) {
173 reason =
"cpu_moe_layers=" + std::to_string(
n)
174 +
" with gpu_layers: auto — auto derives the expert split "
175 "itself from the model's shape, so setting both asks two "
176 "things to decide one placement. Drop cpu_moe_layers and "
177 "let auto choose, or set gpu_layers to an explicit count "
178 "and keep your own split.";
210 if (cpu_moe_layers <= 0) {
return reason; }
212 reason =
"cpu_moe_layers=" + std::to_string(cpu_moe_layers)
213 +
" was requested, but this model declares no experts "
214 "(<arch>.expert_count is absent or 0). Expert-tensor "
215 "offload has nothing to place; use gpu_layers to move "
216 "whole layers on a dense model.";
217 }
else if (cpu_moe_layers >
n_layer) {
218 reason =
"cpu_moe_layers=" + std::to_string(cpu_moe_layers)
219 +
" exceeds the model's " + std::to_string(
n_layer)
220 +
" layers. Lower it to at most " + std::to_string(
n_layer)
221 +
"; it is not clamped, because a count that cannot be "
222 "honoured is a configuration error, not a preference.";
Configuration structs with defaults.
Activate model on GPU (WARM → ACTIVE).
std::string expert_block_pattern(int layer)
The override pattern for ONE layer's expert tensors.
@ optional
optional: every escape asks the host's path approver
constexpr const char * kExpertTensorRegex
Tensor-name pattern tail identifying a layer's ROUTED-expert weights.
std::string expert_offload_conflict_reason(const ModelConfig &cfg)
Configuration-time refusal for a combination that cannot mean what it says.
std::vector< std::string > expert_offload_patterns(int cpu_moe_layers)
Patterns for the FIRST cpu_moe_layers layers, in layer order.
std::string expert_offload_load_refusal(int cpu_moe_layers, int n_layer, int n_expert)
Post-load refusal, against the numbers only the loaded model knows.
Model configuration for a single tier.