(very WIP!) Fast LLM inference in Rust & CUDA doll.tngl.io/firecrest
firecrest docs models.md
9.1 kB 227 lines
Markdown
at main

Getting the model files #

Firecrest reads DeepSeek V4.1 Flash from GGUF files: one language file with the MXFP4 routed experts, Q8_0 dense weights and the Engram tables, and an optional vision-encoder file for image input. The files published with the ds4 engine are the recommended source.

Note

A native weight format and a converter from the official DeepSeek checkpoint are planned (see the README). Until then, GGUF is the only input format, and the steps below may change.

DeepSeek V4.1 Flash 1017 #

What you need #

Resource Amount
Disk 467 GiB for the merged file, on a fast local SSD (the Engram tables are read from it during inference), plus up to 95 GiB while merging
Host RAM About 300 GiB for the routed experts, plus the context store's share
GPUs Two with 24 GB each

Download #

The repository antirez/deepseek-v4.1-flash-gguf holds the 1017 checkpoint's MXFP4 files as nine shards, DeepSeek-V4.1-Flash-1017-MXFP4-experts-0000k-of-00009.gguf. Download only those; the Q2 and Q4 files in the same repository use quantization types the DeepSeek V4.1 engine does not read.

hf download antirez/deepseek-v4.1-flash-gguf \
    --include 'DeepSeek-V4.1-Flash-1017-MXFP4-experts-*' --local-dir MODEL_DIR

Merge the shards #

Firecrest opens one file, and needs every tensor to start on a 16 KiB boundary: it page-locks host memory one whole expert at a time, and each expert is a whole number of pages only when its tensor starts on a page boundary. The shards use 32-byte alignment. scripts/gguf-merge.py (Python 3, standard library only) joins them into one file with 16 KiB alignment and copies the tensor data unchanged. --delete-shards removes each shard once it is copied, so the merge needs at most one shard's size of extra space:

scripts/gguf-merge.py MODEL_DIR/DeepSeek-V4.1-Flash-1017-MXFP4-experts-00001-of-00009.gguf \
    MODEL_DIR/DeepSeek-V4.1-Flash-1017-MXFP4.gguf --delete-shards

--plan prints the merged tensor table without writing anything.

Check the file #

The tensor table of the merged file must match the one this repository records in engines/deepseek-v4.1/docs/spec/gguf-main-dump.txt:

python3 scripts/ggufdump.py MODEL_DIR/DeepSeek-V4.1-Flash-1017-MXFP4.gguf \
    | diff engines/deepseek-v4.1/docs/spec/gguf-main-dump.txt -

Only metadata lines may differ: general.name, deepseek41.calibration and the quantize.imatrix.* keys describe how the files were produced and do not change the weights. A difference on a line that starts with T (a tensor) or data base means the file is not the one Firecrest was tested with.

Firecrest recognizes the 1017 checkpoint by general.source.revision (1bae0e1088993b9b82de08f59de5be5a34e42170) and switches its 1017-specific numerics on from it.

Vision encoder (optional) #

Image input needs a second GGUF with the vision encoder. The same Hugging Face repository has DeepSeek-V4.1-Flash-Vision.gguf, but it is converted from the earlier V4.1 checkpoint, and the 1017 release changed the vision weights. Firecrest runs it beside the 1017 model and logs a warning at load (vision_revision): images are then encoded with weights the model was not released with. A 1017 vision file is not published yet. Without a vision file, leave vision out of the configuration and requests with images are rejected.

hf download antirez/deepseek-v4.1-flash-gguf --include DeepSeek-V4.1-Flash-Vision.gguf --local-dir MODEL_DIR

Configure #

Point the model options at the files (the full example is engines/deepseek-v4.1/engine/examples/gpu.toml):

[[model]]
id = "deepseek-v4.1-flash"
engine = "dsv41"
autoload = true

[model.options]
model = "MODEL_DIR/DeepSeek-V4.1-Flash-1017-MXFP4.gguf"
vision = "MODEL_DIR/DeepSeek-V4.1-Flash-Vision.gguf"   # optional
backend = "gpu"

The engine options (placement, CPU sets, the context store, profiles) are described in the engine README. Steering vectors and adapters are in adapters.md.

Tests and tools #

Tests and examples that need the real model read its location from the environment and skip when it is unset:

Variable What
FIRECREST_MODEL The merged MXFP4 GGUF
FIRECREST_VISION The vision GGUF
FIRECREST_REF_DIR Reference activation dumps, where a test compares against them
FIRECREST_ADAPTER An adapter file, for the adapter tests

Inkling 2 Mini (experimental) #

