vllm-cpu-avx512vnni 0.10.2.post2__cp312-cp312-manylinux_2_17_x86_64.whl

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.

Potentially problematic release.


This version of vllm-cpu-avx512vnni might be problematic. Click here for more details.

Files changed (1395) hide show
  1. vllm/_C.abi3.so +0 -0
  2. vllm/__init__.py +220 -0
  3. vllm/_bc_linter.py +59 -0
  4. vllm/_custom_ops.py +2022 -0
  5. vllm/_ipex_ops.py +404 -0
  6. vllm/_version.py +34 -0
  7. vllm/adapter_commons/__init__.py +0 -0
  8. vllm/adapter_commons/layers.py +16 -0
  9. vllm/adapter_commons/models.py +106 -0
  10. vllm/adapter_commons/request.py +26 -0
  11. vllm/adapter_commons/utils.py +93 -0
  12. vllm/adapter_commons/worker_manager.py +39 -0
  13. vllm/assets/__init__.py +0 -0
  14. vllm/assets/audio.py +45 -0
  15. vllm/assets/base.py +41 -0
  16. vllm/assets/image.py +50 -0
  17. vllm/assets/video.py +138 -0
  18. vllm/attention/__init__.py +19 -0
  19. vllm/attention/backends/__init__.py +0 -0
  20. vllm/attention/backends/abstract.py +348 -0
  21. vllm/attention/backends/differential_flash_attn.py +935 -0
  22. vllm/attention/backends/dual_chunk_flash_attn.py +1499 -0
  23. vllm/attention/backends/flash_attn.py +933 -0
  24. vllm/attention/backends/flashmla.py +238 -0
  25. vllm/attention/backends/mla/__init__.py +0 -0
  26. vllm/attention/backends/mla/common.py +1310 -0
  27. vllm/attention/backends/placeholder_attn.py +340 -0
  28. vllm/attention/backends/rocm_aiter_mla.py +410 -0
  29. vllm/attention/backends/rocm_flash_attn.py +953 -0
  30. vllm/attention/backends/triton_mla.py +111 -0
  31. vllm/attention/backends/utils.py +610 -0
  32. vllm/attention/backends/xformers.py +805 -0
  33. vllm/attention/layer.py +552 -0
  34. vllm/attention/layers/__init__.py +0 -0
  35. vllm/attention/layers/chunked_local_attention.py +91 -0
  36. vllm/attention/layers/cross_attention.py +159 -0
  37. vllm/attention/layers/encoder_only_attention.py +86 -0
  38. vllm/attention/ops/__init__.py +0 -0
  39. vllm/attention/ops/chunked_prefill_paged_decode.py +405 -0
  40. vllm/attention/ops/common.py +139 -0
  41. vllm/attention/ops/flashmla.py +123 -0
  42. vllm/attention/ops/merge_attn_states.py +43 -0
  43. vllm/attention/ops/paged_attn.py +261 -0
  44. vllm/attention/ops/pallas_kv_cache_update.py +124 -0
  45. vllm/attention/ops/prefix_prefill.py +928 -0
  46. vllm/attention/ops/rocm_aiter_mla.py +104 -0
  47. vllm/attention/ops/rocm_aiter_paged_attn.py +102 -0
  48. vllm/attention/ops/triton_decode_attention.py +676 -0
  49. vllm/attention/ops/triton_flash_attention.py +984 -0
  50. vllm/attention/ops/triton_merge_attn_states.py +97 -0
  51. vllm/attention/ops/triton_unified_attention.py +854 -0
  52. vllm/attention/selector.py +243 -0
  53. vllm/attention/utils/__init__.py +0 -0
  54. vllm/attention/utils/fa_utils.py +85 -0
  55. vllm/attention/utils/kv_sharing_utils.py +33 -0
  56. vllm/beam_search.py +87 -0
  57. vllm/benchmarks/__init__.py +0 -0
  58. vllm/benchmarks/datasets.py +2651 -0
  59. vllm/benchmarks/latency.py +170 -0
  60. vllm/benchmarks/lib/__init__.py +3 -0
  61. vllm/benchmarks/lib/endpoint_request_func.py +510 -0
  62. vllm/benchmarks/lib/ready_checker.py +72 -0
  63. vllm/benchmarks/lib/utils.py +80 -0
  64. vllm/benchmarks/serve.py +1247 -0
  65. vllm/benchmarks/throughput.py +696 -0
  66. vllm/collect_env.py +823 -0
  67. vllm/compilation/__init__.py +0 -0
  68. vllm/compilation/activation_quant_fusion.py +193 -0
  69. vllm/compilation/backends.py +641 -0
  70. vllm/compilation/base_static_graph.py +51 -0
  71. vllm/compilation/collective_fusion.py +1190 -0
  72. vllm/compilation/compiler_interface.py +572 -0
  73. vllm/compilation/counter.py +47 -0
  74. vllm/compilation/cuda_graph.py +193 -0
  75. vllm/compilation/cuda_piecewise_backend.py +117 -0
  76. vllm/compilation/decorators.py +316 -0
  77. vllm/compilation/fix_functionalization.py +208 -0
  78. vllm/compilation/fusion.py +600 -0
  79. vllm/compilation/fusion_attn.py +303 -0
  80. vllm/compilation/fx_utils.py +84 -0
  81. vllm/compilation/inductor_pass.py +136 -0
  82. vllm/compilation/monitor.py +57 -0
  83. vllm/compilation/multi_output_match.py +109 -0
  84. vllm/compilation/noop_elimination.py +165 -0
  85. vllm/compilation/pass_manager.py +88 -0
  86. vllm/compilation/sequence_parallelism.py +484 -0
  87. vllm/compilation/torch25_custom_graph_pass.py +42 -0
  88. vllm/compilation/vllm_inductor_pass.py +50 -0
  89. vllm/compilation/wrapper.py +138 -0
  90. vllm/config/__init__.py +3921 -0
  91. vllm/config/cache.py +214 -0
  92. vllm/config/compilation.py +580 -0
  93. vllm/config/kv_events.py +50 -0
  94. vllm/config/kv_transfer.py +111 -0
  95. vllm/config/load.py +113 -0
  96. vllm/config/lora.py +132 -0
  97. vllm/config/parallel.py +446 -0
  98. vllm/config/scheduler.py +304 -0
  99. vllm/config/utils.py +29 -0
  100. vllm/connections.py +174 -0
  101. vllm/core/__init__.py +0 -0
  102. vllm/core/block/__init__.py +0 -0
  103. vllm/core/block/block_table.py +399 -0
  104. vllm/core/block/common.py +371 -0
  105. vllm/core/block/cpu_gpu_block_allocator.py +439 -0
  106. vllm/core/block/interfaces.py +319 -0
  107. vllm/core/block/naive_block.py +466 -0
  108. vllm/core/block/prefix_caching_block.py +1135 -0
  109. vllm/core/block/utils.py +28 -0
  110. vllm/core/block_manager.py +523 -0
  111. vllm/core/evictor.py +157 -0
  112. vllm/core/interfaces.py +139 -0
  113. vllm/core/placeholder_block_space_manager.py +103 -0
  114. vllm/core/scheduler.py +2028 -0
  115. vllm/device_allocator/__init__.py +0 -0
  116. vllm/device_allocator/cumem.py +286 -0
  117. vllm/distributed/__init__.py +6 -0
  118. vllm/distributed/communication_op.py +41 -0
  119. vllm/distributed/device_communicators/__init__.py +0 -0
  120. vllm/distributed/device_communicators/all2all.py +259 -0
  121. vllm/distributed/device_communicators/all_reduce_utils.py +292 -0
  122. vllm/distributed/device_communicators/base_device_communicator.py +277 -0
  123. vllm/distributed/device_communicators/cpu_communicator.py +201 -0
  124. vllm/distributed/device_communicators/cuda_communicator.py +294 -0
  125. vllm/distributed/device_communicators/cuda_wrapper.py +180 -0
  126. vllm/distributed/device_communicators/custom_all_reduce.py +311 -0
  127. vllm/distributed/device_communicators/pynccl.py +290 -0
  128. vllm/distributed/device_communicators/pynccl_wrapper.py +382 -0
  129. vllm/distributed/device_communicators/quick_all_reduce.py +278 -0
  130. vllm/distributed/device_communicators/ray_communicator.py +258 -0
  131. vllm/distributed/device_communicators/shm_broadcast.py +585 -0
  132. vllm/distributed/device_communicators/symm_mem.py +136 -0
  133. vllm/distributed/device_communicators/tpu_communicator.py +102 -0
  134. vllm/distributed/device_communicators/xpu_communicator.py +69 -0
  135. vllm/distributed/eplb/__init__.py +8 -0
  136. vllm/distributed/eplb/eplb_state.py +619 -0
  137. vllm/distributed/eplb/rebalance_algo.py +234 -0
  138. vllm/distributed/eplb/rebalance_execute.py +424 -0
  139. vllm/distributed/kv_events.py +362 -0
  140. vllm/distributed/kv_transfer/README.md +29 -0
  141. vllm/distributed/kv_transfer/__init__.py +13 -0
  142. vllm/distributed/kv_transfer/disagg_prefill_workflow.jpg +0 -0
  143. vllm/distributed/kv_transfer/kv_connector/__init__.py +0 -0
  144. vllm/distributed/kv_transfer/kv_connector/base.py +10 -0
  145. vllm/distributed/kv_transfer/kv_connector/factory.py +108 -0
  146. vllm/distributed/kv_transfer/kv_connector/utils.py +246 -0
  147. vllm/distributed/kv_transfer/kv_connector/v1/__init__.py +6 -0
  148. vllm/distributed/kv_transfer/kv_connector/v1/base.py +356 -0
  149. vllm/distributed/kv_transfer/kv_connector/v1/lmcache_connector.py +167 -0
  150. vllm/distributed/kv_transfer/kv_connector/v1/multi_connector.py +266 -0
  151. vllm/distributed/kv_transfer/kv_connector/v1/nixl_connector.py +1319 -0
  152. vllm/distributed/kv_transfer/kv_connector/v1/p2p/__init__.py +0 -0
  153. vllm/distributed/kv_transfer/kv_connector/v1/p2p/p2p_nccl_connector.py +484 -0
  154. vllm/distributed/kv_transfer/kv_connector/v1/p2p/p2p_nccl_engine.py +542 -0
  155. vllm/distributed/kv_transfer/kv_connector/v1/p2p/tensor_memory_pool.py +266 -0
  156. vllm/distributed/kv_transfer/kv_connector/v1/shared_storage_connector.py +414 -0
  157. vllm/distributed/kv_transfer/kv_lookup_buffer/__init__.py +0 -0
  158. vllm/distributed/kv_transfer/kv_lookup_buffer/base.py +175 -0
  159. vllm/distributed/kv_transfer/kv_lookup_buffer/mooncake_store.py +161 -0
  160. vllm/distributed/kv_transfer/kv_lookup_buffer/simple_buffer.py +237 -0
  161. vllm/distributed/kv_transfer/kv_pipe/__init__.py +0 -0
  162. vllm/distributed/kv_transfer/kv_pipe/base.py +67 -0
  163. vllm/distributed/kv_transfer/kv_pipe/mooncake_pipe.py +290 -0
  164. vllm/distributed/kv_transfer/kv_pipe/pynccl_pipe.py +280 -0
  165. vllm/distributed/kv_transfer/kv_transfer_state.py +73 -0
  166. vllm/distributed/parallel_state.py +1489 -0
  167. vllm/distributed/tpu_distributed_utils.py +178 -0
  168. vllm/distributed/utils.py +536 -0
  169. vllm/engine/__init__.py +0 -0
  170. vllm/engine/arg_utils.py +1857 -0
  171. vllm/engine/async_llm_engine.py +1044 -0
  172. vllm/engine/async_timeout.py +173 -0
  173. vllm/engine/llm_engine.py +1849 -0
  174. vllm/engine/metrics.py +577 -0
  175. vllm/engine/metrics_types.py +84 -0
  176. vllm/engine/multiprocessing/__init__.py +145 -0
  177. vllm/engine/multiprocessing/client.py +643 -0
  178. vllm/engine/multiprocessing/engine.py +470 -0
  179. vllm/engine/output_processor/__init__.py +0 -0
  180. vllm/engine/output_processor/interfaces.py +61 -0
  181. vllm/engine/output_processor/single_step.py +145 -0
  182. vllm/engine/output_processor/stop_checker.py +131 -0
  183. vllm/engine/output_processor/util.py +28 -0
  184. vllm/engine/protocol.py +343 -0
  185. vllm/entrypoints/__init__.py +0 -0
  186. vllm/entrypoints/api_server.py +178 -0
  187. vllm/entrypoints/chat_utils.py +1535 -0
  188. vllm/entrypoints/cli/__init__.py +12 -0
  189. vllm/entrypoints/cli/benchmark/__init__.py +0 -0
  190. vllm/entrypoints/cli/benchmark/base.py +25 -0
  191. vllm/entrypoints/cli/benchmark/latency.py +21 -0
  192. vllm/entrypoints/cli/benchmark/main.py +58 -0
  193. vllm/entrypoints/cli/benchmark/serve.py +21 -0
  194. vllm/entrypoints/cli/benchmark/throughput.py +21 -0
  195. vllm/entrypoints/cli/collect_env.py +36 -0
  196. vllm/entrypoints/cli/main.py +60 -0
  197. vllm/entrypoints/cli/openai.py +214 -0
  198. vllm/entrypoints/cli/run_batch.py +69 -0
  199. vllm/entrypoints/cli/serve.py +232 -0
  200. vllm/entrypoints/cli/types.py +29 -0
  201. vllm/entrypoints/constants.py +10 -0
  202. vllm/entrypoints/context.py +444 -0
  203. vllm/entrypoints/harmony_utils.py +431 -0
  204. vllm/entrypoints/launcher.py +168 -0
  205. vllm/entrypoints/llm.py +1579 -0
  206. vllm/entrypoints/logger.py +79 -0
  207. vllm/entrypoints/openai/__init__.py +0 -0
  208. vllm/entrypoints/openai/api_server.py +2011 -0
  209. vllm/entrypoints/openai/cli_args.py +281 -0
  210. vllm/entrypoints/openai/logits_processors.py +90 -0
  211. vllm/entrypoints/openai/protocol.py +2590 -0
  212. vllm/entrypoints/openai/run_batch.py +497 -0
  213. vllm/entrypoints/openai/serving_chat.py +1591 -0
  214. vllm/entrypoints/openai/serving_classification.py +176 -0
  215. vllm/entrypoints/openai/serving_completion.py +688 -0
  216. vllm/entrypoints/openai/serving_embedding.py +632 -0
  217. vllm/entrypoints/openai/serving_engine.py +996 -0
  218. vllm/entrypoints/openai/serving_models.py +288 -0
  219. vllm/entrypoints/openai/serving_pooling.py +277 -0
  220. vllm/entrypoints/openai/serving_responses.py +1690 -0
  221. vllm/entrypoints/openai/serving_score.py +479 -0
  222. vllm/entrypoints/openai/serving_tokenization.py +196 -0
  223. vllm/entrypoints/openai/serving_transcription.py +136 -0
  224. vllm/entrypoints/openai/speech_to_text.py +388 -0
  225. vllm/entrypoints/openai/tool_parsers/__init__.py +51 -0
  226. vllm/entrypoints/openai/tool_parsers/abstract_tool_parser.py +164 -0
  227. vllm/entrypoints/openai/tool_parsers/deepseekv31_tool_parser.py +367 -0
  228. vllm/entrypoints/openai/tool_parsers/deepseekv3_tool_parser.py +370 -0
  229. vllm/entrypoints/openai/tool_parsers/glm4_moe_tool_parser.py +185 -0
  230. vllm/entrypoints/openai/tool_parsers/granite_20b_fc_tool_parser.py +259 -0
  231. vllm/entrypoints/openai/tool_parsers/granite_tool_parser.py +237 -0
  232. vllm/entrypoints/openai/tool_parsers/hermes_tool_parser.py +418 -0
  233. vllm/entrypoints/openai/tool_parsers/hunyuan_a13b_tool_parser.py +372 -0
  234. vllm/entrypoints/openai/tool_parsers/internlm2_tool_parser.py +216 -0
  235. vllm/entrypoints/openai/tool_parsers/jamba_tool_parser.py +308 -0
  236. vllm/entrypoints/openai/tool_parsers/kimi_k2_tool_parser.py +377 -0
  237. vllm/entrypoints/openai/tool_parsers/llama4_pythonic_tool_parser.py +316 -0
  238. vllm/entrypoints/openai/tool_parsers/llama_tool_parser.py +269 -0
  239. vllm/entrypoints/openai/tool_parsers/minimax_tool_parser.py +816 -0
  240. vllm/entrypoints/openai/tool_parsers/mistral_tool_parser.py +369 -0
  241. vllm/entrypoints/openai/tool_parsers/openai_tool_parser.py +73 -0
  242. vllm/entrypoints/openai/tool_parsers/phi4mini_tool_parser.py +112 -0
  243. vllm/entrypoints/openai/tool_parsers/pythonic_tool_parser.py +308 -0
  244. vllm/entrypoints/openai/tool_parsers/qwen3coder_tool_parser.py +707 -0
  245. vllm/entrypoints/openai/tool_parsers/seed_oss_tool_parser.py +679 -0
  246. vllm/entrypoints/openai/tool_parsers/step3_tool_parser.py +296 -0
  247. vllm/entrypoints/openai/tool_parsers/utils.py +124 -0
  248. vllm/entrypoints/openai/tool_parsers/xlam_tool_parser.py +524 -0
  249. vllm/entrypoints/renderer.py +395 -0
  250. vllm/entrypoints/score_utils.py +232 -0
  251. vllm/entrypoints/ssl.py +75 -0
  252. vllm/entrypoints/tool.py +139 -0
  253. vllm/entrypoints/tool_server.py +195 -0
  254. vllm/entrypoints/utils.py +328 -0
  255. vllm/env_override.py +23 -0
  256. vllm/envs.py +1354 -0
  257. vllm/executor/__init__.py +0 -0
  258. vllm/executor/executor_base.py +378 -0
  259. vllm/executor/mp_distributed_executor.py +244 -0
  260. vllm/executor/msgspec_utils.py +35 -0
  261. vllm/executor/multiproc_worker_utils.py +279 -0
  262. vllm/executor/ray_distributed_executor.py +699 -0
  263. vllm/executor/ray_utils.py +410 -0
  264. vllm/executor/uniproc_executor.py +152 -0
  265. vllm/forward_context.py +273 -0
  266. vllm/inputs/__init__.py +44 -0
  267. vllm/inputs/data.py +356 -0
  268. vllm/inputs/parse.py +151 -0
  269. vllm/inputs/preprocess.py +973 -0
  270. vllm/inputs/registry.py +251 -0
  271. vllm/logger.py +229 -0
  272. vllm/logging_utils/__init__.py +8 -0
  273. vllm/logging_utils/dump_input.py +81 -0
  274. vllm/logging_utils/formatter.py +79 -0
  275. vllm/logits_process.py +119 -0
  276. vllm/logprobs.py +28 -0
  277. vllm/lora/__init__.py +0 -0
  278. vllm/lora/layers/__init__.py +34 -0
  279. vllm/lora/layers/base.py +69 -0
  280. vllm/lora/layers/base_linear.py +184 -0
  281. vllm/lora/layers/column_parallel_linear.py +622 -0
  282. vllm/lora/layers/logits_processor.py +247 -0
  283. vllm/lora/layers/qkv_x_parallel_linear.py +8 -0
  284. vllm/lora/layers/replicated_linear.py +61 -0
  285. vllm/lora/layers/row_parallel_linear.py +201 -0
  286. vllm/lora/layers/utils.py +60 -0
  287. vllm/lora/layers/vocal_parallel_embedding.py +172 -0
  288. vllm/lora/lora.py +199 -0
  289. vllm/lora/models.py +792 -0
  290. vllm/lora/ops/__init__.py +0 -0
  291. vllm/lora/ops/ipex_ops/__init__.py +7 -0
  292. vllm/lora/ops/ipex_ops/lora_ops.py +44 -0
  293. vllm/lora/ops/torch_ops/__init__.py +16 -0
  294. vllm/lora/ops/torch_ops/lora_ops.py +119 -0
  295. vllm/lora/ops/triton_ops/__init__.py +12 -0
  296. vllm/lora/ops/triton_ops/kernel_utils.py +243 -0
  297. vllm/lora/ops/triton_ops/lora_expand_op.py +291 -0
  298. vllm/lora/ops/triton_ops/lora_kernel_metadata.py +148 -0
  299. vllm/lora/ops/triton_ops/lora_shrink_op.py +245 -0
  300. vllm/lora/ops/triton_ops/utils.py +126 -0
  301. vllm/lora/ops/xla_ops/__init__.py +7 -0
  302. vllm/lora/ops/xla_ops/lora_ops.py +145 -0
  303. vllm/lora/peft_helper.py +127 -0
  304. vllm/lora/punica_wrapper/__init__.py +10 -0
  305. vllm/lora/punica_wrapper/punica_base.py +458 -0
  306. vllm/lora/punica_wrapper/punica_cpu.py +349 -0
  307. vllm/lora/punica_wrapper/punica_gpu.py +279 -0
  308. vllm/lora/punica_wrapper/punica_selector.py +20 -0
  309. vllm/lora/punica_wrapper/punica_tpu.py +391 -0
  310. vllm/lora/punica_wrapper/punica_xpu.py +276 -0
  311. vllm/lora/punica_wrapper/utils.py +136 -0
  312. vllm/lora/request.py +99 -0
  313. vllm/lora/resolver.py +85 -0
  314. vllm/lora/utils.py +246 -0
  315. vllm/lora/worker_manager.py +256 -0
  316. vllm/model_executor/__init__.py +16 -0
  317. vllm/model_executor/custom_op.py +194 -0
  318. vllm/model_executor/layers/__init__.py +0 -0
  319. vllm/model_executor/layers/activation.py +575 -0
  320. vllm/model_executor/layers/attention_layer_base.py +23 -0
  321. vllm/model_executor/layers/fla/__init__.py +8 -0
  322. vllm/model_executor/layers/fla/ops/__init__.py +17 -0
  323. vllm/model_executor/layers/fla/ops/chunk.py +225 -0
  324. vllm/model_executor/layers/fla/ops/chunk_delta_h.py +290 -0
  325. vllm/model_executor/layers/fla/ops/chunk_o.py +177 -0
  326. vllm/model_executor/layers/fla/ops/chunk_scaled_dot_kkt.py +140 -0
  327. vllm/model_executor/layers/fla/ops/cumsum.py +226 -0
  328. vllm/model_executor/layers/fla/ops/fused_recurrent.py +366 -0
  329. vllm/model_executor/layers/fla/ops/index.py +39 -0
  330. vllm/model_executor/layers/fla/ops/l2norm.py +143 -0
  331. vllm/model_executor/layers/fla/ops/layernorm_guard.py +337 -0
  332. vllm/model_executor/layers/fla/ops/op.py +39 -0
  333. vllm/model_executor/layers/fla/ops/solve_tril.py +365 -0
  334. vllm/model_executor/layers/fla/ops/utils.py +180 -0
  335. vllm/model_executor/layers/fla/ops/wy_fast.py +114 -0
  336. vllm/model_executor/layers/fused_moe/__init__.py +80 -0
  337. vllm/model_executor/layers/fused_moe/batched_deep_gemm_moe.py +304 -0
  338. vllm/model_executor/layers/fused_moe/batched_triton_or_deep_gemm_moe.py +164 -0
  339. vllm/model_executor/layers/fused_moe/config.py +497 -0
  340. vllm/model_executor/layers/fused_moe/configs/E=1,N=14336,device_name=NVIDIA_A100-SXM4-80GB,dtype=int8_w8a16.json +146 -0
  341. vllm/model_executor/layers/fused_moe/configs/E=1,N=14336,device_name=NVIDIA_A100-SXM4-80GB.json +146 -0
  342. vllm/model_executor/layers/fused_moe/configs/E=1,N=1792,device_name=NVIDIA_A100-SXM4-80GB,dtype=int8_w8a16.json +218 -0
  343. vllm/model_executor/layers/fused_moe/configs/E=1,N=1792,device_name=NVIDIA_A100-SXM4-80GB.json +218 -0
  344. vllm/model_executor/layers/fused_moe/configs/E=1,N=3072,device_name=NVIDIA_A100-SXM4-80GB,dtype=int8_w8a16.json +218 -0
  345. vllm/model_executor/layers/fused_moe/configs/E=1,N=3072,device_name=NVIDIA_H100_80GB_HBM3,dtype=int8_w8a16.json +218 -0
  346. vllm/model_executor/layers/fused_moe/configs/E=1,N=3072,device_name=NVIDIA_H100_80GB_HBM3.json +218 -0
  347. vllm/model_executor/layers/fused_moe/configs/E=1,N=3584,device_name=NVIDIA_A100-SXM4-80GB,dtype=int8_w8a16.json +218 -0
  348. vllm/model_executor/layers/fused_moe/configs/E=1,N=3584,device_name=NVIDIA_A100-SXM4-80GB.json +218 -0
  349. vllm/model_executor/layers/fused_moe/configs/E=1,N=7168,device_name=NVIDIA_A100-SXM4-80GB,dtype=int8_w8a16.json +218 -0
  350. vllm/model_executor/layers/fused_moe/configs/E=1,N=7168,device_name=NVIDIA_A100-SXM4-80GB.json +218 -0
  351. vllm/model_executor/layers/fused_moe/configs/E=128,N=1024,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8.json +164 -0
  352. vllm/model_executor/layers/fused_moe/configs/E=128,N=1024,device_name=AMD_Instinct_MI300X.json +200 -0
  353. vllm/model_executor/layers/fused_moe/configs/E=128,N=192,device_name=NVIDIA_A100-SXM4-80GB.json +146 -0
  354. vllm/model_executor/layers/fused_moe/configs/E=128,N=192,device_name=NVIDIA_H100_80GB_HBM3.json +146 -0
  355. vllm/model_executor/layers/fused_moe/configs/E=128,N=192,device_name=NVIDIA_H20-3e.json +146 -0
  356. vllm/model_executor/layers/fused_moe/configs/E=128,N=192,device_name=NVIDIA_H20.json +146 -0
  357. vllm/model_executor/layers/fused_moe/configs/E=128,N=192,device_name=NVIDIA_H200.json +146 -0
  358. vllm/model_executor/layers/fused_moe/configs/E=128,N=352,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8.json +122 -0
  359. vllm/model_executor/layers/fused_moe/configs/E=128,N=384,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  360. vllm/model_executor/layers/fused_moe/configs/E=128,N=384,device_name=NVIDIA_B200,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  361. vllm/model_executor/layers/fused_moe/configs/E=128,N=384,device_name=NVIDIA_GB200,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  362. vllm/model_executor/layers/fused_moe/configs/E=128,N=384,device_name=NVIDIA_H20,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  363. vllm/model_executor/layers/fused_moe/configs/E=128,N=384,device_name=NVIDIA_H20-3e,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  364. vllm/model_executor/layers/fused_moe/configs/E=128,N=384,device_name=NVIDIA_H20-3e.json +146 -0
  365. vllm/model_executor/layers/fused_moe/configs/E=128,N=384,device_name=NVIDIA_H20.json +146 -0
  366. vllm/model_executor/layers/fused_moe/configs/E=128,N=384,device_name=NVIDIA_H200,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  367. vllm/model_executor/layers/fused_moe/configs/E=128,N=384,device_name=NVIDIA_H200.json +146 -0
  368. vllm/model_executor/layers/fused_moe/configs/E=128,N=512,device_name=NVIDIA_H100_80GB_HBM3.json +146 -0
  369. vllm/model_executor/layers/fused_moe/configs/E=128,N=704,device_name=NVIDIA_B200,dtype=fp8_w8a8.json +146 -0
  370. vllm/model_executor/layers/fused_moe/configs/E=128,N=704,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8.json +114 -0
  371. vllm/model_executor/layers/fused_moe/configs/E=128,N=768,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  372. vllm/model_executor/layers/fused_moe/configs/E=128,N=768,device_name=NVIDIA_B200,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  373. vllm/model_executor/layers/fused_moe/configs/E=128,N=768,device_name=NVIDIA_GB200,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  374. vllm/model_executor/layers/fused_moe/configs/E=128,N=768,device_name=NVIDIA_H20,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  375. vllm/model_executor/layers/fused_moe/configs/E=128,N=768,device_name=NVIDIA_H20-3e,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  376. vllm/model_executor/layers/fused_moe/configs/E=128,N=768,device_name=NVIDIA_H20.json +146 -0
  377. vllm/model_executor/layers/fused_moe/configs/E=128,N=768,device_name=NVIDIA_H200,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  378. vllm/model_executor/layers/fused_moe/configs/E=128,N=768,device_name=NVIDIA_H200.json +146 -0
  379. vllm/model_executor/layers/fused_moe/configs/E=128,N=96,device_name=NVIDIA_H20.json +146 -0
  380. vllm/model_executor/layers/fused_moe/configs/E=16,N=1024,device_name=AMD_Instinct_MI300X.json +200 -0
  381. vllm/model_executor/layers/fused_moe/configs/E=16,N=1024,device_name=NVIDIA_B200,dtype=fp8_w8a8.json +147 -0
  382. vllm/model_executor/layers/fused_moe/configs/E=16,N=1024,device_name=NVIDIA_B200.json +146 -0
  383. vllm/model_executor/layers/fused_moe/configs/E=16,N=1024,device_name=NVIDIA_H100.json +146 -0
  384. vllm/model_executor/layers/fused_moe/configs/E=16,N=1344,device_name=NVIDIA_A100-SXM4-40GB.json +146 -0
  385. vllm/model_executor/layers/fused_moe/configs/E=16,N=1344,device_name=NVIDIA_A100-SXM4-80GB.json +146 -0
  386. vllm/model_executor/layers/fused_moe/configs/E=16,N=1344,device_name=NVIDIA_H100_80GB_HBM3.json +146 -0
  387. vllm/model_executor/layers/fused_moe/configs/E=16,N=14336,device_name=NVIDIA_A100-SXM4-80GB,dtype=int8_w8a16.json +146 -0
  388. vllm/model_executor/layers/fused_moe/configs/E=16,N=14336,device_name=NVIDIA_A100-SXM4-80GB.json +146 -0
  389. vllm/model_executor/layers/fused_moe/configs/E=16,N=1792,device_name=NVIDIA_A100-SXM4-80GB,dtype=int8_w8a16.json +218 -0
  390. vllm/model_executor/layers/fused_moe/configs/E=16,N=1792,device_name=NVIDIA_A100-SXM4-80GB.json +218 -0
  391. vllm/model_executor/layers/fused_moe/configs/E=16,N=2688,device_name=NVIDIA_A100-SXM4-80GB.json +146 -0
  392. vllm/model_executor/layers/fused_moe/configs/E=16,N=2688,device_name=NVIDIA_H100_80GB_HBM3.json +146 -0
  393. vllm/model_executor/layers/fused_moe/configs/E=16,N=3072,device_name=NVIDIA_A100-SXM4-80GB,dtype=int8_w8a16.json +146 -0
  394. vllm/model_executor/layers/fused_moe/configs/E=16,N=3072,device_name=NVIDIA_H100_80GB_HBM3,dtype=int8_w8a16.json +146 -0
  395. vllm/model_executor/layers/fused_moe/configs/E=16,N=3200,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8.json +130 -0
  396. vllm/model_executor/layers/fused_moe/configs/E=16,N=3584,device_name=NVIDIA_A100-SXM4-80GB,dtype=int8_w8a16.json +146 -0
  397. vllm/model_executor/layers/fused_moe/configs/E=16,N=3584,device_name=NVIDIA_A100-SXM4-80GB.json +218 -0
  398. vllm/model_executor/layers/fused_moe/configs/E=16,N=6400,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8.json +130 -0
  399. vllm/model_executor/layers/fused_moe/configs/E=16,N=7168,device_name=NVIDIA_A100-SXM4-80GB,dtype=int8_w8a16.json +146 -0
  400. vllm/model_executor/layers/fused_moe/configs/E=16,N=7168,device_name=NVIDIA_A100-SXM4-80GB.json +146 -0
  401. vllm/model_executor/layers/fused_moe/configs/E=16,N=7168,device_name=NVIDIA_H100_80GB_HBM3,dtype=int8_w8a16.json +146 -0
  402. vllm/model_executor/layers/fused_moe/configs/E=16,N=800,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8.json +130 -0
  403. vllm/model_executor/layers/fused_moe/configs/E=160,N=192,device_name=NVIDIA_A800-SXM4-80GB.json +146 -0
  404. vllm/model_executor/layers/fused_moe/configs/E=160,N=192,device_name=NVIDIA_H20-3e.json +146 -0
  405. vllm/model_executor/layers/fused_moe/configs/E=160,N=320,device_name=NVIDIA_H20-3e.json +146 -0
  406. vllm/model_executor/layers/fused_moe/configs/E=160,N=640,device_name=NVIDIA_B200,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  407. vllm/model_executor/layers/fused_moe/configs/E=160,N=640,device_name=NVIDIA_GB200,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  408. vllm/model_executor/layers/fused_moe/configs/E=160,N=640,device_name=NVIDIA_H100,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  409. vllm/model_executor/layers/fused_moe/configs/E=20,N=2560,device_name=NVIDIA_B200,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  410. vllm/model_executor/layers/fused_moe/configs/E=20,N=2560,device_name=NVIDIA_GB200,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  411. vllm/model_executor/layers/fused_moe/configs/E=20,N=2560,device_name=NVIDIA_H100,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  412. vllm/model_executor/layers/fused_moe/configs/E=20,N=2560,device_name=NVIDIA_H20-3e,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  413. vllm/model_executor/layers/fused_moe/configs/E=256,N=1024,device_name=AMD_Instinct_MI325X,block_shape=[128,128].json +200 -0
  414. vllm/model_executor/layers/fused_moe/configs/E=256,N=1024,device_name=AMD_Instinct_MI325_OAM,dtype=fp8_w8a8,block_shape=[128,128].json +200 -0
  415. vllm/model_executor/layers/fused_moe/configs/E=256,N=128,device_name=NVIDIA_A100-SXM4-80GB,dtype=int8_w8a8,block_shape=[128,128].json +146 -0
  416. vllm/model_executor/layers/fused_moe/configs/E=256,N=128,device_name=NVIDIA_A100-SXM4-80GB,dtype=int8_w8a8.json +146 -0
  417. vllm/model_executor/layers/fused_moe/configs/E=256,N=128,device_name=NVIDIA_A800-SXM4-80GB,dtype=int8_w8a8,block_shape=[128,128].json +146 -0
  418. vllm/model_executor/layers/fused_moe/configs/E=256,N=128,device_name=NVIDIA_A800-SXM4-80GB,dtype=int8_w8a8.json +146 -0
  419. vllm/model_executor/layers/fused_moe/configs/E=256,N=128,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  420. vllm/model_executor/layers/fused_moe/configs/E=256,N=128,device_name=NVIDIA_H20,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  421. vllm/model_executor/layers/fused_moe/configs/E=256,N=128,device_name=NVIDIA_L20Y,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  422. vllm/model_executor/layers/fused_moe/configs/E=256,N=256,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  423. vllm/model_executor/layers/fused_moe/configs/E=256,N=256,device_name=AMD_Instinct_MI325X,dtype=fp8_w8a8,block_shape=[128,128].json +200 -0
  424. vllm/model_executor/layers/fused_moe/configs/E=256,N=256,device_name=AMD_Instinct_MI325_OAM,dtype=fp8_w8a8,block_shape=[128,128].json +200 -0
  425. vllm/model_executor/layers/fused_moe/configs/E=256,N=256,device_name=NVIDIA_B200,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  426. vllm/model_executor/layers/fused_moe/configs/E=256,N=256,device_name=NVIDIA_H20,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  427. vllm/model_executor/layers/fused_moe/configs/E=256,N=256,device_name=NVIDIA_H20,dtype=int8_w8a8,block_shape=[128,128].json +146 -0
  428. vllm/model_executor/layers/fused_moe/configs/E=256,N=256,device_name=NVIDIA_H20-3e,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  429. vllm/model_executor/layers/fused_moe/configs/E=256,N=256,device_name=NVIDIA_H200,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  430. vllm/model_executor/layers/fused_moe/configs/E=256,N=256,device_name=NVIDIA_L20,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  431. vllm/model_executor/layers/fused_moe/configs/E=256,N=512,device_name=AMD_Instinct_MI325_OAM,dtype=fp8_w8a8,block_shape=[128,128].json +200 -0
  432. vllm/model_executor/layers/fused_moe/configs/E=256,N=512,device_name=NVIDIA_H100_80GB_HBM3.json +146 -0
  433. vllm/model_executor/layers/fused_moe/configs/E=256,N=64,device_name=NVIDIA_A800-SXM4-80GB.json +146 -0
  434. vllm/model_executor/layers/fused_moe/configs/E=384,N=128,device_name=NVIDIA_B200,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  435. vllm/model_executor/layers/fused_moe/configs/E=384,N=128,device_name=NVIDIA_GB200,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  436. vllm/model_executor/layers/fused_moe/configs/E=384,N=128,device_name=NVIDIA_H200,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  437. vllm/model_executor/layers/fused_moe/configs/E=384,N=256,device_name=NVIDIA_B200,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  438. vllm/model_executor/layers/fused_moe/configs/E=384,N=256,device_name=NVIDIA_GB200,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  439. vllm/model_executor/layers/fused_moe/configs/E=40,N=2560,device_name=NVIDIA_B200,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  440. vllm/model_executor/layers/fused_moe/configs/E=40,N=2560,device_name=NVIDIA_GB200,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  441. vllm/model_executor/layers/fused_moe/configs/E=40,N=2560,device_name=NVIDIA_H100,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  442. vllm/model_executor/layers/fused_moe/configs/E=512,N=128,device_name=NVIDIA_B200.json +146 -0
  443. vllm/model_executor/layers/fused_moe/configs/E=512,N=128,device_name=NVIDIA_H100_80GB_HBM3.json +146 -0
  444. vllm/model_executor/layers/fused_moe/configs/E=512,N=128,device_name=NVIDIA_H20-3e.json +146 -0
  445. vllm/model_executor/layers/fused_moe/configs/E=512,N=128,device_name=NVIDIA_H200.json +146 -0
  446. vllm/model_executor/layers/fused_moe/configs/E=512,N=256,device_name=NVIDIA_B200.json +146 -0
  447. vllm/model_executor/layers/fused_moe/configs/E=512,N=256,device_name=NVIDIA_H100_80GB_HBM3.json +146 -0
  448. vllm/model_executor/layers/fused_moe/configs/E=512,N=256,device_name=NVIDIA_H20-3e.json +146 -0
  449. vllm/model_executor/layers/fused_moe/configs/E=512,N=256,device_name=NVIDIA_H200.json +146 -0
  450. vllm/model_executor/layers/fused_moe/configs/E=512,N=512,device_name=NVIDIA_B200.json +146 -0
  451. vllm/model_executor/layers/fused_moe/configs/E=512,N=512,device_name=NVIDIA_H100_80GB_HBM3.json +146 -0
  452. vllm/model_executor/layers/fused_moe/configs/E=512,N=512,device_name=NVIDIA_H20-3e.json +146 -0
  453. vllm/model_executor/layers/fused_moe/configs/E=512,N=512,device_name=NVIDIA_H200.json +146 -0
  454. vllm/model_executor/layers/fused_moe/configs/E=512,N=64,device_name=NVIDIA_B200.json +146 -0
  455. vllm/model_executor/layers/fused_moe/configs/E=512,N=64,device_name=NVIDIA_H20-3e.json +146 -0
  456. vllm/model_executor/layers/fused_moe/configs/E=512,N=64,device_name=NVIDIA_H200.json +146 -0
  457. vllm/model_executor/layers/fused_moe/configs/E=60,N=1408,device_name=AMD_Instinct_MI300X.json +200 -0
  458. vllm/model_executor/layers/fused_moe/configs/E=60,N=176,device_name=AMD_Instinct_MI300X.json +200 -0
  459. vllm/model_executor/layers/fused_moe/configs/E=60,N=352,device_name=AMD_Instinct_MI300X.json +200 -0
  460. vllm/model_executor/layers/fused_moe/configs/E=60,N=704,device_name=AMD_Instinct_MI300X.json +200 -0
  461. vllm/model_executor/layers/fused_moe/configs/E=62,N=256,device_name=NVIDIA_H100_80GB_HBM3.json +146 -0
  462. vllm/model_executor/layers/fused_moe/configs/E=62,N=512,device_name=NVIDIA_H100_80GB_HBM3.json +146 -0
  463. vllm/model_executor/layers/fused_moe/configs/E=64,N=1280,device_name=NVIDIA_A100-SXM4-80GB.json +146 -0
  464. vllm/model_executor/layers/fused_moe/configs/E=64,N=1280,device_name=NVIDIA_A800-SXM4-80GB.json +146 -0
  465. vllm/model_executor/layers/fused_moe/configs/E=64,N=1280,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8.json +146 -0
  466. vllm/model_executor/layers/fused_moe/configs/E=64,N=1280,device_name=NVIDIA_H100_80GB_HBM3.json +146 -0
  467. vllm/model_executor/layers/fused_moe/configs/E=64,N=1280,device_name=NVIDIA_H200,dtype=fp8_w8a8.json +146 -0
  468. vllm/model_executor/layers/fused_moe/configs/E=64,N=1280,device_name=NVIDIA_H200.json +146 -0
  469. vllm/model_executor/layers/fused_moe/configs/E=64,N=1536,device_name=NVIDIA_H20,dtype=fp8_w8a8.json +146 -0
  470. vllm/model_executor/layers/fused_moe/configs/E=64,N=2560,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8.json +146 -0
  471. vllm/model_executor/layers/fused_moe/configs/E=64,N=2560,device_name=NVIDIA_H200,dtype=fp8_w8a8.json +146 -0
  472. vllm/model_executor/layers/fused_moe/configs/E=64,N=2560,device_name=NVIDIA_H200.json +146 -0
  473. vllm/model_executor/layers/fused_moe/configs/E=64,N=3072,device_name=NVIDIA_H20,dtype=fp8_w8a8.json +146 -0
  474. vllm/model_executor/layers/fused_moe/configs/E=64,N=3072,device_name=NVIDIA_H20.json +146 -0
  475. vllm/model_executor/layers/fused_moe/configs/E=64,N=320,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8.json +146 -0
  476. vllm/model_executor/layers/fused_moe/configs/E=64,N=320,device_name=NVIDIA_H100_80GB_HBM3.json +146 -0
  477. vllm/model_executor/layers/fused_moe/configs/E=64,N=320,device_name=NVIDIA_H200,dtype=fp8_w8a8.json +146 -0
  478. vllm/model_executor/layers/fused_moe/configs/E=64,N=320,device_name=NVIDIA_H200.json +146 -0
  479. vllm/model_executor/layers/fused_moe/configs/E=64,N=384,device_name=NVIDIA_H20,dtype=fp8_w8a8.json +146 -0
  480. vllm/model_executor/layers/fused_moe/configs/E=64,N=384,device_name=NVIDIA_H20.json +146 -0
  481. vllm/model_executor/layers/fused_moe/configs/E=64,N=640,device_name=NVIDIA_A100-SXM4-80GB.json +146 -0
  482. vllm/model_executor/layers/fused_moe/configs/E=64,N=640,device_name=NVIDIA_A800-SXM4-80GB.json +146 -0
  483. vllm/model_executor/layers/fused_moe/configs/E=64,N=640,device_name=NVIDIA_GeForce_RTX_4090,dtype=fp8_w8a8.json +146 -0
  484. vllm/model_executor/layers/fused_moe/configs/E=64,N=640,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8.json +146 -0
  485. vllm/model_executor/layers/fused_moe/configs/E=64,N=640,device_name=NVIDIA_H100_80GB_HBM3.json +146 -0
  486. vllm/model_executor/layers/fused_moe/configs/E=64,N=640,device_name=NVIDIA_H200,dtype=fp8_w8a8.json +146 -0
  487. vllm/model_executor/layers/fused_moe/configs/E=64,N=640,device_name=NVIDIA_H200.json +146 -0
  488. vllm/model_executor/layers/fused_moe/configs/E=64,N=768,device_name=NVIDIA_H20,dtype=fp8_w8a8.json +146 -0
  489. vllm/model_executor/layers/fused_moe/configs/E=64,N=768,device_name=NVIDIA_H20.json +146 -0
  490. vllm/model_executor/layers/fused_moe/configs/E=64,N=896,device_name=NVIDIA_H20.json +146 -0
  491. vllm/model_executor/layers/fused_moe/configs/E=72,N=384,device_name=NVIDIA_H100_80GB_HBM3.json +146 -0
  492. vllm/model_executor/layers/fused_moe/configs/E=72,N=768,device_name=NVIDIA_H100_80GB_HBM3.json +146 -0
  493. vllm/model_executor/layers/fused_moe/configs/E=8,N=14336,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8.json +164 -0
  494. vllm/model_executor/layers/fused_moe/configs/E=8,N=14336,device_name=AMD_Instinct_MI300X.json +200 -0
  495. vllm/model_executor/layers/fused_moe/configs/E=8,N=14336,device_name=AMD_Instinct_MI325X,dtype=fp8_w8a8.json +164 -0
  496. vllm/model_executor/layers/fused_moe/configs/E=8,N=14336,device_name=AMD_Instinct_MI325X.json +200 -0
  497. vllm/model_executor/layers/fused_moe/configs/E=8,N=14336,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8.json +138 -0
  498. vllm/model_executor/layers/fused_moe/configs/E=8,N=14336,device_name=NVIDIA_H200,dtype=fp8_w8a8.json +146 -0
  499. vllm/model_executor/layers/fused_moe/configs/E=8,N=14336,device_name=NVIDIA_H200.json +146 -0
  500. vllm/model_executor/layers/fused_moe/configs/E=8,N=16384,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8.json +164 -0
  501. vllm/model_executor/layers/fused_moe/configs/E=8,N=16384,device_name=AMD_Instinct_MI300X.json +200 -0
  502. vllm/model_executor/layers/fused_moe/configs/E=8,N=16384,device_name=AMD_Instinct_MI325X,dtype=fp8_w8a8.json +164 -0
  503. vllm/model_executor/layers/fused_moe/configs/E=8,N=16384,device_name=AMD_Instinct_MI325X.json +200 -0
  504. vllm/model_executor/layers/fused_moe/configs/E=8,N=1792,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8.json +164 -0
  505. vllm/model_executor/layers/fused_moe/configs/E=8,N=1792,device_name=AMD_Instinct_MI300X.json +200 -0
  506. vllm/model_executor/layers/fused_moe/configs/E=8,N=1792,device_name=AMD_Instinct_MI325X,dtype=fp8_w8a8.json +164 -0
  507. vllm/model_executor/layers/fused_moe/configs/E=8,N=1792,device_name=AMD_Instinct_MI325X.json +200 -0
  508. vllm/model_executor/layers/fused_moe/configs/E=8,N=1792,device_name=NVIDIA_A100-SXM4-40GB.json +146 -0
  509. vllm/model_executor/layers/fused_moe/configs/E=8,N=1792,device_name=NVIDIA_A100-SXM4-80GB.json +146 -0
  510. vllm/model_executor/layers/fused_moe/configs/E=8,N=1792,device_name=NVIDIA_H100_80GB_HBM3.json +146 -0
  511. vllm/model_executor/layers/fused_moe/configs/E=8,N=1792,device_name=NVIDIA_H200,dtype=fp8_w8a8.json +146 -0
  512. vllm/model_executor/layers/fused_moe/configs/E=8,N=1792,device_name=NVIDIA_H200.json +146 -0
  513. vllm/model_executor/layers/fused_moe/configs/E=8,N=2048,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8.json +164 -0
  514. vllm/model_executor/layers/fused_moe/configs/E=8,N=2048,device_name=AMD_Instinct_MI300X.json +200 -0
  515. vllm/model_executor/layers/fused_moe/configs/E=8,N=2048,device_name=AMD_Instinct_MI325X,dtype=fp8_w8a8.json +164 -0
  516. vllm/model_executor/layers/fused_moe/configs/E=8,N=2048,device_name=AMD_Instinct_MI325X.json +200 -0
  517. vllm/model_executor/layers/fused_moe/configs/E=8,N=2048,device_name=NVIDIA_A100-SXM4-80GB.json +146 -0
  518. vllm/model_executor/layers/fused_moe/configs/E=8,N=2048,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8.json +146 -0
  519. vllm/model_executor/layers/fused_moe/configs/E=8,N=2048,device_name=NVIDIA_H100_80GB_HBM3.json +146 -0
  520. vllm/model_executor/layers/fused_moe/configs/E=8,N=2048,device_name=NVIDIA_H200,dtype=fp8_w8a8,block_shape=[128,128].json +154 -0
  521. vllm/model_executor/layers/fused_moe/configs/E=8,N=2048,device_name=NVIDIA_H200,dtype=fp8_w8a8.json +146 -0
  522. vllm/model_executor/layers/fused_moe/configs/E=8,N=2048,device_name=NVIDIA_H200.json +146 -0
  523. vllm/model_executor/layers/fused_moe/configs/E=8,N=3584,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8.json +164 -0
  524. vllm/model_executor/layers/fused_moe/configs/E=8,N=3584,device_name=AMD_Instinct_MI300X.json +200 -0
  525. vllm/model_executor/layers/fused_moe/configs/E=8,N=3584,device_name=AMD_Instinct_MI325X,dtype=fp8_w8a8.json +164 -0
  526. vllm/model_executor/layers/fused_moe/configs/E=8,N=3584,device_name=AMD_Instinct_MI325X.json +200 -0
  527. vllm/model_executor/layers/fused_moe/configs/E=8,N=3584,device_name=NVIDIA_A100-SXM4-40GB.json +146 -0
  528. vllm/model_executor/layers/fused_moe/configs/E=8,N=3584,device_name=NVIDIA_A100-SXM4-80GB.json +146 -0
  529. vllm/model_executor/layers/fused_moe/configs/E=8,N=3584,device_name=NVIDIA_GeForce_RTX_4090,dtype=fp8_w8a8.json +146 -0
  530. vllm/model_executor/layers/fused_moe/configs/E=8,N=3584,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8.json +146 -0
  531. vllm/model_executor/layers/fused_moe/configs/E=8,N=3584,device_name=NVIDIA_H100_80GB_HBM3.json +146 -0
  532. vllm/model_executor/layers/fused_moe/configs/E=8,N=3584,device_name=NVIDIA_H200,dtype=fp8_w8a8.json +146 -0
  533. vllm/model_executor/layers/fused_moe/configs/E=8,N=3584,device_name=NVIDIA_H200.json +146 -0
  534. vllm/model_executor/layers/fused_moe/configs/E=8,N=3584,device_name=NVIDIA_L40S.json +173 -0
  535. vllm/model_executor/layers/fused_moe/configs/E=8,N=4096,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8.json +164 -0
  536. vllm/model_executor/layers/fused_moe/configs/E=8,N=4096,device_name=AMD_Instinct_MI300X.json +200 -0
  537. vllm/model_executor/layers/fused_moe/configs/E=8,N=4096,device_name=AMD_Instinct_MI325X,dtype=fp8_w8a8.json +164 -0
  538. vllm/model_executor/layers/fused_moe/configs/E=8,N=4096,device_name=AMD_Instinct_MI325X.json +200 -0
  539. vllm/model_executor/layers/fused_moe/configs/E=8,N=4096,device_name=NVIDIA_A100-SXM4-80GB.json +146 -0
  540. vllm/model_executor/layers/fused_moe/configs/E=8,N=4096,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8.json +146 -0
  541. vllm/model_executor/layers/fused_moe/configs/E=8,N=4096,device_name=NVIDIA_H100_80GB_HBM3.json +146 -0
  542. vllm/model_executor/layers/fused_moe/configs/E=8,N=4096,device_name=NVIDIA_H200,dtype=fp8_w8a8.json +146 -0
  543. vllm/model_executor/layers/fused_moe/configs/E=8,N=4096,device_name=NVIDIA_H200.json +146 -0
  544. vllm/model_executor/layers/fused_moe/configs/E=8,N=7168,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8.json +164 -0
  545. vllm/model_executor/layers/fused_moe/configs/E=8,N=7168,device_name=AMD_Instinct_MI300X.json +200 -0
  546. vllm/model_executor/layers/fused_moe/configs/E=8,N=7168,device_name=AMD_Instinct_MI325X,dtype=fp8_w8a8.json +164 -0
  547. vllm/model_executor/layers/fused_moe/configs/E=8,N=7168,device_name=AMD_Instinct_MI325X.json +200 -0
  548. vllm/model_executor/layers/fused_moe/configs/E=8,N=7168,device_name=NVIDIA_A100-SXM4-80GB.json +146 -0
  549. vllm/model_executor/layers/fused_moe/configs/E=8,N=7168,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8.json +146 -0
  550. vllm/model_executor/layers/fused_moe/configs/E=8,N=7168,device_name=NVIDIA_H100_80GB_HBM3.json +146 -0
  551. vllm/model_executor/layers/fused_moe/configs/E=8,N=7168,device_name=NVIDIA_H200,dtype=fp8_w8a8.json +146 -0
  552. vllm/model_executor/layers/fused_moe/configs/E=8,N=7168,device_name=NVIDIA_H200.json +146 -0
  553. vllm/model_executor/layers/fused_moe/configs/E=8,N=8192,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8.json +164 -0
  554. vllm/model_executor/layers/fused_moe/configs/E=8,N=8192,device_name=AMD_Instinct_MI300X.json +200 -0
  555. vllm/model_executor/layers/fused_moe/configs/E=8,N=8192,device_name=AMD_Instinct_MI325X,dtype=fp8_w8a8.json +164 -0
  556. vllm/model_executor/layers/fused_moe/configs/E=8,N=8192,device_name=AMD_Instinct_MI325X.json +200 -0
  557. vllm/model_executor/layers/fused_moe/configs/E=8,N=8192,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8.json +146 -0
  558. vllm/model_executor/layers/fused_moe/configs/E=8,N=8192,device_name=NVIDIA_H200,dtype=fp8_w8a8.json +146 -0
  559. vllm/model_executor/layers/fused_moe/configs/README +12 -0
  560. vllm/model_executor/layers/fused_moe/cpu_fused_moe.py +297 -0
  561. vllm/model_executor/layers/fused_moe/cutlass_moe.py +996 -0
  562. vllm/model_executor/layers/fused_moe/deep_gemm_moe.py +370 -0
  563. vllm/model_executor/layers/fused_moe/deep_gemm_utils.py +413 -0
  564. vllm/model_executor/layers/fused_moe/deepep_ht_prepare_finalize.py +280 -0
  565. vllm/model_executor/layers/fused_moe/deepep_ll_prepare_finalize.py +229 -0
  566. vllm/model_executor/layers/fused_moe/flashinfer_cutlass_moe.py +243 -0
  567. vllm/model_executor/layers/fused_moe/flashinfer_cutlass_prepare_finalize.py +97 -0
  568. vllm/model_executor/layers/fused_moe/fused_batched_moe.py +1042 -0
  569. vllm/model_executor/layers/fused_moe/fused_marlin_moe.py +240 -0
  570. vllm/model_executor/layers/fused_moe/fused_moe.py +2081 -0
  571. vllm/model_executor/layers/fused_moe/gpt_oss_triton_kernels_moe.py +247 -0
  572. vllm/model_executor/layers/fused_moe/layer.py +1951 -0
  573. vllm/model_executor/layers/fused_moe/modular_kernel.py +892 -0
  574. vllm/model_executor/layers/fused_moe/moe_align_block_size.py +87 -0
  575. vllm/model_executor/layers/fused_moe/moe_pallas.py +80 -0
  576. vllm/model_executor/layers/fused_moe/moe_permute_unpermute.py +205 -0
  577. vllm/model_executor/layers/fused_moe/moe_torch_iterative.py +60 -0
  578. vllm/model_executor/layers/fused_moe/pplx_prepare_finalize.py +321 -0
  579. vllm/model_executor/layers/fused_moe/prepare_finalize.py +72 -0
  580. vllm/model_executor/layers/fused_moe/rocm_aiter_fused_moe.py +431 -0
  581. vllm/model_executor/layers/fused_moe/routing_simulator.py +291 -0
  582. vllm/model_executor/layers/fused_moe/topk_weight_and_reduce.py +146 -0
  583. vllm/model_executor/layers/fused_moe/triton_deep_gemm_moe.py +171 -0
  584. vllm/model_executor/layers/fused_moe/trtllm_moe.py +197 -0
  585. vllm/model_executor/layers/fused_moe/utils.py +270 -0
  586. vllm/model_executor/layers/layernorm.py +381 -0
  587. vllm/model_executor/layers/lightning_attn.py +661 -0
  588. vllm/model_executor/layers/linear.py +1567 -0
  589. vllm/model_executor/layers/logits_processor.py +199 -0
  590. vllm/model_executor/layers/mamba/__init__.py +0 -0
  591. vllm/model_executor/layers/mamba/abstract.py +45 -0
  592. vllm/model_executor/layers/mamba/linear_attn.py +432 -0
  593. vllm/model_executor/layers/mamba/mamba2_metadata.py +186 -0
  594. vllm/model_executor/layers/mamba/mamba_mixer.py +517 -0
  595. vllm/model_executor/layers/mamba/mamba_mixer2.py +803 -0
  596. vllm/model_executor/layers/mamba/mamba_utils.py +202 -0
  597. vllm/model_executor/layers/mamba/ops/__init__.py +0 -0
  598. vllm/model_executor/layers/mamba/ops/causal_conv1d.py +982 -0
  599. vllm/model_executor/layers/mamba/ops/layernorm_gated.py +168 -0
  600. vllm/model_executor/layers/mamba/ops/mamba_ssm.py +414 -0
  601. vllm/model_executor/layers/mamba/ops/ssd_bmm.py +262 -0
  602. vllm/model_executor/layers/mamba/ops/ssd_chunk_scan.py +574 -0
  603. vllm/model_executor/layers/mamba/ops/ssd_chunk_state.py +751 -0
  604. vllm/model_executor/layers/mamba/ops/ssd_combined.py +248 -0
  605. vllm/model_executor/layers/mamba/ops/ssd_state_passing.py +248 -0
  606. vllm/model_executor/layers/mamba/short_conv.py +270 -0
  607. vllm/model_executor/layers/mla.py +158 -0
  608. vllm/model_executor/layers/pooler.py +732 -0
  609. vllm/model_executor/layers/quantization/__init__.py +157 -0
  610. vllm/model_executor/layers/quantization/auto_round.py +388 -0
  611. vllm/model_executor/layers/quantization/awq.py +228 -0
  612. vllm/model_executor/layers/quantization/awq_marlin.py +548 -0
  613. vllm/model_executor/layers/quantization/awq_triton.py +320 -0
  614. vllm/model_executor/layers/quantization/base_config.py +164 -0
  615. vllm/model_executor/layers/quantization/bitblas.py +464 -0
  616. vllm/model_executor/layers/quantization/bitsandbytes.py +621 -0
  617. vllm/model_executor/layers/quantization/compressed_tensors/__init__.py +0 -0
  618. vllm/model_executor/layers/quantization/compressed_tensors/compressed_tensors.py +795 -0
  619. vllm/model_executor/layers/quantization/compressed_tensors/compressed_tensors_moe.py +1651 -0
  620. vllm/model_executor/layers/quantization/compressed_tensors/schemes/__init__.py +27 -0
  621. vllm/model_executor/layers/quantization/compressed_tensors/schemes/compressed_tensors_24.py +366 -0
  622. vllm/model_executor/layers/quantization/compressed_tensors/schemes/compressed_tensors_scheme.py +55 -0
  623. vllm/model_executor/layers/quantization/compressed_tensors/schemes/compressed_tensors_w4a16_24.py +160 -0
  624. vllm/model_executor/layers/quantization/compressed_tensors/schemes/compressed_tensors_w4a16_nvfp4.py +105 -0
  625. vllm/model_executor/layers/quantization/compressed_tensors/schemes/compressed_tensors_w4a4_nvfp4.py +161 -0
  626. vllm/model_executor/layers/quantization/compressed_tensors/schemes/compressed_tensors_w4a8_fp8.py +169 -0
  627. vllm/model_executor/layers/quantization/compressed_tensors/schemes/compressed_tensors_w4a8_int.py +135 -0
  628. vllm/model_executor/layers/quantization/compressed_tensors/schemes/compressed_tensors_w8a16_fp8.py +121 -0
  629. vllm/model_executor/layers/quantization/compressed_tensors/schemes/compressed_tensors_w8a8_fp8.py +156 -0
  630. vllm/model_executor/layers/quantization/compressed_tensors/schemes/compressed_tensors_w8a8_int8.py +111 -0
  631. vllm/model_executor/layers/quantization/compressed_tensors/schemes/compressed_tensors_wNa16.py +201 -0
  632. vllm/model_executor/layers/quantization/compressed_tensors/transform/linear.py +227 -0
  633. vllm/model_executor/layers/quantization/compressed_tensors/transform/module.py +135 -0
  634. vllm/model_executor/layers/quantization/compressed_tensors/transform/schemes/linear_qutlass_nvfp4.py +21 -0
  635. vllm/model_executor/layers/quantization/compressed_tensors/transform/utils.py +13 -0
  636. vllm/model_executor/layers/quantization/compressed_tensors/triton_scaled_mm.py +206 -0
  637. vllm/model_executor/layers/quantization/compressed_tensors/utils.py +216 -0
  638. vllm/model_executor/layers/quantization/deepgemm.py +81 -0
  639. vllm/model_executor/layers/quantization/deepspeedfp.py +196 -0
  640. vllm/model_executor/layers/quantization/experts_int8.py +215 -0
  641. vllm/model_executor/layers/quantization/fbgemm_fp8.py +172 -0
  642. vllm/model_executor/layers/quantization/fp8.py +1179 -0
  643. vllm/model_executor/layers/quantization/gguf.py +597 -0
  644. vllm/model_executor/layers/quantization/gptq.py +300 -0
  645. vllm/model_executor/layers/quantization/gptq_bitblas.py +448 -0
  646. vllm/model_executor/layers/quantization/gptq_marlin.py +700 -0
  647. vllm/model_executor/layers/quantization/gptq_marlin_24.py +297 -0
  648. vllm/model_executor/layers/quantization/hqq_marlin.py +333 -0
  649. vllm/model_executor/layers/quantization/inc.py +61 -0
  650. vllm/model_executor/layers/quantization/input_quant_fp8.py +103 -0
  651. vllm/model_executor/layers/quantization/ipex_quant.py +410 -0
  652. vllm/model_executor/layers/quantization/kernels/__init__.py +0 -0
  653. vllm/model_executor/layers/quantization/kernels/mixed_precision/MPLinearKernel.py +91 -0
  654. vllm/model_executor/layers/quantization/kernels/mixed_precision/__init__.py +93 -0
  655. vllm/model_executor/layers/quantization/kernels/mixed_precision/allspark.py +116 -0
  656. vllm/model_executor/layers/quantization/kernels/mixed_precision/bitblas.py +302 -0
  657. vllm/model_executor/layers/quantization/kernels/mixed_precision/conch.py +92 -0
  658. vllm/model_executor/layers/quantization/kernels/mixed_precision/cutlass.py +117 -0
  659. vllm/model_executor/layers/quantization/kernels/mixed_precision/dynamic_4bit.py +92 -0
  660. vllm/model_executor/layers/quantization/kernels/mixed_precision/exllama.py +143 -0
  661. vllm/model_executor/layers/quantization/kernels/mixed_precision/machete.py +144 -0
  662. vllm/model_executor/layers/quantization/kernels/mixed_precision/marlin.py +139 -0
  663. vllm/model_executor/layers/quantization/kernels/scaled_mm/ScaledMMLinearKernel.py +67 -0
  664. vllm/model_executor/layers/quantization/kernels/scaled_mm/__init__.py +89 -0
  665. vllm/model_executor/layers/quantization/kernels/scaled_mm/aiter.py +163 -0
  666. vllm/model_executor/layers/quantization/kernels/scaled_mm/cpu.py +206 -0
  667. vllm/model_executor/layers/quantization/kernels/scaled_mm/cutlass.py +137 -0
  668. vllm/model_executor/layers/quantization/kernels/scaled_mm/triton.py +41 -0
  669. vllm/model_executor/layers/quantization/kernels/scaled_mm/xla.py +104 -0
  670. vllm/model_executor/layers/quantization/kv_cache.py +139 -0
  671. vllm/model_executor/layers/quantization/modelopt.py +1548 -0
  672. vllm/model_executor/layers/quantization/moe_wna16.py +473 -0
  673. vllm/model_executor/layers/quantization/mxfp4.py +951 -0
  674. vllm/model_executor/layers/quantization/petit.py +306 -0
  675. vllm/model_executor/layers/quantization/ptpc_fp8.py +129 -0
  676. vllm/model_executor/layers/quantization/quark/__init__.py +0 -0
  677. vllm/model_executor/layers/quantization/quark/quark.py +431 -0
  678. vllm/model_executor/layers/quantization/quark/quark_moe.py +434 -0
  679. vllm/model_executor/layers/quantization/quark/schemes/__init__.py +9 -0
  680. vllm/model_executor/layers/quantization/quark/schemes/quark_scheme.py +55 -0
  681. vllm/model_executor/layers/quantization/quark/schemes/quark_w4a4_mxfp4.py +112 -0
  682. vllm/model_executor/layers/quantization/quark/schemes/quark_w8a8_fp8.py +163 -0
  683. vllm/model_executor/layers/quantization/quark/schemes/quark_w8a8_int8.py +122 -0
  684. vllm/model_executor/layers/quantization/quark/utils.py +105 -0
  685. vllm/model_executor/layers/quantization/rtn.py +456 -0
  686. vllm/model_executor/layers/quantization/schema.py +86 -0
  687. vllm/model_executor/layers/quantization/torchao.py +214 -0
  688. vllm/model_executor/layers/quantization/tpu_int8.py +125 -0
  689. vllm/model_executor/layers/quantization/utils/__init__.py +6 -0
  690. vllm/model_executor/layers/quantization/utils/allspark_utils.py +52 -0
  691. vllm/model_executor/layers/quantization/utils/bitblas_utils.py +210 -0
  692. vllm/model_executor/layers/quantization/utils/configs/N=12288,K=7168,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  693. vllm/model_executor/layers/quantization/utils/configs/N=12288,K=7168,device_name=NVIDIA_H200,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  694. vllm/model_executor/layers/quantization/utils/configs/N=1536,K=1536,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  695. vllm/model_executor/layers/quantization/utils/configs/N=1536,K=1536,device_name=AMD_Instinct_MI325X,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  696. vllm/model_executor/layers/quantization/utils/configs/N=1536,K=1536,device_name=AMD_Instinct_MI325_OAM,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  697. vllm/model_executor/layers/quantization/utils/configs/N=1536,K=1536,device_name=NVIDIA_A100-SXM4-80GB,dtype=int8_w8a8,block_shape=[128,128].json +146 -0
  698. vllm/model_executor/layers/quantization/utils/configs/N=1536,K=1536,device_name=NVIDIA_A800-SXM4-80GB,dtype=int8_w8a8,block_shape=[128,128].json +146 -0
  699. vllm/model_executor/layers/quantization/utils/configs/N=1536,K=1536,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  700. vllm/model_executor/layers/quantization/utils/configs/N=1536,K=1536,device_name=NVIDIA_H20,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  701. vllm/model_executor/layers/quantization/utils/configs/N=1536,K=1536,device_name=NVIDIA_L20Y,dtype=fp8_w8a8,block_shape=[128,128].json +26 -0
  702. vllm/model_executor/layers/quantization/utils/configs/N=1536,K=7168,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  703. vllm/model_executor/layers/quantization/utils/configs/N=1536,K=7168,device_name=AMD_Instinct_MI325X,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  704. vllm/model_executor/layers/quantization/utils/configs/N=1536,K=7168,device_name=AMD_Instinct_MI325_OAM,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  705. vllm/model_executor/layers/quantization/utils/configs/N=1536,K=7168,device_name=NVIDIA_A100-SXM4-80GB,dtype=int8_w8a8,block_shape=[128,128].json +146 -0
  706. vllm/model_executor/layers/quantization/utils/configs/N=1536,K=7168,device_name=NVIDIA_A800-SXM4-80GB,dtype=int8_w8a8,block_shape=[128,128].json +146 -0
  707. vllm/model_executor/layers/quantization/utils/configs/N=1536,K=7168,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  708. vllm/model_executor/layers/quantization/utils/configs/N=1536,K=7168,device_name=NVIDIA_H20,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  709. vllm/model_executor/layers/quantization/utils/configs/N=1536,K=7168,device_name=NVIDIA_H200,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  710. vllm/model_executor/layers/quantization/utils/configs/N=1536,K=7168,device_name=NVIDIA_L20,dtype=fp8_w8a8,block_shape=[128,128].json +26 -0
  711. vllm/model_executor/layers/quantization/utils/configs/N=1536,K=7168,device_name=NVIDIA_L20Y,dtype=fp8_w8a8,block_shape=[128,128].json +26 -0
  712. vllm/model_executor/layers/quantization/utils/configs/N=2048,K=512,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  713. vllm/model_executor/layers/quantization/utils/configs/N=2048,K=512,device_name=AMD_Instinct_MI325X,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  714. vllm/model_executor/layers/quantization/utils/configs/N=2048,K=512,device_name=AMD_Instinct_MI325_OAM,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  715. vllm/model_executor/layers/quantization/utils/configs/N=2048,K=512,device_name=NVIDIA_A100-SXM4-80GB,dtype=int8_w8a8,block_shape=[128,128].json +146 -0
  716. vllm/model_executor/layers/quantization/utils/configs/N=2048,K=512,device_name=NVIDIA_A800-SXM4-80GB,dtype=int8_w8a8,block_shape=[128,128].json +146 -0
  717. vllm/model_executor/layers/quantization/utils/configs/N=2048,K=512,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  718. vllm/model_executor/layers/quantization/utils/configs/N=2048,K=512,device_name=NVIDIA_H20,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  719. vllm/model_executor/layers/quantization/utils/configs/N=2048,K=512,device_name=NVIDIA_H200,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  720. vllm/model_executor/layers/quantization/utils/configs/N=2048,K=512,device_name=NVIDIA_L20Y,dtype=fp8_w8a8,block_shape=[128,128].json +26 -0
  721. vllm/model_executor/layers/quantization/utils/configs/N=2112,K=7168,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  722. vllm/model_executor/layers/quantization/utils/configs/N=2112,K=7168,device_name=NVIDIA_H200,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  723. vllm/model_executor/layers/quantization/utils/configs/N=2304,K=7168,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  724. vllm/model_executor/layers/quantization/utils/configs/N=2304,K=7168,device_name=AMD_Instinct_MI325X,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  725. vllm/model_executor/layers/quantization/utils/configs/N=2304,K=7168,device_name=AMD_Instinct_MI325_OAM,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  726. vllm/model_executor/layers/quantization/utils/configs/N=2304,K=7168,device_name=NVIDIA_A100-SXM4-80GB,dtype=int8_w8a8,block_shape=[128,128].json +146 -0
  727. vllm/model_executor/layers/quantization/utils/configs/N=2304,K=7168,device_name=NVIDIA_A800-SXM4-80GB,dtype=int8_w8a8,block_shape=[128,128].json +146 -0
  728. vllm/model_executor/layers/quantization/utils/configs/N=2304,K=7168,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  729. vllm/model_executor/layers/quantization/utils/configs/N=2304,K=7168,device_name=NVIDIA_H20,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  730. vllm/model_executor/layers/quantization/utils/configs/N=2304,K=7168,device_name=NVIDIA_H200,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  731. vllm/model_executor/layers/quantization/utils/configs/N=2304,K=7168,device_name=NVIDIA_L20Y,dtype=fp8_w8a8,block_shape=[128,128].json +26 -0
  732. vllm/model_executor/layers/quantization/utils/configs/N=24576,K=1536,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  733. vllm/model_executor/layers/quantization/utils/configs/N=24576,K=1536,device_name=NVIDIA_H200,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  734. vllm/model_executor/layers/quantization/utils/configs/N=24576,K=7168,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  735. vllm/model_executor/layers/quantization/utils/configs/N=24576,K=7168,device_name=AMD_Instinct_MI325X,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  736. vllm/model_executor/layers/quantization/utils/configs/N=24576,K=7168,device_name=AMD_Instinct_MI325_OAM,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  737. vllm/model_executor/layers/quantization/utils/configs/N=24576,K=7168,device_name=NVIDIA_A100-SXM4-80GB,dtype=int8_w8a8,block_shape=[128,128].json +146 -0
  738. vllm/model_executor/layers/quantization/utils/configs/N=24576,K=7168,device_name=NVIDIA_A800-SXM4-80GB,dtype=int8_w8a8,block_shape=[128,128].json +146 -0
  739. vllm/model_executor/layers/quantization/utils/configs/N=24576,K=7168,device_name=NVIDIA_B200,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  740. vllm/model_executor/layers/quantization/utils/configs/N=24576,K=7168,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  741. vllm/model_executor/layers/quantization/utils/configs/N=24576,K=7168,device_name=NVIDIA_H20,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  742. vllm/model_executor/layers/quantization/utils/configs/N=24576,K=7168,device_name=NVIDIA_H20,dtype=int8_w8a8,block_shape=[128,128].json +146 -0
  743. vllm/model_executor/layers/quantization/utils/configs/N=24576,K=7168,device_name=NVIDIA_H200,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  744. vllm/model_executor/layers/quantization/utils/configs/N=24576,K=7168,device_name=NVIDIA_L20,dtype=fp8_w8a8,block_shape=[128,128].json +26 -0
  745. vllm/model_executor/layers/quantization/utils/configs/N=24576,K=7168,device_name=NVIDIA_L20Y,dtype=fp8_w8a8,block_shape=[128,128].json +26 -0
  746. vllm/model_executor/layers/quantization/utils/configs/N=256,K=7168,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  747. vllm/model_executor/layers/quantization/utils/configs/N=256,K=7168,device_name=AMD_Instinct_MI325X,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  748. vllm/model_executor/layers/quantization/utils/configs/N=256,K=7168,device_name=AMD_Instinct_MI325_OAM,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  749. vllm/model_executor/layers/quantization/utils/configs/N=256,K=7168,device_name=NVIDIA_A100-SXM4-80GB,dtype=int8_w8a8,block_shape=[128,128].json +146 -0
  750. vllm/model_executor/layers/quantization/utils/configs/N=256,K=7168,device_name=NVIDIA_A800-SXM4-80GB,dtype=int8_w8a8,block_shape=[128,128].json +146 -0
  751. vllm/model_executor/layers/quantization/utils/configs/N=256,K=7168,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  752. vllm/model_executor/layers/quantization/utils/configs/N=256,K=7168,device_name=NVIDIA_H20,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  753. vllm/model_executor/layers/quantization/utils/configs/N=256,K=7168,device_name=NVIDIA_L20Y,dtype=fp8_w8a8,block_shape=[128,128].json +26 -0
  754. vllm/model_executor/layers/quantization/utils/configs/N=3072,K=1536,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  755. vllm/model_executor/layers/quantization/utils/configs/N=3072,K=1536,device_name=AMD_Instinct_MI325X,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  756. vllm/model_executor/layers/quantization/utils/configs/N=3072,K=1536,device_name=AMD_Instinct_MI325_OAM,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  757. vllm/model_executor/layers/quantization/utils/configs/N=3072,K=1536,device_name=NVIDIA_B200,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  758. vllm/model_executor/layers/quantization/utils/configs/N=3072,K=1536,device_name=NVIDIA_H20,dtype=int8_w8a8,block_shape=[128,128].json +146 -0
  759. vllm/model_executor/layers/quantization/utils/configs/N=3072,K=1536,device_name=NVIDIA_H200,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  760. vllm/model_executor/layers/quantization/utils/configs/N=3072,K=1536,device_name=NVIDIA_L20,dtype=fp8_w8a8,block_shape=[128,128].json +26 -0
  761. vllm/model_executor/layers/quantization/utils/configs/N=3072,K=7168,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  762. vllm/model_executor/layers/quantization/utils/configs/N=3072,K=7168,device_name=AMD_Instinct_MI325X,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  763. vllm/model_executor/layers/quantization/utils/configs/N=3072,K=7168,device_name=AMD_Instinct_MI325_OAM,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  764. vllm/model_executor/layers/quantization/utils/configs/N=3072,K=7168,device_name=NVIDIA_B200,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  765. vllm/model_executor/layers/quantization/utils/configs/N=3072,K=7168,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  766. vllm/model_executor/layers/quantization/utils/configs/N=3072,K=7168,device_name=NVIDIA_H20,dtype=int8_w8a8,block_shape=[128,128].json +146 -0
  767. vllm/model_executor/layers/quantization/utils/configs/N=3072,K=7168,device_name=NVIDIA_H200,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  768. vllm/model_executor/layers/quantization/utils/configs/N=3072,K=7168,device_name=NVIDIA_L20,dtype=fp8_w8a8,block_shape=[128,128].json +26 -0
  769. vllm/model_executor/layers/quantization/utils/configs/N=32768,K=512,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  770. vllm/model_executor/layers/quantization/utils/configs/N=32768,K=512,device_name=AMD_Instinct_MI325X,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  771. vllm/model_executor/layers/quantization/utils/configs/N=32768,K=512,device_name=AMD_Instinct_MI325_OAM,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  772. vllm/model_executor/layers/quantization/utils/configs/N=32768,K=512,device_name=NVIDIA_A100-SXM4-80GB,dtype=int8_w8a8,block_shape=[128,128].json +146 -0
  773. vllm/model_executor/layers/quantization/utils/configs/N=32768,K=512,device_name=NVIDIA_A800-SXM4-80GB,dtype=int8_w8a8,block_shape=[128,128].json +146 -0
  774. vllm/model_executor/layers/quantization/utils/configs/N=32768,K=512,device_name=NVIDIA_B200,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  775. vllm/model_executor/layers/quantization/utils/configs/N=32768,K=512,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  776. vllm/model_executor/layers/quantization/utils/configs/N=32768,K=512,device_name=NVIDIA_H20,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  777. vllm/model_executor/layers/quantization/utils/configs/N=32768,K=512,device_name=NVIDIA_H20,dtype=int8_w8a8,block_shape=[128,128].json +146 -0
  778. vllm/model_executor/layers/quantization/utils/configs/N=32768,K=512,device_name=NVIDIA_H200,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  779. vllm/model_executor/layers/quantization/utils/configs/N=32768,K=512,device_name=NVIDIA_L20,dtype=fp8_w8a8,block_shape=[128,128].json +26 -0
  780. vllm/model_executor/layers/quantization/utils/configs/N=32768,K=512,device_name=NVIDIA_L20Y,dtype=fp8_w8a8,block_shape=[128,128].json +26 -0
  781. vllm/model_executor/layers/quantization/utils/configs/N=36864,K=7168,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  782. vllm/model_executor/layers/quantization/utils/configs/N=36864,K=7168,device_name=AMD_Instinct_MI325X,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  783. vllm/model_executor/layers/quantization/utils/configs/N=36864,K=7168,device_name=AMD_Instinct_MI325_OAM,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  784. vllm/model_executor/layers/quantization/utils/configs/N=36864,K=7168,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  785. vllm/model_executor/layers/quantization/utils/configs/N=36864,K=7168,device_name=NVIDIA_H200,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  786. vllm/model_executor/layers/quantization/utils/configs/N=4096,K=512,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  787. vllm/model_executor/layers/quantization/utils/configs/N=4096,K=512,device_name=AMD_Instinct_MI325X,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  788. vllm/model_executor/layers/quantization/utils/configs/N=4096,K=512,device_name=AMD_Instinct_MI325_OAM,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  789. vllm/model_executor/layers/quantization/utils/configs/N=4096,K=512,device_name=NVIDIA_B200,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  790. vllm/model_executor/layers/quantization/utils/configs/N=4096,K=512,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  791. vllm/model_executor/layers/quantization/utils/configs/N=4096,K=512,device_name=NVIDIA_H20,dtype=int8_w8a8,block_shape=[128,128].json +146 -0
  792. vllm/model_executor/layers/quantization/utils/configs/N=4096,K=512,device_name=NVIDIA_H200,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  793. vllm/model_executor/layers/quantization/utils/configs/N=4096,K=512,device_name=NVIDIA_L20,dtype=fp8_w8a8,block_shape=[128,128].json +26 -0
  794. vllm/model_executor/layers/quantization/utils/configs/N=4096,K=7168,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  795. vllm/model_executor/layers/quantization/utils/configs/N=4096,K=7168,device_name=NVIDIA_H200,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  796. vllm/model_executor/layers/quantization/utils/configs/N=4608,K=7168,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  797. vllm/model_executor/layers/quantization/utils/configs/N=4608,K=7168,device_name=AMD_Instinct_MI325X,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  798. vllm/model_executor/layers/quantization/utils/configs/N=4608,K=7168,device_name=AMD_Instinct_MI325_OAM,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  799. vllm/model_executor/layers/quantization/utils/configs/N=4608,K=7168,device_name=NVIDIA_B200,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  800. vllm/model_executor/layers/quantization/utils/configs/N=4608,K=7168,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  801. vllm/model_executor/layers/quantization/utils/configs/N=4608,K=7168,device_name=NVIDIA_H20,dtype=int8_w8a8,block_shape=[128,128].json +146 -0
  802. vllm/model_executor/layers/quantization/utils/configs/N=4608,K=7168,device_name=NVIDIA_H200,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  803. vllm/model_executor/layers/quantization/utils/configs/N=4608,K=7168,device_name=NVIDIA_L20,dtype=fp8_w8a8,block_shape=[128,128].json +26 -0
  804. vllm/model_executor/layers/quantization/utils/configs/N=512,K=7168,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  805. vllm/model_executor/layers/quantization/utils/configs/N=512,K=7168,device_name=AMD_Instinct_MI325X,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  806. vllm/model_executor/layers/quantization/utils/configs/N=512,K=7168,device_name=AMD_Instinct_MI325_OAM,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  807. vllm/model_executor/layers/quantization/utils/configs/N=512,K=7168,device_name=NVIDIA_B200,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  808. vllm/model_executor/layers/quantization/utils/configs/N=512,K=7168,device_name=NVIDIA_H20,dtype=int8_w8a8,block_shape=[128,128].json +146 -0
  809. vllm/model_executor/layers/quantization/utils/configs/N=512,K=7168,device_name=NVIDIA_H200,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  810. vllm/model_executor/layers/quantization/utils/configs/N=512,K=7168,device_name=NVIDIA_L20,dtype=fp8_w8a8,block_shape=[128,128].json +26 -0
  811. vllm/model_executor/layers/quantization/utils/configs/N=576,K=7168,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  812. vllm/model_executor/layers/quantization/utils/configs/N=576,K=7168,device_name=AMD_Instinct_MI325X,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  813. vllm/model_executor/layers/quantization/utils/configs/N=576,K=7168,device_name=AMD_Instinct_MI325_OAM,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  814. vllm/model_executor/layers/quantization/utils/configs/N=576,K=7168,device_name=NVIDIA_A100-SXM4-80GB,dtype=int8_w8a8,block_shape=[128,128].json +146 -0
  815. vllm/model_executor/layers/quantization/utils/configs/N=576,K=7168,device_name=NVIDIA_A800-SXM4-80GB,dtype=int8_w8a8,block_shape=[128,128].json +146 -0
  816. vllm/model_executor/layers/quantization/utils/configs/N=576,K=7168,device_name=NVIDIA_B200,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  817. vllm/model_executor/layers/quantization/utils/configs/N=576,K=7168,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  818. vllm/model_executor/layers/quantization/utils/configs/N=576,K=7168,device_name=NVIDIA_H20,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  819. vllm/model_executor/layers/quantization/utils/configs/N=576,K=7168,device_name=NVIDIA_H20,dtype=int8_w8a8,block_shape=[128,128].json +146 -0
  820. vllm/model_executor/layers/quantization/utils/configs/N=576,K=7168,device_name=NVIDIA_H200,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  821. vllm/model_executor/layers/quantization/utils/configs/N=576,K=7168,device_name=NVIDIA_L20,dtype=fp8_w8a8,block_shape=[128,128].json +18 -0
  822. vllm/model_executor/layers/quantization/utils/configs/N=576,K=7168,device_name=NVIDIA_L20Y,dtype=fp8_w8a8,block_shape=[128,128].json +26 -0
  823. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=1024,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  824. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=1024,device_name=AMD_Instinct_MI325X,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  825. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=1024,device_name=AMD_Instinct_MI325_OAM,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  826. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=1024,device_name=NVIDIA_A100-SXM4-80GB,dtype=int8_w8a8,block_shape=[128,128].json +146 -0
  827. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=1024,device_name=NVIDIA_A800-SXM4-80GB,dtype=int8_w8a8,block_shape=[128,128].json +146 -0
  828. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=1024,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  829. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=1024,device_name=NVIDIA_H20,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  830. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=1024,device_name=NVIDIA_H200,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  831. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=1024,device_name=NVIDIA_L20Y,dtype=fp8_w8a8,block_shape=[128,128].json +26 -0
  832. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=1152,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  833. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=1152,device_name=AMD_Instinct_MI325X,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  834. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=1152,device_name=AMD_Instinct_MI325_OAM,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  835. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=1152,device_name=NVIDIA_A100-SXM4-80GB,dtype=int8_w8a8,block_shape=[128,128].json +146 -0
  836. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=1152,device_name=NVIDIA_A800-SXM4-80GB,dtype=int8_w8a8,block_shape=[128,128].json +146 -0
  837. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=1152,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  838. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=1152,device_name=NVIDIA_H20,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  839. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=1152,device_name=NVIDIA_H200,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  840. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=1152,device_name=NVIDIA_L20Y,dtype=fp8_w8a8,block_shape=[128,128].json +26 -0
  841. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=128,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  842. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=128,device_name=AMD_Instinct_MI325X,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  843. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=128,device_name=AMD_Instinct_MI325_OAM,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  844. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=128,device_name=NVIDIA_A100-SXM4-80GB,dtype=int8_w8a8,block_shape=[128,128].json +146 -0
  845. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=128,device_name=NVIDIA_A800-SXM4-80GB,dtype=int8_w8a8,block_shape=[128,128].json +146 -0
  846. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=128,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  847. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=128,device_name=NVIDIA_H20,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  848. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=128,device_name=NVIDIA_L20Y,dtype=fp8_w8a8,block_shape=[128,128].json +26 -0
  849. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=16384,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  850. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=16384,device_name=AMD_Instinct_MI325X,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  851. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=16384,device_name=AMD_Instinct_MI325_OAM,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  852. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=16384,device_name=NVIDIA_A100-SXM4-80GB,dtype=int8_w8a8,block_shape=[128,128].json +146 -0
  853. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=16384,device_name=NVIDIA_A800-SXM4-80GB,dtype=int8_w8a8,block_shape=[128,128].json +146 -0
  854. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=16384,device_name=NVIDIA_B200,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  855. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=16384,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  856. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=16384,device_name=NVIDIA_H20,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  857. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=16384,device_name=NVIDIA_H20,dtype=int8_w8a8,block_shape=[128,128].json +146 -0
  858. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=16384,device_name=NVIDIA_H200,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  859. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=16384,device_name=NVIDIA_L20,dtype=fp8_w8a8,block_shape=[128,128].json +26 -0
  860. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=16384,device_name=NVIDIA_L20Y,dtype=fp8_w8a8,block_shape=[128,128].json +26 -0
  861. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=18432,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  862. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=18432,device_name=AMD_Instinct_MI325X,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  863. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=18432,device_name=AMD_Instinct_MI325_OAM,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  864. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=18432,device_name=NVIDIA_A100-SXM4-80GB,dtype=int8_w8a8,block_shape=[128,128].json +146 -0
  865. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=18432,device_name=NVIDIA_A800-SXM4-80GB,dtype=int8_w8a8,block_shape=[128,128].json +146 -0
  866. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=18432,device_name=NVIDIA_B200,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  867. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=18432,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  868. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=18432,device_name=NVIDIA_H20,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  869. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=18432,device_name=NVIDIA_H20,dtype=int8_w8a8,block_shape=[128,128].json +146 -0
  870. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=18432,device_name=NVIDIA_H200,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  871. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=18432,device_name=NVIDIA_L20,dtype=fp8_w8a8,block_shape=[128,128].json +26 -0
  872. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=18432,device_name=NVIDIA_L20Y,dtype=fp8_w8a8,block_shape=[128,128].json +26 -0
  873. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=2048,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  874. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=2048,device_name=AMD_Instinct_MI325X,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  875. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=2048,device_name=AMD_Instinct_MI325_OAM,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  876. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=2048,device_name=NVIDIA_B200,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  877. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=2048,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  878. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=2048,device_name=NVIDIA_H20,dtype=int8_w8a8,block_shape=[128,128].json +146 -0
  879. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=2048,device_name=NVIDIA_H200,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  880. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=2048,device_name=NVIDIA_L20,dtype=fp8_w8a8,block_shape=[128,128].json +26 -0
  881. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=2304,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  882. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=2304,device_name=AMD_Instinct_MI325X,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  883. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=2304,device_name=AMD_Instinct_MI325_OAM,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  884. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=2304,device_name=NVIDIA_B200,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  885. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=2304,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  886. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=2304,device_name=NVIDIA_H20,dtype=int8_w8a8,block_shape=[128,128].json +146 -0
  887. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=2304,device_name=NVIDIA_H200,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  888. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=2304,device_name=NVIDIA_L20,dtype=fp8_w8a8,block_shape=[128,128].json +26 -0
  889. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=256,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  890. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=256,device_name=AMD_Instinct_MI325X,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  891. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=256,device_name=AMD_Instinct_MI325_OAM,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  892. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=256,device_name=NVIDIA_B200,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  893. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=256,device_name=NVIDIA_H20,dtype=int8_w8a8,block_shape=[128,128].json +146 -0
  894. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=256,device_name=NVIDIA_H200,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  895. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=256,device_name=NVIDIA_L20,dtype=fp8_w8a8,block_shape=[128,128].json +26 -0
  896. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=8192,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  897. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=8192,device_name=AMD_Instinct_MI325X,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  898. vllm/model_executor/layers/quantization/utils/configs/N=7168,K=8192,device_name=AMD_Instinct_MI325_OAM,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  899. vllm/model_executor/layers/quantization/utils/configs/N=8192,K=1536,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  900. vllm/model_executor/layers/quantization/utils/configs/N=8192,K=1536,device_name=AMD_Instinct_MI325X,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  901. vllm/model_executor/layers/quantization/utils/configs/N=8192,K=1536,device_name=AMD_Instinct_MI325_OAM,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  902. vllm/model_executor/layers/quantization/utils/configs/README.md +3 -0
  903. vllm/model_executor/layers/quantization/utils/flashinfer_fp4_moe.py +85 -0
  904. vllm/model_executor/layers/quantization/utils/flashinfer_utils.py +258 -0
  905. vllm/model_executor/layers/quantization/utils/fp8_utils.py +795 -0
  906. vllm/model_executor/layers/quantization/utils/gptq_utils.py +96 -0
  907. vllm/model_executor/layers/quantization/utils/int8_utils.py +492 -0
  908. vllm/model_executor/layers/quantization/utils/layer_utils.py +40 -0
  909. vllm/model_executor/layers/quantization/utils/machete_utils.py +50 -0
  910. vllm/model_executor/layers/quantization/utils/marlin_utils.py +479 -0
  911. vllm/model_executor/layers/quantization/utils/marlin_utils_fp4.py +396 -0
  912. vllm/model_executor/layers/quantization/utils/marlin_utils_fp8.py +345 -0
  913. vllm/model_executor/layers/quantization/utils/marlin_utils_test.py +165 -0
  914. vllm/model_executor/layers/quantization/utils/marlin_utils_test_24.py +464 -0
  915. vllm/model_executor/layers/quantization/utils/mxfp4_utils.py +132 -0
  916. vllm/model_executor/layers/quantization/utils/mxfp8_utils.py +20 -0
  917. vllm/model_executor/layers/quantization/utils/nvfp4_emulation_utils.py +137 -0
  918. vllm/model_executor/layers/quantization/utils/nvfp4_moe_support.py +59 -0
  919. vllm/model_executor/layers/quantization/utils/petit_utils.py +122 -0
  920. vllm/model_executor/layers/quantization/utils/quant_utils.py +627 -0
  921. vllm/model_executor/layers/quantization/utils/w8a8_utils.py +458 -0
  922. vllm/model_executor/layers/resampler.py +270 -0
  923. vllm/model_executor/layers/rotary_embedding/__init__.py +190 -0
  924. vllm/model_executor/layers/rotary_embedding/base.py +156 -0
  925. vllm/model_executor/layers/rotary_embedding/common.py +105 -0
  926. vllm/model_executor/layers/rotary_embedding/deepseek_scaling_rope.py +140 -0
  927. vllm/model_executor/layers/rotary_embedding/dual_chunk_rope.py +197 -0
  928. vllm/model_executor/layers/rotary_embedding/dynamic_ntk_alpha_rope.py +41 -0
  929. vllm/model_executor/layers/rotary_embedding/dynamic_ntk_scaling_rope.py +67 -0
  930. vllm/model_executor/layers/rotary_embedding/ernie45_vl_rope.py +80 -0
  931. vllm/model_executor/layers/rotary_embedding/linear_scaling_rope.py +115 -0
  932. vllm/model_executor/layers/rotary_embedding/llama3_rope.py +54 -0
  933. vllm/model_executor/layers/rotary_embedding/llama4_vision_rope.py +81 -0
  934. vllm/model_executor/layers/rotary_embedding/mrope.py +1140 -0
  935. vllm/model_executor/layers/rotary_embedding/ntk_scaling_rope.py +42 -0
  936. vllm/model_executor/layers/rotary_embedding/phi3_long_rope_scaled_rope.py +129 -0
  937. vllm/model_executor/layers/rotary_embedding/yarn_scaling_rope.py +68 -0
  938. vllm/model_executor/layers/sampler.py +1198 -0
  939. vllm/model_executor/layers/shared_fused_moe/__init__.py +6 -0
  940. vllm/model_executor/layers/shared_fused_moe/shared_fused_moe.py +56 -0
  941. vllm/model_executor/layers/utils.py +196 -0
  942. vllm/model_executor/layers/vocab_parallel_embedding.py +487 -0
  943. vllm/model_executor/model_loader/__init__.py +138 -0
  944. vllm/model_executor/model_loader/base_loader.py +52 -0
  945. vllm/model_executor/model_loader/bitsandbytes_loader.py +787 -0
  946. vllm/model_executor/model_loader/default_loader.py +278 -0
  947. vllm/model_executor/model_loader/dummy_loader.py +28 -0
  948. vllm/model_executor/model_loader/gguf_loader.py +155 -0
  949. vllm/model_executor/model_loader/runai_streamer_loader.py +104 -0
  950. vllm/model_executor/model_loader/sharded_state_loader.py +199 -0
  951. vllm/model_executor/model_loader/tensorizer.py +743 -0
  952. vllm/model_executor/model_loader/tensorizer_loader.py +143 -0
  953. vllm/model_executor/model_loader/tpu.py +114 -0
  954. vllm/model_executor/model_loader/utils.py +271 -0
  955. vllm/model_executor/model_loader/weight_utils.py +946 -0
  956. vllm/model_executor/models/__init__.py +30 -0
  957. vllm/model_executor/models/adapters.py +542 -0
  958. vllm/model_executor/models/aimv2.py +246 -0
  959. vllm/model_executor/models/apertus.py +582 -0
  960. vllm/model_executor/models/arcee.py +423 -0
  961. vllm/model_executor/models/arctic.py +560 -0
  962. vllm/model_executor/models/aria.py +662 -0
  963. vllm/model_executor/models/aya_vision.py +470 -0
  964. vllm/model_executor/models/baichuan.py +475 -0
  965. vllm/model_executor/models/bailing_moe.py +529 -0
  966. vllm/model_executor/models/bamba.py +582 -0
  967. vllm/model_executor/models/bart.py +1343 -0
  968. vllm/model_executor/models/bert.py +613 -0
  969. vllm/model_executor/models/bert_with_rope.py +687 -0
  970. vllm/model_executor/models/blip.py +339 -0
  971. vllm/model_executor/models/blip2.py +716 -0
  972. vllm/model_executor/models/bloom.py +374 -0
  973. vllm/model_executor/models/chameleon.py +1141 -0
  974. vllm/model_executor/models/chatglm.py +479 -0
  975. vllm/model_executor/models/clip.py +407 -0
  976. vllm/model_executor/models/cohere2_vision.py +484 -0
  977. vllm/model_executor/models/commandr.py +467 -0
  978. vllm/model_executor/models/config.py +434 -0
  979. vllm/model_executor/models/constant_size_cache.py +137 -0
  980. vllm/model_executor/models/dbrx.py +473 -0
  981. vllm/model_executor/models/deepseek.py +491 -0
  982. vllm/model_executor/models/deepseek_eagle.py +241 -0
  983. vllm/model_executor/models/deepseek_mtp.py +282 -0
  984. vllm/model_executor/models/deepseek_v2.py +1058 -0
  985. vllm/model_executor/models/deepseek_vl2.py +661 -0
  986. vllm/model_executor/models/donut.py +387 -0
  987. vllm/model_executor/models/dots1.py +547 -0
  988. vllm/model_executor/models/ernie45.py +43 -0
  989. vllm/model_executor/models/ernie45_moe.py +608 -0
  990. vllm/model_executor/models/ernie45_vl.py +1510 -0
  991. vllm/model_executor/models/ernie45_vl_moe.py +728 -0
  992. vllm/model_executor/models/ernie_mtp.py +287 -0
  993. vllm/model_executor/models/exaone.py +552 -0
  994. vllm/model_executor/models/exaone4.py +535 -0
  995. vllm/model_executor/models/fairseq2_llama.py +154 -0
  996. vllm/model_executor/models/falcon.py +511 -0
  997. vllm/model_executor/models/falcon_h1.py +739 -0
  998. vllm/model_executor/models/florence2.py +1107 -0
  999. vllm/model_executor/models/fuyu.py +401 -0
  1000. vllm/model_executor/models/gemma.py +428 -0
  1001. vllm/model_executor/models/gemma2.py +425 -0
  1002. vllm/model_executor/models/gemma3.py +542 -0
  1003. vllm/model_executor/models/gemma3_mm.py +723 -0
  1004. vllm/model_executor/models/gemma3n.py +830 -0
  1005. vllm/model_executor/models/gemma3n_mm.py +767 -0
  1006. vllm/model_executor/models/glm.py +23 -0
  1007. vllm/model_executor/models/glm4.py +305 -0
  1008. vllm/model_executor/models/glm4_1v.py +1669 -0
  1009. vllm/model_executor/models/glm4_moe.py +703 -0
  1010. vllm/model_executor/models/glm4_moe_mtp.py +306 -0
  1011. vllm/model_executor/models/glm4v.py +654 -0
  1012. vllm/model_executor/models/gpt2.py +383 -0
  1013. vllm/model_executor/models/gpt_bigcode.py +346 -0
  1014. vllm/model_executor/models/gpt_j.py +340 -0
  1015. vllm/model_executor/models/gpt_neox.py +333 -0
  1016. vllm/model_executor/models/gpt_oss.py +687 -0
  1017. vllm/model_executor/models/granite.py +498 -0
  1018. vllm/model_executor/models/granite_speech.py +799 -0
  1019. vllm/model_executor/models/granitemoe.py +541 -0
  1020. vllm/model_executor/models/granitemoehybrid.py +684 -0
  1021. vllm/model_executor/models/granitemoeshared.py +342 -0
  1022. vllm/model_executor/models/gritlm.py +262 -0
  1023. vllm/model_executor/models/grok1.py +550 -0
  1024. vllm/model_executor/models/h2ovl.py +536 -0
  1025. vllm/model_executor/models/hunyuan_v1.py +937 -0
  1026. vllm/model_executor/models/hyperclovax_vision.py +1206 -0
  1027. vllm/model_executor/models/idefics2_vision_model.py +416 -0
  1028. vllm/model_executor/models/idefics3.py +758 -0
  1029. vllm/model_executor/models/interfaces.py +854 -0
  1030. vllm/model_executor/models/interfaces_base.py +195 -0
  1031. vllm/model_executor/models/intern_vit.py +481 -0
  1032. vllm/model_executor/models/internlm2.py +453 -0
  1033. vllm/model_executor/models/internlm2_ve.py +148 -0
  1034. vllm/model_executor/models/interns1.py +832 -0
  1035. vllm/model_executor/models/interns1_vit.py +418 -0
  1036. vllm/model_executor/models/internvl.py +1423 -0
  1037. vllm/model_executor/models/jais.py +374 -0
  1038. vllm/model_executor/models/jamba.py +630 -0
  1039. vllm/model_executor/models/jina_vl.py +144 -0
  1040. vllm/model_executor/models/keye.py +1684 -0
  1041. vllm/model_executor/models/keye_vl1_5.py +601 -0
  1042. vllm/model_executor/models/kimi_vl.py +620 -0
  1043. vllm/model_executor/models/lfm2.py +558 -0
  1044. vllm/model_executor/models/llama.py +671 -0
  1045. vllm/model_executor/models/llama4.py +732 -0
  1046. vllm/model_executor/models/llama4_eagle.py +241 -0
  1047. vllm/model_executor/models/llama_eagle.py +171 -0
  1048. vllm/model_executor/models/llama_eagle3.py +292 -0
  1049. vllm/model_executor/models/llava.py +872 -0
  1050. vllm/model_executor/models/llava_next.py +572 -0
  1051. vllm/model_executor/models/llava_next_video.py +479 -0
  1052. vllm/model_executor/models/llava_onevision.py +945 -0
  1053. vllm/model_executor/models/mamba.py +310 -0
  1054. vllm/model_executor/models/mamba2.py +346 -0
  1055. vllm/model_executor/models/mamba_cache.py +83 -0
  1056. vllm/model_executor/models/medusa.py +219 -0
  1057. vllm/model_executor/models/midashenglm.py +788 -0
  1058. vllm/model_executor/models/mimo.py +191 -0
  1059. vllm/model_executor/models/mimo_mtp.py +273 -0
  1060. vllm/model_executor/models/minicpm.py +593 -0
  1061. vllm/model_executor/models/minicpm3.py +230 -0
  1062. vllm/model_executor/models/minicpm_eagle.py +391 -0
  1063. vllm/model_executor/models/minicpmo.py +804 -0
  1064. vllm/model_executor/models/minicpmv.py +1786 -0
  1065. vllm/model_executor/models/minimax_cache.py +36 -0
  1066. vllm/model_executor/models/minimax_text_01.py +1027 -0
  1067. vllm/model_executor/models/minimax_vl_01.py +431 -0
  1068. vllm/model_executor/models/mistral3.py +628 -0
  1069. vllm/model_executor/models/mixtral.py +494 -0
  1070. vllm/model_executor/models/mllama.py +1697 -0
  1071. vllm/model_executor/models/mllama4.py +1079 -0
  1072. vllm/model_executor/models/mlp_speculator.py +206 -0
  1073. vllm/model_executor/models/modernbert.py +374 -0
  1074. vllm/model_executor/models/module_mapping.py +72 -0
  1075. vllm/model_executor/models/molmo.py +1569 -0
  1076. vllm/model_executor/models/moonvit.py +663 -0
  1077. vllm/model_executor/models/motif.py +345 -0
  1078. vllm/model_executor/models/mpt.py +332 -0
  1079. vllm/model_executor/models/nano_nemotron_vl.py +1395 -0
  1080. vllm/model_executor/models/nemotron.py +509 -0
  1081. vllm/model_executor/models/nemotron_h.py +633 -0
  1082. vllm/model_executor/models/nemotron_nas.py +484 -0
  1083. vllm/model_executor/models/nemotron_vl.py +655 -0
  1084. vllm/model_executor/models/nvlm_d.py +203 -0
  1085. vllm/model_executor/models/olmo.py +406 -0
  1086. vllm/model_executor/models/olmo2.py +428 -0
  1087. vllm/model_executor/models/olmoe.py +485 -0
  1088. vllm/model_executor/models/opt.py +413 -0
  1089. vllm/model_executor/models/orion.py +350 -0
  1090. vllm/model_executor/models/ovis.py +572 -0
  1091. vllm/model_executor/models/ovis2_5.py +644 -0
  1092. vllm/model_executor/models/paligemma.py +414 -0
  1093. vllm/model_executor/models/persimmon.py +345 -0
  1094. vllm/model_executor/models/phi.py +357 -0
  1095. vllm/model_executor/models/phi3.py +19 -0
  1096. vllm/model_executor/models/phi3v.py +701 -0
  1097. vllm/model_executor/models/phi4_multimodal.py +1478 -0
  1098. vllm/model_executor/models/phi4flash.py +737 -0
  1099. vllm/model_executor/models/phi4mm.py +1281 -0
  1100. vllm/model_executor/models/phi4mm_audio.py +1254 -0
  1101. vllm/model_executor/models/phi4mm_utils.py +1875 -0
  1102. vllm/model_executor/models/phimoe.py +681 -0
  1103. vllm/model_executor/models/pixtral.py +1348 -0
  1104. vllm/model_executor/models/plamo2.py +1126 -0
  1105. vllm/model_executor/models/qwen.py +363 -0
  1106. vllm/model_executor/models/qwen2.py +526 -0
  1107. vllm/model_executor/models/qwen2_5_omni_thinker.py +985 -0
  1108. vllm/model_executor/models/qwen2_5_vl.py +1256 -0
  1109. vllm/model_executor/models/qwen2_audio.py +492 -0
  1110. vllm/model_executor/models/qwen2_moe.py +558 -0
  1111. vllm/model_executor/models/qwen2_rm.py +122 -0
  1112. vllm/model_executor/models/qwen2_vl.py +1512 -0
  1113. vllm/model_executor/models/qwen3.py +344 -0
  1114. vllm/model_executor/models/qwen3_moe.py +704 -0
  1115. vllm/model_executor/models/qwen3_next.py +1298 -0
  1116. vllm/model_executor/models/qwen3_next_mtp.py +285 -0
  1117. vllm/model_executor/models/qwen_vl.py +795 -0
  1118. vllm/model_executor/models/registry.py +891 -0
  1119. vllm/model_executor/models/roberta.py +252 -0
  1120. vllm/model_executor/models/rvl.py +103 -0
  1121. vllm/model_executor/models/seed_oss.py +488 -0
  1122. vllm/model_executor/models/siglip.py +524 -0
  1123. vllm/model_executor/models/siglip2navit.py +688 -0
  1124. vllm/model_executor/models/skyworkr1v.py +914 -0
  1125. vllm/model_executor/models/smolvlm.py +44 -0
  1126. vllm/model_executor/models/solar.py +506 -0
  1127. vllm/model_executor/models/stablelm.py +344 -0
  1128. vllm/model_executor/models/starcoder2.py +357 -0
  1129. vllm/model_executor/models/step3_text.py +521 -0
  1130. vllm/model_executor/models/step3_vl.py +1091 -0
  1131. vllm/model_executor/models/swin.py +475 -0
  1132. vllm/model_executor/models/tarsier.py +649 -0
  1133. vllm/model_executor/models/telechat2.py +151 -0
  1134. vllm/model_executor/models/teleflm.py +79 -0
  1135. vllm/model_executor/models/terratorch.py +294 -0
  1136. vllm/model_executor/models/transformers.py +883 -0
  1137. vllm/model_executor/models/ultravox.py +667 -0
  1138. vllm/model_executor/models/utils.py +770 -0
  1139. vllm/model_executor/models/vision.py +125 -0
  1140. vllm/model_executor/models/voxtral.py +789 -0
  1141. vllm/model_executor/models/whisper.py +966 -0
  1142. vllm/model_executor/models/zamba2.py +1056 -0
  1143. vllm/model_executor/parameter.py +599 -0
  1144. vllm/model_executor/sampling_metadata.py +597 -0
  1145. vllm/model_executor/utils.py +97 -0
  1146. vllm/model_executor/warmup/__init__.py +0 -0
  1147. vllm/model_executor/warmup/deep_gemm_warmup.py +223 -0
  1148. vllm/model_executor/warmup/kernel_warmup.py +83 -0
  1149. vllm/multimodal/__init__.py +35 -0
  1150. vllm/multimodal/audio.py +116 -0
  1151. vllm/multimodal/base.py +219 -0
  1152. vllm/multimodal/cache.py +507 -0
  1153. vllm/multimodal/hasher.py +110 -0
  1154. vllm/multimodal/image.py +130 -0
  1155. vllm/multimodal/inputs.py +979 -0
  1156. vllm/multimodal/parse.py +496 -0
  1157. vllm/multimodal/processing.py +1921 -0
  1158. vllm/multimodal/profiling.py +313 -0
  1159. vllm/multimodal/registry.py +375 -0
  1160. vllm/multimodal/utils.py +754 -0
  1161. vllm/multimodal/video.py +312 -0
  1162. vllm/outputs.py +517 -0
  1163. vllm/platforms/__init__.py +263 -0
  1164. vllm/platforms/cpu.py +353 -0
  1165. vllm/platforms/cuda.py +731 -0
  1166. vllm/platforms/interface.py +599 -0
  1167. vllm/platforms/rocm.py +504 -0
  1168. vllm/platforms/tpu.py +236 -0
  1169. vllm/platforms/xpu.py +243 -0
  1170. vllm/plugins/__init__.py +72 -0
  1171. vllm/plugins/io_processors/__init__.py +68 -0
  1172. vllm/plugins/io_processors/interface.py +67 -0
  1173. vllm/plugins/lora_resolvers/README.md +16 -0
  1174. vllm/plugins/lora_resolvers/__init__.py +0 -0
  1175. vllm/plugins/lora_resolvers/filesystem_resolver.py +50 -0
  1176. vllm/pooling_params.py +183 -0
  1177. vllm/profiler/__init__.py +0 -0
  1178. vllm/profiler/layerwise_profile.py +375 -0
  1179. vllm/profiler/utils.py +148 -0
  1180. vllm/py.typed +2 -0
  1181. vllm/ray/__init__.py +0 -0
  1182. vllm/ray/lazy_utils.py +22 -0
  1183. vllm/ray/ray_env.py +72 -0
  1184. vllm/reasoning/__init__.py +25 -0
  1185. vllm/reasoning/abs_reasoning_parsers.py +202 -0
  1186. vllm/reasoning/deepseek_r1_reasoning_parser.py +173 -0
  1187. vllm/reasoning/glm4_moe_reasoning_parser.py +151 -0
  1188. vllm/reasoning/gptoss_reasoning_parser.py +87 -0
  1189. vllm/reasoning/granite_reasoning_parser.py +363 -0
  1190. vllm/reasoning/hunyuan_a13b_reasoning_parser.py +245 -0
  1191. vllm/reasoning/mistral_reasoning_parser.py +47 -0
  1192. vllm/reasoning/qwen3_reasoning_parser.py +151 -0
  1193. vllm/reasoning/step3_reasoning_parser.py +109 -0
  1194. vllm/sampling_params.py +577 -0
  1195. vllm/scalar_type.py +349 -0
  1196. vllm/scripts.py +15 -0
  1197. vllm/sequence.py +1465 -0
  1198. vllm/tasks.py +11 -0
  1199. vllm/test_utils.py +130 -0
  1200. vllm/third_party/__init__.py +0 -0
  1201. vllm/third_party/pynvml.py +6140 -0
  1202. vllm/tracing.py +136 -0
  1203. vllm/transformers_utils/__init__.py +24 -0
  1204. vllm/transformers_utils/chat_templates/__init__.py +5 -0
  1205. vllm/transformers_utils/chat_templates/registry.py +71 -0
  1206. vllm/transformers_utils/chat_templates/template_basic.jinja +3 -0
  1207. vllm/transformers_utils/chat_templates/template_blip2.jinja +11 -0
  1208. vllm/transformers_utils/chat_templates/template_chatml.jinja +10 -0
  1209. vllm/transformers_utils/chat_templates/template_deepseek_vl2.jinja +23 -0
  1210. vllm/transformers_utils/chat_templates/template_fuyu.jinja +3 -0
  1211. vllm/transformers_utils/chat_templates/template_minicpmv45.jinja +93 -0
  1212. vllm/transformers_utils/config.py +1043 -0
  1213. vllm/transformers_utils/config_parser_base.py +20 -0
  1214. vllm/transformers_utils/configs/__init__.py +55 -0
  1215. vllm/transformers_utils/configs/arctic.py +207 -0
  1216. vllm/transformers_utils/configs/chatglm.py +72 -0
  1217. vllm/transformers_utils/configs/deepseek_vl2.py +216 -0
  1218. vllm/transformers_utils/configs/eagle.py +84 -0
  1219. vllm/transformers_utils/configs/falcon.py +90 -0
  1220. vllm/transformers_utils/configs/jais.py +238 -0
  1221. vllm/transformers_utils/configs/kimi_vl.py +37 -0
  1222. vllm/transformers_utils/configs/medusa.py +63 -0
  1223. vllm/transformers_utils/configs/midashenglm.py +101 -0
  1224. vllm/transformers_utils/configs/mistral.py +165 -0
  1225. vllm/transformers_utils/configs/mlp_speculator.py +68 -0
  1226. vllm/transformers_utils/configs/moonvit.py +33 -0
  1227. vllm/transformers_utils/configs/nemotron.py +205 -0
  1228. vllm/transformers_utils/configs/nemotron_h.py +259 -0
  1229. vllm/transformers_utils/configs/nemotron_vl.py +56 -0
  1230. vllm/transformers_utils/configs/ovis.py +176 -0
  1231. vllm/transformers_utils/configs/qwen3_next.py +275 -0
  1232. vllm/transformers_utils/configs/speculators/__init__.py +2 -0
  1233. vllm/transformers_utils/configs/speculators/algos.py +32 -0
  1234. vllm/transformers_utils/configs/speculators/base.py +91 -0
  1235. vllm/transformers_utils/configs/step3_vl.py +123 -0
  1236. vllm/transformers_utils/configs/ultravox.py +120 -0
  1237. vllm/transformers_utils/detokenizer.py +169 -0
  1238. vllm/transformers_utils/detokenizer_utils.py +199 -0
  1239. vllm/transformers_utils/dynamic_module.py +60 -0
  1240. vllm/transformers_utils/processor.py +245 -0
  1241. vllm/transformers_utils/processors/__init__.py +16 -0
  1242. vllm/transformers_utils/processors/deepseek_vl2.py +363 -0
  1243. vllm/transformers_utils/processors/ovis.py +420 -0
  1244. vllm/transformers_utils/processors/ovis2_5.py +458 -0
  1245. vllm/transformers_utils/runai_utils.py +99 -0
  1246. vllm/transformers_utils/s3_utils.py +90 -0
  1247. vllm/transformers_utils/tokenizer.py +293 -0
  1248. vllm/transformers_utils/tokenizer_base.py +149 -0
  1249. vllm/transformers_utils/tokenizer_group.py +132 -0
  1250. vllm/transformers_utils/tokenizers/__init__.py +10 -0
  1251. vllm/transformers_utils/tokenizers/mistral.py +520 -0
  1252. vllm/transformers_utils/utils.py +99 -0
  1253. vllm/triton_utils/__init__.py +16 -0
  1254. vllm/triton_utils/importing.py +95 -0
  1255. vllm/usage/__init__.py +0 -0
  1256. vllm/usage/usage_lib.py +259 -0
  1257. vllm/utils/__init__.py +3438 -0
  1258. vllm/utils/deep_gemm.py +212 -0
  1259. vllm/utils/flashinfer.py +372 -0
  1260. vllm/utils/jsontree.py +90 -0
  1261. vllm/utils/tensor_schema.py +236 -0
  1262. vllm/v1/__init__.py +0 -0
  1263. vllm/v1/attention/__init__.py +0 -0
  1264. vllm/v1/attention/backends/__init__.py +0 -0
  1265. vllm/v1/attention/backends/cpu_attn.py +922 -0
  1266. vllm/v1/attention/backends/flash_attn.py +800 -0
  1267. vllm/v1/attention/backends/flashinfer.py +1128 -0
  1268. vllm/v1/attention/backends/flex_attention.py +796 -0
  1269. vllm/v1/attention/backends/gdn_attn.py +320 -0
  1270. vllm/v1/attention/backends/linear_attn.py +68 -0
  1271. vllm/v1/attention/backends/mamba1_attn.py +81 -0
  1272. vllm/v1/attention/backends/mamba2_attn.py +224 -0
  1273. vllm/v1/attention/backends/mamba_attn.py +52 -0
  1274. vllm/v1/attention/backends/mla/__init__.py +0 -0
  1275. vllm/v1/attention/backends/mla/common.py +1608 -0
  1276. vllm/v1/attention/backends/mla/cutlass_mla.py +301 -0
  1277. vllm/v1/attention/backends/mla/flashattn_mla.py +273 -0
  1278. vllm/v1/attention/backends/mla/flashinfer_mla.py +110 -0
  1279. vllm/v1/attention/backends/mla/flashmla.py +213 -0
  1280. vllm/v1/attention/backends/mla/rocm_aiter_mla.py +255 -0
  1281. vllm/v1/attention/backends/mla/triton_mla.py +175 -0
  1282. vllm/v1/attention/backends/pallas.py +413 -0
  1283. vllm/v1/attention/backends/rocm_aiter_fa.py +548 -0
  1284. vllm/v1/attention/backends/short_conv_attn.py +82 -0
  1285. vllm/v1/attention/backends/tree_attn.py +450 -0
  1286. vllm/v1/attention/backends/triton_attn.py +430 -0
  1287. vllm/v1/attention/backends/utils.py +834 -0
  1288. vllm/v1/attention/backends/xformers.py +437 -0
  1289. vllm/v1/core/__init__.py +0 -0
  1290. vllm/v1/core/block_pool.py +330 -0
  1291. vllm/v1/core/encoder_cache_manager.py +333 -0
  1292. vllm/v1/core/kv_cache_coordinator.py +440 -0
  1293. vllm/v1/core/kv_cache_manager.py +398 -0
  1294. vllm/v1/core/kv_cache_utils.py +1169 -0
  1295. vllm/v1/core/sched/__init__.py +0 -0
  1296. vllm/v1/core/sched/async_scheduler.py +47 -0
  1297. vllm/v1/core/sched/interface.py +158 -0
  1298. vllm/v1/core/sched/output.py +162 -0
  1299. vllm/v1/core/sched/request_queue.py +224 -0
  1300. vllm/v1/core/sched/scheduler.py +1287 -0
  1301. vllm/v1/core/sched/utils.py +69 -0
  1302. vllm/v1/core/single_type_kv_cache_manager.py +670 -0
  1303. vllm/v1/cudagraph_dispatcher.py +121 -0
  1304. vllm/v1/engine/__init__.py +202 -0
  1305. vllm/v1/engine/async_llm.py +757 -0
  1306. vllm/v1/engine/coordinator.py +357 -0
  1307. vllm/v1/engine/core.py +1245 -0
  1308. vllm/v1/engine/core_client.py +1333 -0
  1309. vllm/v1/engine/detokenizer.py +300 -0
  1310. vllm/v1/engine/exceptions.py +17 -0
  1311. vllm/v1/engine/llm_engine.py +332 -0
  1312. vllm/v1/engine/logprobs.py +201 -0
  1313. vllm/v1/engine/output_processor.py +558 -0
  1314. vllm/v1/engine/parallel_sampling.py +133 -0
  1315. vllm/v1/engine/processor.py +524 -0
  1316. vllm/v1/engine/utils.py +857 -0
  1317. vllm/v1/executor/__init__.py +0 -0
  1318. vllm/v1/executor/abstract.py +126 -0
  1319. vllm/v1/executor/multiproc_executor.py +683 -0
  1320. vllm/v1/executor/ray_distributed_executor.py +109 -0
  1321. vllm/v1/kv_cache_interface.py +275 -0
  1322. vllm/v1/metrics/__init__.py +0 -0
  1323. vllm/v1/metrics/loggers.py +717 -0
  1324. vllm/v1/metrics/prometheus.py +82 -0
  1325. vllm/v1/metrics/ray_wrappers.py +133 -0
  1326. vllm/v1/metrics/reader.py +246 -0
  1327. vllm/v1/metrics/stats.py +248 -0
  1328. vllm/v1/outputs.py +147 -0
  1329. vllm/v1/pool/__init__.py +0 -0
  1330. vllm/v1/pool/metadata.py +77 -0
  1331. vllm/v1/request.py +237 -0
  1332. vllm/v1/sample/__init__.py +0 -0
  1333. vllm/v1/sample/logits_processor/__init__.py +294 -0
  1334. vllm/v1/sample/logits_processor/builtin.py +273 -0
  1335. vllm/v1/sample/logits_processor/interface.py +97 -0
  1336. vllm/v1/sample/logits_processor/state.py +161 -0
  1337. vllm/v1/sample/metadata.py +43 -0
  1338. vllm/v1/sample/ops/__init__.py +0 -0
  1339. vllm/v1/sample/ops/bad_words.py +39 -0
  1340. vllm/v1/sample/ops/logprobs.py +26 -0
  1341. vllm/v1/sample/ops/penalties.py +43 -0
  1342. vllm/v1/sample/ops/topk_topp_sampler.py +254 -0
  1343. vllm/v1/sample/rejection_sampler.py +623 -0
  1344. vllm/v1/sample/sampler.py +281 -0
  1345. vllm/v1/sample/tpu/__init__.py +0 -0
  1346. vllm/v1/sample/tpu/metadata.py +124 -0
  1347. vllm/v1/sample/tpu/sampler.py +213 -0
  1348. vllm/v1/serial_utils.py +395 -0
  1349. vllm/v1/spec_decode/__init__.py +0 -0
  1350. vllm/v1/spec_decode/eagle.py +740 -0
  1351. vllm/v1/spec_decode/medusa.py +66 -0
  1352. vllm/v1/spec_decode/metadata.py +62 -0
  1353. vllm/v1/spec_decode/metrics.py +191 -0
  1354. vllm/v1/spec_decode/ngram_proposer.py +157 -0
  1355. vllm/v1/spec_decode/utils.py +14 -0
  1356. vllm/v1/structured_output/__init__.py +297 -0
  1357. vllm/v1/structured_output/backend_guidance.py +245 -0
  1358. vllm/v1/structured_output/backend_lm_format_enforcer.py +167 -0
  1359. vllm/v1/structured_output/backend_outlines.py +320 -0
  1360. vllm/v1/structured_output/backend_types.py +134 -0
  1361. vllm/v1/structured_output/backend_xgrammar.py +323 -0
  1362. vllm/v1/structured_output/request.py +86 -0
  1363. vllm/v1/structured_output/utils.py +373 -0
  1364. vllm/v1/utils.py +382 -0
  1365. vllm/v1/worker/__init__.py +0 -0
  1366. vllm/v1/worker/block_table.py +221 -0
  1367. vllm/v1/worker/cpu_model_runner.py +163 -0
  1368. vllm/v1/worker/cpu_worker.py +183 -0
  1369. vllm/v1/worker/gpu_input_batch.py +821 -0
  1370. vllm/v1/worker/gpu_model_runner.py +3743 -0
  1371. vllm/v1/worker/gpu_worker.py +697 -0
  1372. vllm/v1/worker/kv_connector_model_runner_mixin.py +122 -0
  1373. vllm/v1/worker/lora_model_runner_mixin.py +192 -0
  1374. vllm/v1/worker/tpu_input_batch.py +585 -0
  1375. vllm/v1/worker/tpu_model_runner.py +1947 -0
  1376. vllm/v1/worker/tpu_worker.py +340 -0
  1377. vllm/v1/worker/utils.py +290 -0
  1378. vllm/v1/worker/worker_base.py +65 -0
  1379. vllm/v1/worker/xpu_model_runner.py +53 -0
  1380. vllm/v1/worker/xpu_worker.py +179 -0
  1381. vllm/version.py +41 -0
  1382. vllm/vllm_flash_attn/.gitkeep +0 -0
  1383. vllm/worker/__init__.py +0 -0
  1384. vllm/worker/cache_engine.py +145 -0
  1385. vllm/worker/enc_dec_model_runner.py +553 -0
  1386. vllm/worker/model_runner.py +2016 -0
  1387. vllm/worker/model_runner_base.py +307 -0
  1388. vllm/worker/utils.py +49 -0
  1389. vllm/worker/worker.py +670 -0
  1390. vllm/worker/worker_base.py +651 -0
  1391. vllm_cpu_avx512vnni-0.10.2.post2.dist-info/METADATA +326 -0
  1392. vllm_cpu_avx512vnni-0.10.2.post2.dist-info/RECORD +1395 -0
  1393. vllm_cpu_avx512vnni-0.10.2.post2.dist-info/WHEEL +5 -0
  1394. vllm_cpu_avx512vnni-0.10.2.post2.dist-info/entry_points.txt +5 -0
  1395. vllm_cpu_avx512vnni-0.10.2.post2.dist-info/top_level.txt +1 -0
