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

  1. Appended MTP block: gigachat4.block_count includes gigachat4.nextn_predict_layers (e.g. block 32 on the 37B-A4B checkpoint). Lucid strips nextn_predict_layers during inspect_gguf so only the 32 main layers are targeted and the MTP block is left untouched.
  2. Gated sandwich post-norms (GigaChat4GatedNorm): subblock outputs pass through 2 * w * rmsnorm(y) * gate. The gigachat4 preset sets use_post_norm_gains = true and wires post_attention_norm.weight / post_ffw_norm.weight so writer projections use the QR-orthonormalized gain-corrected basis P = orth(w * Q). The constant factor 2 does not affect orthogonality, and the input-dependent gate is excluded from the fixed basis.
  3. Bilingual EN/RU handling: the gigachat4 preset enables Russian refusal markers automatically, and Cyrillic prompts in custom --bad/--good files are tagged under the ru arm so ru_chat and ru_think directions are kept separate from English.
ComponentWriter tensorsPost-norm gain
attnattn_output.weight (MLA/DSA), ssm_out.weight (GatedDeltaNet)post_attention_norm.weight
mlpffn_down_shexp.weight, ffn_down.weightpost_ffw_norm.weight
expffn_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-capture

Running 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.toml

Attach 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

Edit this page on GitHub