deepinfer 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.
- deepinfer-0.1.0/LICENSE +201 -0
- deepinfer-0.1.0/MANIFEST.in +3 -0
- deepinfer-0.1.0/PKG-INFO +148 -0
- deepinfer-0.1.0/README.md +107 -0
- deepinfer-0.1.0/csrc/asc_utils.cpp +115 -0
- deepinfer-0.1.0/csrc/cuda_utils.cpp +109 -0
- deepinfer-0.1.0/csrc/cuda_utils.hpp +49 -0
- deepinfer-0.1.0/csrc/engine/block_manager.hpp +243 -0
- deepinfer-0.1.0/csrc/engine/flops_estimator.hpp +330 -0
- deepinfer-0.1.0/csrc/engine/input_metadata/block_load_plan.cpp +60 -0
- deepinfer-0.1.0/csrc/engine/input_metadata/block_load_plan.hpp +34 -0
- deepinfer-0.1.0/csrc/engine/input_metadata/prepare_tensor_input.hpp +73 -0
- deepinfer-0.1.0/csrc/engine/input_metadata/prepare_tensor_input_base.cpp +251 -0
- deepinfer-0.1.0/csrc/engine/input_metadata/prepare_tensor_input_v4.cpp +655 -0
- deepinfer-0.1.0/csrc/engine/mtp_varlen.hpp +275 -0
- deepinfer-0.1.0/csrc/engine/outputs.hpp +308 -0
- deepinfer-0.1.0/csrc/engine/prepare_sample.cpp +284 -0
- deepinfer-0.1.0/csrc/engine/prepare_sample.hpp +66 -0
- deepinfer-0.1.0/csrc/engine/process_output.hpp +39 -0
- deepinfer-0.1.0/csrc/engine/pybind.cpp +11 -0
- deepinfer-0.1.0/csrc/engine/pybind.hpp +14 -0
- deepinfer-0.1.0/csrc/engine/pybind_output.cpp +138 -0
- deepinfer-0.1.0/csrc/engine/pybind_scheduler.cpp +138 -0
- deepinfer-0.1.0/csrc/engine/pybind_sequence.cpp +173 -0
- deepinfer-0.1.0/csrc/engine/scheduler.hpp +1329 -0
- deepinfer-0.1.0/csrc/engine/sequence.hpp +419 -0
- deepinfer-0.1.0/csrc/engine/utils.hpp +40 -0
- deepinfer-0.1.0/csrc/engine/zos.cpp +307 -0
- deepinfer-0.1.0/csrc/engine/zos.hpp +30 -0
- deepinfer-0.1.0/csrc/graph_timer/graph_timer.hpp +87 -0
- deepinfer-0.1.0/csrc/graph_timer/graph_timer_asc.cpp +45 -0
- deepinfer-0.1.0/csrc/graph_timer/graph_timer_cuda.cpp +91 -0
- deepinfer-0.1.0/csrc/graph_timer/pybind.cpp +31 -0
- deepinfer-0.1.0/csrc/pybind.cpp +17 -0
- deepinfer-0.1.0/csrc/utils/lockable.hpp +38 -0
- deepinfer-0.1.0/csrc/utils/log.hpp +62 -0
- deepinfer-0.1.0/csrc/utils/object_pool.hpp +48 -0
- deepinfer-0.1.0/deep_cluster/__init__.py +0 -0
- deepinfer-0.1.0/deep_cluster/hardware/__init__.py +35 -0
- deepinfer-0.1.0/deep_cluster/hardware/ascend.py +155 -0
- deepinfer-0.1.0/deep_cluster/hardware/cpu.py +47 -0
- deepinfer-0.1.0/deep_cluster/hardware/device.py +182 -0
- deepinfer-0.1.0/deep_cluster/hardware/nvidia.py +129 -0
- deepinfer-0.1.0/deep_cluster/topology/__init__.py +9 -0
- deepinfer-0.1.0/deep_cluster/topology/bind.py +99 -0
- deepinfer-0.1.0/deepinfer/_C/__init__.pyi +5 -0
- deepinfer-0.1.0/deepinfer/_C/cuda_utils.pyi +18 -0
- deepinfer-0.1.0/deepinfer/_C/engine.pyi +735 -0
- deepinfer-0.1.0/deepinfer/_C/graph_timer.pyi +61 -0
- deepinfer-0.1.0/deepinfer/__init__.py +64 -0
- deepinfer-0.1.0/deepinfer/attrdict.py +116 -0
- deepinfer-0.1.0/deepinfer/config.py +228 -0
- deepinfer-0.1.0/deepinfer/distributed/__init__.py +0 -0
- deepinfer-0.1.0/deepinfer/distributed/shm_broadcast.py +461 -0
- deepinfer-0.1.0/deepinfer/engine/__init__.py +0 -0
- deepinfer-0.1.0/deepinfer/engine/arg_utils.py +114 -0
- deepinfer-0.1.0/deepinfer/engine/engine_type.py +17 -0
- deepinfer-0.1.0/deepinfer/engine/llm_engine.py +1029 -0
- deepinfer-0.1.0/deepinfer/engine/profile_server.py +320 -0
- deepinfer-0.1.0/deepinfer/engine/stats_logger.py +477 -0
- deepinfer-0.1.0/deepinfer/entrypoints/__init__.py +0 -0
- deepinfer-0.1.0/deepinfer/entrypoints/llm.py +198 -0
- deepinfer-0.1.0/deepinfer/environ.py +221 -0
- deepinfer-0.1.0/deepinfer/hugging_face/__init__.py +49 -0
- deepinfer-0.1.0/deepinfer/hugging_face/config.py +328 -0
- deepinfer-0.1.0/deepinfer/hugging_face/loading.py +121 -0
- deepinfer-0.1.0/deepinfer/hugging_face/names.py +184 -0
- deepinfer-0.1.0/deepinfer/hugging_face/parameters.py +70 -0
- deepinfer-0.1.0/deepinfer/hugging_face/processor.py +66 -0
- deepinfer-0.1.0/deepinfer/hugging_face/tokenizer.py +121 -0
- deepinfer-0.1.0/deepinfer/hugging_face/weights.py +436 -0
- deepinfer-0.1.0/deepinfer/load_class.py +8 -0
- deepinfer-0.1.0/deepinfer/logger.py +174 -0
- deepinfer-0.1.0/deepinfer/model_config_loader.py +23 -0
- deepinfer-0.1.0/deepinfer/model_executor/__init__.py +0 -0
- deepinfer-0.1.0/deepinfer/model_executor/eplb/__init__.py +434 -0
- deepinfer-0.1.0/deepinfer/model_executor/eplb/policy.py +140 -0
- deepinfer-0.1.0/deepinfer/model_executor/eplb/shuffle.py +218 -0
- deepinfer-0.1.0/deepinfer/model_executor/input_metadata/__init__.py +13 -0
- deepinfer-0.1.0/deepinfer/model_executor/input_metadata/dflash.py +84 -0
- deepinfer-0.1.0/deepinfer/model_executor/input_metadata/input_metadata.py +490 -0
- deepinfer-0.1.0/deepinfer/model_executor/input_metadata/prepare_tensor_input_zos.py +382 -0
- deepinfer-0.1.0/deepinfer/model_executor/input_metadata/yoco.py +182 -0
- deepinfer-0.1.0/deepinfer/model_executor/layer_utils.py +16 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/__init__.py +0 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/attention_backend.py +146 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/layernorm.py +63 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/linear.py +185 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/mtp_info_pool.py +78 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/rotary_embedding.py +284 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/sampler.py +683 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/sampler_utils.py +196 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/__init__.py +0 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/asc/__init__.py +0 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/asc/candidate_blocks.py +350 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/asc/compress.py +407 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/asc/compute_seqlens_k_zos.py +59 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/asc/dflash.py +150 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/asc/dflash_copy.py +129 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/asc/flash_mla_utils.py +53 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/asc/fused_sample.py +673 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/asc/fused_transform.py +899 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/asc/gather.py +107 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/asc/gather_engram_tokens_zos.py +145 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/asc/gather_input_ids_zos.py +87 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/asc/get_kv_index.py +263 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/asc/image_embed_ops.py +402 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/asc/kv_index_cat.py +71 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/asc/kv_quant.py +196 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/asc/load_paged_kv_cache.py +345 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/asc/norm.py +431 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/asc/prepare_cp_mirror.py +518 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/asc/prepare_v4_decode_metadata.py +257 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/asc/random_sampling.py +258 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/asc/rstd_1ulp.py +98 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/asc/sampler.py +663 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/asc/schedule_mtp_varlen.py +121 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/asc/state_cache.py +96 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/asc/store_kv_cache.py +310 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/asc/store_mtp_info.py +67 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/asc/structure_output.py +102 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/asc/sum_smaller_probs.py +99 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/asc/swa_index.py +62 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/cache_common.py +461 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/candidate_blocks.py +328 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/common.py +53 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/compress.py +663 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/compute_seqlens_k_zos.py +121 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/conftest.py +113 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/cuda/__init__.py +0 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/cuda/candidate_blocks.py +225 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/cuda/compress.py +292 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/cuda/compute_seqlens_k_zos.py +38 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/cuda/dflash.py +119 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/cuda/dflash_copy.py +82 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/cuda/flash_mla_utils.py +40 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/cuda/fused_sample.py +524 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/cuda/fused_transform.py +619 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/cuda/gather.py +69 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/cuda/gather_engram_tokens_zos.py +76 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/cuda/gather_input_ids_zos.py +48 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/cuda/get_kv_index.py +138 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/cuda/image_embed_ops.py +275 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/cuda/kv_index_cat.py +82 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/cuda/load_paged_kv_cache.py +165 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/cuda/norm.py +326 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/cuda/outlier_detection.py +40 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/cuda/prepare_cp_mirror.py +313 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/cuda/prepare_decode_metadata.py +196 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/cuda/quant.py +9 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/cuda/random_sampling.py +258 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/cuda/sampler.py +411 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/cuda/schedule_mtp_varlen.py +83 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/cuda/state_cache.py +136 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/cuda/store_kv_cache.py +195 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/cuda/store_mtp_info.py +59 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/cuda/structure_output.py +59 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/cuda/sum_smaller_probs.py +57 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/cuda/swa_index.py +34 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/dflash.py +224 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/dflash_copy.py +151 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/flash_mla_utils.py +107 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/fused_sample.py +832 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/fused_transform.py +1330 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/gather.py +136 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/gather_engram_tokens_zos.py +248 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/gather_input_ids_zos.py +193 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/get_kv_index.py +518 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/image_embed_ops.py +630 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/kv_index_cat.py +117 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/load_paged_kv_cache.py +382 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/norm.py +587 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/ops.py +32 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/outlier_detection.py +26 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/prepare_cp_mirror.py +394 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/prepare_v4_decode_metadata.py +545 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/random_sampling.py +332 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/sampler.py +1080 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/schedule_mtp_varlen.py +166 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/state_cache.py +220 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/store_kv_cache.py +380 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/store_mtp_info.py +226 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/structure_output.py +150 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/sum_smaller_probs.py +83 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/tilelang_ops/swa_index.py +117 -0
- deepinfer-0.1.0/deepinfer/model_executor/layers/vocab_parallel_embedding.py +30 -0
- deepinfer-0.1.0/deepinfer/model_executor/model_loader.py +153 -0
- deepinfer-0.1.0/deepinfer/model_executor/model_metadata_utils.py +188 -0
- deepinfer-0.1.0/deepinfer/model_executor/model_output.py +21 -0
- deepinfer-0.1.0/deepinfer/model_executor/models/__init__.py +37 -0
- deepinfer-0.1.0/deepinfer/model_executor/models/decoder_layer.py +239 -0
- deepinfer-0.1.0/deepinfer/model_executor/models/deepseek.py +525 -0
- deepinfer-0.1.0/deepinfer/model_executor/models/deepseek_vl.py +267 -0
- deepinfer-0.1.0/deepinfer/model_executor/models/mtp/__init__.py +0 -0
- deepinfer-0.1.0/deepinfer/model_executor/models/mtp/dflash.py +392 -0
- deepinfer-0.1.0/deepinfer/model_executor/models/v4_modules/__init__.py +42 -0
- deepinfer-0.1.0/deepinfer/model_executor/models/v4_modules/attn.py +1008 -0
- deepinfer-0.1.0/deepinfer/model_executor/models/v4_modules/builder.py +130 -0
- deepinfer-0.1.0/deepinfer/model_executor/models/v4_modules/compress.py +167 -0
- deepinfer-0.1.0/deepinfer/model_executor/models/v4_modules/containers.py +135 -0
- deepinfer-0.1.0/deepinfer/model_executor/models/v4_modules/cross_layer.py +383 -0
- deepinfer-0.1.0/deepinfer/model_executor/models/v4_modules/engram.py +219 -0
- deepinfer-0.1.0/deepinfer/model_executor/models/v4_modules/engram_metadata.py +116 -0
- deepinfer-0.1.0/deepinfer/model_executor/models/v4_modules/engram_parameters.py +64 -0
- deepinfer-0.1.0/deepinfer/model_executor/models/v4_modules/hc.py +397 -0
- deepinfer-0.1.0/deepinfer/model_executor/models/v4_modules/hc_blocks.py +109 -0
- deepinfer-0.1.0/deepinfer/model_executor/models/v4_modules/hc_lazy.py +35 -0
- deepinfer-0.1.0/deepinfer/model_executor/models/v4_modules/heads.py +108 -0
- deepinfer-0.1.0/deepinfer/model_executor/models/v4_modules/index_attn.py +575 -0
- deepinfer-0.1.0/deepinfer/model_executor/models/v4_modules/linear.py +34 -0
- deepinfer-0.1.0/deepinfer/model_executor/models/v4_modules/mhc_modeling.py +142 -0
- deepinfer-0.1.0/deepinfer/model_executor/models/v4_modules/mhc_ops.py +148 -0
- deepinfer-0.1.0/deepinfer/model_executor/models/v4_modules/mla_attn.py +299 -0
- deepinfer-0.1.0/deepinfer/model_executor/models/v4_modules/mlp.py +616 -0
- deepinfer-0.1.0/deepinfer/model_executor/models/v4_modules/moe.py +112 -0
- deepinfer-0.1.0/deepinfer/model_executor/models/v4_modules/norm.py +39 -0
- deepinfer-0.1.0/deepinfer/model_executor/models/v4_modules/rope.py +53 -0
- deepinfer-0.1.0/deepinfer/model_executor/models/v4_modules/utils.py +143 -0
- deepinfer-0.1.0/deepinfer/model_executor/models/v4_modules/yoco.py +123 -0
- deepinfer-0.1.0/deepinfer/model_executor/models/vision_encoder/__init__.py +0 -0
- deepinfer-0.1.0/deepinfer/model_executor/models/vision_encoder/mlp_projector.py +23 -0
- deepinfer-0.1.0/deepinfer/model_executor/models/vision_encoder/vit.py +230 -0
- deepinfer-0.1.0/deepinfer/model_executor/models/vision_encoder/vl_aligner.py +141 -0
- deepinfer-0.1.0/deepinfer/model_executor/parallel_utils/__init__.py +0 -0
- deepinfer-0.1.0/deepinfer/model_executor/parallel_utils/communication_op.py +82 -0
- deepinfer-0.1.0/deepinfer/model_executor/parallel_utils/cp.py +54 -0
- deepinfer-0.1.0/deepinfer/model_executor/parallel_utils/nccl_memory.py +100 -0
- deepinfer-0.1.0/deepinfer/model_executor/parallel_utils/parallel_state.py +230 -0
- deepinfer-0.1.0/deepinfer/model_executor/parallel_utils/userbuffer.py +240 -0
- deepinfer-0.1.0/deepinfer/model_executor/sampling_inputs.py +132 -0
- deepinfer-0.1.0/deepinfer/model_executor/utils.py +101 -0
- deepinfer-0.1.0/deepinfer/multimodal_tokens.py +41 -0
- deepinfer-0.1.0/deepinfer/npu_ops/__init__.py +12 -0
- deepinfer-0.1.0/deepinfer/npu_ops/deep_select.py +26 -0
- deepinfer-0.1.0/deepinfer/npu_ops/patch_imports.py +142 -0
- deepinfer-0.1.0/deepinfer/npu_ops/vit_attn.py +31 -0
- deepinfer-0.1.0/deepinfer/platform.py +227 -0
- deepinfer-0.1.0/deepinfer/py.typed +2 -0
- deepinfer-0.1.0/deepinfer/sampling_params.py +119 -0
- deepinfer-0.1.0/deepinfer/sequence.py +281 -0
- deepinfer-0.1.0/deepinfer/shared_memory.py +363 -0
- deepinfer-0.1.0/deepinfer/structure_output/__init__.py +0 -0
- deepinfer-0.1.0/deepinfer/structure_output/compiler.py +74 -0
- deepinfer-0.1.0/deepinfer/structure_output/mask.py +36 -0
- deepinfer-0.1.0/deepinfer/structure_output/matcher.py +347 -0
- deepinfer-0.1.0/deepinfer/structure_output/so_matcher_builder.py +138 -0
- deepinfer-0.1.0/deepinfer/testing.py +23 -0
- deepinfer-0.1.0/deepinfer/timer.py +295 -0
- deepinfer-0.1.0/deepinfer/utils.py +282 -0
- deepinfer-0.1.0/deepinfer/ve/__init__.py +0 -0
- deepinfer-0.1.0/deepinfer/ve/multimodal_processor.py +326 -0
- deepinfer-0.1.0/deepinfer/ve/prepare_tensor_input_vl.py +163 -0
- deepinfer-0.1.0/deepinfer/ve/processor/__init__.py +0 -0
- deepinfer-0.1.0/deepinfer/ve/processor/common.py +52 -0
- deepinfer-0.1.0/deepinfer/ve/processor/image_processor.py +318 -0
- deepinfer-0.1.0/deepinfer/ve/processor/mm_processor.py +30 -0
- deepinfer-0.1.0/deepinfer/ve/processor/text_processor.py +13 -0
- deepinfer-0.1.0/deepinfer/ve/schema.py +77 -0
- deepinfer-0.1.0/deepinfer/worker/__init__.py +0 -0
- deepinfer-0.1.0/deepinfer/worker/base.py +357 -0
- deepinfer-0.1.0/deepinfer/worker/cache_engine.py +978 -0
- deepinfer-0.1.0/deepinfer/worker/cuda_graph_runner.py +168 -0
- deepinfer-0.1.0/deepinfer/worker/decode_perf_cache.py +166 -0
- deepinfer-0.1.0/deepinfer/worker/dflash_cuda_graph_runner.py +100 -0
- deepinfer-0.1.0/deepinfer/worker/model_runner.py +644 -0
- deepinfer-0.1.0/deepinfer/worker/runtime_config.py +69 -0
- deepinfer-0.1.0/deepinfer/worker/worker.py +283 -0
- deepinfer-0.1.0/deepinfer/worker/zos_status.py +40 -0
- deepinfer-0.1.0/deepinfer.egg-info/PKG-INFO +148 -0
- deepinfer-0.1.0/deepinfer.egg-info/SOURCES.txt +279 -0
- deepinfer-0.1.0/deepinfer.egg-info/dependency_links.txt +1 -0
- deepinfer-0.1.0/deepinfer.egg-info/requires.txt +21 -0
- deepinfer-0.1.0/deepinfer.egg-info/top_level.txt +2 -0
- deepinfer-0.1.0/pyproject.toml +83 -0
- deepinfer-0.1.0/requirements-ascend.txt +4 -0
- deepinfer-0.1.0/requirements-dev.txt +19 -0
- deepinfer-0.1.0/requirements-nvidia.txt +5 -0
- deepinfer-0.1.0/requirements.txt +21 -0
- deepinfer-0.1.0/setup.cfg +4 -0
- deepinfer-0.1.0/setup.py +94 -0
- deepinfer-0.1.0/tests/test_cuda_sync_guards.py +213 -0
deepinfer-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
deepinfer-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: deepinfer
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: DeepInfer: High-performance, large-scale inference framework for DeepSeek models
|
|
5
|
+
Author: DeepSeek-AI
|
|
6
|
+
Maintainer: Xuan Xin
|
|
7
|
+
License-Expression: Apache-2.0
|
|
8
|
+
Project-URL: Repository, https://github.com/deepseek-ai/deepinfer
|
|
9
|
+
Project-URL: Issues, https://github.com/deepseek-ai/deepinfer/issues
|
|
10
|
+
Keywords: llm,inference,deepseek,cuda,ascend
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
15
|
+
Requires-Python: >=3.12
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
License-File: LICENSE
|
|
18
|
+
Requires-Dist: einops==0.8.2
|
|
19
|
+
Requires-Dist: huggingface_hub==0.36.2
|
|
20
|
+
Requires-Dist: ninja==1.13.0
|
|
21
|
+
Requires-Dist: numpy==2.3.5
|
|
22
|
+
Requires-Dist: orjson==3.11.7
|
|
23
|
+
Requires-Dist: pillow==11.3.0
|
|
24
|
+
Requires-Dist: posix_ipc==1.3.2
|
|
25
|
+
Requires-Dist: psutil==7.2.2
|
|
26
|
+
Requires-Dist: pybind11==3.0.1
|
|
27
|
+
Requires-Dist: pyzmq==27.1.0
|
|
28
|
+
Requires-Dist: requests==2.32.5
|
|
29
|
+
Requires-Dist: safetensors==0.8.0
|
|
30
|
+
Requires-Dist: scipy==1.17.0
|
|
31
|
+
Requires-Dist: sympy==1.14.0
|
|
32
|
+
Requires-Dist: tabulate==0.9.0
|
|
33
|
+
Requires-Dist: tilelang==0.1.15
|
|
34
|
+
Requires-Dist: tile-kernels==2.1.0
|
|
35
|
+
Requires-Dist: tokenizers==0.21.4
|
|
36
|
+
Requires-Dist: tqdm==4.67.3
|
|
37
|
+
Requires-Dist: transformers==4.50.0
|
|
38
|
+
Requires-Dist: xgrammar==0.2.2
|
|
39
|
+
Dynamic: license-file
|
|
40
|
+
Dynamic: requires-dist
|
|
41
|
+
|
|
42
|
+
# DeepInfer
|
|
43
|
+
|
|
44
|
+
DeepInfer is the high-performance inference framework that powers DeepSeek's large-scale production services. This open-source release provides offline inference with the core features needed for serving at scale.
|
|
45
|
+
|
|
46
|
+
Supported models:
|
|
47
|
+
|
|
48
|
+
- DeepSeek-V4.1-Flash
|
|
49
|
+
|
|
50
|
+
Supported features:
|
|
51
|
+
|
|
52
|
+
- Optimized kernels, model and sampler runtime
|
|
53
|
+
- Parallelism: Attention DP / balanced CP, MoE EP + EPLB
|
|
54
|
+
- DSpark and confidence-scheduled verification
|
|
55
|
+
- SWA bounded replay
|
|
56
|
+
- Asynchronous scheduling (zero-overhead batch scheduler)
|
|
57
|
+
- Batch-invariant inference
|
|
58
|
+
- Deterministic sampling
|
|
59
|
+
- Structured outputs
|
|
60
|
+
|
|
61
|
+
<details>
|
|
62
|
+
<summary>Feature details and configuration</summary>
|
|
63
|
+
|
|
64
|
+
- **Optimized kernels:** [FlashMLA](https://github.com/deepseek-ai/FlashMLA), [DeepGEMM](https://github.com/deepseek-ai/DeepGEMM), [DeepEP](https://github.com/deepseek-ai/DeepEP), [TileKernels](https://github.com/deepseek-ai/TileKernels), [DeepSelect](https://github.com/deepseek-ai/DeepSelect), and custom [TileLang kernels](deepinfer/model_executor/layers/tilelang_ops).
|
|
65
|
+
- **DSpark and confidence-scheduled verification:** accelerate decoding with draft tokens and use confidence estimates to schedule verification. Set `DEEPINFER_ENABLE_MTP_VARLEN=1`; `DEEPINFER_USE_NEXTN_DECODE` controls the maximum draft length (default: 5).
|
|
66
|
+
- **Decoder SWA bounded replay:** reduce decoder prefill work by replaying only a bounded suffix. Set `DEEPINFER_YOCO_PREFILL_TRUNCATION_MODE=compact` and `DEEPINFER_YOCO_PREFILL_KEEP_TOKENS=140` for the default V4.1 settings; the retained suffix must cover the SWA window plus the maximum backtracking length.
|
|
67
|
+
- **Asynchronous scheduling:** overlap CPU batch scheduling with device execution. Enabled by default.
|
|
68
|
+
- **Batch-invariant inference:** keep model results identical across different batch compositions. Enable with `DEEPINFER_BATCH_INVARIANT=1` (NVIDIA only).
|
|
69
|
+
- **Deterministic sampling:** produce identical outputs for identical input tokens and sampling parameters. Set `DEEPINFER_BATCH_INVARIANT=1 DEEPINFER_ENABLE_MTP_VARLEN=0` and pass a fixed `seq_seed` to `SamplingParams` (NVIDIA only).
|
|
70
|
+
- **Structured outputs:** constrain generation to a regex, JSON schema, or EBNF grammar. Pass `so_args={"schema_type": ..., "schema": ...}` to `SamplingParams`; see [examples](examples/_structured_output.py).
|
|
71
|
+
|
|
72
|
+
</details>
|
|
73
|
+
|
|
74
|
+
Supported hardware:
|
|
75
|
+
|
|
76
|
+
- NVIDIA SM100 GPUs
|
|
77
|
+
- Huawei Ascend 950 NPUs
|
|
78
|
+
|
|
79
|
+
Required for a complete inference service (not included in this release):
|
|
80
|
+
|
|
81
|
+
- A KV cache system
|
|
82
|
+
- VE/Prefill/Decode disaggregation (most required engine functionality is already implemented)
|
|
83
|
+
- Load balancing across data-parallel replicas for both prefill and decode
|
|
84
|
+
|
|
85
|
+
## Getting started
|
|
86
|
+
|
|
87
|
+
### Prerequisites
|
|
88
|
+
|
|
89
|
+
- Linux
|
|
90
|
+
- GCC >= 13.0
|
|
91
|
+
- Python 3.12
|
|
92
|
+
- CUDA 13 (NVIDIA only)
|
|
93
|
+
- CANN 9.2 (Ascend only)
|
|
94
|
+
|
|
95
|
+
### Build from source
|
|
96
|
+
|
|
97
|
+
Before building DeepInfer, please create and activate an empty Python 3.12 environment.
|
|
98
|
+
|
|
99
|
+
``` bash
|
|
100
|
+
# Use `ascend` instead for the Ascend platform
|
|
101
|
+
# Keep it exported in the environment where you run DeepInfer
|
|
102
|
+
export DEEPINFER_ACCELERATOR=nvidia
|
|
103
|
+
./build.sh
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Offline inference
|
|
107
|
+
|
|
108
|
+
The default checkpoint, [`deepseek-ai/DeepSeek-V4.1-Flash-1017`](https://huggingface.co/deepseek-ai/DeepSeek-V4.1-Flash-1017), is
|
|
109
|
+
downloaded into the Hugging Face cache on the first run; set `DEEPINFER_HF_MODEL_DIR=/path/to/DeepSeek-V4.1-Flash-1017` to
|
|
110
|
+
run from a local copy instead.
|
|
111
|
+
|
|
112
|
+
``` bash
|
|
113
|
+
python examples/offline_inference.py
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
See [examples](examples/README.md) for details.
|
|
117
|
+
|
|
118
|
+
## Performance benchmarks
|
|
119
|
+
|
|
120
|
+
| Prefill | Decode |
|
|
121
|
+
| :---: | :---: |
|
|
122
|
+
| [](doc/images/prefill_pareto.png) | [](doc/images/decode_pareto.png) |
|
|
123
|
+
|
|
124
|
+
Measured on 4 SM100 GPUs for prefill and 64 for decode — each within one scale-up domain. To reproduce the benchmarks, see [run_sweep.sh](examples/sweep/run_sweep.sh).
|
|
125
|
+
|
|
126
|
+
## Evaluation benchmarks
|
|
127
|
+
|
|
128
|
+
See [eval/README.md](eval/README.md).
|
|
129
|
+
|
|
130
|
+
## License
|
|
131
|
+
|
|
132
|
+
DeepInfer is released under the Apache License 2.0. See [LICENSE](LICENSE) for details.
|
|
133
|
+
|
|
134
|
+
## Acknowledgments
|
|
135
|
+
|
|
136
|
+
DeepInfer was originally built primarily on [vLLM](https://github.com/vllm-project/vllm), with additional inspiration from [SGLang](https://github.com/sgl-project/sglang) and [TensorRT-LLM](https://github.com/NVIDIA/TensorRT-LLM). We thank their developers.
|
|
137
|
+
|
|
138
|
+
## Citation
|
|
139
|
+
|
|
140
|
+
```bibtex
|
|
141
|
+
@misc{deepinfer2026,
|
|
142
|
+
title = {DeepInfer: High-performance, large-scale inference framework for DeepSeek models},
|
|
143
|
+
author = {DeepSeek-AI},
|
|
144
|
+
year = {2026},
|
|
145
|
+
publisher = {GitHub},
|
|
146
|
+
howpublished = {\url{https://github.com/deepseek-ai/DeepInfer}},
|
|
147
|
+
}
|
|
148
|
+
```
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# DeepInfer
|
|
2
|
+
|
|
3
|
+
DeepInfer is the high-performance inference framework that powers DeepSeek's large-scale production services. This open-source release provides offline inference with the core features needed for serving at scale.
|
|
4
|
+
|
|
5
|
+
Supported models:
|
|
6
|
+
|
|
7
|
+
- DeepSeek-V4.1-Flash
|
|
8
|
+
|
|
9
|
+
Supported features:
|
|
10
|
+
|
|
11
|
+
- Optimized kernels, model and sampler runtime
|
|
12
|
+
- Parallelism: Attention DP / balanced CP, MoE EP + EPLB
|
|
13
|
+
- DSpark and confidence-scheduled verification
|
|
14
|
+
- SWA bounded replay
|
|
15
|
+
- Asynchronous scheduling (zero-overhead batch scheduler)
|
|
16
|
+
- Batch-invariant inference
|
|
17
|
+
- Deterministic sampling
|
|
18
|
+
- Structured outputs
|
|
19
|
+
|
|
20
|
+
<details>
|
|
21
|
+
<summary>Feature details and configuration</summary>
|
|
22
|
+
|
|
23
|
+
- **Optimized kernels:** [FlashMLA](https://github.com/deepseek-ai/FlashMLA), [DeepGEMM](https://github.com/deepseek-ai/DeepGEMM), [DeepEP](https://github.com/deepseek-ai/DeepEP), [TileKernels](https://github.com/deepseek-ai/TileKernels), [DeepSelect](https://github.com/deepseek-ai/DeepSelect), and custom [TileLang kernels](deepinfer/model_executor/layers/tilelang_ops).
|
|
24
|
+
- **DSpark and confidence-scheduled verification:** accelerate decoding with draft tokens and use confidence estimates to schedule verification. Set `DEEPINFER_ENABLE_MTP_VARLEN=1`; `DEEPINFER_USE_NEXTN_DECODE` controls the maximum draft length (default: 5).
|
|
25
|
+
- **Decoder SWA bounded replay:** reduce decoder prefill work by replaying only a bounded suffix. Set `DEEPINFER_YOCO_PREFILL_TRUNCATION_MODE=compact` and `DEEPINFER_YOCO_PREFILL_KEEP_TOKENS=140` for the default V4.1 settings; the retained suffix must cover the SWA window plus the maximum backtracking length.
|
|
26
|
+
- **Asynchronous scheduling:** overlap CPU batch scheduling with device execution. Enabled by default.
|
|
27
|
+
- **Batch-invariant inference:** keep model results identical across different batch compositions. Enable with `DEEPINFER_BATCH_INVARIANT=1` (NVIDIA only).
|
|
28
|
+
- **Deterministic sampling:** produce identical outputs for identical input tokens and sampling parameters. Set `DEEPINFER_BATCH_INVARIANT=1 DEEPINFER_ENABLE_MTP_VARLEN=0` and pass a fixed `seq_seed` to `SamplingParams` (NVIDIA only).
|
|
29
|
+
- **Structured outputs:** constrain generation to a regex, JSON schema, or EBNF grammar. Pass `so_args={"schema_type": ..., "schema": ...}` to `SamplingParams`; see [examples](examples/_structured_output.py).
|
|
30
|
+
|
|
31
|
+
</details>
|
|
32
|
+
|
|
33
|
+
Supported hardware:
|
|
34
|
+
|
|
35
|
+
- NVIDIA SM100 GPUs
|
|
36
|
+
- Huawei Ascend 950 NPUs
|
|
37
|
+
|
|
38
|
+
Required for a complete inference service (not included in this release):
|
|
39
|
+
|
|
40
|
+
- A KV cache system
|
|
41
|
+
- VE/Prefill/Decode disaggregation (most required engine functionality is already implemented)
|
|
42
|
+
- Load balancing across data-parallel replicas for both prefill and decode
|
|
43
|
+
|
|
44
|
+
## Getting started
|
|
45
|
+
|
|
46
|
+
### Prerequisites
|
|
47
|
+
|
|
48
|
+
- Linux
|
|
49
|
+
- GCC >= 13.0
|
|
50
|
+
- Python 3.12
|
|
51
|
+
- CUDA 13 (NVIDIA only)
|
|
52
|
+
- CANN 9.2 (Ascend only)
|
|
53
|
+
|
|
54
|
+
### Build from source
|
|
55
|
+
|
|
56
|
+
Before building DeepInfer, please create and activate an empty Python 3.12 environment.
|
|
57
|
+
|
|
58
|
+
``` bash
|
|
59
|
+
# Use `ascend` instead for the Ascend platform
|
|
60
|
+
# Keep it exported in the environment where you run DeepInfer
|
|
61
|
+
export DEEPINFER_ACCELERATOR=nvidia
|
|
62
|
+
./build.sh
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Offline inference
|
|
66
|
+
|
|
67
|
+
The default checkpoint, [`deepseek-ai/DeepSeek-V4.1-Flash-1017`](https://huggingface.co/deepseek-ai/DeepSeek-V4.1-Flash-1017), is
|
|
68
|
+
downloaded into the Hugging Face cache on the first run; set `DEEPINFER_HF_MODEL_DIR=/path/to/DeepSeek-V4.1-Flash-1017` to
|
|
69
|
+
run from a local copy instead.
|
|
70
|
+
|
|
71
|
+
``` bash
|
|
72
|
+
python examples/offline_inference.py
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
See [examples](examples/README.md) for details.
|
|
76
|
+
|
|
77
|
+
## Performance benchmarks
|
|
78
|
+
|
|
79
|
+
| Prefill | Decode |
|
|
80
|
+
| :---: | :---: |
|
|
81
|
+
| [](doc/images/prefill_pareto.png) | [](doc/images/decode_pareto.png) |
|
|
82
|
+
|
|
83
|
+
Measured on 4 SM100 GPUs for prefill and 64 for decode — each within one scale-up domain. To reproduce the benchmarks, see [run_sweep.sh](examples/sweep/run_sweep.sh).
|
|
84
|
+
|
|
85
|
+
## Evaluation benchmarks
|
|
86
|
+
|
|
87
|
+
See [eval/README.md](eval/README.md).
|
|
88
|
+
|
|
89
|
+
## License
|
|
90
|
+
|
|
91
|
+
DeepInfer is released under the Apache License 2.0. See [LICENSE](LICENSE) for details.
|
|
92
|
+
|
|
93
|
+
## Acknowledgments
|
|
94
|
+
|
|
95
|
+
DeepInfer was originally built primarily on [vLLM](https://github.com/vllm-project/vllm), with additional inspiration from [SGLang](https://github.com/sgl-project/sglang) and [TensorRT-LLM](https://github.com/NVIDIA/TensorRT-LLM). We thank their developers.
|
|
96
|
+
|
|
97
|
+
## Citation
|
|
98
|
+
|
|
99
|
+
```bibtex
|
|
100
|
+
@misc{deepinfer2026,
|
|
101
|
+
title = {DeepInfer: High-performance, large-scale inference framework for DeepSeek models},
|
|
102
|
+
author = {DeepSeek-AI},
|
|
103
|
+
year = {2026},
|
|
104
|
+
publisher = {GitHub},
|
|
105
|
+
howpublished = {\url{https://github.com/deepseek-ai/DeepInfer}},
|
|
106
|
+
}
|
|
107
|
+
```
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
#include "cuda_utils.hpp"
|
|
2
|
+
|
|
3
|
+
#include <cstring>
|
|
4
|
+
#include <optional>
|
|
5
|
+
#include <string>
|
|
6
|
+
#include <torch/extension.h>
|
|
7
|
+
|
|
8
|
+
#include "third_party/acl/inc/acl/acl.h"
|
|
9
|
+
#include <torch_npu/csrc/core/npu/NPUCachingAllocator.h> // kAclIpcHandleSize
|
|
10
|
+
#include <torch_npu/csrc/core/npu/NPUStream.h>
|
|
11
|
+
|
|
12
|
+
#include "utils/log.hpp"
|
|
13
|
+
|
|
14
|
+
namespace deepinfer::cuda::utils {
|
|
15
|
+
|
|
16
|
+
static void close_npu_ipc_handle(void *ptr, const std::string &key) {
|
|
17
|
+
aclError ret = aclrtIpcMemClose(key.c_str());
|
|
18
|
+
if (ret == ACL_SUCCESS) {
|
|
19
|
+
LOG_INFO("close NPU IPC handle at {}", ptr);
|
|
20
|
+
} else {
|
|
21
|
+
LOG_ERROR("failed to close NPU IPC handle at {}: aclError={}", ptr, ret);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
static constexpr size_t kIpcKeyLen = c10_npu::kAclIpcHandleSize;
|
|
26
|
+
|
|
27
|
+
struct ipc_mem_handle_info {
|
|
28
|
+
char key[kIpcKeyLen];
|
|
29
|
+
ssize_t nbytes;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
std::optional<torch::Tensor> import_ipc_tensor(py::bytes data) {
|
|
33
|
+
ipc_mem_handle_info info;
|
|
34
|
+
void *ptr = nullptr;
|
|
35
|
+
{
|
|
36
|
+
const char *buffer = PYBIND11_BYTES_AS_STRING(data.ptr());
|
|
37
|
+
py::ssize_t size = PYBIND11_BYTES_SIZE(data.ptr());
|
|
38
|
+
TORCH_CHECK_EQ((size_t)size, sizeof(info));
|
|
39
|
+
memcpy(&info, buffer, sizeof(info));
|
|
40
|
+
TORCH_CHECK_GT(info.nbytes, 0);
|
|
41
|
+
}
|
|
42
|
+
// Ascend 上 kernel 需要直接跨卡访问 IPC 导入的内存(CP>1 fan-out),
|
|
43
|
+
// 必须用 ENABLE_PEER_ACCESS,否则导入在跨进程/跨卡时直接失败(507899)。
|
|
44
|
+
aclError ret = aclrtIpcMemImportByKey(&ptr, info.key, ACL_RT_IPC_MEM_IMPORT_FLAG_ENABLE_PEER_ACCESS);
|
|
45
|
+
if (ret == ACL_SUCCESS && ptr != nullptr) {
|
|
46
|
+
LOG_INFO("imported NPU IPC handle of size {} at {}", info.nbytes, ptr);
|
|
47
|
+
auto deleter = [key = std::string(info.key, strnlen(info.key, kIpcKeyLen))](void *ptr) { close_npu_ipc_handle(ptr, key); };
|
|
48
|
+
return {make_from_blob(
|
|
49
|
+
ptr, {(int64_t)info.nbytes}, deleter, at::TensorOptions().device(c10::DeviceType::PrivateUse1).dtype(torch::kByte))};
|
|
50
|
+
} else {
|
|
51
|
+
LOG_ERROR("failed to import NPU IPC handle of size {}: aclError={}", info.nbytes, ret);
|
|
52
|
+
return std::nullopt;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
py::bytes export_ipc_tensor(size_t ptr, ssize_t nbytes) {
|
|
57
|
+
// ACL 要求被导出的地址 2MB 对齐,否则 aclrtIpcMemGetExportKey 返回
|
|
58
|
+
// ACL_ERROR_RT_DRV_INTERNAL_ERROR(507899),且不区分大小写仅看地址。
|
|
59
|
+
// 生产环境 KV cache 均为大块分配,天然对齐;这里显式校验以便快速定位。
|
|
60
|
+
TORCH_CHECK(ptr % (2 * 1024 * 1024) == 0, "NPU IPC export requires a 2MB-aligned address, got ", (void *)ptr);
|
|
61
|
+
ipc_mem_handle_info info = {};
|
|
62
|
+
info.nbytes = nbytes;
|
|
63
|
+
// 默认 export 带 PID 白名单校验,跨进程 import 直接失败(507899)。
|
|
64
|
+
aclError ret = aclrtIpcMemGetExportKey((void *)ptr, nbytes, info.key, kIpcKeyLen, ACL_RT_IPC_MEM_EXPORT_FLAG_DISABLE_PID_VALIDATION);
|
|
65
|
+
if (ret == ACL_SUCCESS) {
|
|
66
|
+
LOG_INFO("exported NPU IPC handle at {} with {} bytes", (void *)ptr, nbytes);
|
|
67
|
+
return {py::bytes((char *)&info, sizeof(info))};
|
|
68
|
+
} else {
|
|
69
|
+
LOG_ERROR("failed to export NPU IPC handle at {}: aclError={}", (void *)ptr, ret);
|
|
70
|
+
TORCH_CHECK(false, "failed to export NPU IPC handle");
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
static void free_npu_memory(void *ptr) {
|
|
75
|
+
aclError ret = aclrtFree(ptr);
|
|
76
|
+
if (ret == ACL_SUCCESS) {
|
|
77
|
+
LOG_INFO("aclrtFree: freed NPU memory at {}", ptr);
|
|
78
|
+
} else {
|
|
79
|
+
LOG_ERROR("aclrtFree: failed to free NPU memory at {}: aclError={}", ptr, ret);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
static size_t round_up_page_size(size_t sz) {
|
|
84
|
+
const size_t page_size = 4096;
|
|
85
|
+
return (sz + page_size - 1) / page_size * page_size;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
std::optional<torch::Tensor> alloc_tensor(ssize_t size) {
|
|
89
|
+
void *ptr = nullptr;
|
|
90
|
+
aclError ret = aclrtMalloc(&ptr, round_up_page_size(size), ACL_MEM_MALLOC_HUGE_FIRST);
|
|
91
|
+
if (ret == ACL_SUCCESS && ptr != nullptr) {
|
|
92
|
+
LOG_INFO("aclrtMalloc: allocated NPU memory of size {} at {}", size, ptr);
|
|
93
|
+
return {make_from_blob(
|
|
94
|
+
ptr, {(int64_t)size}, free_npu_memory, at::TensorOptions().device(c10::DeviceType::PrivateUse1).dtype(torch::kByte))};
|
|
95
|
+
} else {
|
|
96
|
+
LOG_ERROR("aclrtMalloc: failed to allocate NPU memory of size {}: aclError={}", size, ret);
|
|
97
|
+
return std::nullopt;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
void cuda_copy_async(void *dst, void *src, size_t size, uint64_t stream) {
|
|
102
|
+
auto result = aclrtMemcpyAsync(dst, size, src, size, ACL_MEMCPY_DEVICE_TO_DEVICE, reinterpret_cast<aclrtStream>(stream));
|
|
103
|
+
TORCH_CHECK(result == ACL_SUCCESS, "aclrtMemcpyAsync failed: ", result);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
uint64_t get_current_stream() { return reinterpret_cast<uint64_t>(c10_npu::getCurrentNPUStream().stream()); }
|
|
107
|
+
|
|
108
|
+
void pymodule_init(pybind11::module &m) {
|
|
109
|
+
m.def("alloc_tensor", &deepinfer::cuda::utils::alloc_tensor, "Allocate a 1D byte tensor on NPU.", py::arg("size"))
|
|
110
|
+
.def("export_ipc_tensor", &deepinfer::cuda::utils::export_ipc_tensor, "Export NPU IPC memory handle.", py::arg("ptr"),
|
|
111
|
+
py::arg("nbytes"))
|
|
112
|
+
.def("import_ipc_tensor", &deepinfer::cuda::utils::import_ipc_tensor, "Import NPU IPC memory handle as a tensor.", py::arg("data"));
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
} // namespace deepinfer::cuda::utils
|