GigaChat 4
Model-specific notes for abliterating GigaChat 4 37B-A4B and 708B-A41B with llama.cpp.
GigaChat 4 is a hybrid MLA/DSA + GatedDeltaNet MoE with gated sandwich post-norms and an appended MTP block. Use the gigachat4 preset (detected automatically from the GGUF header) together with examples/gigachat4.toml.
Architecture quirks
- Appended MTP block:
gigachat4.block_countincludesgigachat4.nextn_predict_layers(e.g. block 32 on the 37B-A4B checkpoint). Lucid stripsnextn_predict_layersduringinspect_ggufso only the 32 main layers are targeted and the MTP block is left untouched. - Gated sandwich post-norms (
GigaChat4GatedNorm): subblock outputs pass through2 * w * rmsnorm(y) * gate. Thegigachat4preset setsuse_post_norm_gains = trueand wirespost_attention_norm.weight/post_ffw_norm.weightso writer projections use the QR-orthonormalized gain-corrected basisP = orth(w * Q). The constant factor2does not affect orthogonality, and the input-dependent gate is excluded from the fixed basis. - Bilingual EN/RU handling: the
gigachat4preset enables Russian refusal markers automatically, and Cyrillic prompts in custom--bad/--goodfiles are tagged under theruarm soru_chatandru_thinkdirections are kept separate from English.
| Component | Writer tensors | Post-norm gain |
|---|---|---|
attn | attn_output.weight (MLA/DSA), ssm_out.weight (GatedDeltaNet) | post_attention_norm.weight |
mlp | ffn_down_shexp.weight, ffn_down.weight | post_ffw_norm.weight |
exp | ffn_down_exps.weight (192 routed experts) | post_ffw_norm.weight |
Building llama.cpp
Build llama-server, llama-cli, and Lucid's llama-ablate-capture from a llama.cpp checkout that supports gigachat4:
cmake -S . -B build \
-DCMAKE_BUILD_TYPE=Release \
-DGGML_CUDA=ON \
-DLLAMA_BUILD_TESTS=OFF -DLLAMA_BUILD_EXAMPLES=ON -DLLAMA_BUILD_SERVER=ON
cmake --build build -j --target llama-server llama-cli
lucid export-cpp examples/ablate-capture
# Add add_subdirectory(ablate-capture) to examples/CMakeLists.txt, then:
cmake -S . -B build
cmake --build build -j --target llama-ablate-captureRunning search and exporting a LoRA
On 24 GB GPUs, pin routed experts in host RAM via llama_cpp_args (already configured in examples/gigachat4.toml) and export a standalone GGUF LoRA:
lucid run ./GigaChat4-37B-A4B-Q4_K_M.gguf \
--backend llama_cpp \
--config examples/gigachat4.toml \
--bad ./bad_en_ru.txt \
--good ./good_en_ru.txt \
--no-bake \
--work-dir ./lucid_gc4 \
--ctx-size 8192 --parallel 8
lucid merge-lora ./GigaChat4-37B-A4B-Q4_K_M.gguf \
./lucid_gc4/edit.npz \
./gigachat4-lucid-lora.gguf \
--config examples/gigachat4.tomlAttach the exported LoRA to any stock quant at scale 1.0:
llama-server \
-m ./GigaChat4-37B-A4B-Q4_K_M.gguf \
--lora ./gigachat4-lucid-lora.gguf \
-ngl 999 -cmoe --moe-cache-mib 4096 \
-fa on -c 8192 --host 127.0.0.1 --port 8080