中文 | English
PocketLLM is an experimental C++/CUDA and PyTorch inference stack for running large language models on consumer multi-GPU systems. It combines model-specific kernels, low-bit formats, tensor/expert parallelism, CPU/GPU placement, and reproducible single-request benchmarks.
The project started with DeepSeek-V4 on 4×RTX 2080 Ti and now includes validated runtimes for DeepSeek-V4, MiniMax-M2.7, GLM-5.2, and Qwen3.8-27B-FP8. PocketLLM is not a single universal backend: each model has a runtime matched to its architecture and checkpoint format.
Status: research and engineering software. The numbers below are measurements from specific checkpoints and hardware configurations, not general performance guarantees.
cpp_engine/ path supports DeepSeek-V4 GGUF/Safetensors flows and Qwen3.8 FP8 Safetensors text generation.| Model | Checkpoint / format | Runtime status | Validated path | Reference result on 4×RTX 2080 Ti |
|---|---|---|---|---|
| DeepSeek-V4-Flash | Safetensors FP4/FP8; GGUF Q2/IQ2/IQ1 | Validated generation | PyTorch heterogeneous, C++/CUDA, GGUF TP4 | C++ FP4: ~401 tok/s prefill at 32K–64K; ~3.7 tok/s decode |
| MiniMax-M2.7 | GGUF UD-IQ1_M | Validated TP4 generation | Raw-block CUDA, GGUF TP4 | Full-model 256-token prefill: ~104.9–107 tok/s; 43-layer decode benchmark: 10.32 tok/s |
| GLM-5.2 | GGUF UD-Q2_K_XL | Validated text generation | Raw-block CUDA, GGUF TP4 | ~0.79 tok/s prefill; ~0.66 tok/s decode |
| Qwen3.8-27B-FP8 | Safetensors FP8 E4M3 | Validated C++ text runtime | C++/CUDA TP4, GPU-resident FP8 | 416.48 tok/s prefill; 35.87 tok/s decode on a 512-token prompt |
The model pages separate architecture specifications from what PocketLLM currently implements. inspect, smoke, and a benchmark are not automatically equivalent to a production serving guarantee.
All figures in this section use real checkpoints on the same baseline system unless noted otherwise: 4× NVIDIA RTX 2080 Ti 22 GiB, PCIe Gen3, no NVLink, single-request execution, TP4 where applicable. See Benchmarking before comparing results.
These are architecture-specific results. They should not be averaged into one PocketLLM score.
PocketLLM has two complementary execution families:
The runtime is intentionally model-specific. DeepSeek-V4 uses MLA/indexing and routed-expert scheduling; MiniMax-M2.7 and GLM-5.2 use GGUF raw-block paths; Qwen3.8 uses Safetensors FP8 online unpacking plus hybrid linear/full attention. Raw quantized weights are not expanded to a full FP32 copy in the intended hot paths.
python -m pip install -r requirements.txt
python setup.py build_ext
The Python package metadata is named pocketllm; existing Python imports under src.* remain unchanged for compatibility.
cmake -S cpp_engine -B build/cpp_engine -DCMAKE_BUILD_TYPE=Release
cmake --build build/cpp_engine -j
The current executable keeps the compatibility name dsv4_cpp_engine:
build/cpp_engine/dsv4_cpp_engine
The backend is selected at configure time via POCKET_BACKEND, which defaults
to cuda, so the command above is unchanged from before:
cmake -S cpp_engine -B build/cpp_engine -DPOCKET_BACKEND=cuda
POCKET_BACKEND=ascend reserves the layout for Ascend NPUs. It configures but
does not yet link, because the ACL runtime, AscendC kernels and HCCL collectives
under cpp_engine/backends/ascend/ are not implemented.
The source tree is layered so that a second backend can reuse everything that is not vendor-specific:
cpp_engine/
core/ device-agnostic: loaders, tokenizer, HTTP server
engine/ one engine implementation, shared by all backends
backends/
api/ vendor-neutral contracts (to be populated)
cuda/ kernels/ runtime/ collective/
ascend/ kernels/ runtime/ collective/
core/ and the public headers under include/ must not include a vendor SDK.
This is enforced, not merely documented:
cmake --build build/cpp_engine --target check_layering
CKPT=/path/to/DeepSeek-V4-Flash \
PORT=8000 \
MAX_CONTEXT=8192 \
PYTHON=python \
bash scripts/run_cpp_serve_tp4.sh
This starts rank 0 as the OpenAI-compatible server and ranks 1–3 as NCCL workers.
PYTHONPATH=$PWD torchrun --standalone --nproc-per-node=4 \
-m src.cli.generate_gguf \
--gguf-path /path/to/model.gguf \
--seed-file /path/to/prompt_tokens.bin \
--max-new-tokens 32 \
--prewarm
For GLM-5.2 text prompts:
PYTHONPATH=$PWD torchrun --standalone --nproc-per-node=4 \
-m src.cli.generate_glm \
--gguf-path /path/to/GLM-5.2-GGUF/UD-Q2_K_XL \
--prompt "Hello" \
--chat \
--max-new-tokens 32 \
--prewarm
PYTHONPATH=$PWD python -m src.cli.inspect_gguf \
--gguf-path /path/to/model.gguf \
--architecture auto \
--spec-summary \
--validate-spec \
--capability-report \
--placement-report
The Qwen path accepts a text prompt or token IDs and uses TP4 ranks with an NCCL ID file:
rm -f /tmp/pocketllm_qwen_nccl.id
for rank in 0 1 2 3; do
CUDA_VISIBLE_DEVICES=$rank \
build/cpp_engine/dsv4_cpp_engine \
--ckpt /path/to/Qwen3.8-27B-FP8 \
--tp-world 4 --tp-rank $rank --device 0 \
--nccl-id-path /tmp/pocketllm_qwen_nccl.id \
--prompt "Explain tensor parallelism in one paragraph." \
--generate-token 123 --max-new-tokens 32 --smoke-layers 0 --resident-bench \
> /tmp/pocketllm_qwen_rank${rank}.log 2>&1 &
done
wait
For a normal run, use the same command-line options as the Qwen smoke entrypoint and let rank 0 report prefill_tokens_per_s, decode_tokens_per_s, resident weight bytes, and GPU memory. The Qwen OpenAI server adapter is not implemented yet.
External Qwen DSpark is available as an opt-in with --qwen-dspark /path/to/Qwen3.8-27B-DSpark; it cannot be combined with native MTP. The real five-layer drafter proposes seven tokens and verifies eight target rows at once. It remains default-off because measured gains are acceptance-dependent. See the Qwen model page for real 512/8K/32K results and the prefix/cold-parity command.
External Qwen DFlash2 is a second opt-in drafter, --qwen-dflash2 /path/to/Qwen3.8-27B-DFlash2, mutually exclusive with both DSpark and native MTP. With its four opt-in flags enabled it measures 2.78x full-request and 3.02x decode on a 512-token fixture, and 1.33x aggregate on eight GSM8K prompts, with exact token parity in every case. Decode-phase speedup falls inside upstream's published 2.67–3.43x band. See the Qwen model page for the full table, the FP32-residual numerical requirement, and the reproduction commands.
For a single-concurrency client whose next request extends or compresses the previous one, keep one TP4 process group alive with the persistent token-ID worker. Rank 0 reads <max_new_tokens> token0 token1 ... lines and reports exact prefix accounting; the worker reuses live state for appends and device snapshots for branches:
python scripts/bench_qwen_prefix_cache.py \\
--ckpt /path/to/Qwen3.8-27B-FP8 \\
--token-ids-file /path/to/prompt_ids.csv \\
--max-context 32768 \\
--max-new-tokens 4 \\
--compression-prefix-tokens 4096
The benchmark starts ranks 1–3 as command workers and keeps rank 0 alive for all requests. Use --disable-prefix-cache for a cold parity A/B. One-shot Qwen commands disable prefix snapshots because their engine lifetime covers only one request; --qwen-persistent-stdin enables the cache, while --qwen-no-prefix-cache explicitly disables it.
PocketLLM code is licensed under the PolyForm Noncommercial License 1.0.0.
Permitted uses include personal use, academic research, education, non-commercial benchmarking, and non-commercial deployment. Commercial use requires separate written permission from the copyright holder.
Model weights, tokenizer files, CUDA, PyTorch, GGUF assets, and other third-party components are governed by their respective licenses. PocketLLM's code license does not grant additional rights to third-party model assets.
PocketLLM builds on CUDA, PyTorch, safetensors, GGUF, Transformers, NCCL, and llama.cpp quantization research. The model-specific runtimes and benchmarks are engineering work for reproducible local inference on consumer hardware.
334 commits
C++
45.2%
Python
29.7%
Cuda
22.4%
Shell
1.3%
中文 | English
PocketLLM is an experimental C++/CUDA and PyTorch inference stack for running large language models on consumer multi-GPU systems. It combines model-specific kernels, low-bit formats, tensor/expert parallelism, CPU/GPU placement, and reproducible single-request benchmarks.
The project started with DeepSeek-V4 on 4×RTX 2080 Ti and now includes validated runtimes for DeepSeek-V4, MiniMax-M2.7, GLM-5.2, and Qwen3.8-27B-FP8. PocketLLM is not a single universal backend: each model has a runtime matched to its architecture and checkpoint format.
Status: research and engineering software. The numbers below are measurements from specific checkpoints and hardware configurations, not general performance guarantees.
cpp_engine/ path supports DeepSeek-V4 GGUF/Safetensors flows and Qwen3.8 FP8 Safetensors text generation.| Model | Checkpoint / format | Runtime status | Validated path | Reference result on 4×RTX 2080 Ti |
|---|---|---|---|---|
| DeepSeek-V4-Flash | Safetensors FP4/FP8; GGUF Q2/IQ2/IQ1 | Validated generation | PyTorch heterogeneous, C++/CUDA, GGUF TP4 | C++ FP4: ~401 tok/s prefill at 32K–64K; ~3.7 tok/s decode |
| MiniMax-M2.7 | GGUF UD-IQ1_M | Validated TP4 generation | Raw-block CUDA, GGUF TP4 | Full-model 256-token prefill: ~104.9–107 tok/s; 43-layer decode benchmark: 10.32 tok/s |
| GLM-5.2 | GGUF UD-Q2_K_XL | Validated text generation | Raw-block CUDA, GGUF TP4 | ~0.79 tok/s prefill; ~0.66 tok/s decode |
| Qwen3.8-27B-FP8 | Safetensors FP8 E4M3 | Validated C++ text runtime | C++/CUDA TP4, GPU-resident FP8 | 416.48 tok/s prefill; 35.87 tok/s decode on a 512-token prompt |
The model pages separate architecture specifications from what PocketLLM currently implements. inspect, smoke, and a benchmark are not automatically equivalent to a production serving guarantee.
All figures in this section use real checkpoints on the same baseline system unless noted otherwise: 4× NVIDIA RTX 2080 Ti 22 GiB, PCIe Gen3, no NVLink, single-request execution, TP4 where applicable. See Benchmarking before comparing results.
These are architecture-specific results. They should not be averaged into one PocketLLM score.
PocketLLM has two complementary execution families:
The runtime is intentionally model-specific. DeepSeek-V4 uses MLA/indexing and routed-expert scheduling; MiniMax-M2.7 and GLM-5.2 use GGUF raw-block paths; Qwen3.8 uses Safetensors FP8 online unpacking plus hybrid linear/full attention. Raw quantized weights are not expanded to a full FP32 copy in the intended hot paths.
python -m pip install -r requirements.txt
python setup.py build_ext
The Python package metadata is named pocketllm; existing Python imports under src.* remain unchanged for compatibility.
cmake -S cpp_engine -B build/cpp_engine -DCMAKE_BUILD_TYPE=Release
cmake --build build/cpp_engine -j
The current executable keeps the compatibility name dsv4_cpp_engine:
build/cpp_engine/dsv4_cpp_engine
The backend is selected at configure time via POCKET_BACKEND, which defaults
to cuda, so the command above is unchanged from before:
cmake -S cpp_engine -B build/cpp_engine -DPOCKET_BACKEND=cuda
POCKET_BACKEND=ascend reserves the layout for Ascend NPUs. It configures but
does not yet link, because the ACL runtime, AscendC kernels and HCCL collectives
under cpp_engine/backends/ascend/ are not implemented.
The source tree is layered so that a second backend can reuse everything that is not vendor-specific:
cpp_engine/
core/ device-agnostic: loaders, tokenizer, HTTP server
engine/ one engine implementation, shared by all backends
backends/
api/ vendor-neutral contracts (to be populated)
cuda/ kernels/ runtime/ collective/
ascend/ kernels/ runtime/ collective/
core/ and the public headers under include/ must not include a vendor SDK.
This is enforced, not merely documented:
cmake --build build/cpp_engine --target check_layering
CKPT=/path/to/DeepSeek-V4-Flash \
PORT=8000 \
MAX_CONTEXT=8192 \
PYTHON=python \
bash scripts/run_cpp_serve_tp4.sh
This starts rank 0 as the OpenAI-compatible server and ranks 1–3 as NCCL workers.
PYTHONPATH=$PWD torchrun --standalone --nproc-per-node=4 \
-m src.cli.generate_gguf \
--gguf-path /path/to/model.gguf \
--seed-file /path/to/prompt_tokens.bin \
--max-new-tokens 32 \
--prewarm
For GLM-5.2 text prompts:
PYTHONPATH=$PWD torchrun --standalone --nproc-per-node=4 \
-m src.cli.generate_glm \
--gguf-path /path/to/GLM-5.2-GGUF/UD-Q2_K_XL \
--prompt "Hello" \
--chat \
--max-new-tokens 32 \
--prewarm
PYTHONPATH=$PWD python -m src.cli.inspect_gguf \
--gguf-path /path/to/model.gguf \
--architecture auto \
--spec-summary \
--validate-spec \
--capability-report \
--placement-report
The Qwen path accepts a text prompt or token IDs and uses TP4 ranks with an NCCL ID file:
rm -f /tmp/pocketllm_qwen_nccl.id
for rank in 0 1 2 3; do
CUDA_VISIBLE_DEVICES=$rank \
build/cpp_engine/dsv4_cpp_engine \
--ckpt /path/to/Qwen3.8-27B-FP8 \
--tp-world 4 --tp-rank $rank --device 0 \
--nccl-id-path /tmp/pocketllm_qwen_nccl.id \
--prompt "Explain tensor parallelism in one paragraph." \
--generate-token 123 --max-new-tokens 32 --smoke-layers 0 --resident-bench \
> /tmp/pocketllm_qwen_rank${rank}.log 2>&1 &
done
wait
For a normal run, use the same command-line options as the Qwen smoke entrypoint and let rank 0 report prefill_tokens_per_s, decode_tokens_per_s, resident weight bytes, and GPU memory. The Qwen OpenAI server adapter is not implemented yet.
External Qwen DSpark is available as an opt-in with --qwen-dspark /path/to/Qwen3.8-27B-DSpark; it cannot be combined with native MTP. The real five-layer drafter proposes seven tokens and verifies eight target rows at once. It remains default-off because measured gains are acceptance-dependent. See the Qwen model page for real 512/8K/32K results and the prefix/cold-parity command.
External Qwen DFlash2 is a second opt-in drafter, --qwen-dflash2 /path/to/Qwen3.8-27B-DFlash2, mutually exclusive with both DSpark and native MTP. With its four opt-in flags enabled it measures 2.78x full-request and 3.02x decode on a 512-token fixture, and 1.33x aggregate on eight GSM8K prompts, with exact token parity in every case. Decode-phase speedup falls inside upstream's published 2.67–3.43x band. See the Qwen model page for the full table, the FP32-residual numerical requirement, and the reproduction commands.
For a single-concurrency client whose next request extends or compresses the previous one, keep one TP4 process group alive with the persistent token-ID worker. Rank 0 reads <max_new_tokens> token0 token1 ... lines and reports exact prefix accounting; the worker reuses live state for appends and device snapshots for branches:
python scripts/bench_qwen_prefix_cache.py \\
--ckpt /path/to/Qwen3.8-27B-FP8 \\
--token-ids-file /path/to/prompt_ids.csv \\
--max-context 32768 \\
--max-new-tokens 4 \\
--compression-prefix-tokens 4096
The benchmark starts ranks 1–3 as command workers and keeps rank 0 alive for all requests. Use --disable-prefix-cache for a cold parity A/B. One-shot Qwen commands disable prefix snapshots because their engine lifetime covers only one request; --qwen-persistent-stdin enables the cache, while --qwen-no-prefix-cache explicitly disables it.
PocketLLM code is licensed under the PolyForm Noncommercial License 1.0.0.
Permitted uses include personal use, academic research, education, non-commercial benchmarking, and non-commercial deployment. Commercial use requires separate written permission from the copyright holder.
Model weights, tokenizer files, CUDA, PyTorch, GGUF assets, and other third-party components are governed by their respective licenses. PocketLLM's code license does not grant additional rights to third-party model assets.
PocketLLM builds on CUDA, PyTorch, safetensors, GGUF, Transformers, NCCL, and llama.cpp quantization research. The model-specific runtimes and benchmarks are engineering work for reproducible local inference on consumer hardware.
334 commits
C++
45.2%
Python
29.7%
Cuda
22.4%
Shell
1.3%