The Inkling engine reads the release checkpoint in safetensors format from thinkingmachines/Inkling-2-Mini, about 20 GB including the drafter (mtp.safetensors):

hf download thinkingmachines/Inkling-2-Mini --local-dir INKLING_DIR
export FIRECREST_INKLING_MODEL=INKLING_DIR

firecrest serve does not serve Inkling yet; the engine's tests, examples and the Python oracle in engines/inkling/ use FIRECREST_INKLING_MODEL. See engines/inkling/docs/spec/README.md.

SmolLM3-3B #

The SmolLM3 engine reads the llama.cpp GGUF files of SmolLM3-3B on the CPU and the GPU, each tensor in its own type (F16, BF16, Q4_0, Q4_1, Q8_0, Q2_K to Q6_K, IQ1_S to IQ4_XS): ggml-org/SmolLM3-3B-GGUF (SmolLM3-f16.gguf, 6.2 GB, the reference file; SmolLM3-Q8_0.gguf, 3.3 GB; SmolLM3-Q4_K_M.gguf), bartowski/HuggingFaceTB_SmolLM3-3B-GGUF (Q2_K to Q8_0 and the IQ files) and unsloth/SmolLM3-3B-GGUF (the UD-* files included); the GPU does not read BF16 or F32 matrices. Down to about 2.9 bits per weight (IQ2_M) the text stays coherent; below that (UD-IQ2_XXS, the IQ1 files) the model runs but its text degrades (engines/smollm3/gpu/VALIDATION.md). A file with a tensor of another type is refused at load. Its Python oracle also needs the release checkpoint, HuggingFaceTB/SmolLM3-3B (6.2 GB):

hf download ggml-org/SmolLM3-3B-GGUF SmolLM3-f16.gguf --local-dir SMOLLM3_DIR
export FIRECREST_SMOLLM3_MODEL=SMOLLM3_DIR/SmolLM3-f16.gguf
hf download HuggingFaceTB/SmolLM3-3B --local-dir SMOLLM3_HF   # for the oracle only

firecrest serve runs SmolLM3 with engine = "smollm3":

[[model]]
id = "smollm3"
engine = "smollm3"
autoload = true
gpus = [0]            # keeps other models off this GPU

[model.options]
model = "SMOLLM3_DIR/HuggingFaceTB_SmolLM3-3B-Q4_K_M.gguf"
device = "gpu"        # needs a binary built with the gpu feature
max_ctx = 8192

The options are in engines/smollm3/engine/README.md. The engine, the CPU reference, the GPU forward, their tests and the oracle are in engines/smollm3/. See engines/smollm3/docs/spec/README.md.

Qwen3.6-35B-A3B #

The Qwen3.6 engine reads one file, the UD-Q4_K_XL GGUF of unsloth/Qwen3.6-35B-A3B-MTP-GGUF (Qwen3.6-35B-A3B-UD-Q4_K_XL.gguf, 22.9 GB: Q8_0 attention, DeltaNet and shared experts, Q4_K/Q5_K/Q6_K routed experts, and the MTP layer, which is loaded but not run). It is served on one GPU: the non-expert weights, the KV cache and as many routed experts as fit in VRAM (12.5 GB of a 16 GB card), the most routed ones once the engine has counted its traffic (expert_profile), the other experts computed on the host from the mapped file or, in long prefills, copied to the GPU; 54.5 tokens per second of decode after a short prompt and 50.8 after 4K tokens, and 571 / 553 / 509 of prefill at 512 / 2048 / 8192 tokens, on an RTX 4060 Ti with a Ryzen 5 5500 (engines/qwen3.6/gpu/VALIDATION.md, Speed). The CPU reference forward (device = "cpu") runs a few tokens per second. Both map the file and need the host RAM to keep it in the page cache.

hf download unsloth/Qwen3.6-35B-A3B-MTP-GGUF Qwen3.6-35B-A3B-UD-Q4_K_XL.gguf --local-dir QWEN36_DIR
export FIRECREST_QWEN36_MODEL=QWEN36_DIR/Qwen3.6-35B-A3B-UD-Q4_K_XL.gguf

firecrest serve runs it with engine = "qwen3.6":

[[model]]
id = "qwen3.6"
engine = "qwen3.6"
autoload = true

[model.options]
model = "QWEN36_DIR/Qwen3.6-35B-A3B-UD-Q4_K_XL.gguf"
device = "gpu"
context = 32768

The options are in engines/qwen3.6/engine/README.md. The engine, the CPU reference, the GPU forward and the oracle are in engines/qwen3.6/. See engines/qwen3.6/docs/spec/README.md.