pocketllm 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pocketllm-0.1.0/LICENSE +21 -0
- pocketllm-0.1.0/MANIFEST.in +25 -0
- pocketllm-0.1.0/PKG-INFO +431 -0
- pocketllm-0.1.0/README.md +390 -0
- pocketllm-0.1.0/README_CN.md +225 -0
- pocketllm-0.1.0/cpp_engine/CMakeLists.txt +915 -0
- pocketllm-0.1.0/cpp_engine/backends/api/device_runtime.hpp +124 -0
- pocketllm-0.1.0/cpp_engine/backends/ascend/collective/tp_comm.cpp +619 -0
- pocketllm-0.1.0/cpp_engine/backends/ascend/kernels/aclnn_common.hpp +295 -0
- pocketllm-0.1.0/cpp_engine/backends/ascend/kernels/aclnn_ops.cpp +744 -0
- pocketllm-0.1.0/cpp_engine/backends/ascend/kernels/qwen_argmax_f32.cpp +111 -0
- pocketllm-0.1.0/cpp_engine/backends/ascend/kernels/qwen_ascend_kernel_common.hpp +251 -0
- pocketllm-0.1.0/cpp_engine/backends/ascend/kernels/qwen_ascend_ops_launch.cpp +663 -0
- pocketllm-0.1.0/cpp_engine/backends/ascend/kernels/qwen_attention_f16.cpp +1194 -0
- pocketllm-0.1.0/cpp_engine/backends/ascend/kernels/qwen_gated_delta_f16.cpp +444 -0
- pocketllm-0.1.0/cpp_engine/backends/ascend/kernels/qwen_linear_f16.cpp +344 -0
- pocketllm-0.1.0/cpp_engine/backends/ascend/runtime/device_runtime_ascend.cpp +357 -0
- pocketllm-0.1.0/cpp_engine/backends/cuda/collective/tp_comm.cpp +510 -0
- pocketllm-0.1.0/cpp_engine/backends/cuda/kernels/bf16_ops.cu +490 -0
- pocketllm-0.1.0/cpp_engine/backends/cuda/kernels/cuda_ops.cu +2681 -0
- pocketllm-0.1.0/cpp_engine/backends/cuda/kernels/flashmemory_ops.cu +576 -0
- pocketllm-0.1.0/cpp_engine/backends/cuda/kernels/fp4_ops.cu +1970 -0
- pocketllm-0.1.0/cpp_engine/backends/cuda/kernels/fp8_ops.cu +382 -0
- pocketllm-0.1.0/cpp_engine/backends/cuda/kernels/iq1_ops.cu +1530 -0
- pocketllm-0.1.0/cpp_engine/backends/cuda/kernels/q2_ops.cu +1273 -0
- pocketllm-0.1.0/cpp_engine/backends/cuda/kernels/quant_gemm.cu +247 -0
- pocketllm-0.1.0/cpp_engine/backends/cuda/kernels/qwen_attention_ops.cu +970 -0
- pocketllm-0.1.0/cpp_engine/backends/cuda/kernels/qwen_dflash2_ops.cu +1287 -0
- pocketllm-0.1.0/cpp_engine/backends/cuda/kernels/qwen_dspark_ops.cu +430 -0
- pocketllm-0.1.0/cpp_engine/backends/cuda/kernels/qwen_fp8_ops.cu +1400 -0
- pocketllm-0.1.0/cpp_engine/backends/cuda/kernels/qwen_gdn_flashqla.cu +333 -0
- pocketllm-0.1.0/cpp_engine/backends/cuda/kernels/qwen_gqa_optimized.cu +3371 -0
- pocketllm-0.1.0/cpp_engine/backends/cuda/kernels/qwen_half_ops.cu +4563 -0
- pocketllm-0.1.0/cpp_engine/backends/cuda/kernels/qwen_int8_per_token_head_ops.cu +305 -0
- pocketllm-0.1.0/cpp_engine/backends/cuda/kernels/qwen_nvfp4_ops.cu +936 -0
- pocketllm-0.1.0/cpp_engine/backends/cuda/kernels/qwen_turboquant_ops.cu +955 -0
- pocketllm-0.1.0/cpp_engine/backends/cuda/kernels/rmsnorm_rope.cu +85 -0
- pocketllm-0.1.0/cpp_engine/backends/cuda/kernels/sampler_ops.cu +385 -0
- pocketllm-0.1.0/cpp_engine/backends/cuda/runtime/device_runtime_cuda.cpp +229 -0
- pocketllm-0.1.0/cpp_engine/cmake/CheckLayering.cmake +120 -0
- pocketllm-0.1.0/cpp_engine/core/block_pool.cpp +99 -0
- pocketllm-0.1.0/cpp_engine/core/block_table.cpp +176 -0
- pocketllm-0.1.0/cpp_engine/core/cmd_channel.cpp +175 -0
- pocketllm-0.1.0/cpp_engine/core/gguf_reader.cpp +425 -0
- pocketllm-0.1.0/cpp_engine/core/json_constraint.cpp +818 -0
- pocketllm-0.1.0/cpp_engine/core/json_lite.cpp +210 -0
- pocketllm-0.1.0/cpp_engine/core/metrics.cpp +166 -0
- pocketllm-0.1.0/cpp_engine/core/metrics.hpp +66 -0
- pocketllm-0.1.0/cpp_engine/core/model_config.cpp +236 -0
- pocketllm-0.1.0/cpp_engine/core/model_registry.cpp +180 -0
- pocketllm-0.1.0/cpp_engine/core/python_sidecar.cpp +345 -0
- pocketllm-0.1.0/cpp_engine/core/qwen_config.cpp +313 -0
- pocketllm-0.1.0/cpp_engine/core/qwen_weight_map.cpp +1050 -0
- pocketllm-0.1.0/cpp_engine/core/safetensors_model.cpp +82 -0
- pocketllm-0.1.0/cpp_engine/core/safetensors_reader.cpp +267 -0
- pocketllm-0.1.0/cpp_engine/core/sampler.cpp +70 -0
- pocketllm-0.1.0/cpp_engine/core/tensor.cpp +33 -0
- pocketllm-0.1.0/cpp_engine/core/token_constraint.cpp +116 -0
- pocketllm-0.1.0/cpp_engine/core/tokenizer.cpp +360 -0
- pocketllm-0.1.0/cpp_engine/core/weight_source.cpp +216 -0
- pocketllm-0.1.0/cpp_engine/engine/backend_unimplemented_ascend.cpp +273 -0
- pocketllm-0.1.0/cpp_engine/engine/batch_scheduler.cpp +843 -0
- pocketllm-0.1.0/cpp_engine/engine/deepseek_v4_engine.cpp +11572 -0
- pocketllm-0.1.0/cpp_engine/engine/dspark_engine.cpp +1750 -0
- pocketllm-0.1.0/cpp_engine/engine/engine_registry_builtin.cpp +79 -0
- pocketllm-0.1.0/cpp_engine/engine/main.cpp +1308 -0
- pocketllm-0.1.0/cpp_engine/engine/openai_server.cpp +1270 -0
- pocketllm-0.1.0/cpp_engine/engine/persistent_engine_adapter.cpp +258 -0
- pocketllm-0.1.0/cpp_engine/engine/qwen_dflash2.cpp +1381 -0
- pocketllm-0.1.0/cpp_engine/engine/qwen_dspark.cpp +941 -0
- pocketllm-0.1.0/cpp_engine/engine/qwen_engine.cpp +5681 -0
- pocketllm-0.1.0/cpp_engine/engine/qwen_layer_components.hpp +176 -0
- pocketllm-0.1.0/cpp_engine/engine/qwen_target_head.cpp +57 -0
- pocketllm-0.1.0/cpp_engine/engine/qwen_weights.cpp +266 -0
- pocketllm-0.1.0/cpp_engine/include/batch_scheduler.hpp +266 -0
- pocketllm-0.1.0/cpp_engine/include/block_pool.hpp +70 -0
- pocketllm-0.1.0/cpp_engine/include/block_table.hpp +84 -0
- pocketllm-0.1.0/cpp_engine/include/cmd_channel.hpp +42 -0
- pocketllm-0.1.0/cpp_engine/include/cuda_ops.hpp +1156 -0
- pocketllm-0.1.0/cpp_engine/include/deepseek_v4_engine.hpp +296 -0
- pocketllm-0.1.0/cpp_engine/include/dspark.hpp +150 -0
- pocketllm-0.1.0/cpp_engine/include/flashmemory_ops.hpp +137 -0
- pocketllm-0.1.0/cpp_engine/include/gguf_reader.hpp +101 -0
- pocketllm-0.1.0/cpp_engine/include/inference_engine.hpp +266 -0
- pocketllm-0.1.0/cpp_engine/include/json_constraint.hpp +137 -0
- pocketllm-0.1.0/cpp_engine/include/json_lite.hpp +40 -0
- pocketllm-0.1.0/cpp_engine/include/model_config.hpp +52 -0
- pocketllm-0.1.0/cpp_engine/include/model_registry.hpp +104 -0
- pocketllm-0.1.0/cpp_engine/include/openai_server.hpp +60 -0
- pocketllm-0.1.0/cpp_engine/include/persistent_engine.hpp +244 -0
- pocketllm-0.1.0/cpp_engine/include/persistent_engine_adapter.hpp +99 -0
- pocketllm-0.1.0/cpp_engine/include/python_sidecar.hpp +76 -0
- pocketllm-0.1.0/cpp_engine/include/qwen_ascend_ops.hpp +93 -0
- pocketllm-0.1.0/cpp_engine/include/qwen_config.hpp +82 -0
- pocketllm-0.1.0/cpp_engine/include/qwen_cuda_ops.hpp +1139 -0
- pocketllm-0.1.0/cpp_engine/include/qwen_dflash2.hpp +195 -0
- pocketllm-0.1.0/cpp_engine/include/qwen_dspark.hpp +159 -0
- pocketllm-0.1.0/cpp_engine/include/qwen_engine.hpp +479 -0
- pocketllm-0.1.0/cpp_engine/include/qwen_ops.hpp +303 -0
- pocketllm-0.1.0/cpp_engine/include/qwen_target_head.hpp +25 -0
- pocketllm-0.1.0/cpp_engine/include/qwen_weights.hpp +310 -0
- pocketllm-0.1.0/cpp_engine/include/safetensors_model.hpp +68 -0
- pocketllm-0.1.0/cpp_engine/include/safetensors_reader.hpp +114 -0
- pocketllm-0.1.0/cpp_engine/include/sampler.hpp +13 -0
- pocketllm-0.1.0/cpp_engine/include/sampler_ops.hpp +107 -0
- pocketllm-0.1.0/cpp_engine/include/tensor.hpp +35 -0
- pocketllm-0.1.0/cpp_engine/include/token_constraint.hpp +42 -0
- pocketllm-0.1.0/cpp_engine/include/tokenizer.hpp +42 -0
- pocketllm-0.1.0/cpp_engine/include/tp_comm.hpp +78 -0
- pocketllm-0.1.0/cpp_engine/include/weight_source.hpp +115 -0
- pocketllm-0.1.0/cpp_engine/python/bindings.cpp +674 -0
- pocketllm-0.1.0/cpp_engine/third_party/httplib.cpp +16509 -0
- pocketllm-0.1.0/cpp_engine/third_party/httplib.h +3883 -0
- pocketllm-0.1.0/pocketllm/__init__.py +53 -0
- pocketllm-0.1.0/pocketllm/__main__.py +3 -0
- pocketllm-0.1.0/pocketllm/api/__init__.py +41 -0
- pocketllm-0.1.0/pocketllm/api/backend.py +60 -0
- pocketllm-0.1.0/pocketllm/api/errors.py +27 -0
- pocketllm-0.1.0/pocketllm/api/types.py +374 -0
- pocketllm-0.1.0/pocketllm/backends/__init__.py +7 -0
- pocketllm-0.1.0/pocketllm/backends/base.py +117 -0
- pocketllm-0.1.0/pocketllm/backends/cpp_backend.py +924 -0
- pocketllm-0.1.0/pocketllm/backends/factory.py +307 -0
- pocketllm-0.1.0/pocketllm/backends/torch_backend.py +397 -0
- pocketllm-0.1.0/pocketllm/cli.py +241 -0
- pocketllm-0.1.0/pocketllm/engine.py +342 -0
- pocketllm-0.1.0/pocketllm/protocol/__init__.py +37 -0
- pocketllm-0.1.0/pocketllm/protocol/chat.py +258 -0
- pocketllm-0.1.0/pocketllm/protocol/prompt.py +221 -0
- pocketllm-0.1.0/pocketllm/protocol/requests.py +93 -0
- pocketllm-0.1.0/pocketllm/server/__init__.py +6 -0
- pocketllm-0.1.0/pocketllm/server/metrics.py +72 -0
- pocketllm-0.1.0/pocketllm/server/openai.py +322 -0
- pocketllm-0.1.0/pocketllm/supervisor.py +678 -0
- pocketllm-0.1.0/pocketllm.egg-info/PKG-INFO +431 -0
- pocketllm-0.1.0/pocketllm.egg-info/SOURCES.txt +336 -0
- pocketllm-0.1.0/pocketllm.egg-info/dependency_links.txt +1 -0
- pocketllm-0.1.0/pocketllm.egg-info/entry_points.txt +2 -0
- pocketllm-0.1.0/pocketllm.egg-info/requires.txt +16 -0
- pocketllm-0.1.0/pocketllm.egg-info/top_level.txt +5 -0
- pocketllm-0.1.0/pyproject.toml +77 -0
- pocketllm-0.1.0/requirements.txt +9 -0
- pocketllm-0.1.0/setup.cfg +4 -0
- pocketllm-0.1.0/setup.py +207 -0
- pocketllm-0.1.0/src/__init__.py +0 -0
- pocketllm-0.1.0/src/cli/__init__.py +0 -0
- pocketllm-0.1.0/src/cli/convert_checkpoint.py +167 -0
- pocketllm-0.1.0/src/cli/generate.py +40 -0
- pocketllm-0.1.0/src/cli/generate_gguf.py +60 -0
- pocketllm-0.1.0/src/cli/generate_glm.py +110 -0
- pocketllm-0.1.0/src/cli/inspect_gguf.py +635 -0
- pocketllm-0.1.0/src/cli/make_routed_source_gguf.py +561 -0
- pocketllm-0.1.0/src/cli/merge_imatrix.py +23 -0
- pocketllm-0.1.0/src/components/gguf/__init__.py +1 -0
- pocketllm-0.1.0/src/components/gguf/quantized_ops.py +151 -0
- pocketllm-0.1.0/src/components/gguf/tp_logits.py +57 -0
- pocketllm-0.1.0/src/components/moe/__init__.py +25 -0
- pocketllm-0.1.0/src/components/moe/capability.py +63 -0
- pocketllm-0.1.0/src/components/moe/cpu_backend.py +1832 -0
- pocketllm-0.1.0/src/components/moe/gpu_prefill_backend.py +901 -0
- pocketllm-0.1.0/src/components/moe/ipc.py +130 -0
- pocketllm-0.1.0/src/components/moe/placement.py +56 -0
- pocketllm-0.1.0/src/components/moe/registry.py +47 -0
- pocketllm-0.1.0/src/components/moe/shared_weights.py +318 -0
- pocketllm-0.1.0/src/components/moe/spec.py +135 -0
- pocketllm-0.1.0/src/csrc/cuda_kernel.cpp +2255 -0
- pocketllm-0.1.0/src/csrc/cuda_kernel_impl.cu +9730 -0
- pocketllm-0.1.0/src/csrc/deepseek_cpu_moe_ext.cpp +3040 -0
- pocketllm-0.1.0/src/csrc/dot_microbench.cpp +252 -0
- pocketllm-0.1.0/src/csrc/fused_decode_gqa_attention.cu +221 -0
- pocketllm-0.1.0/src/csrc/gguf_mma.h +20 -0
- pocketllm-0.1.0/src/csrc/llama_mmq/common_shim.cuh +198 -0
- pocketllm-0.1.0/src/csrc/llama_mmq/ggml-common.h +1900 -0
- pocketllm-0.1.0/src/csrc/llama_mmq/gguf_mma_wrapper.cu +524 -0
- pocketllm-0.1.0/src/csrc/llama_mmq/mma.cuh +1456 -0
- pocketllm-0.1.0/src/csrc/llama_mmq/mmq.cuh +3525 -0
- pocketllm-0.1.0/src/csrc/llama_mmq/vecdotq.cuh +1317 -0
- pocketllm-0.1.0/src/csrc/minimax_gqa_kernel.cu +173 -0
- pocketllm-0.1.0/src/csrc/minimax_rope_kernel.cu +159 -0
- pocketllm-0.1.0/src/csrc/moe_dispatch_cuda_ext.cpp +150 -0
- pocketllm-0.1.0/src/csrc/moe_dispatch_cuda_kernel.cu +418 -0
- pocketllm-0.1.0/src/csrc/qwen4_exp_gated_delta.cu +383 -0
- pocketllm-0.1.0/src/csrc/qwen4_exp_hyper_connection.cu +231 -0
- pocketllm-0.1.0/src/csrc/qwen4_exp_moe.cu +289 -0
- pocketllm-0.1.0/src/csrc/qwen4_exp_qsa.cu +503 -0
- pocketllm-0.1.0/src/encoding/__init__.py +1 -0
- pocketllm-0.1.0/src/encoding/deepseek_v4.py +770 -0
- pocketllm-0.1.0/src/encoding/gguf_tokenizer.py +259 -0
- pocketllm-0.1.0/src/encoding/glm_dsa.py +181 -0
- pocketllm-0.1.0/src/encoding/minimax_m2.py +180 -0
- pocketllm-0.1.0/src/kernels/__init__.py +0 -0
- pocketllm-0.1.0/src/kernels/cuda_loader.py +63 -0
- pocketllm-0.1.0/src/kernels/int8_per_token_head_triton.py +204 -0
- pocketllm-0.1.0/src/kernels/int8_triton_wrapper.py +154 -0
- pocketllm-0.1.0/src/kernels/moe_dispatch_loader.py +58 -0
- pocketllm-0.1.0/src/kernels/ops.py +1250 -0
- pocketllm-0.1.0/src/kernels/tq4nc_quantizer.py +281 -0
- pocketllm-0.1.0/src/loader/__init__.py +1 -0
- pocketllm-0.1.0/src/loader/gguf/__init__.py +1 -0
- pocketllm-0.1.0/src/loader/gguf/bundle.py +227 -0
- pocketllm-0.1.0/src/loader/gguf/imatrix.py +327 -0
- pocketllm-0.1.0/src/loader/gguf/iq1_grid.py +321 -0
- pocketllm-0.1.0/src/loader/gguf/prewarm.py +116 -0
- pocketllm-0.1.0/src/loader/gguf/quant_types.py +15 -0
- pocketllm-0.1.0/src/loader/gguf/quantized_loader.py +103 -0
- pocketllm-0.1.0/src/loader/gguf/quantized_tensor.py +26 -0
- pocketllm-0.1.0/src/loader/gguf/reader.py +228 -0
- pocketllm-0.1.0/src/loader/gguf/tensor_reader.py +1009 -0
- pocketllm-0.1.0/src/loader/mappings/deepseek_v4.py +218 -0
- pocketllm-0.1.0/src/loader/mappings/glm_dsa.py +107 -0
- pocketllm-0.1.0/src/loader/mappings/minimax_m2.py +48 -0
- pocketllm-0.1.0/src/loader/safetensors.py +76 -0
- pocketllm-0.1.0/src/models/__init__.py +1 -0
- pocketllm-0.1.0/src/models/deepseek_v4/__init__.py +3 -0
- pocketllm-0.1.0/src/models/deepseek_v4/dspark.py +275 -0
- pocketllm-0.1.0/src/models/deepseek_v4/dspark_gate.py +255 -0
- pocketllm-0.1.0/src/models/deepseek_v4/dspark_loop.py +253 -0
- pocketllm-0.1.0/src/models/deepseek_v4/generation.py +1220 -0
- pocketllm-0.1.0/src/models/deepseek_v4/loader.py +675 -0
- pocketllm-0.1.0/src/models/deepseek_v4/moe_server.py +355 -0
- pocketllm-0.1.0/src/models/deepseek_v4/partition.py +379 -0
- pocketllm-0.1.0/src/models/deepseek_v4/runtime.py +4940 -0
- pocketllm-0.1.0/src/models/deepseek_v4/spec.py +144 -0
- pocketllm-0.1.0/src/models/glm_dsa/__init__.py +5 -0
- pocketllm-0.1.0/src/models/glm_dsa/architecture.py +1000 -0
- pocketllm-0.1.0/src/models/glm_dsa/gguf_model.py +452 -0
- pocketllm-0.1.0/src/models/glm_dsa/spec.py +352 -0
- pocketllm-0.1.0/src/models/minimax_m2/__init__.py +3 -0
- pocketllm-0.1.0/src/models/minimax_m2/architecture.py +484 -0
- pocketllm-0.1.0/src/models/minimax_m2/gguf_model.py +191 -0
- pocketllm-0.1.0/src/models/minimax_m2/moe_planning.py +353 -0
- pocketllm-0.1.0/src/models/minimax_m2/moe_runtime.py +397 -0
- pocketllm-0.1.0/src/models/minimax_m2/spec.py +280 -0
- pocketllm-0.1.0/src/models/qwen4_exp/__init__.py +15 -0
- pocketllm-0.1.0/src/models/qwen4_exp/attention.py +737 -0
- pocketllm-0.1.0/src/models/qwen4_exp/builder.py +437 -0
- pocketllm-0.1.0/src/models/qwen4_exp/config.py +294 -0
- pocketllm-0.1.0/src/models/qwen4_exp/layers.py +627 -0
- pocketllm-0.1.0/src/models/qwen4_exp/model.py +421 -0
- pocketllm-0.1.0/src/models/qwen4_exp/moe.py +501 -0
- pocketllm-0.1.0/src/models/qwen4_exp/profiler.py +182 -0
- pocketllm-0.1.0/src/models/qwen4_exp/quant.py +131 -0
- pocketllm-0.1.0/src/models/qwen4_exp/runtime.py +485 -0
- pocketllm-0.1.0/src/models/qwen4_exp/weights.py +737 -0
- pocketllm-0.1.0/src/runtime/__init__.py +0 -0
- pocketllm-0.1.0/src/runtime/generation.py +276 -0
- pocketllm-0.1.0/src/runtime/pd_scheduler.py +361 -0
- pocketllm-0.1.0/src/runtime/prefix_snapshot.py +306 -0
- pocketllm-0.1.0/src/server/__init__.py +0 -0
- pocketllm-0.1.0/src/server/cpp_sidecar.py +288 -0
- pocketllm-0.1.0/src/server/engine.py +249 -0
- pocketllm-0.1.0/src/server/openai.py +977 -0
- pocketllm-0.1.0/tests/test_backend_contract.py +343 -0
- pocketllm-0.1.0/tests/test_backend_selection.py +64 -0
- pocketllm-0.1.0/tests/test_cli.py +339 -0
- pocketllm-0.1.0/tests/test_compressor_step_order.py +176 -0
- pocketllm-0.1.0/tests/test_cpp_backend.py +708 -0
- pocketllm-0.1.0/tests/test_cpp_backend_batching.py +145 -0
- pocketllm-0.1.0/tests/test_cpp_backend_serial_ttft.py +94 -0
- pocketllm-0.1.0/tests/test_cpp_backend_tp.py +328 -0
- pocketllm-0.1.0/tests/test_cpp_backend_worker.py +73 -0
- pocketllm-0.1.0/tests/test_cpp_binding_smoke.py +36 -0
- pocketllm-0.1.0/tests/test_cpp_scheduler_streaming.py +330 -0
- pocketllm-0.1.0/tests/test_cpp_sidecar.py +118 -0
- pocketllm-0.1.0/tests/test_cpu_fp4_arena_fallback.py +70 -0
- pocketllm-0.1.0/tests/test_cpu_fp4_raw_moe.py +129 -0
- pocketllm-0.1.0/tests/test_deepseek_v4_model_namespace.py +123 -0
- pocketllm-0.1.0/tests/test_dspark_attention_parity.py +386 -0
- pocketllm-0.1.0/tests/test_dspark_gate.py +195 -0
- pocketllm-0.1.0/tests/test_dspark_gate_replay.py +174 -0
- pocketllm-0.1.0/tests/test_dspark_head_parity.py +228 -0
- pocketllm-0.1.0/tests/test_dspark_moe_parity.py +263 -0
- pocketllm-0.1.0/tests/test_dspark_predraft_gate.py +51 -0
- pocketllm-0.1.0/tests/test_encoding_deepseek_v4.py +89 -0
- pocketllm-0.1.0/tests/test_encoding_glm_dsa.py +118 -0
- pocketllm-0.1.0/tests/test_encoding_minimax_m2.py +68 -0
- pocketllm-0.1.0/tests/test_factory_tp_supervision_reuse.py +153 -0
- pocketllm-0.1.0/tests/test_fused_attn_prefuse.py +177 -0
- pocketllm-0.1.0/tests/test_fused_decode_gqa_real.py +79 -0
- pocketllm-0.1.0/tests/test_gguf_bundle.py +79 -0
- pocketllm-0.1.0/tests/test_gguf_imatrix.py +83 -0
- pocketllm-0.1.0/tests/test_gguf_iq1m_reader.py +118 -0
- pocketllm-0.1.0/tests/test_gguf_prewarm.py +62 -0
- pocketllm-0.1.0/tests/test_gguf_q2_precision.py +160 -0
- pocketllm-0.1.0/tests/test_gguf_quantized_ops_cuda.py +92 -0
- pocketllm-0.1.0/tests/test_gguf_tokenizer_pre.py +81 -0
- pocketllm-0.1.0/tests/test_glm_dsa_fused_rmsnorm.py +50 -0
- pocketllm-0.1.0/tests/test_glm_dsa_iq2xs_iq3xxs_dp4a.py +155 -0
- pocketllm-0.1.0/tests/test_glm_dsa_quant_cuda.py +245 -0
- pocketllm-0.1.0/tests/test_glm_dsa_resident_experts.py +117 -0
- pocketllm-0.1.0/tests/test_glm_dsa_spec.py +141 -0
- pocketllm-0.1.0/tests/test_glm_dsa_tp_routed.py +219 -0
- pocketllm-0.1.0/tests/test_hc_cuda.py +96 -0
- pocketllm-0.1.0/tests/test_inspect_gguf_specs.py +197 -0
- pocketllm-0.1.0/tests/test_install_smoke.py +59 -0
- pocketllm-0.1.0/tests/test_int8_gemm_imma.py +119 -0
- pocketllm-0.1.0/tests/test_minimax_decode_reduce.py +118 -0
- pocketllm-0.1.0/tests/test_minimax_fused_rope.py +67 -0
- pocketllm-0.1.0/tests/test_minimax_gqa_kernel.py +126 -0
- pocketllm-0.1.0/tests/test_minimax_iq2xxs_w2_dp4a.py +297 -0
- pocketllm-0.1.0/tests/test_minimax_m2_gguf_runtime.py +75 -0
- pocketllm-0.1.0/tests/test_minimax_m2_moe_runtime.py +217 -0
- pocketllm-0.1.0/tests/test_minimax_m2_spec.py +117 -0
- pocketllm-0.1.0/tests/test_moe_kernel_determinism.py +229 -0
- pocketllm-0.1.0/tests/test_moe_model_registry.py +51 -0
- pocketllm-0.1.0/tests/test_moe_multi_token_fp4.py +393 -0
- pocketllm-0.1.0/tests/test_moe_single_token.py +173 -0
- pocketllm-0.1.0/tests/test_moe_single_token_fp4.py +162 -0
- pocketllm-0.1.0/tests/test_openai_server.py +134 -0
- pocketllm-0.1.0/tests/test_openai_utils.py +289 -0
- pocketllm-0.1.0/tests/test_package_boundaries.py +122 -0
- pocketllm-0.1.0/tests/test_partition_policy.py +217 -0
- pocketllm-0.1.0/tests/test_protocol_chat.py +109 -0
- pocketllm-0.1.0/tests/test_protocol_prompt.py +150 -0
- pocketllm-0.1.0/tests/test_protocol_requests.py +139 -0
- pocketllm-0.1.0/tests/test_public_api.py +217 -0
- pocketllm-0.1.0/tests/test_pytorch_gqa_sdpa.py +45 -0
- pocketllm-0.1.0/tests/test_q4k_q5k_mma.py +161 -0
- pocketllm-0.1.0/tests/test_q8_0_cuda.py +45 -0
- pocketllm-0.1.0/tests/test_qwen4_exp_fp8_dequant.py +76 -0
- pocketllm-0.1.0/tests/test_qwen4_exp_fp8_loader.py +177 -0
- pocketllm-0.1.0/tests/test_qwen4_exp_gated_delta_cuda.py +112 -0
- pocketllm-0.1.0/tests/test_qwen4_exp_hc_activation_cuda.py +50 -0
- pocketllm-0.1.0/tests/test_qwen4_exp_hyper_connection_cuda.py +96 -0
- pocketllm-0.1.0/tests/test_qwen4_exp_moe_cuda.py +72 -0
- pocketllm-0.1.0/tests/test_qwen4_exp_parity.py +165 -0
- pocketllm-0.1.0/tests/test_qwen4_exp_prefill_linear.py +83 -0
- pocketllm-0.1.0/tests/test_qwen4_exp_profiler.py +33 -0
- pocketllm-0.1.0/tests/test_qwen4_exp_qsa_cuda.py +86 -0
- pocketllm-0.1.0/tests/test_qwen4_exp_qsa_fallback.py +69 -0
- pocketllm-0.1.0/tests/test_qwen4_exp_qsa_indexer.py +107 -0
- pocketllm-0.1.0/tests/test_qwen4_exp_real_checkpoint.py +249 -0
- pocketllm-0.1.0/tests/test_qwen4_exp_runtime.py +41 -0
- pocketllm-0.1.0/tests/test_qwen4_exp_tp_sharding.py +375 -0
- pocketllm-0.1.0/tests/test_supervisor.py +590 -0
- pocketllm-0.1.0/tests/test_supervisor_orphan_guard.py +145 -0
- pocketllm-0.1.0/tests/test_torch_backend_config_autodetect.py +176 -0
- pocketllm-0.1.0/tests/test_torch_backend_prompt.py +172 -0
pocketllm-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 lvyufeng
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
include README.md
|
|
2
|
+
include README_CN.md
|
|
3
|
+
include LICENSE
|
|
4
|
+
include requirements.txt
|
|
5
|
+
|
|
6
|
+
# Torch extension sources, needed for an sdist to rebuild ext_modules.
|
|
7
|
+
recursive-include src/csrc *.cpp *.cu *.cuh *.h *.hpp
|
|
8
|
+
|
|
9
|
+
# C++ engine sources, needed for an sdist to build the optional native module
|
|
10
|
+
# under POCKETLLM_BUILD_CPP=1.
|
|
11
|
+
include cpp_engine/CMakeLists.txt
|
|
12
|
+
recursive-include cpp_engine/cmake *.cmake
|
|
13
|
+
recursive-include cpp_engine/backends *.cpp *.cu *.cuh *.h *.hpp *.txt *.cmake
|
|
14
|
+
recursive-include cpp_engine/core *.cpp *.h *.hpp
|
|
15
|
+
recursive-include cpp_engine/engine *.cpp *.h *.hpp
|
|
16
|
+
recursive-include cpp_engine/include *.h *.hpp
|
|
17
|
+
recursive-include cpp_engine/python *.cpp
|
|
18
|
+
recursive-include cpp_engine/third_party *.cpp *.h *.hpp
|
|
19
|
+
|
|
20
|
+
# Build trees are environment-specific and are already git-ignored.
|
|
21
|
+
prune cpp_engine/build
|
|
22
|
+
prune cpp_engine/build-python
|
|
23
|
+
prune cpp_engine/build-ascend
|
|
24
|
+
prune cpp_engine/build-cuda
|
|
25
|
+
prune build
|
pocketllm-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,431 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pocketllm
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Inference engine for large language models on consumer GPUs with deep optimization for older hardware
|
|
5
|
+
Author: lvyufeng
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/lvyufeng/PocketLLM
|
|
8
|
+
Project-URL: Documentation, https://github.com/lvyufeng/PocketLLM/tree/master/docs
|
|
9
|
+
Project-URL: Repository, https://github.com/lvyufeng/PocketLLM
|
|
10
|
+
Project-URL: Issues, https://github.com/lvyufeng/PocketLLM/issues
|
|
11
|
+
Project-URL: Changelog, https://github.com/lvyufeng/PocketLLM/blob/master/CHANGELOG.md
|
|
12
|
+
Keywords: llm,inference,cuda,gguf,quantization,deepseek,qwen,fp4,fp8,tensor-parallel
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Intended Audience :: Science/Research
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: C++
|
|
23
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
24
|
+
Requires-Python: >=3.10
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
License-File: LICENSE
|
|
27
|
+
Requires-Dist: torch<2.7,>=2.0
|
|
28
|
+
Requires-Dist: transformers>=4.40
|
|
29
|
+
Requires-Dist: safetensors>=0.4
|
|
30
|
+
Requires-Dist: tqdm>=4.66
|
|
31
|
+
Requires-Dist: setuptools>=68
|
|
32
|
+
Requires-Dist: ninja>=1.11
|
|
33
|
+
Requires-Dist: pybind11>=2.10
|
|
34
|
+
Requires-Dist: cmake>=3.18
|
|
35
|
+
Provides-Extra: triton
|
|
36
|
+
Requires-Dist: triton>=2.0; extra == "triton"
|
|
37
|
+
Provides-Extra: minimal
|
|
38
|
+
Provides-Extra: all
|
|
39
|
+
Requires-Dist: pocketllm[triton]; extra == "all"
|
|
40
|
+
Dynamic: license-file
|
|
41
|
+
|
|
42
|
+
# PocketLLM
|
|
43
|
+
|
|
44
|
+
[](https://pypi.org/project/pocketllm/)
|
|
45
|
+
[](https://opensource.org/licenses/MIT)
|
|
46
|
+
[](https://www.python.org/downloads/)
|
|
47
|
+
|
|
48
|
+
[中文](README_CN.md) | English
|
|
49
|
+
|
|
50
|
+
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.
|
|
51
|
+
|
|
52
|
+
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.
|
|
53
|
+
|
|
54
|
+
> **Status:** research and engineering software. The numbers below are measurements from specific checkpoints and hardware configurations, not general performance guarantees.
|
|
55
|
+
|
|
56
|
+
## Installation
|
|
57
|
+
|
|
58
|
+
### Quick install (full capabilities)
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
pip install pocketllm --no-build-isolation
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
This installs PocketLLM with both PyTorch and C++ engine backends. The build process compiles CUDA extensions and the native C++ engine, which takes 5-15 minutes.
|
|
65
|
+
|
|
66
|
+
**Requirements:**
|
|
67
|
+
- Python >= 3.10
|
|
68
|
+
- PyTorch >= 2.0 (install first: `pip install torch`)
|
|
69
|
+
- CUDA toolkit 11.8+ (for GPU acceleration)
|
|
70
|
+
- CMake >= 3.18
|
|
71
|
+
- pybind11 >= 2.10
|
|
72
|
+
- NCCL (for tensor parallelism with TP > 1)
|
|
73
|
+
- 16GB+ system RAM (for compilation)
|
|
74
|
+
|
|
75
|
+
**Note:** `--no-build-isolation` is required so the build uses your environment's PyTorch, which must match your CUDA toolkit version.
|
|
76
|
+
|
|
77
|
+
### PyTorch-only install (skip C++ engine)
|
|
78
|
+
|
|
79
|
+
If you only need the PyTorch backend or lack the C++ build dependencies:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
POCKETLLM_BUILD_CPP=0 pip install pocketllm --no-build-isolation
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
This skips the C++ engine build but still compiles PyTorch CUDA extensions.
|
|
86
|
+
|
|
87
|
+
### Development install
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
git clone https://github.com/lvyufeng/PocketLLM.git
|
|
91
|
+
cd PocketLLM
|
|
92
|
+
pip install -e . --no-build-isolation
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Quick Start
|
|
96
|
+
|
|
97
|
+
### Python API
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
from pocketllm import LLM
|
|
101
|
+
|
|
102
|
+
# Initialize with automatic backend selection
|
|
103
|
+
llm = LLM(
|
|
104
|
+
model="/path/to/checkpoint",
|
|
105
|
+
backend="auto", # or "torch", "cpp"
|
|
106
|
+
tensor_parallel_size=1
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
# Generate text
|
|
110
|
+
result = llm.generate("What is artificial intelligence?")
|
|
111
|
+
print(result.text)
|
|
112
|
+
|
|
113
|
+
# Stream tokens
|
|
114
|
+
for token in llm.stream("Explain quantum computing"):
|
|
115
|
+
print(token.text, end="", flush=True)
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### OpenAI-Compatible Server
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
# Start server on default port 8000
|
|
122
|
+
pocketllm serve \
|
|
123
|
+
--model /path/to/checkpoint \
|
|
124
|
+
--backend auto \
|
|
125
|
+
--tensor-parallel-size 4
|
|
126
|
+
|
|
127
|
+
# Test with curl
|
|
128
|
+
curl http://localhost:8000/v1/chat/completions \
|
|
129
|
+
-H "Content-Type: application/json" \
|
|
130
|
+
-d '{
|
|
131
|
+
"model": "pocketllm",
|
|
132
|
+
"messages": [{"role": "user", "content": "Hello!"}],
|
|
133
|
+
"stream": true
|
|
134
|
+
}'
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Tensor Parallel Inference (Multi-GPU)
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
# 4-GPU setup (TP4)
|
|
141
|
+
pocketllm serve \
|
|
142
|
+
--model /path/to/qwen-27b-fp8 \
|
|
143
|
+
--backend cpp \
|
|
144
|
+
--tensor-parallel-size 4 \
|
|
145
|
+
--host 0.0.0.0 \
|
|
146
|
+
--port 8000
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## When to use PocketLLM
|
|
150
|
+
|
|
151
|
+
**PocketLLM excels at:**
|
|
152
|
+
- ✅ Single-request low-latency inference on consumer GPUs (RTX 2080 Ti, 3090, 4090)
|
|
153
|
+
- ✅ Running large models on older hardware with aggressive quantization (GGUF IQ1/IQ2, FP4)
|
|
154
|
+
- ✅ TP4 inference without NVLink (PCIe-only multi-GPU systems)
|
|
155
|
+
- ✅ Research and experimentation with model-specific kernel optimization
|
|
156
|
+
|
|
157
|
+
**Consider alternatives like vLLM or SGLang if you need:**
|
|
158
|
+
- ❌ High-throughput serving with dynamic batching (PocketLLM batching is sequential)
|
|
159
|
+
- ❌ Broad model support (PocketLLM focuses on 4 models with deep optimization)
|
|
160
|
+
- ❌ Production features (advanced scheduling, monitoring, multi-LoRA)
|
|
161
|
+
- ❌ Multimodal inputs (images/video are not yet supported)
|
|
162
|
+
|
|
163
|
+
## What PocketLLM provides
|
|
164
|
+
|
|
165
|
+
- **Model-specific inference paths** for hybrid attention, MLA, GQA, Gated DeltaNet, dense MLPs, and routed MoE layers.
|
|
166
|
+
- **Low-bit execution without unnecessary expansion:** FP4, FP8 E4M3, GGUF Q4/Q5/Q8, IQ1/IQ2/IQ3, and Q2 paths consume quantized blocks directly in the hot path where supported.
|
|
167
|
+
- **Consumer-GPU parallelism:** TP4/NCCL execution on PCIe-connected GPUs, with CPU/NUMA expert placement for checkpoints that do not fit in device memory.
|
|
168
|
+
- **Separate prefill and decode dispatch:** large-row kernels are optimized independently from single-token latency paths.
|
|
169
|
+
- **Native C++/CUDA runtime:** the `cpp_engine/` path supports DeepSeek-V4 GGUF/Safetensors flows, Qwen3.8 FP8 Safetensors text generation, and the validated Qwen OpenAI-compatible text server.
|
|
170
|
+
- **Inspection and validation tools:** GGUF architecture/spec reports, Safetensors audits, tensor-shape checks, numerical parity tests, and real-checkpoint benchmarks.
|
|
171
|
+
|
|
172
|
+
## Supported models at a glance
|
|
173
|
+
|
|
174
|
+
| Model | Checkpoint / format | Runtime status | Validated path | Reference result on 4×RTX 2080 Ti |
|
|
175
|
+
| --- | --- | --- | --- | --- |
|
|
176
|
+
| [DeepSeek-V4-Flash](docs/models/deepseek-v4.md) | 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 |
|
|
177
|
+
| [MiniMax-M2.7](docs/models/minimax-m2.7.md) | 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 |
|
|
178
|
+
| [GLM-5.2](docs/models/glm-5.2.md) | GGUF `UD-Q2_K_XL` | **Validated text generation** | Raw-block CUDA, GGUF TP4 | ~0.79 tok/s prefill; ~0.66 tok/s decode |
|
|
179
|
+
| [Qwen3.8-27B-FP8](docs/models/qwen3.8-27b-fp8.md) | Safetensors FP8 E4M3 | **Validated C++ text runtime and server** | C++/CUDA TP4, GPU-resident FP8 | 416.48 tok/s prefill; 35.87 tok/s decode on a 512-token prompt |
|
|
180
|
+
|
|
181
|
+
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.
|
|
182
|
+
|
|
183
|
+
## Performance highlights
|
|
184
|
+
|
|
185
|
+
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](docs/benchmarking.md) before comparing results.
|
|
186
|
+
|
|
187
|
+
### Qwen3.8-27B-FP8 C++ runtime
|
|
188
|
+
|
|
189
|
+
- 64-token prompt: 138.61–138.69 tok/s prefill, 36.82 tok/s decode.
|
|
190
|
+
- 512-token prompt: 416.48 tok/s prefill, 35.87 tok/s decode.
|
|
191
|
+
- Approximately 8.0–8.6 GiB used per rank in the measured runs; local FP8 weights and scales remain GPU-resident.
|
|
192
|
+
- Token sequences were identical across all four TP ranks. The native OpenAI-compatible server is validated for text requests; image and video inputs remain unsupported.
|
|
193
|
+
|
|
194
|
+
### DeepSeek-V4 C++ FP4 runtime
|
|
195
|
+
|
|
196
|
+
- 32K prompt: approximately 402 tok/s prefill, approximately 11.2 GiB/rank.
|
|
197
|
+
- 64K prompt: approximately 401 tok/s prefill, approximately 14.5 GiB/rank.
|
|
198
|
+
- Decode: approximately 3.7 tok/s on the measured 4×RTX 2080 Ti configuration.
|
|
199
|
+
|
|
200
|
+
### MiniMax-M2.7 and GLM-5.2 GGUF runtimes
|
|
201
|
+
|
|
202
|
+
- MiniMax-M2.7 reaches approximately 104.9–107 tok/s full-model 256-token prefill after Q4/Q5 MMA and IQ2 DP4A paths; a separate 43-layer decode benchmark reached 10.32 tok/s after fused RMSNorm.
|
|
203
|
+
- GLM-5.2 generation is functional through the raw-block GGUF path. Its current decode floor is much lower because of the model size, expert staging, and per-layer synchronization; experimental resident-cache, routed-TP, and fused-RMSNorm switches are not enabled by default.
|
|
204
|
+
|
|
205
|
+
These are architecture-specific results. They should not be averaged into one PocketLLM score.
|
|
206
|
+
|
|
207
|
+
## Architecture overview
|
|
208
|
+
|
|
209
|
+
PocketLLM has two complementary execution families:
|
|
210
|
+
|
|
211
|
+
1. **GPU-resident and low-bit execution** keeps local weights or expert blocks on device when the aggregate memory budget permits it.
|
|
212
|
+
2. **Heterogeneous execution** keeps routed experts in CPU/NUMA memory and stages only the active quantized blocks needed by the current token or prefill chunk.
|
|
213
|
+
|
|
214
|
+
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.
|
|
215
|
+
|
|
216
|
+
## Quick start
|
|
217
|
+
|
|
218
|
+
### Install the Python package
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
python -m pip install -r requirements.txt
|
|
222
|
+
python -m pip install --no-build-isolation .
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
This installs the `pocketllm` package and the `pocketllm` CLI. `--no-build-isolation` keeps the
|
|
226
|
+
build using the active environment's Torch, which must match the CUDA toolkit the extensions
|
|
227
|
+
compile against.
|
|
228
|
+
|
|
229
|
+
To also build the optional native C++ engine module (`pocketllm_cpp`), which the
|
|
230
|
+
`backend="cpp"` path needs:
|
|
231
|
+
|
|
232
|
+
```bash
|
|
233
|
+
POCKETLLM_BUILD_CPP=1 python -m pip install --no-build-isolation .
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
Building the Torch extensions in place, without installing, still works:
|
|
237
|
+
|
|
238
|
+
```bash
|
|
239
|
+
python setup.py build_ext
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
The Python package metadata is named `pocketllm`; existing Python imports under `src.*` remain unchanged for compatibility.
|
|
243
|
+
|
|
244
|
+
### Build the C++/CUDA engine
|
|
245
|
+
|
|
246
|
+
```bash
|
|
247
|
+
cmake -S cpp_engine -B build/cpp_engine -DCMAKE_BUILD_TYPE=Release
|
|
248
|
+
cmake --build build/cpp_engine -j
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
The executable is `pocketllm_engine`:
|
|
252
|
+
|
|
253
|
+
```text
|
|
254
|
+
build/cpp_engine/pocketllm_engine
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
It was formerly `dsv4_cpp_engine`. That rename, along with the `pocket::` namespace and the
|
|
258
|
+
`POCKETLLM_*` environment variables, is a breaking change — see
|
|
259
|
+
[the migration note](docs/migration/dsv4-to-pocket-rename.md).
|
|
260
|
+
|
|
261
|
+
The backend is selected at configure time via `POCKET_BACKEND`, which defaults
|
|
262
|
+
to `cuda`, so the command above is unchanged from before:
|
|
263
|
+
|
|
264
|
+
```bash
|
|
265
|
+
cmake -S cpp_engine -B build/cpp_engine -DPOCKET_BACKEND=cuda
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
`POCKET_BACKEND=ascend` reserves the layout for Ascend NPUs. It configures but
|
|
269
|
+
does not yet link, because the ACL runtime, AscendC kernels and HCCL collectives
|
|
270
|
+
under `cpp_engine/backends/ascend/` are not implemented.
|
|
271
|
+
|
|
272
|
+
The source tree is layered so that a second backend can reuse everything that is
|
|
273
|
+
not vendor-specific:
|
|
274
|
+
|
|
275
|
+
```text
|
|
276
|
+
cpp_engine/
|
|
277
|
+
core/ device-agnostic: loaders, tokenizer, HTTP server
|
|
278
|
+
engine/ one engine implementation, shared by all backends
|
|
279
|
+
backends/
|
|
280
|
+
api/ vendor-neutral contracts (to be populated)
|
|
281
|
+
cuda/ kernels/ runtime/ collective/
|
|
282
|
+
ascend/ kernels/ runtime/ collective/
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
`core/` and the public headers under `include/` must not include a vendor SDK.
|
|
286
|
+
This is enforced, not merely documented:
|
|
287
|
+
|
|
288
|
+
```bash
|
|
289
|
+
cmake --build build/cpp_engine --target check_layering
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
### Run DeepSeek-V4 C++ TP4 serving
|
|
293
|
+
|
|
294
|
+
```bash
|
|
295
|
+
CKPT=/path/to/DeepSeek-V4-Flash \
|
|
296
|
+
PORT=8000 \
|
|
297
|
+
MAX_CONTEXT=8192 \
|
|
298
|
+
PYTHON=python \
|
|
299
|
+
bash scripts/run_cpp_serve_tp4.sh
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
This starts rank 0 as the OpenAI-compatible server and ranks 1–3 as NCCL workers.
|
|
303
|
+
|
|
304
|
+
### Run a GGUF model through the shared raw-block CLI
|
|
305
|
+
|
|
306
|
+
```bash
|
|
307
|
+
PYTHONPATH=$PWD torchrun --standalone --nproc-per-node=4 \
|
|
308
|
+
-m src.cli.generate_gguf \
|
|
309
|
+
--gguf-path /path/to/model.gguf \
|
|
310
|
+
--seed-file /path/to/prompt_tokens.bin \
|
|
311
|
+
--max-new-tokens 32 \
|
|
312
|
+
--prewarm
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
For GLM-5.2 text prompts:
|
|
316
|
+
|
|
317
|
+
```bash
|
|
318
|
+
PYTHONPATH=$PWD torchrun --standalone --nproc-per-node=4 \
|
|
319
|
+
-m src.cli.generate_glm \
|
|
320
|
+
--gguf-path /path/to/GLM-5.2-GGUF/UD-Q2_K_XL \
|
|
321
|
+
--prompt "Hello" \
|
|
322
|
+
--chat \
|
|
323
|
+
--max-new-tokens 32 \
|
|
324
|
+
--prewarm
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
### Inspect a GGUF checkpoint
|
|
328
|
+
|
|
329
|
+
```bash
|
|
330
|
+
PYTHONPATH=$PWD python -m src.cli.inspect_gguf \
|
|
331
|
+
--gguf-path /path/to/model.gguf \
|
|
332
|
+
--architecture auto \
|
|
333
|
+
--spec-summary \
|
|
334
|
+
--validate-spec \
|
|
335
|
+
--capability-report \
|
|
336
|
+
--placement-report
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
### Run a Qwen3.8-27B-FP8 C++ smoke/benchmark
|
|
340
|
+
|
|
341
|
+
The Qwen path accepts a text prompt or token IDs and uses TP4 ranks with an NCCL ID file:
|
|
342
|
+
|
|
343
|
+
```bash
|
|
344
|
+
rm -f /tmp/pocketllm_qwen_nccl.id
|
|
345
|
+
for rank in 0 1 2 3; do
|
|
346
|
+
CUDA_VISIBLE_DEVICES=$rank \
|
|
347
|
+
build/cpp_engine/pocketllm_engine \
|
|
348
|
+
--ckpt /path/to/Qwen3.8-27B-FP8 \
|
|
349
|
+
--tp-world 4 --tp-rank $rank --device 0 \
|
|
350
|
+
--nccl-id-path /tmp/pocketllm_qwen_nccl.id \
|
|
351
|
+
--prompt "Explain tensor parallelism in one paragraph." \
|
|
352
|
+
--generate-token 123 --max-new-tokens 32 --smoke-layers 0 --resident-bench \
|
|
353
|
+
> /tmp/pocketllm_qwen_rank${rank}.log 2>&1 &
|
|
354
|
+
done
|
|
355
|
+
wait
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
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 native Qwen text server can be verified against a real checkpoint with:
|
|
359
|
+
|
|
360
|
+
```bash
|
|
361
|
+
python scripts/verify_cpp_qwen_openai.py \\
|
|
362
|
+
--ckpt /path/to/Qwen3.8-27B-FP8 \\
|
|
363
|
+
--binary build/cpp_engine/pocketllm_engine \\
|
|
364
|
+
--python /path/to/python-with-transformers \\
|
|
365
|
+
--sidecar src/server/cpp_sidecar.py \\
|
|
366
|
+
--devices 0,1,2,3
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
The harness checks health, model discovery, non-streaming and streaming chat completions, fixed-sampling validation, and concurrent scheduler admission.
|
|
370
|
+
|
|
371
|
+
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](docs/models/qwen3.8-27b-fp8.md#external-dspark-speculative-decoding) for real 512/8K/32K results and the prefix/cold-parity command.
|
|
372
|
+
|
|
373
|
+
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](docs/models/qwen3.8-27b-fp8.md#external-dflash2-speculative-decoding) for the full table, the FP32-residual numerical requirement, and the reproduction commands.
|
|
374
|
+
|
|
375
|
+
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:
|
|
376
|
+
|
|
377
|
+
```bash
|
|
378
|
+
python scripts/bench_qwen_prefix_cache.py \\
|
|
379
|
+
--ckpt /path/to/Qwen3.8-27B-FP8 \\
|
|
380
|
+
--token-ids-file /path/to/prompt_ids.csv \\
|
|
381
|
+
--max-context 32768 \\
|
|
382
|
+
--max-new-tokens 4 \\
|
|
383
|
+
--compression-prefix-tokens 4096
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
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.
|
|
387
|
+
|
|
388
|
+
## Documentation
|
|
389
|
+
|
|
390
|
+
- [Documentation index](docs/README.md)
|
|
391
|
+
- [Model support matrix](docs/models/README.md)
|
|
392
|
+
- [Benchmarking and reporting rules](docs/benchmarking.md)
|
|
393
|
+
- [DeepSeek-V4](docs/models/deepseek-v4.md)
|
|
394
|
+
- [MiniMax-M2.7](docs/models/minimax-m2.7.md)
|
|
395
|
+
- [GLM-5.2](docs/models/glm-5.2.md)
|
|
396
|
+
- [Qwen3.8-27B-FP8](docs/models/qwen3.8-27b-fp8.md)
|
|
397
|
+
- [DSpark speculative decoding](docs/dspark.md)
|
|
398
|
+
- [FlashMemory 1M context](docs/FLASHMEMORY_1M_CONTEXT.md)
|
|
399
|
+
- [MiniMax decode bottleneck analysis](docs/minimax_decode_bottleneck_analysis.md)
|
|
400
|
+
- [Historical 2080 Ti report](docs/reports/dsv4_2080ti_report.pdf)
|
|
401
|
+
|
|
402
|
+
## Roadmap
|
|
403
|
+
|
|
404
|
+
- [x] DeepSeek-V4 FP4/FP8 and GGUF Q2/IQ2/IQ1 generation paths.
|
|
405
|
+
- [x] MiniMax-M2.7 and GLM-5.2 GGUF raw-block generation paths.
|
|
406
|
+
- [x] Qwen3.8-27B-FP8 C++ TP4 text runtime.
|
|
407
|
+
- [x] Generalize the C++ model dispatch and binary naming without breaking existing scripts.
|
|
408
|
+
- [x] Qwen OpenAI-compatible text serving adapter.
|
|
409
|
+
- [ ] CUDA Graph and persistent decode dispatch where measured beneficial.
|
|
410
|
+
- [ ] More model-specific benchmark fixtures and automated regression dashboards.
|
|
411
|
+
|
|
412
|
+
## Known limitations
|
|
413
|
+
|
|
414
|
+
- Performance is highly sensitive to GPU model, PCIe topology, NUMA placement, driver/runtime versions, and checkpoint variant.
|
|
415
|
+
- GGUF expert staging can dominate decode on PCIe-only systems; a high prefill number does not imply high decode TPS.
|
|
416
|
+
- DeepSeek-V4 DSpark's current C++ verify path is sequential and should not be presented as a speedup claim. Qwen DSpark is a separate external drafter with one eight-row target verification and model-specific parity/performance data.
|
|
417
|
+
- Qwen DFlash2 wall-clock speedup is acceptance-dependent and prefill-capped: the synthetic fixtures accept the full eight-row block while GSM8K accepts 2.9–4.4, and shared prefill limits the 8,192-token case to 1.95x even with zero decode time. Upstream's 2.67–3.43x is a decode-latency ratio, not a full-request wall ratio.
|
|
418
|
+
- The Qwen runtime currently supports the text checkpoint path only. Vision inputs and multimodal serving are not implemented.
|
|
419
|
+
- Some experimental optimizations are intentionally opt-in or disabled after real end-to-end regressions. See the model pages and historical notes for details.
|
|
420
|
+
|
|
421
|
+
## License
|
|
422
|
+
|
|
423
|
+
PocketLLM code is licensed under the [PolyForm Noncommercial License 1.0.0](LICENSE).
|
|
424
|
+
|
|
425
|
+
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.
|
|
426
|
+
|
|
427
|
+
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.
|
|
428
|
+
|
|
429
|
+
## Acknowledgements
|
|
430
|
+
|
|
431
|
+
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.
|