Formats & Baking

Native-precision safetensors bakes, in-place GGUF patching, and LoRA export.

Every bake and GGUF patch starts from a self-describing EditSpec (edit.npz) containing the orthonormal basis Q, per-layer/component scales, component names, optional sandwich-norm gains G, and a SHA-256 provenance fingerprint.

Native-precision safetensors baking

lucid bake updates only the targeted writer tensors inside a checkpoint copy, leaving embeddings, routers, vision towers, MTP/nextn layers, and untouched layers bit-identical.

Checkpoint formatScale handlingRounding
BF16 / FP16 / FP32N/ARow-wise BF16 error diffusion (bf16_diffuse)
FP8 E4M3 (HF float scales)Keeps original _scale_inv; bumps a block only on overflowRow-wise error diffusion (diffuse_grid)
FP8 E4M3 (UE8M0 power-of-two)Supports .scale and Mistral consolidated .qscale_weight; bumps to next power of two on overflowRow-wise error diffusion (diffuse_grid)
ModelOpt NVFP4Keeps all per-16 E4M3 block scales and per-expert global scales fixed; updates 4-bit E2M1 codes onlyRow-wise error diffusion (diffuse_grid)
ModelOpt MXFP8Keeps all per-32 UE8M0 block scales fixed; updates FP8 codes onlyRow-wise error diffusion (diffuse_grid)

All codecs run in pure NumPy (using ml_dtypes when installed for faster FP8 conversion).

Streaming shard-by-shard bakes

For checkpoints too large to duplicate on disk, query the affected shards first and bake one shard at a time:

lucid bake --config lucid.toml --model-dir ./ckpt --edit ./edit.npz --shards-only
lucid bake --config lucid.toml --model-dir ./ckpt --edit ./edit.npz --only-shards model-00012-of-00100.safetensors

In-place GGUF patching

lucid patch-gguf modifies stock GGUF quants while preserving every tensor's ggml type and exact byte size:

lucid patch-gguf ./model-Q4_K_M.gguf ./edit.npz -o ./model-abliterated-Q4_K_M.gguf

Lucid uses two requantization paths automatically:

  1. Pure-NumPy codebook error diffusion (no compiled libggml required): handles Q8_0, Q4_0, Q4_K, IQ4_XS, IQ4_NL, Q2_0, MXFP4, and NVFP4. Every block scale/header is preserved untouched and only codes are re-picked row by row so rounding error cancels along Q.
  2. libggml ctypes error-feedback loop (fallback for Q6_K, Q5_K, Q3_K, IQ2_*, IQ1_*, etc.): pass --libggml /path/to/llama.cpp/build and Lucid runs iterative error feedback against ggml_quantize_chunk, keeping the lowest subspace-error iterate within the weight-error tolerance.

Standalone rank-k LoRA GGUF

You can also export any EditSpec as a single rank-k LoRA GGUF (B = -Q, A = s Q^T W, alpha = 0.0):

lucid merge-lora ./gguf_q8_dir ./edit.npz ./abliteration-lora.gguf
llama-server -m ./any-stock-quant.gguf --lora ./abliteration-lora.gguf

Because alpha = 0.0, llama.cpp applies the exact searched scale at --lora scale 1.0.

Edit this page on GitHub