vllm/utils/__init__.py ADDED
@@ -0,0 +1,3438 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ # SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3
+
4
+ from __future__ import annotations
5
+
6
+ import asyncio
7
+ import concurrent
8
+ import contextlib
9
+ import datetime
10
+ import enum
11
+ import gc
12
+ import getpass
13
+ import hashlib
14
+ import importlib
15
+ import importlib.metadata
16
+ import importlib.util
17
+ import inspect
18
+ import ipaddress
19
+ import json
20
+ import multiprocessing
21
+ import os
22
+ import pickle
23
+ import signal
24
+ import socket
25
+ import subprocess
26
+ import sys
27
+ import tempfile
28
+ import textwrap
29
+ import threading
30
+ import time
31
+ import traceback
32
+ import types
33
+ import uuid
34
+ import warnings
35
+ import weakref
36
+ from argparse import (Action, ArgumentDefaultsHelpFormatter, ArgumentParser,
37
+ ArgumentTypeError, RawDescriptionHelpFormatter,
38
+ _ArgumentGroup)
39
+ from asyncio import FIRST_COMPLETED, AbstractEventLoop, Task
40
+ from collections import UserDict, defaultdict
41
+ from collections.abc import (AsyncGenerator, Awaitable, Collection, Generator,
42
+ Hashable, Iterable, Iterator, KeysView, Mapping,
43
+ Sequence)
44
+ from concurrent.futures import ThreadPoolExecutor
45
+ from concurrent.futures.process import ProcessPoolExecutor
46
+ from dataclasses import dataclass, field
47
+ from functools import cache, lru_cache, partial, wraps
48
+ from types import MappingProxyType
49
+ from typing import (TYPE_CHECKING, Any, Callable, Generic, Literal, NamedTuple,
50
+ Optional, TextIO, TypeVar, Union, cast, overload)
51
+ from urllib.parse import urlparse
52
+ from uuid import uuid4
53
+
54
+ import cachetools
55
+ import cbor2
56
+ import cloudpickle
57
+ import numpy as np
58
+ import numpy.typing as npt
59
+ import psutil
60
+ import regex as re
61
+ import setproctitle
62
+ import torch
63
+ import torch.types
64
+ import yaml
65
+ import zmq
66
+ import zmq.asyncio
67
+ from packaging import version
68
+ from packaging.version import Version
69
+ from torch.library import Library
70
+ from transformers.tokenization_utils_base import BatchEncoding
71
+ from typing_extensions import Never, ParamSpec, TypeIs, assert_never
72
+
73
+ import vllm.envs as envs
74
+ from vllm.logger import enable_trace_function_call, init_logger
75
+ from vllm.ray.lazy_utils import is_in_ray_actor
76
+
77
+ if TYPE_CHECKING:
78
+ from argparse import Namespace
79
+
80
+ from vllm.config import ModelConfig, VllmConfig
81
+ from vllm.sequence import IntermediateTensors
82
+
83
+ logger = init_logger(__name__)
84
+
85
+ # This value is chosen to have a balance between ITL and TTFT. Note it is
86
+ # not optimized for throughput.
87
+ DEFAULT_MAX_NUM_BATCHED_TOKENS = 2048
88
+ POOLING_MODEL_MAX_NUM_BATCHED_TOKENS = 32768
89
+ MULTIMODAL_MODEL_MAX_NUM_BATCHED_TOKENS = 5120
90
+
91
+ # Exception strings for non-implemented encoder/decoder scenarios
92
+
93
+ # Reminder: Please update docs/features/compatibility_matrix.md
94
+ # If the feature combo become valid
95
+
96
+ STR_NOT_IMPL_ENC_DEC_SWA = \
97
+ "Sliding window attention for encoder/decoder models " + \
98
+ "is not currently supported."
99
+
100
+ STR_NOT_IMPL_ENC_DEC_PREFIX_CACHE = \
101
+ "Prefix caching for encoder/decoder models " + \
102
+ "is not currently supported."
103
+
104
+ STR_NOT_IMPL_ENC_DEC_CHUNKED_PREFILL = \
105
+ "Chunked prefill for encoder/decoder models " + \
106
+ "is not currently supported."
107
+
108
+ STR_NOT_IMPL_ENC_DEC_LOGIT_SOFTCAP = (
109
+ "Models with logits_soft_cap "
110
+ "require FlashInfer backend, which is "
111
+ "currently not supported for encoder/decoder "
112
+ "models.")
113
+
114
+ STR_NOT_IMPL_ENC_DEC_LORA = ("LoRA is not currently "
115
+ "supported with encoder/decoder "
116
+ "models.")
117
+
118
+ STR_NOT_IMPL_ENC_DEC_PP = ("Pipeline parallelism is not "
119
+ "currently supported with "
120
+ "encoder/decoder models.")
121
+
122
+ STR_NOT_IMPL_ENC_DEC_MM = ("Multimodal is not currently "
123
+ "supported with encoder/decoder "
124
+ "models.")
125
+
126
+ STR_NOT_IMPL_ENC_DEC_SPEC_DEC = ("Speculative decoding is not "
127
+ "currently supported with encoder/"
128
+ "decoder models.")
129
+
130
+ STR_NOT_IMPL_ENC_DEC_BACKEND = ("XFormers and Flash-Attention are the only "
131
+ "backends currently supported with encoder/"
132
+ "decoder models.")
133
+
134
+ # Efficiently import all enc/dec error strings
135
+ # rather than having to import all of the above
136
+ STR_NOT_IMPL_ENC_DEC_ERR_STRS = {
137
+ "STR_NOT_IMPL_ENC_DEC_SWA": STR_NOT_IMPL_ENC_DEC_SWA,
138
+ "STR_NOT_IMPL_ENC_DEC_PREFIX_CACHE": STR_NOT_IMPL_ENC_DEC_PREFIX_CACHE,
139
+ "STR_NOT_IMPL_ENC_DEC_CHUNKED_PREFILL":
140
+ STR_NOT_IMPL_ENC_DEC_CHUNKED_PREFILL,
141
+ "STR_NOT_IMPL_ENC_DEC_LOGIT_SOFTCAP": STR_NOT_IMPL_ENC_DEC_LOGIT_SOFTCAP,
142
+ "STR_NOT_IMPL_ENC_DEC_LORA": STR_NOT_IMPL_ENC_DEC_LORA,
143
+ "STR_NOT_IMPL_ENC_DEC_PP": STR_NOT_IMPL_ENC_DEC_PP,
144
+ "STR_NOT_IMPL_ENC_DEC_MM": STR_NOT_IMPL_ENC_DEC_MM,
145
+ "STR_NOT_IMPL_ENC_DEC_SPEC_DEC": STR_NOT_IMPL_ENC_DEC_SPEC_DEC,
146
+ "STR_NOT_IMPL_ENC_DEC_BACKEND": STR_NOT_IMPL_ENC_DEC_BACKEND,
147
+ }
148
+
149
+ # Constants related to forcing the attention backend selection
150
+
151
+ # String name of register which may be set in order to
152
+ # force auto-selection of attention backend by Attention
153
+ # wrapper
154
+ STR_BACKEND_ENV_VAR: str = "VLLM_ATTENTION_BACKEND"
155
+
156
+ # Possible string values of STR_BACKEND_ENV_VAR
157
+ # register, corresponding to possible backends
158
+ STR_FLASHINFER_ATTN_VAL: str = "FLASHINFER"
159
+ STR_TORCH_SDPA_ATTN_VAL: str = "TORCH_SDPA"
160
+ STR_ROCM_FLASH_ATTN_VAL: str = "ROCM_FLASH"
161
+ STR_XFORMERS_ATTN_VAL: str = "XFORMERS"
162
+ STR_FLASH_ATTN_VAL: str = "FLASH_ATTN"
163
+ STR_DUAL_CHUNK_FLASH_ATTN_VAL: str = "DUAL_CHUNK_FLASH_ATTN"
164
+ STR_INVALID_VAL: str = "INVALID"
165
+
166
+ GB_bytes = 1_000_000_000
167
+ """The number of bytes in one gigabyte (GB)."""
168
+
169
+ GiB_bytes = 1 << 30
170
+ """The number of bytes in one gibibyte (GiB)."""
171
+
172
+ # ANSI color codes
173
+ CYAN = '\033[1;36m'
174
+ RESET = '\033[0;0m'
175
+
176
+ STR_DTYPE_TO_TORCH_DTYPE = {
177
+ "float32": torch.float32,
178
+ "half": torch.half,
179
+ "bfloat16": torch.bfloat16,
180
+ "float": torch.float,
181
+ "fp8": torch.uint8,
182
+ "fp8_e4m3": torch.uint8,
183
+ "fp8_e5m2": torch.uint8,
184
+ "int8": torch.int8,
185
+ "fp8_inc": torch.float8_e4m3fn,
186
+ }
187
+
188
+ TORCH_DTYPE_TO_NUMPY_DTYPE = {
189
+ torch.float16: np.float16,
190
+ torch.float32: np.float32,
191
+ torch.float64: np.float64,
192
+ torch.uint8: np.uint8,
193
+ torch.int32: np.int32,
194
+ torch.int64: np.int64,
195
+ }
196
+
197
+
198
+ @contextlib.contextmanager
199
+ def set_default_torch_num_threads(num_threads: int):
200
+ """Sets the default number of threads for PyTorch to the given value."""
201
+ old_num_threads = torch.get_num_threads()
202
+ torch.set_num_threads(num_threads)
203
+ yield
204
+ torch.set_num_threads(old_num_threads)
205
+
206
+
207
+ P = ParamSpec('P')
208
+ T = TypeVar("T")
209
+ U = TypeVar("U")
210
+
211
+ _K = TypeVar("_K", bound=Hashable)
212
+ _V = TypeVar("_V")
213
+ _T = TypeVar("_T")
214
+
215
+
216
+ class _Sentinel:
217
+ ...
218
+
219
+
220
+ ALL_PINNED_SENTINEL = _Sentinel()
221
+
222
+
223
+ class Device(enum.Enum):
224
+ GPU = enum.auto()
225
+ CPU = enum.auto()
226
+
227
+
228
+ class LayerBlockType(enum.Enum):
229
+ attention = "attention"
230
+ mamba = "mamba"
231
+
232
+
233
+ class Counter:
234
+
235
+ def __init__(self, start: int = 0) -> None:
236
+ self.counter = start
237
+
238
+ def __next__(self) -> int:
239
+ i = self.counter
240
+ self.counter += 1
241
+ return i
242
+
243
+ def reset(self) -> None:
244
+ self.counter = 0
245
+
246
+
247
+ class _MappingOrderCacheView(UserDict[_K, _V]):
248
+
249
+ def __init__(self, data: Mapping[_K, _V], ordered_keys: Mapping[_K, None]):
250
+ super().__init__(data)
251
+ self.ordered_keys = ordered_keys
252
+
253
+ def __iter__(self) -> Iterator[_K]:
254
+ return iter(self.ordered_keys)
255
+
256
+ def keys(self) -> KeysView[_K]:
257
+ return KeysView(self.ordered_keys)
258
+
259
+
260
+ class CacheInfo(NamedTuple):
261
+ hits: int
262
+ total: int
263
+
264
+ @property
265
+ def hit_ratio(self) -> float:
266
+ if self.total == 0:
267
+ return 0
268
+
269
+ return self.hits / self.total
270
+
271
+ def __sub__(self, other: CacheInfo):
272
+ return CacheInfo(
273
+ hits=self.hits - other.hits,
274
+ total=self.total - other.total,
275
+ )
276
+
277
+
278
+ class LRUCache(cachetools.LRUCache[_K, _V], Generic[_K, _V]):
279
+
280
+ def __init__(self,
281
+ capacity: float,
282
+ getsizeof: Optional[Callable[[_V], float]] = None):
283
+ super().__init__(capacity, getsizeof)
284
+
285
+ self.pinned_items = set[_K]()
286
+
287
+ self._hits = 0
288
+ self._total = 0
289
+ self._last_info = CacheInfo(hits=0, total=0)
290
+
291
+ def __getitem__(self, key: _K, *, update_info: bool = True) -> _V:
292
+ value = super().__getitem__(key)
293
+
294
+ if update_info:
295
+ self._hits += 1
296
+ self._total += 1
297
+
298
+ return value
299
+
300
+ def __delitem__(self, key: _K) -> None:
301
+ run_on_remove = key in self
302
+ value = self.__getitem__(key,
303
+ update_info=False) # type: ignore[call-arg]
304
+ super().__delitem__(key)
305
+ if key in self.pinned_items:
306
+ # Todo: add warning to inform that del pinned item
307
+ self._unpin(key)
308
+ if run_on_remove:
309
+ self._on_remove(key, value)
310
+
311
+ @property
312
+ def cache(self) -> Mapping[_K, _V]:
313
+ """Return the internal cache dictionary in order (read-only)."""
314
+ return _MappingOrderCacheView(
315
+ self._Cache__data, # type: ignore
316
+ self.order)
317
+
318
+ @property
319
+ def order(self) -> Mapping[_K, None]:
320
+ """Return the internal order dictionary (read-only)."""
321
+ return MappingProxyType(self._LRUCache__order) # type: ignore
322
+
323
+ @property
324
+ def capacity(self) -> float:
325
+ return self.maxsize
326
+
327
+ @property
328
+ def usage(self) -> float:
329
+ if self.maxsize == 0:
330
+ return 0
331
+
332
+ return self.currsize / self.maxsize
333
+
334
+ def stat(self, *, delta: bool = False) -> CacheInfo:
335
+ """
336
+ Gets the cumulative number of hits and queries against this cache.
337
+
338
+ If `delta=True`, instead gets these statistics
339
+ since the last call that also passed `delta=True`.
340
+ """
341
+ info = CacheInfo(hits=self._hits, total=self._total)
342
+
343
+ if delta:
344
+ info_delta = info - self._last_info
345
+ self._last_info = info
346
+ info = info_delta
347
+
348
+ return info
349
+
350
+ def touch(self, key: _K) -> None:
351
+ try:
352
+ self._LRUCache__order.move_to_end(key) # type: ignore
353
+ except KeyError:
354
+ self._LRUCache__order[key] = None # type: ignore
355
+
356
+ @overload
357
+ def get(self, key: _K, /) -> Optional[_V]:
358
+ ...
359
+
360
+ @overload
361
+ def get(self, key: _K, /, default: Union[_V, _T]) -> Union[_V, _T]:
362
+ ...
363
+
364
+ def get(self,
365
+ key: _K,
366
+ /,
367
+ default: Optional[Union[_V,
368
+ _T]] = None) -> Optional[Union[_V, _T]]:
369
+ value: Optional[Union[_V, _T]]
370
+ if key in self:
371
+ value = self.__getitem__(
372
+ key, update_info=False) # type: ignore[call-arg]
373
+
374
+ self._hits += 1
375
+ else:
376
+ value = default
377
+
378
+ self._total += 1
379
+ return value
380
+
381
+ @overload
382
+ def pop(self, key: _K) -> _V:
383
+ ...
384
+
385
+ @overload
386
+ def pop(self, key: _K, default: Union[_V, _T]) -> Union[_V, _T]:
387
+ ...
388
+
389
+ def pop(self,
390
+ key: _K,
391
+ default: Optional[Union[_V,
392
+ _T]] = None) -> Optional[Union[_V, _T]]:
393
+ value: Optional[Union[_V, _T]]
394
+ if key not in self:
395
+ return default
396
+
397
+ value = self.__getitem__(key,
398
+ update_info=False) # type: ignore[call-arg]
399
+ self.__delitem__(key)
400
+ return value
401
+
402
+ def put(self, key: _K, value: _V) -> None:
403
+ self.__setitem__(key, value)
404
+
405
+ def pin(self, key: _K) -> None:
406
+ """
407
+ Pins a key in the cache preventing it from being
408
+ evicted in the LRU order.
409
+ """
410
+ if key not in self:
411
+ raise ValueError(f"Cannot pin key: {key} not in cache.")
412
+ self.pinned_items.add(key)
413
+
414
+ def _unpin(self, key: _K) -> None:
415
+ """
416
+ Unpins a key in the cache allowing it to be
417
+ evicted in the LRU order.
418
+ """
419
+ self.pinned_items.remove(key)
420
+
421
+ def _on_remove(self, key: _K, value: Optional[_V]) -> None:
422
+ pass
423
+
424
+ def remove_oldest(self, *, remove_pinned: bool = False) -> None:
425
+ if len(self) == 0:
426
+ return
427
+
428
+ self.popitem(remove_pinned=remove_pinned)
429
+
430
+ def _remove_old_if_needed(self) -> None:
431
+ while self.currsize > self.capacity:
432
+ self.remove_oldest()
433
+
434
+ def popitem(self, remove_pinned: bool = False):
435
+ """Remove and return the `(key, value)` pair least recently used."""
436
+ if not remove_pinned:
437
+ # pop the oldest item in the cache that is not pinned
438
+ lru_key = next(
439
+ (key for key in self.order if key not in self.pinned_items),
440
+ ALL_PINNED_SENTINEL)
441
+ if lru_key is ALL_PINNED_SENTINEL:
442
+ raise RuntimeError("All items are pinned, "
443
+ "cannot remove oldest from the cache.")
444
+ else:
445
+ lru_key = next(iter(self.order))
446
+ value = self.pop(cast(_K, lru_key))
447
+ return (lru_key, value)
448
+
449
+ def clear(self) -> None:
450
+ while len(self) > 0:
451
+ self.remove_oldest(remove_pinned=True)
452
+
453
+ self._hits = 0
454
+ self._total = 0
455
+ self._last_info = CacheInfo(hits=0, total=0)
456
+
457
+
458
+ class PyObjectCache:
459
+ """Used to cache python objects to avoid object allocations
460
+ across scheduler iterations.
461
+ """
462
+
463
+ def __init__(self, obj_builder):
464
+ self._obj_builder = obj_builder
465
+ self._index = 0
466
+
467
+ self._obj_cache = []
468
+ for _ in range(128):
469
+ self._obj_cache.append(self._obj_builder())
470
+
471
+ def _grow_cache(self):
472
+ # Double the size of the cache
473
+ num_objs = len(self._obj_cache)
474
+ for _ in range(num_objs):
475
+ self._obj_cache.append(self._obj_builder())
476
+
477
+ def get_object(self):
478
+ """Returns a pre-allocated cached object. If there is not enough
479
+ objects, then the cache size will double.
480
+ """
481
+ if self._index >= len(self._obj_cache):
482
+ self._grow_cache()
483
+ assert self._index < len(self._obj_cache)
484
+
485
+ obj = self._obj_cache[self._index]
486
+ self._index += 1
487
+
488
+ return obj
489
+
490
+ def reset(self):
491
+ """Makes all cached-objects available for the next scheduler iteration.
492
+ """
493
+ self._index = 0
494
+
495
+
496
+ @cache
497
+ def get_max_shared_memory_bytes(gpu: int = 0) -> int:
498
+ """Returns the maximum shared memory per thread block in bytes."""
499
+ from vllm import _custom_ops as ops
500
+ max_shared_mem = (
501
+ ops.get_max_shared_memory_per_block_device_attribute(gpu))
502
+ # value 0 will cause MAX_SEQ_LEN become negative and test_attention.py
503
+ # will fail
504
+ assert max_shared_mem > 0, "max_shared_mem can not be zero"
505
+ return int(max_shared_mem)
506
+
507
+
508
+ def get_cpu_memory() -> int:
509
+ """Returns the total CPU memory of the node in bytes."""
510
+ return psutil.virtual_memory().total
511
+
512
+
513
+ def random_uuid() -> str:
514
+ return str(uuid.uuid4().hex)
515
+
516
+
517
+ class AsyncMicrobatchTokenizer:
518
+ """Asynchronous tokenizer with micro-batching.
519
+
520
+ Pulls pending encode/decode requests from a queue and batches them
521
+ up to reduce overhead. A single-thread ThreadPoolExecutor is used
522
+ so the event loop stays responsive.
523
+ """
524
+
525
+ def __init__(
526
+ self,
527
+ tokenizer,
528
+ max_batch_size: int = 32,
529
+ batch_wait_timeout_s: float = 0.002,
530
+ ) -> None:
531
+ self.tokenizer = tokenizer
532
+ self.max_batch_size = max_batch_size
533
+ self.batch_wait_timeout_s = batch_wait_timeout_s
534
+
535
+ self._loop = asyncio.get_running_loop()
536
+ self._queues: dict[tuple,
537
+ asyncio.Queue[Union[tuple[str, dict,
538
+ asyncio.Future],
539
+ tuple[list[int],
540
+ asyncio.Future]]]] = {}
541
+ self._batcher_tasks: list[asyncio.Task] = []
542
+
543
+ # Single-thread executor for blocking tokenizer calls.
544
+ self._executor = ThreadPoolExecutor(max_workers=1)
545
+
546
+ # === Public async API ===
547
+ async def __call__(self, prompt, **kwargs):
548
+ result_future: asyncio.Future = self._loop.create_future()
549
+ key = self._queue_key("encode", kwargs)
550
+ queue = self._get_queue(self._loop, key)
551
+ await queue.put((prompt, kwargs, result_future))
552
+ return await result_future
553
+
554
+ async def decode(self, token_ids, **kwargs):
555
+ result_future: asyncio.Future = self._loop.create_future()
556
+ key = self._queue_key("decode", kwargs)
557
+ queue = self._get_queue(self._loop, key)
558
+ await queue.put((token_ids, result_future))
559
+ return await result_future
560
+
561
+ # === Internal helpers ===
562
+ def _get_queue(
563
+ self, loop: asyncio.AbstractEventLoop, key: tuple
564
+ ) -> asyncio.Queue[Union[tuple[str, dict, asyncio.Future], tuple[
565
+ list[int], asyncio.Future]]]:
566
+ """Get the request queue for the given operation key, creating a new
567
+ queue and batcher task if needed."""
568
+ queue = self._queues.get(key)
569
+ if queue is None:
570
+ self._queues[key] = queue = asyncio.Queue()
571
+ if key[0] == "encode":
572
+ can_batch = key[1] != "other"
573
+ coro = self._batch_encode_loop(queue, can_batch)
574
+ else:
575
+ assert key[0] == "decode", \
576
+ f"Unknown operation type: {key[0]}."
577
+ coro = self._batch_decode_loop(queue)
578
+ self._batcher_tasks.append(loop.create_task(coro))
579
+ return queue
580
+
581
+ async def _batch_encode_loop(self, queue: asyncio.Queue, can_batch: bool):
582
+ """Batch incoming encode requests for efficiency."""
583
+ while True:
584
+ prompt, kwargs, result_future = await queue.get()
585
+ prompts = [prompt]
586
+ kwargs_list = [kwargs]
587
+ result_futures = [result_future]
588
+ deadline = self._loop.time() + self.batch_wait_timeout_s
589
+
590
+ while len(prompts) < self.max_batch_size:
591
+ timeout = deadline - self._loop.time()
592
+ if timeout <= 0:
593
+ break
594
+ try:
595
+ prompt, kwargs, result_future = await asyncio.wait_for(
596
+ queue.get(), timeout)
597
+ prompts.append(prompt)
598
+ result_futures.append(result_future)
599
+ if not can_batch:
600
+ kwargs_list.append(kwargs)
601
+ except asyncio.TimeoutError:
602
+ break
603
+
604
+ try:
605
+ # If every request uses identical kwargs we can run a single
606
+ # batched tokenizer call for a big speed-up.
607
+ if can_batch and len(prompts) > 1:
608
+ encode_fn = partial(self.tokenizer, prompts, **kwargs)
609
+ results = await self._loop.run_in_executor(
610
+ self._executor, encode_fn)
611
+
612
+ for i, fut in enumerate(result_futures):
613
+ if not fut.done():
614
+ data = {k: v[i] for k, v in results.items()}
615
+ fut.set_result(BatchEncoding(data))
616
+ else:
617
+ encode_fn = lambda prompts=prompts, kwargs=kwargs_list: [
618
+ self.tokenizer(p, **kw)
619
+ for p, kw in zip(prompts, kwargs)
620
+ ]
621
+ results = await self._loop.run_in_executor(
622
+ self._executor, encode_fn)
623
+
624
+ for fut, res in zip(result_futures, results):
625
+ if not fut.done():
626
+ fut.set_result(res)
627
+ except Exception as e:
628
+ for fut in result_futures:
629
+ if not fut.done():
630
+ fut.set_exception(e)
631
+
632
+ async def _batch_decode_loop(self, queue: asyncio.Queue):
633
+ """Batch incoming decode requests for efficiency."""
634
+ while True:
635
+ token_ids, result_future = await queue.get()
636
+ token_ids_list = [token_ids]
637
+ result_futures = [result_future]
638
+ deadline = self._loop.time() + self.batch_wait_timeout_s
639
+
640
+ while len(token_ids_list) < self.max_batch_size:
641
+ timeout = deadline - self._loop.time()
642
+ if timeout <= 0:
643
+ break
644
+ try:
645
+ token_ids, result_future = await asyncio.wait_for(
646
+ queue.get(), timeout)
647
+ token_ids_list.append(token_ids)
648
+ result_futures.append(result_future)
649
+ except asyncio.TimeoutError:
650
+ break
651
+
652
+ try:
653
+ # Perform a single batched decode call for all requests
654
+ results = await self._loop.run_in_executor(
655
+ self._executor, self.tokenizer.batch_decode,
656
+ token_ids_list)
657
+ for fut, res in zip(result_futures, results):
658
+ if not fut.done():
659
+ fut.set_result(res)
660
+ except Exception as e:
661
+ for fut in result_futures:
662
+ if not fut.done():
663
+ fut.set_exception(e)
664
+
665
+ def _queue_key(self, op: str, kwargs: dict) -> tuple:
666
+ """
667
+ Return a normalized key describing operation + kwargs.
668
+
669
+ - `add_special_tokens`: {True/False}
670
+ - `truncation`: {True/False}
671
+ - If `truncation` is False (`max_length` is None),
672
+ returns a key for a can_batch queue.
673
+ - If `truncation` is True and `max_length` is None or equals
674
+ `tokenizer.model_max_length`, returns a key for a can_batch queue.
675
+ - Otherwise, returns a key for a cannot_batch queue.
676
+
677
+ Examples:
678
+ - Decode: ("decode",)
679
+ - Encode typical:
680
+ ("encode", add_special_tokens, bool_truncation, max_length_label)
681
+ - Fallback: ("encode", "other")
682
+ """
683
+
684
+ if op == "decode":
685
+ return ("decode", )
686
+
687
+ add_special_tokens = kwargs.get("add_special_tokens", True)
688
+ truncation = kwargs.get("truncation", False)
689
+ max_length = kwargs.get("max_length")
690
+
691
+ if not truncation:
692
+ return "encode", add_special_tokens, False, None
693
+
694
+ model_max = getattr(self.tokenizer, "model_max_length", None)
695
+ if max_length is None or (model_max is not None
696
+ and max_length == model_max):
697
+ return "encode", add_special_tokens, True, "model_max"
698
+
699
+ return "encode", "other"
700
+
701
+ def __del__(self):
702
+ if ((tasks := getattr(self, "_batcher_tasks", None))
703
+ and (loop := getattr(self, "_loop", None))
704
+ and not loop.is_closed()):
705
+
706
+ def cancel_tasks():
707
+ for task in tasks:
708
+ task.cancel()
709
+
710
+ loop.call_soon_threadsafe(cancel_tasks)
711
+
712
+
713
+ def cancel_task_threadsafe(task: Task):
714
+ if task and not task.done():
715
+ run_in_loop(task.get_loop(), task.cancel)
716
+
717
+
718
+ def close_sockets(sockets: Sequence[Union[zmq.Socket, zmq.asyncio.Socket]]):
719
+ for sock in sockets:
720
+ if sock is not None:
721
+ sock.close(linger=0)
722
+
723
+
724
+ def run_in_loop(loop: AbstractEventLoop, function: Callable, *args):
725
+ if in_loop(loop):
726
+ function(*args)
727
+ elif not loop.is_closed():
728
+ loop.call_soon_threadsafe(function, *args)
729
+
730
+
731
+ def in_loop(event_loop: AbstractEventLoop) -> bool:
732
+ try:
733
+ return asyncio.get_running_loop() == event_loop
734
+ except RuntimeError:
735
+ return False
736
+
737
+
738
+ def make_async(
739
+ func: Callable[P, T],
740
+ executor: Optional[concurrent.futures.Executor] = None
741
+ ) -> Callable[P, Awaitable[T]]:
742
+ """Take a blocking function, and run it on in an executor thread.
743
+
744
+ This function prevents the blocking function from blocking the
745
+ asyncio event loop.
746
+ The code in this function needs to be thread safe.
747
+ """
748
+
749
+ def _async_wrapper(*args: P.args, **kwargs: P.kwargs) -> asyncio.Future:
750
+ loop = asyncio.get_event_loop()
751
+ p_func = partial(func, *args, **kwargs)
752
+ return loop.run_in_executor(executor=executor, func=p_func)
753
+
754
+ return _async_wrapper
755
+
756
+
757
+ def _next_task(iterator: AsyncGenerator[T, None],
758
+ loop: AbstractEventLoop) -> Task:
759
+ # Can use anext() in python >= 3.10
760
+ return loop.create_task(iterator.__anext__()) # type: ignore[arg-type]
761
+
762
+
763
+ async def merge_async_iterators(
764
+ *iterators: AsyncGenerator[T,
765
+ None], ) -> AsyncGenerator[tuple[int, T], None]:
766
+ """Merge multiple asynchronous iterators into a single iterator.
767
+
768
+ This method handle the case where some iterators finish before others.
769
+ When it yields, it yields a tuple (i, item) where i is the index of the
770
+ iterator that yields the item.
771
+ """
772
+ if len(iterators) == 1:
773
+ # Fast-path single iterator case.
774
+ async for item in iterators[0]:
775
+ yield 0, item
776
+ return
777
+
778
+ loop = asyncio.get_running_loop()
779
+
780
+ awaits = {_next_task(pair[1], loop): pair for pair in enumerate(iterators)}
781
+ try:
782
+ while awaits:
783
+ done, _ = await asyncio.wait(awaits.keys(),
784
+ return_when=FIRST_COMPLETED)
785
+ for d in done:
786
+ pair = awaits.pop(d)
787
+ try:
788
+ item = await d
789
+ i, it = pair
790
+ awaits[_next_task(it, loop)] = pair
791
+ yield i, item
792
+ except StopAsyncIteration:
793
+ pass
794
+ finally:
795
+ # Cancel any remaining iterators
796
+ for f, (_, it) in awaits.items():
797
+ with contextlib.suppress(BaseException):
798
+ f.cancel()
799
+ await it.aclose()
800
+
801
+
802
+ async def collect_from_async_generator(
803
+ iterator: AsyncGenerator[T, None]) -> list[T]:
804
+ """Collect all items from an async generator into a list."""
805
+ items = []
806
+ async for item in iterator:
807
+ items.append(item)
808
+ return items
809
+
810
+
811
+ def get_ip() -> str:
812
+ host_ip = envs.VLLM_HOST_IP
813
+ if "HOST_IP" in os.environ and "VLLM_HOST_IP" not in os.environ:
814
+ logger.warning(
815
+ "The environment variable HOST_IP is deprecated and ignored, as"
816
+ " it is often used by Docker and other software to"
817
+ " interact with the container's network stack. Please "
818
+ "use VLLM_HOST_IP instead to set the IP address for vLLM processes"
819
+ " to communicate with each other.")
820
+ if host_ip:
821
+ return host_ip
822
+
823
+ # IP is not set, try to get it from the network interface
824
+
825
+ # try ipv4
826
+ s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
827
+ try:
828
+ s.connect(("8.8.8.8", 80)) # Doesn't need to be reachable
829
+ return s.getsockname()[0]
830
+ except Exception:
831
+ pass
832
+
833
+ # try ipv6
834
+ try:
835
+ s = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)
836
+ # Google's public DNS server, see
837
+ # https://developers.google.com/speed/public-dns/docs/using#addresses
838
+ s.connect(("2001:4860:4860::8888", 80)) # Doesn't need to be reachable
839
+ return s.getsockname()[0]
840
+ except Exception:
841
+ pass
842
+
843
+ warnings.warn(
844
+ "Failed to get the IP address, using 0.0.0.0 by default."
845
+ "The value can be set by the environment variable"
846
+ " VLLM_HOST_IP or HOST_IP.",
847
+ stacklevel=2)
848
+ return "0.0.0.0"
849
+
850
+
851
+ def test_loopback_bind(address, family):
852
+ try:
853
+ s = socket.socket(family, socket.SOCK_DGRAM)
854
+ s.bind((address, 0)) # Port 0 = auto assign
855
+ s.close()
856
+ return True
857
+ except OSError:
858
+ return False
859
+
860
+
861
+ def get_loopback_ip() -> str:
862
+ loopback_ip = envs.VLLM_LOOPBACK_IP
863
+ if loopback_ip:
864
+ return loopback_ip
865
+
866
+ # VLLM_LOOPBACK_IP is not set, try to get it based on network interface
867
+
868
+ if test_loopback_bind("127.0.0.1", socket.AF_INET):
869
+ return "127.0.0.1"
870
+ elif test_loopback_bind("::1", socket.AF_INET6):
871
+ return "::1"
872
+ else:
873
+ raise RuntimeError(
874
+ "Neither 127.0.0.1 nor ::1 are bound to a local interface. "
875
+ "Set the VLLM_LOOPBACK_IP environment variable explicitly.")
876
+
877
+
878
+ def is_valid_ipv6_address(address: str) -> bool:
879
+ try:
880
+ ipaddress.IPv6Address(address)
881
+ return True
882
+ except ValueError:
883
+ return False
884
+
885
+
886
+ def split_host_port(host_port: str) -> tuple[str, int]:
887
+ # ipv6
888
+ if host_port.startswith('['):
889
+ host, port = host_port.rsplit(']', 1)
890
+ host = host[1:]
891
+ port = port.split(':')[1]
892
+ return host, int(port)
893
+ else:
894
+ host, port = host_port.split(':')
895
+ return host, int(port)
896
+
897
+
898
+ def join_host_port(host: str, port: int) -> str:
899
+ if is_valid_ipv6_address(host):
900
+ return f"[{host}]:{port}"
901
+ else:
902
+ return f"{host}:{port}"
903
+
904
+
905
+ def get_distributed_init_method(ip: str, port: int) -> str:
906
+ return get_tcp_uri(ip, port)
907
+
908
+
909
+ def get_tcp_uri(ip: str, port: int) -> str:
910
+ if is_valid_ipv6_address(ip):
911
+ return f"tcp://[{ip}]:{port}"
912
+ else:
913
+ return f"tcp://{ip}:{port}"
914
+
915
+
916
+ def get_open_zmq_ipc_path() -> str:
917
+ base_rpc_path = envs.VLLM_RPC_BASE_PATH
918
+ return f"ipc://{base_rpc_path}/{uuid4()}"
919
+
920
+
921
+ def get_open_zmq_inproc_path() -> str:
922
+ return f"inproc://{uuid4()}"
923
+
924
+
925
+ def get_open_port() -> int:
926
+ """
927
+ Get an open port for the vLLM process to listen on.
928
+ An edge case to handle, is when we run data parallel,
929
+ we need to avoid ports that are potentially used by
930
+ the data parallel master process.
931
+ Right now we reserve 10 ports for the data parallel master
932
+ process. Currently it uses 2 ports.
933
+ """
934
+ if "VLLM_DP_MASTER_PORT" in os.environ:
935
+ dp_master_port = envs.VLLM_DP_MASTER_PORT
936
+ reserved_port_range = range(dp_master_port, dp_master_port + 10)
937
+ while True:
938
+ candidate_port = _get_open_port()
939
+ if candidate_port not in reserved_port_range:
940
+ return candidate_port
941
+ return _get_open_port()
942
+
943
+
944
+ def get_open_ports_list(count: int = 5) -> list[int]:
945
+ """Get a list of open ports."""
946
+ ports = set()
947
+ while len(ports) < count:
948
+ ports.add(get_open_port())
949
+ return list(ports)
950
+
951
+
952
+ def _get_open_port() -> int:
953
+ port = envs.VLLM_PORT
954
+ if port is not None:
955
+ while True:
956
+ try:
957
+ with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
958
+ s.bind(("", port))
959
+ return port
960
+ except OSError:
961
+ port += 1 # Increment port number if already in use
962
+ logger.info("Port %d is already in use, trying port %d",
963
+ port - 1, port)
964
+ # try ipv4
965
+ try:
966
+ with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
967
+ s.bind(("", 0))
968
+ return s.getsockname()[1]
969
+ except OSError:
970
+ # try ipv6
971
+ with socket.socket(socket.AF_INET6, socket.SOCK_STREAM) as s:
972
+ s.bind(("", 0))
973
+ return s.getsockname()[1]
974
+
975
+
976
+ def find_process_using_port(port: int) -> Optional[psutil.Process]:
977
+ # TODO: We can not check for running processes with network
978
+ # port on macOS. Therefore, we can not have a full graceful shutdown
979
+ # of vLLM. For now, let's not look for processes in this case.
980
+ # Ref: https://www.florianreinhard.de/accessdenied-in-psutil/
981
+ if sys.platform.startswith("darwin"):
982
+ return None
983
+
984
+ for conn in psutil.net_connections():
985
+ if conn.laddr.port == port:
986
+ try:
987
+ return psutil.Process(conn.pid)
988
+ except psutil.NoSuchProcess:
989
+ return None
990
+ return None
991
+
992
+
993
+ def update_environment_variables(envs: dict[str, str]):
994
+ for k, v in envs.items():
995
+ if k in os.environ and os.environ[k] != v:
996
+ logger.warning(
997
+ "Overwriting environment variable %s "
998
+ "from '%s' to '%s'", k, os.environ[k], v)
999
+ os.environ[k] = v
1000
+
1001
+
1002
+ def chunk_list(lst: list[T], chunk_size: int):
1003
+ """Yield successive chunk_size chunks from lst."""
1004
+ for i in range(0, len(lst), chunk_size):
1005
+ yield lst[i:i + chunk_size]
1006
+
1007
+
1008
+ def cdiv(a: int, b: int) -> int:
1009
+ """Ceiling division."""
1010
+ return -(a // -b)
1011
+
1012
+
1013
+ def next_power_of_2(n) -> int:
1014
+ """The next power of 2 (inclusive)"""
1015
+ if n < 1:
1016
+ return 1
1017
+ return 1 << (n - 1).bit_length()
1018
+
1019
+
1020
+ def prev_power_of_2(n: int) -> int:
1021
+ """The previous power of 2 (inclusive)"""
1022
+ if n <= 0:
1023
+ return 0
1024
+ return 1 << (n.bit_length() - 1)
1025
+
1026
+
1027
+ def round_up(x: int, y: int) -> int:
1028
+ return ((x + y - 1) // y) * y
1029
+
1030
+
1031
+ def round_down(x: int, y: int) -> int:
1032
+ return (x // y) * y
1033
+
1034
+
1035
+ def _generate_random_fp8(
1036
+ tensor: torch.Tensor,
1037
+ low: float,
1038
+ high: float,
1039
+ ) -> None:
1040
+ # NOTE(zhaoyang): Due to NaN and Inf representation for fp8 data type,
1041
+ # it may occur Inf or NaN if we directly use torch.randint
1042
+ # to generate random data for fp8 data.
1043
+ # For example, s.11111.00 in fp8e5m2 format represents Inf.
1044
+ # | E4M3 | E5M2
1045
+ # -----|-------------|-------------------
1046
+ # Inf | N/A | s.11111.00
1047
+ # NaN | s.1111.111 | s.11111.{01,10,11}
1048
+ from vllm import _custom_ops as ops
1049
+ tensor_tmp = torch.empty_like(tensor, dtype=torch.float16)
1050
+ tensor_tmp.uniform_(low, high)
1051
+ ops.convert_fp8(tensor, tensor_tmp)
1052
+ del tensor_tmp
1053
+
1054
+
1055
+ def get_kv_cache_torch_dtype(
1056
+ cache_dtype: Optional[Union[str, torch.dtype]],
1057
+ model_dtype: Optional[Union[str, torch.dtype]] = None) -> torch.dtype:
1058
+ if isinstance(cache_dtype, str):
1059
+ if cache_dtype == "auto":
1060
+ if isinstance(model_dtype,
1061
+ str) and model_dtype in STR_DTYPE_TO_TORCH_DTYPE:
1062
+ torch_dtype = STR_DTYPE_TO_TORCH_DTYPE[model_dtype]
1063
+ elif isinstance(model_dtype, torch.dtype):
1064
+ torch_dtype = model_dtype
1065
+ else:
1066
+ raise ValueError(f"Invalid model dtype: {model_dtype}")
1067
+ elif cache_dtype in STR_DTYPE_TO_TORCH_DTYPE:
1068
+ torch_dtype = STR_DTYPE_TO_TORCH_DTYPE[cache_dtype]
1069
+ else:
1070
+ raise ValueError(f"Invalid kv cache dtype: {cache_dtype}")
1071
+ elif isinstance(cache_dtype, torch.dtype):
1072
+ torch_dtype = cache_dtype
1073
+ else:
1074
+ raise ValueError(f"Invalid kv cache dtype: {cache_dtype}")
1075
+ return torch_dtype
1076
+
1077
+
1078
+ def create_kv_caches_with_random_flash(
1079
+ num_blocks: int,
1080
+ block_size: int,
1081
+ num_layers: int,
1082
+ num_heads: int,
1083
+ head_size: int,
1084
+ cache_dtype: Optional[Union[str, torch.dtype]],
1085
+ model_dtype: Optional[Union[str, torch.dtype]] = None,
1086
+ seed: Optional[int] = None,
1087
+ device: Optional[str] = "cuda",
1088
+ cache_layout: Optional[str] = "NHD",
1089
+ ) -> tuple[list[torch.Tensor], list[torch.Tensor]]:
1090
+ from vllm.platforms import current_platform
1091
+ current_platform.seed_everything(seed)
1092
+
1093
+ torch_dtype = get_kv_cache_torch_dtype(cache_dtype, model_dtype)
1094
+ generic_kv_cache_shape = (num_blocks, 2, block_size, num_heads, head_size)
1095
+ assert cache_layout in ("NHD", "HND")
1096
+ stride_order = (0, 1, 2, 3, 4) if cache_layout == "NHD" else (0, 1, 3, 2,
1097
+ 4)
1098
+
1099
+ kv_cache_allocation_shape = tuple(generic_kv_cache_shape[i]
1100
+ for i in stride_order)
1101
+ scale = head_size**-0.5
1102
+
1103
+ key_caches: list[torch.Tensor] = []
1104
+ value_caches: list[torch.Tensor] = []
1105
+
1106
+ for _ in range(num_layers):
1107
+ key_value_cache = torch.empty(size=kv_cache_allocation_shape,
1108
+ dtype=torch_dtype,
1109
+ device=device).permute(*stride_order)
1110
+ if cache_dtype in ["auto", "half", "bfloat16", "float"]:
1111
+ key_value_cache.uniform_(-scale, scale)
1112
+ elif cache_dtype == 'fp8':
1113
+ _generate_random_fp8(key_value_cache, -scale, scale)
1114
+ else:
1115
+ raise ValueError(
1116
+ f"Does not support key cache of type {cache_dtype}")
1117
+ key_caches.append(key_value_cache[:, 0])
1118
+ value_caches.append(key_value_cache[:, 1])
1119
+ return key_caches, value_caches
1120
+
1121
+
1122
+ def create_kv_caches_with_random(
1123
+ num_blocks: int,
1124
+ block_size: int,
1125
+ num_layers: int,
1126
+ num_heads: int,
1127
+ head_size: int,
1128
+ cache_dtype: Optional[Union[str, torch.dtype]],
1129
+ model_dtype: Optional[Union[str, torch.dtype]] = None,
1130
+ seed: Optional[int] = None,
1131
+ device: Optional[str] = "cuda",
1132
+ ) -> tuple[list[torch.Tensor], list[torch.Tensor]]:
1133
+ if cache_dtype == "fp8" and head_size % 16:
1134
+ raise ValueError(
1135
+ f"Does not support key cache of type fp8 with head_size {head_size}"
1136
+ )
1137
+ from vllm.platforms import current_platform
1138
+ current_platform.seed_everything(seed)
1139
+
1140
+ torch_dtype = get_kv_cache_torch_dtype(cache_dtype, model_dtype)
1141
+
1142
+ scale = head_size**-0.5
1143
+ x = 16 // torch.tensor([], dtype=torch_dtype).element_size()
1144
+ key_cache_shape = (num_blocks, num_heads, head_size // x, block_size, x)
1145
+ key_caches: list[torch.Tensor] = []
1146
+ for _ in range(num_layers):
1147
+ key_cache = torch.empty(size=key_cache_shape,
1148
+ dtype=torch_dtype,
1149
+ device=device)
1150
+ if cache_dtype in ["auto", "half", "bfloat16", "float"]:
1151
+ key_cache.uniform_(-scale, scale)
1152
+ elif cache_dtype == 'fp8':
1153
+ _generate_random_fp8(key_cache, -scale, scale)
1154
+ else:
1155
+ raise ValueError(
1156
+ f"Does not support key cache of type {cache_dtype}")
1157
+ key_caches.append(key_cache)
1158
+
1159
+ value_cache_shape = (num_blocks, num_heads, head_size, block_size)
1160
+ value_caches: list[torch.Tensor] = []
1161
+ for _ in range(num_layers):
1162
+ value_cache = torch.empty(size=value_cache_shape,
1163
+ dtype=torch_dtype,
1164
+ device=device)
1165
+ if cache_dtype in ["auto", "half", "bfloat16", "float"]:
1166
+ value_cache.uniform_(-scale, scale)
1167
+ elif cache_dtype == 'fp8':
1168
+ _generate_random_fp8(value_cache, -scale, scale)
1169
+ else:
1170
+ raise ValueError(
1171
+ f"Does not support value cache of type {cache_dtype}")
1172
+ value_caches.append(value_cache)
1173
+ return key_caches, value_caches
1174
+
1175
+
1176
+ @cache
1177
+ def is_pin_memory_available() -> bool:
1178
+ from vllm.platforms import current_platform
1179
+ return current_platform.is_pin_memory_available()
1180
+
1181
+
1182
+ @cache
1183
+ def is_uva_available() -> bool:
1184
+ """Check if Unified Virtual Addressing (UVA) is available."""
1185
+ # UVA requires pinned memory.
1186
+ # TODO: Add more requirements for UVA if needed.
1187
+ return is_pin_memory_available()
1188
+
1189
+
1190
+ class DeviceMemoryProfiler:
1191
+
1192
+ def __init__(self, device: Optional[torch.types.Device] = None):
1193
+ self.device = device
1194
+
1195
+ def current_memory_usage(self) -> float:
1196
+ # Return the memory usage in bytes.
1197
+ from vllm.platforms import current_platform
1198
+ gc.collect()
1199
+ return current_platform.get_current_memory_usage(self.device)
1200
+
1201
+ def __enter__(self):
1202
+ self.initial_memory = self.current_memory_usage()
1203
+ # This allows us to call methods of the context manager if needed
1204
+ return self
1205
+
1206
+ def __exit__(self, exc_type, exc_val, exc_tb):
1207
+ self.final_memory = self.current_memory_usage()
1208
+ self.consumed_memory = self.final_memory - self.initial_memory
1209
+
1210
+ # Force garbage collection
1211
+ gc.collect()
1212
+
1213
+
1214
+ def make_ndarray_with_pad(
1215
+ x: list[list[T]],
1216
+ pad: T,
1217
+ dtype: npt.DTypeLike,
1218
+ *,
1219
+ max_len: Optional[int] = None,
1220
+ ) -> npt.NDArray:
1221
+ """
1222
+ Make a padded array from 2D inputs.
1223
+
1224
+ The padding is applied to the end of each inner list until it reaches
1225
+ `max_len`.
1226
+ """
1227
+ if max_len is None:
1228
+ # Unlike for most functions, map is faster than a genexpr over `len`
1229
+ max_len = max(map(len, x), default=0)
1230
+
1231
+ padded_x = np.full((len(x), max_len), pad, dtype=dtype)
1232
+ for ind, blocktb in enumerate(x):
1233
+ assert len(blocktb) <= max_len
1234
+ padded_x[ind, :len(blocktb)] = blocktb
1235
+
1236
+ return padded_x
1237
+
1238
+
1239
+ def make_tensor_with_pad(
1240
+ x: list[list[T]],
1241
+ pad: T,
1242
+ dtype: torch.dtype,
1243
+ *,
1244
+ max_len: Optional[int] = None,
1245
+ device: Optional[Union[str, torch.device]] = None,
1246
+ pin_memory: bool = False,
1247
+ ) -> torch.Tensor:
1248
+ """
1249
+ Make a padded tensor from 2D inputs.
1250
+
1251
+ The padding is applied to the end of each inner list until it reaches
1252
+ `max_len`.
1253
+ """
1254
+ np_dtype = TORCH_DTYPE_TO_NUMPY_DTYPE[dtype]
1255
+ padded_x = make_ndarray_with_pad(x, pad, np_dtype, max_len=max_len)
1256
+
1257
+ tensor = torch.from_numpy(padded_x).to(device)
1258
+ if pin_memory:
1259
+ tensor = tensor.pin_memory()
1260
+
1261
+ return tensor
1262
+
1263
+
1264
+ def async_tensor_h2d(
1265
+ data: list,
1266
+ dtype: torch.dtype,
1267
+ target_device: Union[str, torch.device],
1268
+ pin_memory: bool,
1269
+ ) -> torch.Tensor:
1270
+ """Asynchronously create a tensor and copy it from host to device."""
1271
+ t = torch.tensor(data, dtype=dtype, pin_memory=pin_memory, device="cpu")
1272
+ return t.to(device=target_device, non_blocking=True)
1273
+
1274
+
1275
+ def get_dtype_size(dtype: torch.dtype) -> int:
1276
+ """Get the size of the data type in bytes."""
1277
+ return torch.tensor([], dtype=dtype).element_size()
1278
+
1279
+
1280
+ # bool = 0, int = 1, float = 2, complex = 3
1281
+ def _get_precision_level(dtype: torch.dtype) -> int:
1282
+ # NOTE: Complex dtypes return `is_floating_point=False`
1283
+ return ((dtype != torch.bool) + dtype.is_floating_point +
1284
+ dtype.is_complex * 2)
1285
+
1286
+
1287
+ def is_lossless_cast(src_dtype: torch.dtype, tgt_dtype: torch.dtype):
1288
+ """
1289
+ Test whether it is lossless to cast a tensor from
1290
+ `src_dtype` to `tgt_dtype`.
1291
+ """
1292
+ if src_dtype == tgt_dtype:
1293
+ return True
1294
+
1295
+ src_level = _get_precision_level(src_dtype)
1296
+ tgt_level = _get_precision_level(tgt_dtype)
1297
+
1298
+ if src_level < tgt_level:
1299
+ return True
1300
+ if src_level > tgt_level:
1301
+ return False
1302
+
1303
+ # Compare integral types
1304
+ if not src_dtype.is_floating_point and not src_dtype.is_complex:
1305
+ src_info = torch.iinfo(src_dtype)
1306
+ tgt_info = torch.iinfo(tgt_dtype)
1307
+ return src_info.min >= tgt_info.min and src_info.max <= tgt_info.max
1308
+
1309
+ # Compare floating-point types
1310
+ src_info = torch.finfo(src_dtype)
1311
+ tgt_info = torch.finfo(tgt_dtype)
1312
+ return (src_info.min >= tgt_info.min and src_info.max <= tgt_info.max
1313
+ and src_info.resolution >= tgt_info.resolution)
1314
+
1315
+
1316
+ def common_broadcastable_dtype(dtypes: Collection[torch.dtype]):
1317
+ """
1318
+ Get the common `dtype` where all of the other `dtypes` can be
1319
+ cast to it without losing any information.
1320
+ """
1321
+ return max(
1322
+ dtypes,
1323
+ key=lambda dtype: sum(is_lossless_cast(dt, dtype) for dt in dtypes),
1324
+ )
1325
+
1326
+
1327
+ def as_list(maybe_list: Iterable[T]) -> list[T]:
1328
+ """Convert iterable to list, unless it's already a list."""
1329
+ return maybe_list if isinstance(maybe_list, list) else list(maybe_list)
1330
+
1331
+
1332
+ def as_iter(obj: Union[T, Iterable[T]]) -> Iterable[T]:
1333
+ if isinstance(obj, str) or not isinstance(obj, Iterable):
1334
+ obj = [obj]
1335
+ return obj
1336
+
1337
+
1338
+ # `collections` helpers
1339
+ def is_list_of(
1340
+ value: object,
1341
+ typ: Union[type[T], tuple[type[T], ...]],
1342
+ *,
1343
+ check: Literal["first", "all"] = "first",
1344
+ ) -> TypeIs[list[T]]:
1345
+ if not isinstance(value, list):
1346
+ return False
1347
+
1348
+ if check == "first":
1349
+ return len(value) == 0 or isinstance(value[0], typ)
1350
+ elif check == "all":
1351
+ return all(isinstance(v, typ) for v in value)
1352
+
1353
+ assert_never(check)
1354
+
1355
+
1356
+ def flatten_2d_lists(lists: Iterable[Iterable[T]]) -> list[T]:
1357
+ """Flatten a list of lists to a single list."""
1358
+ return [item for sublist in lists for item in sublist]
1359
+
1360
+
1361
+ def full_groupby(values: Iterable[_V], *, key: Callable[[_V], _K]):
1362
+ """
1363
+ Unlike [`itertools.groupby`][], groups are not broken by
1364
+ non-contiguous data.
1365
+ """
1366
+ groups = defaultdict[_K, list[_V]](list)
1367
+
1368
+ for value in values:
1369
+ groups[key(value)].append(value)
1370
+
1371
+ return groups.items()
1372
+
1373
+
1374
+ # TODO: This function can be removed if transformer_modules classes are
1375
+ # serialized by value when communicating between processes
1376
+ def init_cached_hf_modules() -> None:
1377
+ """
1378
+ Lazy initialization of the Hugging Face modules.
1379
+ """
1380
+ from transformers.dynamic_module_utils import init_hf_modules
1381
+ init_hf_modules()
1382
+
1383
+
1384
+ @cache
1385
+ def find_library(lib_name: str) -> str:
1386
+ """
1387
+ Find the library file in the system.
1388
+ `lib_name` is full filename, with both prefix and suffix.
1389
+ This function resolves `lib_name` to the full path of the library.
1390
+ """
1391
+ # Adapted from https://github.com/openai/triton/blob/main/third_party/nvidia/backend/driver.py#L19 # noqa
1392
+ # According to https://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard
1393
+ # `/sbin/ldconfig` should exist in all Linux systems.
1394
+ # `/sbin/ldconfig` searches the library in the system
1395
+ libs = subprocess.check_output(["/sbin/ldconfig", "-p"]).decode()
1396
+ # each line looks like the following:
1397
+ # libcuda.so.1 (libc6,x86-64) => /lib/x86_64-linux-gnu/libcuda.so.1
1398
+ locs = [line.split()[-1] for line in libs.splitlines() if lib_name in line]
1399
+ # `LD_LIBRARY_PATH` searches the library in the user-defined paths
1400
+ env_ld_library_path = envs.LD_LIBRARY_PATH
1401
+ if not locs and env_ld_library_path:
1402
+ locs = [
1403
+ os.path.join(dir, lib_name)
1404
+ for dir in env_ld_library_path.split(":")
1405
+ if os.path.exists(os.path.join(dir, lib_name))
1406
+ ]
1407
+ if not locs:
1408
+ raise ValueError(f"Cannot find {lib_name} in the system.")
1409
+ return locs[0]
1410
+
1411
+
1412
+ def find_nccl_library() -> str:
1413
+ """
1414
+ We either use the library file specified by the `VLLM_NCCL_SO_PATH`
1415
+ environment variable, or we find the library file brought by PyTorch.
1416
+ After importing `torch`, `libnccl.so.2` or `librccl.so.1` can be
1417
+ found by `ctypes` automatically.
1418
+ """
1419
+ so_file = envs.VLLM_NCCL_SO_PATH
1420
+
1421
+ # manually load the nccl library
1422
+ if so_file:
1423
+ logger.info(
1424
+ "Found nccl from environment variable VLLM_NCCL_SO_PATH=%s",
1425
+ so_file)
1426
+ else:
1427
+ if torch.version.cuda is not None:
1428
+ so_file = "libnccl.so.2"
1429
+ elif torch.version.hip is not None:
1430
+ so_file = "librccl.so.1"
1431
+ else:
1432
+ raise ValueError("NCCL only supports CUDA and ROCm backends.")
1433
+ logger.info("Found nccl from library %s", so_file)
1434
+ return so_file
1435
+
1436
+
1437
+ prev_set_stream = torch.cuda.set_stream
1438
+
1439
+ _current_stream_tls = threading.local()
1440
+
1441
+
1442
+ def _patched_set_stream(stream: torch.cuda.Stream) -> None:
1443
+ _current_stream_tls.value = stream
1444
+ prev_set_stream(stream)
1445
+
1446
+
1447
+ torch.cuda.set_stream = _patched_set_stream
1448
+
1449
+
1450
+ class _StreamPlaceholder:
1451
+
1452
+ def __init__(self):
1453
+ self.synchronize = lambda: None
1454
+
1455
+
1456
+ def current_stream() -> torch.cuda.Stream:
1457
+ """
1458
+ replace `torch.cuda.current_stream()` with `vllm.utils.current_stream()`.
1459
+ it turns out that `torch.cuda.current_stream()` is quite expensive,
1460
+ as it will construct a new stream object at each call.
1461
+ here we patch `torch.cuda.set_stream` to keep track of the current stream
1462
+ directly, so that we can avoid calling `torch.cuda.current_stream()`.
1463
+
1464
+ the underlying hypothesis is that we do not call `torch._C._cuda_setStream`
1465
+ from C/C++ code.
1466
+ """
1467
+ from vllm.platforms import current_platform
1468
+ if not hasattr(_current_stream_tls,
1469
+ "value") or _current_stream_tls.value is None:
1470
+ # when this function is called before any stream is set,
1471
+ # we return the default stream.
1472
+ # On ROCm using the default 0 stream in combination with RCCL
1473
+ # is hurting performance. Therefore creating a dedicated stream
1474
+ # per process
1475
+ if current_platform.is_rocm():
1476
+ # torch.cuda.set_stream here is the alias of _pathed_set_stream
1477
+ torch.cuda.set_stream(torch.cuda.Stream())
1478
+ elif current_platform.is_cpu():
1479
+ _current_stream_tls.value = _StreamPlaceholder()
1480
+ else:
1481
+ current_stream = current_platform.current_stream
1482
+ if current_stream is not None:
1483
+ _current_stream_tls.value = current_stream()
1484
+ else:
1485
+ raise ValueError(
1486
+ "Fail to set current stream, current platform "
1487
+ "may not support current_stream with torch API")
1488
+ return _current_stream_tls.value
1489
+
1490
+
1491
+ def enable_trace_function_call_for_thread(vllm_config: VllmConfig) -> None:
1492
+ """Set up function tracing for the current thread,
1493
+ if enabled via the VLLM_TRACE_FUNCTION environment variable
1494
+ """
1495
+
1496
+ if envs.VLLM_TRACE_FUNCTION:
1497
+ tmp_dir = tempfile.gettempdir()
1498
+ # add username to tmp_dir to avoid permission issues
1499
+ tmp_dir = os.path.join(tmp_dir, getpass.getuser())
1500
+ filename = (f"VLLM_TRACE_FUNCTION_for_process_{os.getpid()}"
1501
+ f"_thread_{threading.get_ident()}_"
1502
+ f"at_{datetime.datetime.now()}.log").replace(" ", "_")
1503
+ log_path = os.path.join(tmp_dir, "vllm",
1504
+ f"vllm-instance-{vllm_config.instance_id}",
1505
+ filename)
1506
+ os.makedirs(os.path.dirname(log_path), exist_ok=True)
1507
+ enable_trace_function_call(log_path)
1508
+
1509
+
1510
+ # `functools` helpers
1511
+ def identity(value: T, **kwargs) -> T:
1512
+ """Returns the first provided value."""
1513
+ return value
1514
+
1515
+
1516
+ F = TypeVar('F', bound=Callable[..., Any])
1517
+
1518
+
1519
+ def deprecate_args(
1520
+ start_index: int,
1521
+ is_deprecated: Union[bool, Callable[[], bool]] = True,
1522
+ additional_message: Optional[str] = None,
1523
+ ) -> Callable[[F], F]:
1524
+ if not callable(is_deprecated):
1525
+ is_deprecated = partial(identity, is_deprecated)
1526
+
1527
+ def wrapper(fn: F) -> F:
1528
+
1529
+ params = inspect.signature(fn).parameters
1530
+ pos_types = (
1531
+ inspect.Parameter.POSITIONAL_ONLY,
1532
+ inspect.Parameter.POSITIONAL_OR_KEYWORD,
1533
+ )
1534
+ pos_kws = [
1535
+ kw for kw, param in params.items() if param.kind in pos_types
1536
+ ]
1537
+
1538
+ @wraps(fn)
1539
+ def inner(*args, **kwargs):
1540
+ if is_deprecated():
1541
+ deprecated_args = pos_kws[start_index:len(args)]
1542
+ if deprecated_args:
1543
+ msg = (
1544
+ f"The positional arguments {deprecated_args} are "
1545
+ "deprecated and will be removed in a future update.")
1546
+ if additional_message is not None:
1547
+ msg += f" {additional_message}"
1548
+
1549
+ warnings.warn(
1550
+ DeprecationWarning(msg),
1551
+ stacklevel=3, # The inner function takes up one level
1552
+ )
1553
+
1554
+ return fn(*args, **kwargs)
1555
+
1556
+ return inner # type: ignore
1557
+
1558
+ return wrapper
1559
+
1560
+
1561
+ def deprecate_kwargs(
1562
+ *kws: str,
1563
+ is_deprecated: Union[bool, Callable[[], bool]] = True,
1564
+ additional_message: Optional[str] = None,
1565
+ ) -> Callable[[F], F]:
1566
+ deprecated_kws = set(kws)
1567
+
1568
+ if not callable(is_deprecated):
1569
+ is_deprecated = partial(identity, is_deprecated)
1570
+
1571
+ def wrapper(fn: F) -> F:
1572
+
1573
+ @wraps(fn)
1574
+ def inner(*args, **kwargs):
1575
+ if is_deprecated():
1576
+ deprecated_kwargs = kwargs.keys() & deprecated_kws
1577
+ if deprecated_kwargs:
1578
+ msg = (
1579
+ f"The keyword arguments {deprecated_kwargs} are "
1580
+ "deprecated and will be removed in a future update.")
1581
+ if additional_message is not None:
1582
+ msg += f" {additional_message}"
1583
+
1584
+ warnings.warn(
1585
+ DeprecationWarning(msg),
1586
+ stacklevel=3, # The inner function takes up one level
1587
+ )
1588
+
1589
+ return fn(*args, **kwargs)
1590
+
1591
+ return inner # type: ignore
1592
+
1593
+ return wrapper
1594
+
1595
+
1596
+ @lru_cache(maxsize=8)
1597
+ def _cuda_device_count_stateless(
1598
+ cuda_visible_devices: Optional[str] = None) -> int:
1599
+ # Note: cuda_visible_devices is not used, but we keep it as an argument for
1600
+ # LRU Cache purposes.
1601
+
1602
+ # Code below is based on
1603
+ # https://github.com/pytorch/pytorch/blob/
1604
+ # c1cd946818442aca8c7f812b16d187ce1586c3bc/
1605
+ # torch/cuda/__init__.py#L831C1-L831C17
1606
+ import torch.cuda
1607
+ import torch.version
1608
+
1609
+ from vllm.platforms import current_platform
1610
+ if not torch.cuda._is_compiled():
1611
+ return 0
1612
+ if current_platform.is_rocm():
1613
+ # ROCm uses amdsmi instead of nvml for stateless device count
1614
+ # This requires a sufficiently modern version of Torch 2.4.0
1615
+ raw_count = torch.cuda._device_count_amdsmi() if (hasattr(
1616
+ torch.cuda, "_device_count_amdsmi")) else -1
1617
+ else:
1618
+ raw_count = torch.cuda._device_count_nvml()
1619
+ r = torch._C._cuda_getDeviceCount() if raw_count < 0 else raw_count
1620
+ return r
1621
+
1622
+
1623
+ def cuda_device_count_stateless() -> int:
1624
+ """Get number of CUDA devices, caching based on the value of
1625
+ CUDA_VISIBLE_DEVICES at the time of call.
1626
+
1627
+ This should be used instead of torch.cuda.device_count()
1628
+ unless CUDA_VISIBLE_DEVICES has already been set to the desired
1629
+ value."""
1630
+
1631
+ # This can be removed and simply replaced with torch.cuda.get_device_count
1632
+ # after https://github.com/pytorch/pytorch/pull/122815 is released.
1633
+ return _cuda_device_count_stateless(envs.CUDA_VISIBLE_DEVICES)
1634
+
1635
+
1636
+ def cuda_is_initialized() -> bool:
1637
+ """Check if CUDA is initialized."""
1638
+ if not torch.cuda._is_compiled():
1639
+ return False
1640
+ return torch.cuda.is_initialized()
1641
+
1642
+
1643
+ def xpu_is_initialized() -> bool:
1644
+ """Check if XPU is initialized."""
1645
+ if not torch.xpu._is_compiled():
1646
+ return False
1647
+ return torch.xpu.is_initialized()
1648
+
1649
+
1650
+ def cuda_get_device_properties(device,
1651
+ names: Sequence[str],
1652
+ init_cuda=False) -> tuple[Any, ...]:
1653
+ """Get specified CUDA device property values without initializing CUDA in
1654
+ the current process."""
1655
+ if init_cuda or cuda_is_initialized():
1656
+ props = torch.cuda.get_device_properties(device)
1657
+ return tuple(getattr(props, name) for name in names)
1658
+
1659
+ # Run in subprocess to avoid initializing CUDA as a side effect.
1660
+ mp_ctx = multiprocessing.get_context("fork")
1661
+ with ProcessPoolExecutor(max_workers=1, mp_context=mp_ctx) as executor:
1662
+ return executor.submit(cuda_get_device_properties, device, names,
1663
+ True).result()
1664
+
1665
+
1666
+ def weak_bind(bound_method: Callable[..., Any], ) -> Callable[..., None]:
1667
+ """Make an instance method that weakly references
1668
+ its associated instance and no-ops once that
1669
+ instance is collected."""
1670
+ ref = weakref.ref(bound_method.__self__) # type: ignore[attr-defined]
1671
+ unbound = bound_method.__func__ # type: ignore[attr-defined]
1672
+
1673
+ def weak_bound(*args, **kwargs) -> None:
1674
+ if inst := ref():
1675
+ unbound(inst, *args, **kwargs)
1676
+
1677
+ return weak_bound
1678
+
1679
+
1680
+ def run_once(f: Callable[P, None]) -> Callable[P, None]:
1681
+
1682
+ def wrapper(*args: P.args, **kwargs: P.kwargs) -> None:
1683
+ if wrapper.has_run: # type: ignore[attr-defined]
1684
+ return
1685
+
1686
+ with wrapper.lock: # type: ignore[attr-defined]
1687
+ if not wrapper.has_run: # type: ignore[attr-defined]
1688
+ wrapper.has_run = True # type: ignore[attr-defined]
1689
+ return f(*args, **kwargs)
1690
+
1691
+ wrapper.has_run = False # type: ignore[attr-defined]
1692
+ wrapper.lock = threading.Lock() # type: ignore[attr-defined]
1693
+ return wrapper
1694
+
1695
+
1696
+ class StoreBoolean(Action):
1697
+
1698
+ def __call__(self, parser, namespace, values, option_string=None):
1699
+ if values.lower() == "true":
1700
+ setattr(namespace, self.dest, True)
1701
+ elif values.lower() == "false":
1702
+ setattr(namespace, self.dest, False)
1703
+ else:
1704
+ raise ValueError(f"Invalid boolean value: {values}. "
1705
+ "Expected 'true' or 'false'.")
1706
+
1707
+
1708
+ class SortedHelpFormatter(ArgumentDefaultsHelpFormatter,
1709
+ RawDescriptionHelpFormatter):
1710
+ """SortedHelpFormatter that sorts arguments by their option strings."""
1711
+
1712
+ def _split_lines(self, text, width):
1713
+ """
1714
+ 1. Sentences split across lines have their single newlines removed.
1715
+ 2. Paragraphs and explicit newlines are split into separate lines.
1716
+ 3. Each line is wrapped to the specified width (width of terminal).
1717
+ """
1718
+ # The patterns also include whitespace after the newline
1719
+ single_newline = re.compile(r"(?<!\n)\n(?!\n)\s*")
1720
+ multiple_newlines = re.compile(r"\n{2,}\s*")
1721
+ text = single_newline.sub(' ', text)
1722
+ lines = re.split(multiple_newlines, text)
1723
+ return sum([textwrap.wrap(line, width) for line in lines], [])
1724
+
1725
+ def add_arguments(self, actions):
1726
+ actions = sorted(actions, key=lambda x: x.option_strings)
1727
+ super().add_arguments(actions)
1728
+
1729
+
1730
+ class FlexibleArgumentParser(ArgumentParser):
1731
+ """ArgumentParser that allows both underscore and dash in names."""
1732
+
1733
+ _deprecated: set[Action] = set()
1734
+ _json_tip: str = (
1735
+ "When passing JSON CLI arguments, the following sets of arguments "
1736
+ "are equivalent:\n"
1737
+ ' --json-arg \'{"key1": "value1", "key2": {"key3": "value2"}}\'\n'
1738
+ " --json-arg.key1 value1 --json-arg.key2.key3 value2\n\n"
1739
+ "Additionally, list elements can be passed individually using +:\n"
1740
+ ' --json-arg \'{"key4": ["value3", "value4", "value5"]}\'\n'
1741
+ " --json-arg.key4+ value3 --json-arg.key4+=\'value4,value5\'\n\n")
1742
+
1743
+ def __init__(self, *args, **kwargs):
1744
+ # Set the default "formatter_class" to SortedHelpFormatter
1745
+ if "formatter_class" not in kwargs:
1746
+ kwargs["formatter_class"] = SortedHelpFormatter
1747
+ # Pop kwarg "add_json_tip" to control whether to add the JSON tip
1748
+ self.add_json_tip = kwargs.pop("add_json_tip", True)
1749
+ super().__init__(*args, **kwargs)
1750
+
1751
+ if sys.version_info < (3, 13):
1752
+ # Enable the deprecated kwarg for Python 3.12 and below
1753
+
1754
+ def parse_known_args(self, args=None, namespace=None):
1755
+ if args is not None and "--disable-log-requests" in args:
1756
+ # Special case warning because the warning below won't trigger
1757
+ # if –-disable-log-requests because its value is default.
1758
+ logger.warning_once(
1759
+ "argument '--disable-log-requests' is deprecated and "
1760
+ "replaced with '--enable-log-requests'. This will be "
1761
+ "removed in v0.12.0.")
1762
+ namespace, args = super().parse_known_args(args, namespace)
1763
+ for action in FlexibleArgumentParser._deprecated:
1764
+ if (hasattr(namespace, dest := action.dest)
1765
+ and getattr(namespace, dest) != action.default):
1766
+ logger.warning_once("argument '%s' is deprecated", dest)
1767
+ return namespace, args
1768
+
1769
+ def add_argument(self, *args, **kwargs):
1770
+ deprecated = kwargs.pop("deprecated", False)
1771
+ action = super().add_argument(*args, **kwargs)
1772
+ if deprecated:
1773
+ FlexibleArgumentParser._deprecated.add(action)
1774
+ return action
1775
+
1776
+ class _FlexibleArgumentGroup(_ArgumentGroup):
1777
+
1778
+ def add_argument(self, *args, **kwargs):
1779
+ deprecated = kwargs.pop("deprecated", False)
1780
+ action = super().add_argument(*args, **kwargs)
1781
+ if deprecated:
1782
+ FlexibleArgumentParser._deprecated.add(action)
1783
+ return action
1784
+
1785
+ def add_argument_group(self, *args, **kwargs):
1786
+ group = self._FlexibleArgumentGroup(self, *args, **kwargs)
1787
+ self._action_groups.append(group)
1788
+ return group
1789
+
1790
+ def format_help(self) -> str:
1791
+ # Add tip about JSON arguments to the epilog
1792
+ epilog = self.epilog or ""
1793
+ if (self.add_json_tip
1794
+ and not epilog.startswith(FlexibleArgumentParser._json_tip)):
1795
+ self.epilog = FlexibleArgumentParser._json_tip + epilog
1796
+ return super().format_help()
1797
+
1798
+ def parse_args( # type: ignore[override]
1799
+ self,
1800
+ args: list[str] | None = None,
1801
+ namespace: Namespace | None = None,
1802
+ ):
1803
+ if args is None:
1804
+ args = sys.argv[1:]
1805
+
1806
+ # Check for --model in command line arguments first
1807
+ if args and args[0] == "serve":
1808
+ model_in_cli_args = any(arg == '--model' for arg in args)
1809
+
1810
+ if model_in_cli_args:
1811
+ raise ValueError(
1812
+ "With `vllm serve`, you should provide the model as a "
1813
+ "positional argument or in a config file instead of via "
1814
+ "the `--model` option.")
1815
+
1816
+ if '--config' in args:
1817
+ args = self._pull_args_from_config(args)
1818
+
1819
+ def repl(match: re.Match) -> str:
1820
+ """Replaces underscores with dashes in the matched string."""
1821
+ return match.group(0).replace("_", "-")
1822
+
1823
+ # Everything between the first -- and the first .
1824
+ pattern = re.compile(r"(?<=--)[^\.]*")
1825
+
1826
+ # Convert underscores to dashes and vice versa in argument names
1827
+ processed_args = list[str]()
1828
+ for i, arg in enumerate(args):
1829
+ if arg.startswith('--'):
1830
+ if '=' in arg:
1831
+ key, value = arg.split('=', 1)
1832
+ key = pattern.sub(repl, key, count=1)
1833
+ processed_args.append(f'{key}={value}')
1834
+ else:
1835
+ key = pattern.sub(repl, arg, count=1)
1836
+ processed_args.append(key)
1837
+ elif arg.startswith('-O') and arg != '-O' and arg[2] != '.':
1838
+ # allow -O flag to be used without space, e.g. -O3 or -Odecode
1839
+ # -O.<...> handled later
1840
+ # also handle -O=<level> here
1841
+ level = arg[3:] if arg[2] == '=' else arg[2:]
1842
+ processed_args.append(f'-O.level={level}')
1843
+ elif arg == '-O' and i + 1 < len(args) and args[i + 1] in {
1844
+ "0", "1", "2", "3"
1845
+ }:
1846
+ # Convert -O <n> to -O.level <n>
1847
+ processed_args.append('-O.level')
1848
+ else:
1849
+ processed_args.append(arg)
1850
+
1851
+ def create_nested_dict(keys: list[str], value: str) -> dict[str, Any]:
1852
+ """Creates a nested dictionary from a list of keys and a value.
1853
+
1854
+ For example, `keys = ["a", "b", "c"]` and `value = 1` will create:
1855
+ `{"a": {"b": {"c": 1}}}`
1856
+ """
1857
+ nested_dict: Any = value
1858
+ for key in reversed(keys):
1859
+ nested_dict = {key: nested_dict}
1860
+ return nested_dict
1861
+
1862
+ def recursive_dict_update(
1863
+ original: dict[str, Any],
1864
+ update: dict[str, Any],
1865
+ ) -> set[str]:
1866
+ """Recursively updates a dictionary with another dictionary.
1867
+ Returns a set of duplicate keys that were overwritten.
1868
+ """
1869
+ duplicates = set[str]()
1870
+ for k, v in update.items():
1871
+ if isinstance(v, dict) and isinstance(original.get(k), dict):
1872
+ nested_duplicates = recursive_dict_update(original[k], v)
1873
+ duplicates |= {f"{k}.{d}" for d in nested_duplicates}
1874
+ elif isinstance(v, list) and isinstance(original.get(k), list):
1875
+ original[k] += v
1876
+ else:
1877
+ if k in original:
1878
+ duplicates.add(k)
1879
+ original[k] = v
1880
+ return duplicates
1881
+
1882
+ delete = set[int]()
1883
+ dict_args = defaultdict[str, dict[str, Any]](dict)
1884
+ duplicates = set[str]()
1885
+ for i, processed_arg in enumerate(processed_args):
1886
+ if i in delete: # skip if value from previous arg
1887
+ continue
1888
+
1889
+ if processed_arg.startswith("-") and "." in processed_arg:
1890
+ if "=" in processed_arg:
1891
+ processed_arg, value_str = processed_arg.split("=", 1)
1892
+ if "." not in processed_arg:
1893
+ # False positive, '.' was only in the value
1894
+ continue
1895
+ else:
1896
+ value_str = processed_args[i + 1]
1897
+ delete.add(i + 1)
1898
+
1899
+ if processed_arg.endswith("+"):
1900
+ processed_arg = processed_arg[:-1]
1901
+ value_str = json.dumps(list(value_str.split(",")))
1902
+
1903
+ key, *keys = processed_arg.split(".")
1904
+ try:
1905
+ value = json.loads(value_str)
1906
+ except json.decoder.JSONDecodeError:
1907
+ value = value_str
1908
+
1909
+ # Merge all values with the same key into a single dict
1910
+ arg_dict = create_nested_dict(keys, value)
1911
+ arg_duplicates = recursive_dict_update(dict_args[key],
1912
+ arg_dict)
1913
+ duplicates |= {f'{key}.{d}' for d in arg_duplicates}
1914
+ delete.add(i)
1915
+ # Filter out the dict args we set to None
1916
+ processed_args = [
1917
+ a for i, a in enumerate(processed_args) if i not in delete
1918
+ ]
1919
+ if duplicates:
1920
+ logger.warning("Found duplicate keys %s", ", ".join(duplicates))
1921
+
1922
+ # Add the dict args back as if they were originally passed as JSON
1923
+ for dict_arg, dict_value in dict_args.items():
1924
+ processed_args.append(dict_arg)
1925
+ processed_args.append(json.dumps(dict_value))
1926
+
1927
+ return super().parse_args(processed_args, namespace)
1928
+
1929
+ def check_port(self, value):
1930
+ try:
1931
+ value = int(value)
1932
+ except ValueError:
1933
+ msg = "Port must be an integer"
1934
+ raise ArgumentTypeError(msg) from None
1935
+
1936
+ if not (1024 <= value <= 65535):
1937
+ raise ArgumentTypeError("Port must be between 1024 and 65535")
1938
+
1939
+ return value
1940
+
1941
+ def _pull_args_from_config(self, args: list[str]) -> list[str]:
1942
+ """Method to pull arguments specified in the config file
1943
+ into the command-line args variable.
1944
+
1945
+ The arguments in config file will be inserted between
1946
+ the argument list.
1947
+
1948
+ example:
1949
+ ```yaml
1950
+ port: 12323
1951
+ tensor-parallel-size: 4
1952
+ ```
1953
+ ```python
1954
+ $: vllm {serve,chat,complete} "facebook/opt-12B" \
1955
+ --config config.yaml -tp 2
1956
+ $: args = [
1957
+ "serve,chat,complete",
1958
+ "facebook/opt-12B",
1959
+ '--config', 'config.yaml',
1960
+ '-tp', '2'
1961
+ ]
1962
+ $: args = [
1963
+ "serve,chat,complete",
1964
+ "facebook/opt-12B",
1965
+ '--port', '12323',
1966
+ '--tensor-parallel-size', '4',
1967
+ '-tp', '2'
1968
+ ]
1969
+ ```
1970
+
1971
+ Please note how the config args are inserted after the sub command.
1972
+ this way the order of priorities is maintained when these are args
1973
+ parsed by super().
1974
+ """
1975
+ assert args.count(
1976
+ '--config') <= 1, "More than one config file specified!"
1977
+
1978
+ index = args.index('--config')
1979
+ if index == len(args) - 1:
1980
+ raise ValueError("No config file specified! \
1981
+ Please check your command-line arguments.")
1982
+
1983
+ file_path = args[index + 1]
1984
+
1985
+ config_args = self.load_config_file(file_path)
1986
+
1987
+ # 0th index might be the sub command {serve,chat,complete,...}
1988
+ # optionally followed by model_tag (only for serve)
1989
+ # followed by config args
1990
+ # followed by rest of cli args.
1991
+ # maintaining this order will enforce the precedence
1992
+ # of cli > config > defaults
1993
+ if args[0].startswith('-'):
1994
+ # No sub command (e.g., api_server entry point)
1995
+ args = config_args + args[0:index] + args[index + 2:]
1996
+ elif args[0] == "serve":
1997
+ model_in_cli = len(args) > 1 and not args[1].startswith('-')
1998
+ model_in_config = any(arg == '--model' for arg in config_args)
1999
+
2000
+ if not model_in_cli and not model_in_config:
2001
+ raise ValueError(
2002
+ "No model specified! Please specify model either "
2003
+ "as a positional argument or in a config file.")
2004
+
2005
+ if model_in_cli:
2006
+ # Model specified as positional arg, keep CLI version
2007
+ args = [args[0]] + [
2008
+ args[1]
2009
+ ] + config_args + args[2:index] + args[index + 2:]
2010
+ else:
2011
+ # No model in CLI, use config if available
2012
+ args = [args[0]
2013
+ ] + config_args + args[1:index] + args[index + 2:]
2014
+ else:
2015
+ args = [args[0]] + config_args + args[1:index] + args[index + 2:]
2016
+
2017
+ return args
2018
+
2019
+ def load_config_file(self, file_path: str) -> list[str]:
2020
+ """Loads a yaml file and returns the key value pairs as a
2021
+ flattened list with argparse like pattern
2022
+ ```yaml
2023
+ port: 12323
2024
+ tensor-parallel-size: 4
2025
+ ```
2026
+ returns:
2027
+ processed_args: list[str] = [
2028
+ '--port': '12323',
2029
+ '--tensor-parallel-size': '4'
2030
+ ]
2031
+ """
2032
+ extension: str = file_path.split('.')[-1]
2033
+ if extension not in ('yaml', 'yml'):
2034
+ raise ValueError(
2035
+ "Config file must be of a yaml/yml type.\
2036
+ %s supplied", extension)
2037
+
2038
+ # only expecting a flat dictionary of atomic types
2039
+ processed_args: list[str] = []
2040
+
2041
+ config: dict[str, Union[int, str]] = {}
2042
+ try:
2043
+ with open(file_path) as config_file:
2044
+ config = yaml.safe_load(config_file)
2045
+ except Exception as ex:
2046
+ logger.error(
2047
+ "Unable to read the config file at %s. \
2048
+ Make sure path is correct", file_path)
2049
+ raise ex
2050
+
2051
+ store_boolean_arguments = [
2052
+ action.dest for action in self._actions
2053
+ if isinstance(action, StoreBoolean)
2054
+ ]
2055
+
2056
+ for key, value in config.items():
2057
+ if isinstance(value, bool) and key not in store_boolean_arguments:
2058
+ if value:
2059
+ processed_args.append('--' + key)
2060
+ elif isinstance(value, list):
2061
+ if value:
2062
+ processed_args.append('--' + key)
2063
+ for item in value:
2064
+ processed_args.append(str(item))
2065
+ else:
2066
+ processed_args.append('--' + key)
2067
+ processed_args.append(str(value))
2068
+
2069
+ return processed_args
2070
+
2071
+
2072
+ async def _run_task_with_lock(task: Callable, lock: asyncio.Lock, *args,
2073
+ **kwargs):
2074
+ """Utility function to run async task in a lock"""
2075
+ async with lock:
2076
+ return await task(*args, **kwargs)
2077
+
2078
+
2079
+ def supports_kw(
2080
+ callable: Callable[..., object],
2081
+ kw_name: str,
2082
+ *,
2083
+ requires_kw_only: bool = False,
2084
+ allow_var_kwargs: bool = True,
2085
+ ) -> bool:
2086
+ """Check if a keyword is a valid kwarg for a callable; if requires_kw_only
2087
+ disallows kwargs names that can also be positional arguments.
2088
+ """
2089
+ params = inspect.signature(callable).parameters
2090
+ if not params:
2091
+ return False
2092
+
2093
+ param_val = params.get(kw_name)
2094
+
2095
+ # Types where the it may be valid, i.e., explicitly defined & nonvariadic
2096
+ passable_kw_types = set((inspect.Parameter.POSITIONAL_ONLY,
2097
+ inspect.Parameter.POSITIONAL_OR_KEYWORD,
2098
+ inspect.Parameter.KEYWORD_ONLY))
2099
+
2100
+ if param_val:
2101
+ is_sig_param = param_val.kind in passable_kw_types
2102
+ # We want kwargs only, but this is passable as a positional arg
2103
+ if (requires_kw_only and is_sig_param
2104
+ and param_val.kind != inspect.Parameter.KEYWORD_ONLY):
2105
+ return False
2106
+ if ((requires_kw_only
2107
+ and param_val.kind == inspect.Parameter.KEYWORD_ONLY)
2108
+ or (not requires_kw_only and is_sig_param)):
2109
+ return True
2110
+
2111
+ # If we're okay with var-kwargs, it's supported as long as
2112
+ # the kw_name isn't something like *args, **kwargs
2113
+ if allow_var_kwargs:
2114
+ # Get the last param; type is ignored here because params is a proxy
2115
+ # mapping, but it wraps an ordered dict, and they appear in order.
2116
+ # Ref: https://docs.python.org/3/library/inspect.html#inspect.Signature.parameters
2117
+ last_param = params[next(reversed(params))] # type: ignore
2118
+ return (last_param.kind == inspect.Parameter.VAR_KEYWORD
2119
+ and last_param.name != kw_name)
2120
+
2121
+ return False
2122
+
2123
+
2124
+ def get_allowed_kwarg_only_overrides(
2125
+ callable: Callable[..., object],
2126
+ overrides: Optional[Mapping[str, object]],
2127
+ *,
2128
+ requires_kw_only: bool = True,
2129
+ allow_var_kwargs: bool = False,
2130
+ ) -> dict[str, Any]:
2131
+ """
2132
+ Given a callable which has one or more keyword only params and a dict
2133
+ mapping param names to values, drop values that can be not be kwarg
2134
+ expanded to overwrite one or more keyword-only args. This is used in a
2135
+ few places to handle custom processor overrides for multimodal models,
2136
+ e.g., for profiling when processor options provided by the user
2137
+ may affect the number of mm tokens per instance.
2138
+
2139
+ Args:
2140
+ callable: Callable which takes 0 or more keyword only arguments.
2141
+ If None is provided, all overrides names are allowed.
2142
+ overrides: Potential overrides to be used when invoking the callable.
2143
+ allow_var_kwargs: Allows overrides that are expandable for var kwargs.
2144
+
2145
+ Returns:
2146
+ Dictionary containing the kwargs to be leveraged which may be used
2147
+ to overwrite one or more keyword only arguments when invoking the
2148
+ callable.
2149
+ """
2150
+ if not overrides:
2151
+ return {}
2152
+
2153
+ # Drop any mm_processor_kwargs provided by the user that
2154
+ # are not kwargs, unless it can fit it var_kwargs param
2155
+ filtered_overrides = {
2156
+ kwarg_name: val
2157
+ for kwarg_name, val in overrides.items()
2158
+ if supports_kw(callable,
2159
+ kwarg_name,
2160
+ requires_kw_only=requires_kw_only,
2161
+ allow_var_kwargs=allow_var_kwargs)
2162
+ }
2163
+
2164
+ # If anything is dropped, log a warning
2165
+ dropped_keys = overrides.keys() - filtered_overrides.keys()
2166
+ if dropped_keys:
2167
+ if requires_kw_only:
2168
+ logger.warning(
2169
+ "The following intended overrides are not keyword-only args "
2170
+ "and will be dropped: %s", dropped_keys)
2171
+ else:
2172
+ logger.warning(
2173
+ "The following intended overrides are not keyword args "
2174
+ "and will be dropped: %s", dropped_keys)
2175
+
2176
+ return filtered_overrides
2177
+
2178
+
2179
+ # Using dynamo with vLLM doesn't really work well with PyTorch versions < 2.4.0.
2180
+ # In particular, the FakeScalarType is not supported for earlier versions of
2181
+ # PyTorch which breaks dynamo for any ops registered using ScalarType.
2182
+ def supports_dynamo() -> bool:
2183
+ base_torch_version = Version(Version(torch.__version__).base_version)
2184
+ return base_torch_version >= Version("2.4.0")
2185
+
2186
+
2187
+ # Supports xccl with PyTorch versions >= 2.8.0.dev for XPU platform
2188
+ def supports_xccl() -> bool:
2189
+ return is_torch_equal_or_newer(
2190
+ "2.8.0.dev") and torch.distributed.is_xccl_available()
2191
+
2192
+
2193
+ # Some backends use pytorch version < 2.4.0 which doesn't
2194
+ # support `torch.library.custom_op`.
2195
+ def supports_custom_op() -> bool:
2196
+ return hasattr(torch.library, "custom_op")
2197
+
2198
+
2199
+ class AtomicCounter:
2200
+ """An atomic, thread-safe counter"""
2201
+
2202
+ def __init__(self, initial=0):
2203
+ """Initialize a new atomic counter to given initial value"""
2204
+ self._value = initial
2205
+ self._lock = threading.Lock()
2206
+
2207
+ def inc(self, num=1):
2208
+ """Atomically increment the counter by num and return the new value"""
2209
+ with self._lock:
2210
+ self._value += num
2211
+ return self._value
2212
+
2213
+ def dec(self, num=1):
2214
+ """Atomically decrement the counter by num and return the new value"""
2215
+ with self._lock:
2216
+ self._value -= num
2217
+ return self._value
2218
+
2219
+ @property
2220
+ def value(self):
2221
+ return self._value
2222
+
2223
+
2224
+ # Adapted from: https://stackoverflow.com/a/47212782/5082708
2225
+ class LazyDict(Mapping[str, T], Generic[T]):
2226
+
2227
+ def __init__(self, factory: dict[str, Callable[[], T]]):
2228
+ self._factory = factory
2229
+ self._dict: dict[str, T] = {}
2230
+
2231
+ def __getitem__(self, key: str) -> T:
2232
+ if key not in self._dict:
2233
+ if key not in self._factory:
2234
+ raise KeyError(key)
2235
+ self._dict[key] = self._factory[key]()
2236
+ return self._dict[key]
2237
+
2238
+ def __setitem__(self, key: str, value: Callable[[], T]):
2239
+ self._factory[key] = value
2240
+
2241
+ def __iter__(self):
2242
+ return iter(self._factory)
2243
+
2244
+ def __len__(self):
2245
+ return len(self._factory)
2246
+
2247
+
2248
+ class ClassRegistry(UserDict[type[T], _V]):
2249
+
2250
+ def __getitem__(self, key: type[T]) -> _V:
2251
+ for cls in key.mro():
2252
+ if cls in self.data:
2253
+ return self.data[cls]
2254
+
2255
+ raise KeyError(key)
2256
+
2257
+ def __contains__(self, key: object) -> bool:
2258
+ return self.contains(key)
2259
+
2260
+ def contains(self, key: object, *, strict: bool = False) -> bool:
2261
+ if not isinstance(key, type):
2262
+ return False
2263
+
2264
+ if strict:
2265
+ return key in self.data
2266
+
2267
+ return any(cls in self.data for cls in key.mro())
2268
+
2269
+
2270
+ def weak_ref_tensor(tensor: Any) -> Any:
2271
+ """
2272
+ Create a weak reference to a tensor.
2273
+ The new tensor will share the same data as the original tensor,
2274
+ but will not keep the original tensor alive.
2275
+ """
2276
+ if isinstance(tensor, torch.Tensor):
2277
+ return torch.ops._C.weak_ref_tensor(tensor)
2278
+ else:
2279
+ return tensor
2280
+
2281
+
2282
+ def weak_ref_tensors(
2283
+ tensors: Union[torch.Tensor, list[torch.Tensor], tuple[torch.Tensor],
2284
+ IntermediateTensors]
2285
+ ) -> Union[torch.Tensor, list[Any], tuple[Any], Any]:
2286
+ """
2287
+ Convenience function to create weak references to tensors,
2288
+ for single tensor, list of tensors or tuple of tensors.
2289
+ """
2290
+ if isinstance(tensors, torch.Tensor):
2291
+ return weak_ref_tensor(tensors)
2292
+ if isinstance(tensors, list):
2293
+ return [weak_ref_tensor(t) for t in tensors]
2294
+ if isinstance(tensors, tuple):
2295
+ return tuple(weak_ref_tensor(t) for t in tensors)
2296
+
2297
+ # For IntermediateTensors used in pipeline parallelism
2298
+ from vllm.sequence import IntermediateTensors
2299
+ if isinstance(tensors, IntermediateTensors):
2300
+ ret = IntermediateTensors({
2301
+ key: weak_ref_tensor(val)
2302
+ for key, val in tensors.tensors.items()
2303
+ })
2304
+ return ret
2305
+ raise ValueError("Invalid type for tensors")
2306
+
2307
+
2308
+ def get_cuda_view_from_cpu_tensor(cpu_tensor: torch.Tensor) -> torch.Tensor:
2309
+ """
2310
+ Get a CUDA view of a CPU tensor using Unified Virtual Addressing (UVA).
2311
+ """
2312
+ assert cpu_tensor.is_pinned(), "CPU tensor must be pinned"
2313
+ return torch.ops._C.get_cuda_view_from_cpu_tensor(cpu_tensor)
2314
+
2315
+
2316
+ def import_from_path(module_name: str, file_path: Union[str, os.PathLike]):
2317
+ """
2318
+ Import a Python file according to its file path.
2319
+
2320
+ Based on the official recipe:
2321
+ https://docs.python.org/3/library/importlib.html#importing-a-source-file-directly
2322
+ """
2323
+ spec = importlib.util.spec_from_file_location(module_name, file_path)
2324
+ if spec is None:
2325
+ raise ModuleNotFoundError(f"No module named '{module_name}'")
2326
+
2327
+ assert spec.loader is not None
2328
+
2329
+ module = importlib.util.module_from_spec(spec)
2330
+ sys.modules[module_name] = module
2331
+ spec.loader.exec_module(module)
2332
+ return module
2333
+
2334
+
2335
+ @cache
2336
+ def get_vllm_optional_dependencies():
2337
+ metadata = importlib.metadata.metadata("vllm")
2338
+ requirements = metadata.get_all("Requires-Dist", [])
2339
+ extras = metadata.get_all("Provides-Extra", [])
2340
+
2341
+ return {
2342
+ extra: [
2343
+ re.split(r";|>=|<=|==", req)[0] for req in requirements
2344
+ if req.endswith(f'extra == "{extra}"')
2345
+ ]
2346
+ for extra in extras
2347
+ }
2348
+
2349
+
2350
+ class _PlaceholderBase:
2351
+ """
2352
+ Disallows downstream usage of placeholder modules.
2353
+
2354
+ We need to explicitly override each dunder method because
2355
+ [`__getattr__`][vllm.utils._PlaceholderBase.__getattr__]
2356
+ is not called when they are accessed.
2357
+
2358
+ Info:
2359
+ [Special method lookup](https://docs.python.org/3/reference/datamodel.html#special-lookup)
2360
+ """
2361
+
2362
+ def __getattr__(self, key: str) -> Never:
2363
+ """
2364
+ The main class should implement this to throw an error
2365
+ for attribute accesses representing downstream usage.
2366
+ """
2367
+ raise NotImplementedError
2368
+
2369
+ # [Basic customization]
2370
+
2371
+ def __lt__(self, other: object):
2372
+ return self.__getattr__("__lt__")
2373
+
2374
+ def __le__(self, other: object):
2375
+ return self.__getattr__("__le__")
2376
+
2377
+ def __eq__(self, other: object):
2378
+ return self.__getattr__("__eq__")
2379
+
2380
+ def __ne__(self, other: object):
2381
+ return self.__getattr__("__ne__")
2382
+
2383
+ def __gt__(self, other: object):
2384
+ return self.__getattr__("__gt__")
2385
+
2386
+ def __ge__(self, other: object):
2387
+ return self.__getattr__("__ge__")
2388
+
2389
+ def __hash__(self):
2390
+ return self.__getattr__("__hash__")
2391
+
2392
+ def __bool__(self):
2393
+ return self.__getattr__("__bool__")
2394
+
2395
+ # [Callable objects]
2396
+
2397
+ def __call__(self, *args: object, **kwargs: object):
2398
+ return self.__getattr__("__call__")
2399
+
2400
+ # [Container types]
2401
+
2402
+ def __len__(self):
2403
+ return self.__getattr__("__len__")
2404
+
2405
+ def __getitem__(self, key: object):
2406
+ return self.__getattr__("__getitem__")
2407
+
2408
+ def __setitem__(self, key: object, value: object):
2409
+ return self.__getattr__("__setitem__")
2410
+
2411
+ def __delitem__(self, key: object):
2412
+ return self.__getattr__("__delitem__")
2413
+
2414
+ # __missing__ is optional according to __getitem__ specification,
2415
+ # so it is skipped
2416
+
2417
+ # __iter__ and __reversed__ have a default implementation
2418
+ # based on __len__ and __getitem__, so they are skipped.
2419
+
2420
+ # [Numeric Types]
2421
+
2422
+ def __add__(self, other: object):
2423
+ return self.__getattr__("__add__")
2424
+
2425
+ def __sub__(self, other: object):
2426
+ return self.__getattr__("__sub__")
2427
+
2428
+ def __mul__(self, other: object):
2429
+ return self.__getattr__("__mul__")
2430
+
2431
+ def __matmul__(self, other: object):
2432
+ return self.__getattr__("__matmul__")
2433
+
2434
+ def __truediv__(self, other: object):
2435
+ return self.__getattr__("__truediv__")
2436
+
2437
+ def __floordiv__(self, other: object):
2438
+ return self.__getattr__("__floordiv__")
2439
+
2440
+ def __mod__(self, other: object):
2441
+ return self.__getattr__("__mod__")
2442
+
2443
+ def __divmod__(self, other: object):
2444
+ return self.__getattr__("__divmod__")
2445
+
2446
+ def __pow__(self, other: object, modulo: object = ...):
2447
+ return self.__getattr__("__pow__")
2448
+
2449
+ def __lshift__(self, other: object):
2450
+ return self.__getattr__("__lshift__")
2451
+
2452
+ def __rshift__(self, other: object):
2453
+ return self.__getattr__("__rshift__")
2454
+
2455
+ def __and__(self, other: object):
2456
+ return self.__getattr__("__and__")
2457
+
2458
+ def __xor__(self, other: object):
2459
+ return self.__getattr__("__xor__")
2460
+
2461
+ def __or__(self, other: object):
2462
+ return self.__getattr__("__or__")
2463
+
2464
+ # r* and i* methods have lower priority than
2465
+ # the methods for left operand so they are skipped
2466
+
2467
+ def __neg__(self):
2468
+ return self.__getattr__("__neg__")
2469
+
2470
+ def __pos__(self):
2471
+ return self.__getattr__("__pos__")
2472
+
2473
+ def __abs__(self):
2474
+ return self.__getattr__("__abs__")
2475
+
2476
+ def __invert__(self):
2477
+ return self.__getattr__("__invert__")
2478
+
2479
+ # __complex__, __int__ and __float__ have a default implementation
2480
+ # based on __index__, so they are skipped.
2481
+
2482
+ def __index__(self):
2483
+ return self.__getattr__("__index__")
2484
+
2485
+ def __round__(self, ndigits: object = ...):
2486
+ return self.__getattr__("__round__")
2487
+
2488
+ def __trunc__(self):
2489
+ return self.__getattr__("__trunc__")
2490
+
2491
+ def __floor__(self):
2492
+ return self.__getattr__("__floor__")
2493
+
2494
+ def __ceil__(self):
2495
+ return self.__getattr__("__ceil__")
2496
+
2497
+ # [Context managers]
2498
+
2499
+ def __enter__(self):
2500
+ return self.__getattr__("__enter__")
2501
+
2502
+ def __exit__(self, *args: object, **kwargs: object):
2503
+ return self.__getattr__("__exit__")
2504
+
2505
+
2506
+ class PlaceholderModule(_PlaceholderBase):
2507
+ """
2508
+ A placeholder object to use when a module does not exist.
2509
+
2510
+ This enables more informative errors when trying to access attributes
2511
+ of a module that does not exist.
2512
+ """
2513
+
2514
+ def __init__(self, name: str) -> None:
2515
+ super().__init__()
2516
+
2517
+ # Apply name mangling to avoid conflicting with module attributes
2518
+ self.__name = name
2519
+
2520
+ def placeholder_attr(self, attr_path: str):
2521
+ return _PlaceholderModuleAttr(self, attr_path)
2522
+
2523
+ def __getattr__(self, key: str):
2524
+ name = self.__name
2525
+
2526
+ try:
2527
+ importlib.import_module(name)
2528
+ except ImportError as exc:
2529
+ for extra, names in get_vllm_optional_dependencies().items():
2530
+ if name in names:
2531
+ msg = f"Please install vllm[{extra}] for {extra} support"
2532
+ raise ImportError(msg) from exc
2533
+
2534
+ raise exc
2535
+
2536
+ raise AssertionError("PlaceholderModule should not be used "
2537
+ "when the original module can be imported")
2538
+
2539
+
2540
+ class _PlaceholderModuleAttr(_PlaceholderBase):
2541
+
2542
+ def __init__(self, module: PlaceholderModule, attr_path: str) -> None:
2543
+ super().__init__()
2544
+
2545
+ # Apply name mangling to avoid conflicting with module attributes
2546
+ self.__module = module
2547
+ self.__attr_path = attr_path
2548
+
2549
+ def placeholder_attr(self, attr_path: str):
2550
+ return _PlaceholderModuleAttr(self.__module,
2551
+ f"{self.__attr_path}.{attr_path}")
2552
+
2553
+ def __getattr__(self, key: str):
2554
+ getattr(self.__module, f"{self.__attr_path}.{key}")
2555
+
2556
+ raise AssertionError("PlaceholderModule should not be used "
2557
+ "when the original module can be imported")
2558
+
2559
+
2560
+ # create a library to hold the custom op
2561
+ vllm_lib = Library("vllm", "FRAGMENT") # noqa
2562
+
2563
+
2564
+ def direct_register_custom_op(
2565
+ op_name: str,
2566
+ op_func: Callable,
2567
+ mutates_args: list[str],
2568
+ fake_impl: Optional[Callable] = None,
2569
+ target_lib: Optional[Library] = None,
2570
+ dispatch_key: str = "CUDA",
2571
+ tags: tuple[torch.Tag, ...] = (),
2572
+ ):
2573
+ """
2574
+ `torch.library.custom_op` can have significant overhead because it
2575
+ needs to consider complicated dispatching logic. This function
2576
+ directly registers a custom op and dispatches it to the CUDA backend.
2577
+ See https://gist.github.com/youkaichao/ecbea9ec9fc79a45d2adce1784d7a9a5
2578
+ for more details.
2579
+
2580
+ By default, the custom op is registered to the vLLM library. If you
2581
+ want to register it to a different library, you can pass the library
2582
+ object to the `target_lib` argument.
2583
+
2584
+ IMPORTANT: the lifetime of the operator is tied to the lifetime of the
2585
+ library object. If you want to bind the operator to a different library,
2586
+ make sure the library object is alive when the operator is used.
2587
+ """
2588
+ if not supports_custom_op():
2589
+ from vllm.platforms import current_platform
2590
+ assert not current_platform.is_cuda_alike(), (
2591
+ "cuda platform needs torch>=2.4 to support custom op, "
2592
+ "chances are you are using an old version of pytorch "
2593
+ "or a custom build of pytorch. It is recommended to "
2594
+ "use vLLM in a fresh new environment and let it install "
2595
+ "the required dependencies.")
2596
+ return
2597
+
2598
+ import torch.library
2599
+ if hasattr(torch.library, "infer_schema"):
2600
+ schema_str = torch.library.infer_schema(op_func,
2601
+ mutates_args=mutates_args)
2602
+ else:
2603
+ # for pytorch 2.4
2604
+ import torch._custom_op.impl
2605
+ schema_str = torch._custom_op.impl.infer_schema(op_func, mutates_args)
2606
+ my_lib = target_lib or vllm_lib
2607
+ my_lib.define(op_name + schema_str, tags=tags)
2608
+ my_lib.impl(op_name, op_func, dispatch_key=dispatch_key)
2609
+ if fake_impl is not None:
2610
+ my_lib._register_fake(op_name, fake_impl)
2611
+
2612
+
2613
+ def resolve_obj_by_qualname(qualname: str) -> Any:
2614
+ """
2615
+ Resolve an object by its fully-qualified class name.
2616
+ """
2617
+ module_name, obj_name = qualname.rsplit(".", 1)
2618
+ module = importlib.import_module(module_name)
2619
+ return getattr(module, obj_name)
2620
+
2621
+
2622
+ def kill_process_tree(pid: int):
2623
+ """
2624
+ Kills all descendant processes of the given pid by sending SIGKILL.
2625
+
2626
+ Args:
2627
+ pid (int): Process ID of the parent process
2628
+ """
2629
+ try:
2630
+ parent = psutil.Process(pid)
2631
+ except psutil.NoSuchProcess:
2632
+ return
2633
+
2634
+ # Get all children recursively
2635
+ children = parent.children(recursive=True)
2636
+
2637
+ # Send SIGKILL to all children first
2638
+ for child in children:
2639
+ with contextlib.suppress(ProcessLookupError):
2640
+ os.kill(child.pid, signal.SIGKILL)
2641
+
2642
+ # Finally kill the parent
2643
+ with contextlib.suppress(ProcessLookupError):
2644
+ os.kill(pid, signal.SIGKILL)
2645
+
2646
+
2647
+ @dataclass
2648
+ class MemorySnapshot:
2649
+ """Memory snapshot."""
2650
+ torch_peak: int = 0
2651
+ free_memory: int = 0
2652
+ total_memory: int = 0
2653
+ cuda_memory: int = 0
2654
+ torch_memory: int = 0
2655
+ non_torch_memory: int = 0
2656
+ timestamp: float = 0.0
2657
+ auto_measure: bool = True
2658
+
2659
+ def __post_init__(self):
2660
+ if self.auto_measure:
2661
+ self.measure()
2662
+
2663
+ def measure(self):
2664
+ # we measure the torch peak memory usage via allocated_bytes,
2665
+ # rather than `torch.cuda.memory_reserved()` .
2666
+ # After `torch.cuda.reset_peak_memory_stats()`,
2667
+ # `torch.cuda.memory_reserved()` will keep growing, and only shrink
2668
+ # when we call `torch.cuda.empty_cache()` or OOM happens.
2669
+ self.torch_peak = torch.cuda.memory_stats().get(
2670
+ "allocated_bytes.all.peak", 0)
2671
+
2672
+ self.free_memory, self.total_memory = torch.cuda.mem_get_info()
2673
+ self.cuda_memory = self.total_memory - self.free_memory
2674
+
2675
+ # torch.cuda.memory_reserved() is how many bytes
2676
+ # PyTorch gets from cuda (by calling cudaMalloc, etc.)
2677
+ # this is used to measure the non-torch memory usage
2678
+ self.torch_memory = torch.cuda.memory_reserved()
2679
+
2680
+ self.non_torch_memory = self.cuda_memory - self.torch_memory
2681
+ self.timestamp = time.time()
2682
+
2683
+ def __sub__(self, other: MemorySnapshot) -> MemorySnapshot:
2684
+ return MemorySnapshot(
2685
+ torch_peak=self.torch_peak - other.torch_peak,
2686
+ free_memory=self.free_memory - other.free_memory,
2687
+ total_memory=self.total_memory - other.total_memory,
2688
+ cuda_memory=self.cuda_memory - other.cuda_memory,
2689
+ torch_memory=self.torch_memory - other.torch_memory,
2690
+ non_torch_memory=self.non_torch_memory - other.non_torch_memory,
2691
+ timestamp=self.timestamp - other.timestamp,
2692
+ auto_measure=False,
2693
+ )
2694
+
2695
+
2696
+ @dataclass
2697
+ class MemoryProfilingResult:
2698
+ """Memory profiling result. All numbers are in bytes.
2699
+ """
2700
+ non_kv_cache_memory: int = 0
2701
+ torch_peak_increase: int = 0
2702
+ non_torch_increase: int = 0
2703
+ weights_memory: float = 0
2704
+ before_create: MemorySnapshot = field(default_factory=MemorySnapshot)
2705
+ before_profile: MemorySnapshot = field(default_factory=MemorySnapshot)
2706
+ after_profile: MemorySnapshot = field(default_factory=MemorySnapshot)
2707
+ profile_time: float = 0.0
2708
+
2709
+ def __repr__(self) -> str:
2710
+ return (f"Memory profiling takes {self.profile_time:.2f} seconds. "
2711
+ f"Total non KV cache memory: "
2712
+ f"{(self.non_kv_cache_memory / GiB_bytes):.2f}GiB; "
2713
+ f"torch peak memory increase: "
2714
+ f"{(self.torch_peak_increase / GiB_bytes):.2f}GiB; "
2715
+ f"non-torch forward increase memory: "
2716
+ f"{(self.non_torch_increase / GiB_bytes):.2f}GiB; "
2717
+ f"weights memory: {(self.weights_memory / GiB_bytes):.2f}GiB.")
2718
+
2719
+
2720
+ @contextlib.contextmanager
2721
+ def memory_profiling(
2722
+ baseline_snapshot: MemorySnapshot,
2723
+ weights_memory: int) -> Generator[MemoryProfilingResult, None, None]:
2724
+ """Memory profiling context manager.
2725
+ baseline_snapshot: the memory snapshot before the current vLLM instance.
2726
+ weights_memory: memory used by PyTorch when loading the model weights.
2727
+ Note that, before loading the model weights, we also initialize the device
2728
+ and distributed environment, which may consume some memory. This part is not
2729
+ included in the weights_memory because PyTorch does not control it.
2730
+
2731
+ The memory in one GPU can be classified into 3 categories:
2732
+ 1. memory used by anything other than the current vLLM instance.
2733
+ 2. memory used by torch in the current vLLM instance.
2734
+ 3. memory used in the current vLLM instance, but not by torch.
2735
+
2736
+ A quantitive example:
2737
+
2738
+ Before creating the current vLLM instance:
2739
+ category 1: 1 GiB
2740
+ category 2: 0 GiB
2741
+ category 3: 0 GiB
2742
+
2743
+ After creating the current vLLM instance and loading the model,
2744
+ (i.e. before profiling):
2745
+ category 1: 1 GiB
2746
+ category 2: 2 GiB (model weights take 2 GiB)
2747
+ category 3: 0.5 GiB (memory used by NCCL)
2748
+
2749
+ During profiling (peak):
2750
+ category 1: 1 GiB
2751
+ category 2: 4 GiB (peak activation tensors take 2 GiB)
2752
+ category 3: 1 GiB (memory used by NCCL + buffers for some attention backends)
2753
+
2754
+ After profiling:
2755
+ category 1: 1 GiB
2756
+ category 2: 3 GiB (after garbage-collecting activation tensors)
2757
+ category 3: 1 GiB (memory used by NCCL + buffers for some attention backends)
2758
+
2759
+ In this case, non-kv cache takes 5 GiB in total, including:
2760
+ a. 2 GiB used by the model weights (category 2)
2761
+ b. 2 GiB reserved for the peak activation tensors (category 2)
2762
+ c. 1 GiB used by non-torch components (category 3)
2763
+
2764
+ The memory used for loading weights (a.) is directly given from the argument `weights_memory`.
2765
+
2766
+ The increase of `torch.cuda.memory_stats()["allocated_bytes.all.peak"]` during profiling gives (b.).
2767
+
2768
+ The increase of `non_torch_memory` from creating the current vLLM instance until after profiling to get (c.).
2769
+ """ # noqa
2770
+ gc.collect()
2771
+ torch.cuda.empty_cache()
2772
+ torch.cuda.reset_peak_memory_stats()
2773
+
2774
+ result = MemoryProfilingResult()
2775
+
2776
+ result.before_create = baseline_snapshot
2777
+ # the part of memory used for holding the model weights
2778
+ result.weights_memory = weights_memory
2779
+
2780
+ result.before_profile.measure()
2781
+
2782
+ yield result
2783
+
2784
+ gc.collect()
2785
+ torch.cuda.empty_cache()
2786
+
2787
+ result.after_profile.measure()
2788
+
2789
+ diff_profile = result.after_profile - result.before_profile
2790
+ diff_from_create = result.after_profile - result.before_create
2791
+ result.torch_peak_increase = diff_profile.torch_peak
2792
+ result.non_torch_increase = diff_from_create.non_torch_memory
2793
+ result.profile_time = diff_profile.timestamp
2794
+
2795
+ non_torch_memory = result.non_torch_increase
2796
+ peak_activation_memory = result.torch_peak_increase
2797
+ result.non_kv_cache_memory = non_torch_memory + peak_activation_memory + result.weights_memory # noqa
2798
+
2799
+
2800
+ # Adapted from: https://github.com/sgl-project/sglang/blob/v0.4.1/python/sglang/srt/utils.py#L630 # noqa: E501
2801
+ def set_ulimit(target_soft_limit=65535):
2802
+ if sys.platform.startswith('win'):
2803
+ logger.info("Windows detected, skipping ulimit adjustment.")
2804
+ return
2805
+
2806
+ import resource
2807
+ resource_type = resource.RLIMIT_NOFILE
2808
+ current_soft, current_hard = resource.getrlimit(resource_type)
2809
+
2810
+ if current_soft < target_soft_limit:
2811
+ try:
2812
+ resource.setrlimit(resource_type,
2813
+ (target_soft_limit, current_hard))
2814
+ except ValueError as e:
2815
+ logger.warning(
2816
+ "Found ulimit of %s and failed to automatically increase "
2817
+ "with error %s. This can cause fd limit errors like "
2818
+ "`OSError: [Errno 24] Too many open files`. Consider "
2819
+ "increasing with ulimit -n", current_soft, e)
2820
+
2821
+
2822
+ # Adapted from: https://github.com/sgl-project/sglang/blob/v0.4.1/python/sglang/utils.py#L28 # noqa: E501
2823
+ def get_exception_traceback():
2824
+ etype, value, tb = sys.exc_info()
2825
+ err_str = "".join(traceback.format_exception(etype, value, tb))
2826
+ return err_str
2827
+
2828
+
2829
+ def split_zmq_path(path: str) -> tuple[str, str, str]:
2830
+ """Split a zmq path into its parts."""
2831
+ parsed = urlparse(path)
2832
+ if not parsed.scheme:
2833
+ raise ValueError(f"Invalid zmq path: {path}")
2834
+
2835
+ scheme = parsed.scheme
2836
+ host = parsed.hostname or ""
2837
+ port = str(parsed.port or "")
2838
+
2839
+ if scheme == "tcp" and not all((host, port)):
2840
+ # The host and port fields are required for tcp
2841
+ raise ValueError(f"Invalid zmq path: {path}")
2842
+
2843
+ if scheme != "tcp" and port:
2844
+ # port only makes sense with tcp
2845
+ raise ValueError(f"Invalid zmq path: {path}")
2846
+
2847
+ return scheme, host, port
2848
+
2849
+
2850
+ def make_zmq_path(scheme: str, host: str, port: Optional[int] = None) -> str:
2851
+ """Make a ZMQ path from its parts.
2852
+
2853
+ Args:
2854
+ scheme: The ZMQ transport scheme (e.g. tcp, ipc, inproc).
2855
+ host: The host - can be an IPv4 address, IPv6 address, or hostname.
2856
+ port: Optional port number, only used for TCP sockets.
2857
+
2858
+ Returns:
2859
+ A properly formatted ZMQ path string.
2860
+ """
2861
+ if port is None:
2862
+ return f"{scheme}://{host}"
2863
+ if is_valid_ipv6_address(host):
2864
+ return f"{scheme}://[{host}]:{port}"
2865
+ return f"{scheme}://{host}:{port}"
2866
+
2867
+
2868
+ # Adapted from: https://github.com/sgl-project/sglang/blob/v0.4.1/python/sglang/srt/utils.py#L783 # noqa: E501
2869
+ def make_zmq_socket(
2870
+ ctx: Union[zmq.asyncio.Context, zmq.Context], # type: ignore[name-defined]
2871
+ path: str,
2872
+ socket_type: Any,
2873
+ bind: Optional[bool] = None,
2874
+ identity: Optional[bytes] = None,
2875
+ linger: Optional[int] = None,
2876
+ ) -> Union[zmq.Socket, zmq.asyncio.Socket]: # type: ignore[name-defined]
2877
+ """Make a ZMQ socket with the proper bind/connect semantics."""
2878
+
2879
+ mem = psutil.virtual_memory()
2880
+ socket = ctx.socket(socket_type)
2881
+
2882
+ # Calculate buffer size based on system memory
2883
+ total_mem = mem.total / 1024**3
2884
+ available_mem = mem.available / 1024**3
2885
+ # For systems with substantial memory (>32GB total, >16GB available):
2886
+ # - Set a large 0.5GB buffer to improve throughput
2887
+ # For systems with less memory:
2888
+ # - Use system default (-1) to avoid excessive memory consumption
2889
+ if total_mem > 32 and available_mem > 16:
2890
+ buf_size = int(0.5 * 1024**3) # 0.5GB in bytes
2891
+ else:
2892
+ buf_size = -1 # Use system default buffer size
2893
+
2894
+ if bind is None:
2895
+ bind = socket_type not in (zmq.PUSH, zmq.SUB, zmq.XSUB)
2896
+
2897
+ if socket_type in (zmq.PULL, zmq.DEALER, zmq.ROUTER):
2898
+ socket.setsockopt(zmq.RCVHWM, 0)
2899
+ socket.setsockopt(zmq.RCVBUF, buf_size)
2900
+
2901
+ if socket_type in (zmq.PUSH, zmq.DEALER, zmq.ROUTER):
2902
+ socket.setsockopt(zmq.SNDHWM, 0)
2903
+ socket.setsockopt(zmq.SNDBUF, buf_size)
2904
+
2905
+ if identity is not None:
2906
+ socket.setsockopt(zmq.IDENTITY, identity)
2907
+
2908
+ if linger is not None:
2909
+ socket.setsockopt(zmq.LINGER, linger)
2910
+
2911
+ if socket_type == zmq.XPUB:
2912
+ socket.setsockopt(zmq.XPUB_VERBOSE, True)
2913
+
2914
+ # Determine if the path is a TCP socket with an IPv6 address.
2915
+ # Enable IPv6 on the zmq socket if so.
2916
+ scheme, host, _ = split_zmq_path(path)
2917
+ if scheme == "tcp" and is_valid_ipv6_address(host):
2918
+ socket.setsockopt(zmq.IPV6, 1)
2919
+
2920
+ if bind:
2921
+ socket.bind(path)
2922
+ else:
2923
+ socket.connect(path)
2924
+
2925
+ return socket
2926
+
2927
+
2928
+ @contextlib.contextmanager
2929
+ def zmq_socket_ctx(
2930
+ path: str,
2931
+ socket_type: Any,
2932
+ bind: Optional[bool] = None,
2933
+ linger: int = 0,
2934
+ identity: Optional[bytes] = None,
2935
+ ) -> Iterator[zmq.Socket]:
2936
+ """Context manager for a ZMQ socket"""
2937
+
2938
+ ctx = zmq.Context() # type: ignore[attr-defined]
2939
+ try:
2940
+ yield make_zmq_socket(ctx,
2941
+ path,
2942
+ socket_type,
2943
+ bind=bind,
2944
+ identity=identity)
2945
+ except KeyboardInterrupt:
2946
+ logger.debug("Got Keyboard Interrupt.")
2947
+
2948
+ finally:
2949
+ ctx.destroy(linger=linger)
2950
+
2951
+
2952
+ def _maybe_force_spawn():
2953
+ """Check if we need to force the use of the `spawn` multiprocessing start
2954
+ method.
2955
+ """
2956
+ if os.environ.get("VLLM_WORKER_MULTIPROC_METHOD") == "spawn":
2957
+ return
2958
+
2959
+ reasons = []
2960
+ if is_in_ray_actor():
2961
+ # even if we choose to spawn, we need to pass the ray address
2962
+ # to the subprocess so that it knows how to connect to the ray cluster.
2963
+ # env vars are inherited by subprocesses, even if we use spawn.
2964
+ import ray
2965
+ os.environ["RAY_ADDRESS"] = ray.get_runtime_context().gcs_address
2966
+ reasons.append("In a Ray actor and can only be spawned")
2967
+
2968
+ if cuda_is_initialized():
2969
+ reasons.append("CUDA is initialized")
2970
+ elif xpu_is_initialized():
2971
+ reasons.append("XPU is initialized")
2972
+
2973
+ if reasons:
2974
+ logger.warning(
2975
+ "We must use the `spawn` multiprocessing start method. "
2976
+ "Overriding VLLM_WORKER_MULTIPROC_METHOD to 'spawn'. "
2977
+ "See https://docs.vllm.ai/en/latest/usage/"
2978
+ "troubleshooting.html#python-multiprocessing "
2979
+ "for more information. Reasons: %s", "; ".join(reasons))
2980
+ os.environ["VLLM_WORKER_MULTIPROC_METHOD"] = "spawn"
2981
+
2982
+
2983
+ def get_mp_context():
2984
+ """Get a multiprocessing context with a particular method (spawn or fork).
2985
+ By default we follow the value of the VLLM_WORKER_MULTIPROC_METHOD to
2986
+ determine the multiprocessing method (default is fork). However, under
2987
+ certain conditions, we may enforce spawn and override the value of
2988
+ VLLM_WORKER_MULTIPROC_METHOD.
2989
+ """
2990
+ _maybe_force_spawn()
2991
+ mp_method = envs.VLLM_WORKER_MULTIPROC_METHOD
2992
+ return multiprocessing.get_context(mp_method)
2993
+
2994
+
2995
+ def bind_kv_cache(
2996
+ ctx: dict[str, Any],
2997
+ kv_cache: list[list[torch.Tensor]], # [virtual_engine][layer_index]
2998
+ shared_kv_cache_layers: Optional[dict[str, str]] = None
2999
+ ) -> None:
3000
+ # Bind the kv_cache tensor to Attention modules, similar to
3001
+ # ctx[layer_name].kv_cache[ve]=kv_cache[ve][extract_layer_index(layer_name)]
3002
+ # Special things handled here:
3003
+ # 1. Some models have non-attention layers, e.g., Jamba
3004
+ # 2. Pipeline parallelism, each rank only has a subset of layers
3005
+ # 3. Encoder attention has no kv cache
3006
+ # 4. Encoder-decoder models, encoder-decoder attention and decoder-only
3007
+ # attention of the same layer (e.g., bart's decoder.layers.1.self_attn
3008
+ # and decoder.layers.1.encoder_attn) is mapped to the same kv cache
3009
+ # tensor
3010
+ # 5. Some models have attention layers that share kv cache with previous
3011
+ # layers, this is specified through shared_kv_cache_layers
3012
+ if shared_kv_cache_layers is None:
3013
+ shared_kv_cache_layers = {}
3014
+ from vllm.attention import AttentionType
3015
+ from vllm.model_executor.models.utils import extract_layer_index
3016
+ layer_need_kv_cache = [
3017
+ layer_name for layer_name in ctx
3018
+ if (hasattr(ctx[layer_name], 'attn_type') and ctx[layer_name].attn_type
3019
+ in (AttentionType.DECODER, AttentionType.ENCODER_DECODER)) \
3020
+ and ctx[layer_name].kv_sharing_target_layer_name is None
3021
+ ]
3022
+ layer_index_sorted = sorted(
3023
+ set(
3024
+ extract_layer_index(layer_name)
3025
+ for layer_name in layer_need_kv_cache))
3026
+ for layer_name in layer_need_kv_cache:
3027
+ kv_cache_idx = layer_index_sorted.index(
3028
+ extract_layer_index(layer_name))
3029
+ forward_ctx = ctx[layer_name]
3030
+ assert len(forward_ctx.kv_cache) == len(kv_cache)
3031
+ for ve, ve_kv_cache in enumerate(kv_cache):
3032
+ forward_ctx.kv_cache[ve] = ve_kv_cache[kv_cache_idx]
3033
+ if shared_kv_cache_layers is not None:
3034
+ for layer_name, target_layer_name in shared_kv_cache_layers.items():
3035
+ assert extract_layer_index(target_layer_name) < \
3036
+ extract_layer_index(layer_name), \
3037
+ "v0 doesn't support interleaving kv sharing"
3038
+ ctx[layer_name].kv_cache = ctx[target_layer_name].kv_cache
3039
+
3040
+
3041
+ def run_method(obj: Any, method: Union[str, bytes, Callable], args: tuple[Any],
3042
+ kwargs: dict[str, Any]) -> Any:
3043
+ """
3044
+ Run a method of an object with the given arguments and keyword arguments.
3045
+ If the method is string, it will be converted to a method using getattr.
3046
+ If the method is serialized bytes and will be deserialized using
3047
+ cloudpickle.
3048
+ If the method is a callable, it will be called directly.
3049
+ """
3050
+ if isinstance(method, bytes):
3051
+ func = partial(cloudpickle.loads(method), obj)
3052
+ elif isinstance(method, str):
3053
+ try:
3054
+ func = getattr(obj, method)
3055
+ except AttributeError:
3056
+ raise NotImplementedError(f"Method {method!r} is not"
3057
+ " implemented.") from None
3058
+ else:
3059
+ func = partial(method, obj) # type: ignore
3060
+ return func(*args, **kwargs)
3061
+
3062
+
3063
+ def import_pynvml():
3064
+ """
3065
+ Historical comments:
3066
+
3067
+ libnvml.so is the library behind nvidia-smi, and
3068
+ pynvml is a Python wrapper around it. We use it to get GPU
3069
+ status without initializing CUDA context in the current process.
3070
+ Historically, there are two packages that provide pynvml:
3071
+ - `nvidia-ml-py` (https://pypi.org/project/nvidia-ml-py/): The official
3072
+ wrapper. It is a dependency of vLLM, and is installed when users
3073
+ install vLLM. It provides a Python module named `pynvml`.
3074
+ - `pynvml` (https://pypi.org/project/pynvml/): An unofficial wrapper.
3075
+ Prior to version 12.0, it also provides a Python module `pynvml`,
3076
+ and therefore conflicts with the official one. What's worse,
3077
+ the module is a Python package, and has higher priority than
3078
+ the official one which is a standalone Python file.
3079
+ This causes errors when both of them are installed.
3080
+ Starting from version 12.0, it migrates to a new module
3081
+ named `pynvml_utils` to avoid the conflict.
3082
+ It is so confusing that many packages in the community use the
3083
+ unofficial one by mistake, and we have to handle this case.
3084
+ For example, `nvcr.io/nvidia/pytorch:24.12-py3` uses the unofficial
3085
+ one, and it will cause errors, see the issue
3086
+ https://github.com/vllm-project/vllm/issues/12847 for example.
3087
+ After all the troubles, we decide to copy the official `pynvml`
3088
+ module to our codebase, and use it directly.
3089
+ """
3090
+ import vllm.third_party.pynvml as pynvml
3091
+ return pynvml
3092
+
3093
+
3094
+ def warn_for_unimplemented_methods(cls: type[T]) -> type[T]:
3095
+ """
3096
+ A replacement for `abc.ABC`.
3097
+ When we use `abc.ABC`, subclasses will fail to instantiate
3098
+ if they do not implement all abstract methods.
3099
+ Here, we only require `raise NotImplementedError` in the
3100
+ base class, and log a warning if the method is not implemented
3101
+ in the subclass.
3102
+ """
3103
+
3104
+ original_init = cls.__init__
3105
+
3106
+ def find_unimplemented_methods(self: object):
3107
+ unimplemented_methods = []
3108
+ for attr_name in dir(self):
3109
+ # bypass inner method
3110
+ if attr_name.startswith('_'):
3111
+ continue
3112
+
3113
+ try:
3114
+ attr = getattr(self, attr_name)
3115
+ # get the func of callable method
3116
+ if callable(attr):
3117
+ attr_func = attr.__func__
3118
+ except AttributeError:
3119
+ continue
3120
+ src = inspect.getsource(attr_func)
3121
+ if "NotImplementedError" in src:
3122
+ unimplemented_methods.append(attr_name)
3123
+ if unimplemented_methods:
3124
+ method_names = ','.join(unimplemented_methods)
3125
+ msg = (f"Methods {method_names} not implemented in {self}")
3126
+ logger.debug(msg)
3127
+
3128
+ @wraps(original_init)
3129
+ def wrapped_init(self, *args, **kwargs) -> None:
3130
+ original_init(self, *args, **kwargs)
3131
+ find_unimplemented_methods(self)
3132
+
3133
+ type.__setattr__(cls, '__init__', wrapped_init)
3134
+ return cls
3135
+
3136
+
3137
+ class LazyLoader(types.ModuleType):
3138
+ """
3139
+ LazyLoader module borrowed from Tensorflow
3140
+ https://github.com/tensorflow/tensorflow/blob/main/tensorflow/python/util/lazy_loader.py
3141
+ with an addition of "module caching".
3142
+
3143
+ Lazily import a module, mainly to avoid pulling in large dependencies.
3144
+ Modules such as `xgrammar` might do additional side effects, so we
3145
+ only want to use this when it is needed, delaying all eager effects
3146
+ """
3147
+
3148
+ def __init__(
3149
+ self,
3150
+ local_name: str,
3151
+ parent_module_globals: dict[str, Any],
3152
+ name: str,
3153
+ ):
3154
+ self._local_name = local_name
3155
+ self._parent_module_globals = parent_module_globals
3156
+ self._module: types.ModuleType | None = None
3157
+
3158
+ super().__init__(str(name))
3159
+
3160
+ def _load(self) -> types.ModuleType:
3161
+ # Import the target module and insert it into the parent's namespace
3162
+ try:
3163
+ module = importlib.import_module(self.__name__)
3164
+ self._parent_module_globals[self._local_name] = module
3165
+ # The additional add to sys.modules
3166
+ # ensures library is actually loaded.
3167
+ sys.modules[self._local_name] = module
3168
+ except ModuleNotFoundError as err:
3169
+ raise err from None
3170
+
3171
+ # Update this object's dict so that if someone keeps a
3172
+ # reference to the LazyLoader, lookups are efficient
3173
+ # (__getattr__ is only called on lookups that fail).
3174
+ self.__dict__.update(module.__dict__)
3175
+ return module
3176
+
3177
+ def __getattr__(self, item: Any) -> Any:
3178
+ if self._module is None:
3179
+ self._module = self._load()
3180
+ return getattr(self._module, item)
3181
+
3182
+ def __dir__(self) -> list[str]:
3183
+ if self._module is None:
3184
+ self._module = self._load()
3185
+ return dir(self._module)
3186
+
3187
+
3188
+ def swap_dict_values(obj: dict[_K, _V], key1: _K, key2: _K) -> None:
3189
+ """
3190
+ Helper function to swap values for two keys
3191
+ """
3192
+ v1 = obj.get(key1)
3193
+ v2 = obj.get(key2)
3194
+ if v1 is not None:
3195
+ obj[key2] = v1
3196
+ else:
3197
+ obj.pop(key2, None)
3198
+ if v2 is not None:
3199
+ obj[key1] = v2
3200
+ else:
3201
+ obj.pop(key1, None)
3202
+
3203
+
3204
+ @contextlib.contextmanager
3205
+ def cprofile_context(save_file: Optional[str] = None):
3206
+ """Run a cprofile
3207
+
3208
+ Args:
3209
+ save_file: path to save the profile result. "1" or
3210
+ None will result in printing to stdout.
3211
+ """
3212
+ import cProfile
3213
+
3214
+ prof = cProfile.Profile()
3215
+ prof.enable()
3216
+
3217
+ try:
3218
+ yield
3219
+ finally:
3220
+ prof.disable()
3221
+ if save_file and save_file != "1":
3222
+ prof.dump_stats(save_file)
3223
+ else:
3224
+ prof.print_stats(sort="cumtime")
3225
+
3226
+
3227
+ def cprofile(save_file: Optional[str] = None, enabled: bool = True):
3228
+ """Decorator to profile a Python method using cProfile.
3229
+
3230
+ Args:
3231
+ save_file: Path to save the profile result.
3232
+ If "1", None, or "", results will be printed to stdout.
3233
+ enabled: Set to false to turn this into a no-op
3234
+ """
3235
+
3236
+ def decorator(func: Callable):
3237
+
3238
+ @wraps(func)
3239
+ def wrapper(*args, **kwargs):
3240
+ if not enabled:
3241
+ # If profiling is disabled, just call the function directly.
3242
+ return func(*args, **kwargs)
3243
+
3244
+ with cprofile_context(save_file):
3245
+ return func(*args, **kwargs)
3246
+
3247
+ return wrapper
3248
+
3249
+ return decorator
3250
+
3251
+
3252
+ # Only relevant for models using ALiBi (e.g, MPT)
3253
+ def check_use_alibi(model_config: ModelConfig) -> bool:
3254
+ cfg = model_config.hf_text_config
3255
+ return (getattr(cfg, "alibi", False) # Falcon
3256
+ or ("BloomForCausalLM" in getattr(model_config.hf_config,
3257
+ "architectures", [])) # Bloom
3258
+ or getattr(cfg, "position_encoding_type", "") ==
3259
+ "alibi" # codellm_1b_alibi
3260
+ or (hasattr(cfg, "attn_config") # MPT
3261
+ and ((isinstance(cfg.attn_config, dict)
3262
+ and cfg.attn_config.get("alibi", False)) or
3263
+ (not isinstance(cfg.attn_config, dict)
3264
+ and getattr(cfg.attn_config, "alibi", False)))))
3265
+
3266
+
3267
+ def sha256(input) -> bytes:
3268
+ """Hash any picklable Python object using SHA-256.
3269
+
3270
+ The input is serialized using pickle before hashing, which allows
3271
+ arbitrary Python objects to be used. Note that this function does
3272
+ not use a hash seed—if you need one, prepend it explicitly to the input.
3273
+
3274
+ Args:
3275
+ input: Any picklable Python object.
3276
+
3277
+ Returns:
3278
+ Bytes representing the SHA-256 hash of the serialized input.
3279
+ """
3280
+ input_bytes = pickle.dumps(input, protocol=pickle.HIGHEST_PROTOCOL)
3281
+ return hashlib.sha256(input_bytes).digest()
3282
+
3283
+
3284
+ def sha256_cbor(input) -> bytes:
3285
+ """
3286
+ Hash objects using CBOR serialization and SHA-256.
3287
+
3288
+ This option is useful for non-Python-dependent serialization and hashing.
3289
+
3290
+ Args:
3291
+ input: Object to be serialized and hashed. Supported types include
3292
+ basic Python types and complex structures like lists, tuples, and
3293
+ dictionaries.
3294
+ Custom classes must implement CBOR serialization methods.
3295
+
3296
+ Returns:
3297
+ Bytes representing the SHA-256 hash of the CBOR serialized input.
3298
+ """
3299
+ input_bytes = cbor2.dumps(input, canonical=True)
3300
+ return hashlib.sha256(input_bytes).digest()
3301
+
3302
+
3303
+ def get_hash_fn_by_name(hash_fn_name: str) -> Callable[[Any], bytes]:
3304
+ """Get a hash function by name, or raise an error if
3305
+ the function is not found.
3306
+ Args:
3307
+ hash_fn_name: Name of the hash function.
3308
+ Returns:
3309
+ A hash function.
3310
+ """
3311
+ if hash_fn_name == "sha256":
3312
+ return sha256
3313
+ if hash_fn_name == "sha256_cbor":
3314
+ return sha256_cbor
3315
+
3316
+ raise ValueError(f"Unsupported hash function: {hash_fn_name}")
3317
+
3318
+
3319
+ def is_torch_equal_or_newer(target: str) -> bool:
3320
+ """Check if the installed torch version is >= the target version.
3321
+
3322
+ Args:
3323
+ target: a version string, like "2.6.0".
3324
+
3325
+ Returns:
3326
+ Whether the condition meets.
3327
+ """
3328
+ try:
3329
+ return _is_torch_equal_or_newer(str(torch.__version__), target)
3330
+ except Exception:
3331
+ # Fallback to PKG-INFO to load the package info, needed by the doc gen.
3332
+ return Version(importlib.metadata.version('torch')) >= Version(target)
3333
+
3334
+
3335
+ # Helper function used in testing.
3336
+ def _is_torch_equal_or_newer(torch_version: str, target: str) -> bool:
3337
+ torch_version = version.parse(torch_version)
3338
+ return torch_version >= version.parse(target)
3339
+
3340
+
3341
+ @cache
3342
+ def _has_module(module_name: str) -> bool:
3343
+ """Return True if *module_name* can be found in the current environment.
3344
+
3345
+ The result is cached so that subsequent queries for the same module incur
3346
+ no additional overhead.
3347
+ """
3348
+ return importlib.util.find_spec(module_name) is not None
3349
+
3350
+
3351
+ def has_pplx() -> bool:
3352
+ """Whether the optional `pplx_kernels` package is available."""
3353
+
3354
+ return _has_module("pplx_kernels")
3355
+
3356
+
3357
+ def has_deep_ep() -> bool:
3358
+ """Whether the optional `deep_ep` package is available."""
3359
+
3360
+ return _has_module("deep_ep")
3361
+
3362
+
3363
+ def has_deep_gemm() -> bool:
3364
+ """Whether the optional `deep_gemm` package is available."""
3365
+
3366
+ return _has_module("deep_gemm")
3367
+
3368
+
3369
+ def has_triton_kernels() -> bool:
3370
+ """Whether the optional `triton_kernels` package is available."""
3371
+
3372
+ return _has_module("triton_kernels")
3373
+
3374
+
3375
+ def set_process_title(name: str,
3376
+ suffix: str = "",
3377
+ prefix: str = envs.VLLM_PROCESS_NAME_PREFIX) -> None:
3378
+ """
3379
+ Set the current process title to a specific name with an
3380
+ optional suffix.
3381
+
3382
+ Args:
3383
+ name: The title to assign to the current process.
3384
+ suffix: An optional suffix to append to the base name.
3385
+ prefix: A prefix to prepend to the front separated by `::`.
3386
+ """
3387
+ if suffix:
3388
+ name = f"{name}_{suffix}"
3389
+ setproctitle.setproctitle(f"{prefix}::{name}")
3390
+
3391
+
3392
+ def _add_prefix(file: TextIO, worker_name: str, pid: int) -> None:
3393
+ """Prepend each output line with process-specific prefix"""
3394
+
3395
+ prefix = f"{CYAN}({worker_name} pid={pid}){RESET} "
3396
+ file_write = file.write
3397
+
3398
+ def write_with_prefix(s: str):
3399
+ if not s:
3400
+ return
3401
+ if file.start_new_line: # type: ignore[attr-defined]
3402
+ file_write(prefix)
3403
+ idx = 0
3404
+ while (next_idx := s.find('\n', idx)) != -1:
3405
+ next_idx += 1
3406
+ file_write(s[idx:next_idx])
3407
+ if next_idx == len(s):
3408
+ file.start_new_line = True # type: ignore[attr-defined]
3409
+ return
3410
+ file_write(prefix)
3411
+ idx = next_idx
3412
+ file_write(s[idx:])
3413
+ file.start_new_line = False # type: ignore[attr-defined]
3414
+
3415
+ file.start_new_line = True # type: ignore[attr-defined]
3416
+ file.write = write_with_prefix # type: ignore[method-assign]
3417
+
3418
+
3419
+ def decorate_logs(process_name: Optional[str] = None) -> None:
3420
+ """
3421
+ Adds a process-specific prefix to each line of output written to stdout and
3422
+ stderr.
3423
+
3424
+ This function is intended to be called before initializing the api_server,
3425
+ engine_core, or worker classes, so that all subsequent output from the
3426
+ process is prefixed with the process name and PID. This helps distinguish
3427
+ log output from different processes in multi-process environments.
3428
+
3429
+ Args:
3430
+ process_name: Optional; the name of the process to use in the prefix.
3431
+ If not provided, the current process name from the multiprocessing
3432
+ context is used.
3433
+ """
3434
+ if process_name is None:
3435
+ process_name = get_mp_context().current_process().name
3436
+ pid = os.getpid()
3437
+ _add_prefix(sys.stdout, process_name, pid)
3438
+ _add_prefix(sys.stderr, process_name, pid)