Repository navigation
convert : fix Granite Switch block_count for MultiSwitch checkpoints - #30621
Conversation
Signed-off-by: Nigel Jones <jonesn@uk.ibm.com>
|
cc: @gabe-l-hart |
gabe-l-hart
left a comment
There was a problem hiding this comment.
One quick comment NIT, but otherwise this looks like a good quick solution. I confirmed that the updated version of ibm-granite/granite-switch-4.1-3b-preview no longer runs after conversion on master and that this conversion change effectively fixes the hparams and no further c++ side changes are needed to work with the converted file.
|
It's worth noting that ibm-granite/granite-switch-4.1-3b-preview was updated in-place, so older pulls of the model work with the existing conversion, but a fresh pull does not. |
|
Related! https://huggingface.co/blog/ibm-granite/granite-switch-4-1 (new Switch with decision adapter, guardian, and ASR baked in). We'll be working on extending for multimodal adapters soon |
Co-authored-by: Gabe Goodhart <ghart@us.ibm.com>
…MultiSwitch fix Current Granite Switch checkpoints use MultiSwitch, which reserves two cache slots. Every llama.cpp converter up to and including v0.7.0 writes a block count one too high for them, so the script's GGUF converted but llama-server refused to load it (ggml-org/llama.cpp#30617). Pin the converter to build b11675, the first with the fix (ggml-org/llama.cpp#30621). Verified from a cold cache on the current 3b revision: the script downloads, converts with transformers 5.20.0, and serves on a v0.6.0 llama-server; the GGUF's block_count is 40, matching blocks 0-39, and the example and the adapter functions run against it. Assisted-by: Claude Code Signed-off-by: Nigel Jones <jonesn@uk.ibm.com>
…gml-org#30621) * convert : fix Granite Switch block_count for MultiSwitch checkpoints Signed-off-by: Nigel Jones <jonesn@uk.ibm.com> * Update granite.py Co-authored-by: Gabe Goodhart <ghart@us.ibm.com> --------- Signed-off-by: Nigel Jones <jonesn@uk.ibm.com> Co-authored-by: Gabe Goodhart <ghart@us.ibm.com>
…gml-org#30621) * convert : fix Granite Switch block_count for MultiSwitch checkpoints Signed-off-by: Nigel Jones <jonesn@uk.ibm.com> * Update granite.py Co-authored-by: Gabe Goodhart <ghart@us.ibm.com> --------- Signed-off-by: Nigel Jones <jonesn@uk.ibm.com> Co-authored-by: Gabe Goodhart <ghart@us.ibm.com>
Overview
GGUF files converted from newer Granite Switch checkpoints fail to load with the error:
The conversion itself succeeds and writes every real decoder layer.
Unfortunate one metadata value is wrong:
GraniteSwitchModelassumes the checkpoint's weightless switch owns exactly one KV cache slot and setsblock_count = num_hidden_layers - 1.The newer switch generation (MultiSwitch) owns two slots, so
num_hidden_layerscounts real layers plus two, and the storedgraniteswitch.block_countcomes out one too high. So the loader asks for a block that was never written.This PR derives the block count from the
model.layers.Ntensors actually present in the checkpoint instead of assuming a fixed offset. That is the count the runtime already expects:granite-switch.cppsizes the model type from it and adds the router layer beyondn_layerat load time.Affected are newer-generation Granite Switch checkpoints, for example
ibm-granite/granite-switch-4.1-3b-preview. Older SingleSwitch-generation checkpoints convert identically before and after this change.Fixes #30617
Additional information
llama-serverfails to load it with the error above; with the patch it loads.granite-switch.cpp'screate_tensorcalls.generative-computing/granite-switch,num_cache_layers), which buildsnum_hidden_layers - num_cache_layersdecoder layers.block_count -= 2 if "ms_code_m" in self.hparams else 1) also works today but breaks again the next time the engine's slot budget changes.NOTE that the
flakepre-commit was skipped (SKIP=flake8) due to dependency issues/crashesRequirements