#!/usr/bin/env python3
"""
Build tiny slices of a Qwen3.5 base model and of a LoRA decision adapter trained on it, for testing. Output is gibberish, only the shapes and code paths are real.
Adapted from the slice-model skill of llama.cpp (skills/slice-model): tensors are fetched with HTTP range requests (only the needed rows) and config.json is patched to match, then convert_hf_to_gguf.py does the conversion. The stock script only drops layers, which cannot go below the 248320 x hidden token embedding, so this one also narrows the hidden sizes.
The adapter is narrowed with the same indices as the base: LoRA A keeps the input columns of its base weight, LoRA B its output rows (the rank is kept). Only the LoRA tensors of the kept layers are kept.
Widths follow the tinyopenjev Qwen3.5 slice: 4 layers (3 linear attention + 1 full attention), hidden 32, FFN 128, 2 heads / 1 KV head (head_dim 256 kept), linear attention 2 key heads / 6 value heads (head dims 128 kept), the MTP layer is kept (narrowed), vision encoder 2 blocks, 2 heads (head_dim kept), out hidden 32 (the text GGUF budget is 10 MB: a 248320 x 32 matrix is 4.5 MB in Q4_0).
usage:
slice_qwen35_lora.py base