vllm-cpu 0.8.5.post2__cp310-cp310-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 might be problematic. Click here for more details.

Files changed (1103) hide show
  1. vllm/_C.abi3.so +0 -0
  2. vllm/__init__.py +170 -0
  3. vllm/_custom_ops.py +1536 -0
  4. vllm/_ipex_ops.py +241 -0
  5. vllm/_version.py +34 -0
  6. vllm/adapter_commons/__init__.py +0 -0
  7. vllm/adapter_commons/layers.py +16 -0
  8. vllm/adapter_commons/models.py +105 -0
  9. vllm/adapter_commons/request.py +25 -0
  10. vllm/adapter_commons/utils.py +92 -0
  11. vllm/adapter_commons/worker_manager.py +38 -0
  12. vllm/assets/__init__.py +0 -0
  13. vllm/assets/audio.py +38 -0
  14. vllm/assets/base.py +40 -0
  15. vllm/assets/image.py +31 -0
  16. vllm/assets/video.py +103 -0
  17. vllm/attention/__init__.py +19 -0
  18. vllm/attention/backends/__init__.py +0 -0
  19. vllm/attention/backends/abstract.py +306 -0
  20. vllm/attention/backends/blocksparse_attn.py +457 -0
  21. vllm/attention/backends/cpu_mla.py +303 -0
  22. vllm/attention/backends/flash_attn.py +999 -0
  23. vllm/attention/backends/flashinfer.py +1092 -0
  24. vllm/attention/backends/flashmla.py +242 -0
  25. vllm/attention/backends/hpu_attn.py +301 -0
  26. vllm/attention/backends/ipex_attn.py +396 -0
  27. vllm/attention/backends/mla/__init__.py +0 -0
  28. vllm/attention/backends/mla/common.py +1444 -0
  29. vllm/attention/backends/pallas.py +346 -0
  30. vllm/attention/backends/placeholder_attn.py +399 -0
  31. vllm/attention/backends/rocm_aiter_mla.py +412 -0
  32. vllm/attention/backends/rocm_flash_attn.py +969 -0
  33. vllm/attention/backends/torch_sdpa.py +691 -0
  34. vllm/attention/backends/triton_mla.py +113 -0
  35. vllm/attention/backends/utils.py +609 -0
  36. vllm/attention/backends/xformers.py +798 -0
  37. vllm/attention/layer.py +443 -0
  38. vllm/attention/ops/__init__.py +0 -0
  39. vllm/attention/ops/blocksparse_attention/__init__.py +0 -0
  40. vllm/attention/ops/blocksparse_attention/blocksparse_attention_kernel.py +432 -0
  41. vllm/attention/ops/blocksparse_attention/interface.py +238 -0
  42. vllm/attention/ops/blocksparse_attention/utils.py +244 -0
  43. vllm/attention/ops/chunked_prefill_paged_decode.py +366 -0
  44. vllm/attention/ops/flashmla.py +115 -0
  45. vllm/attention/ops/hpu_paged_attn.py +105 -0
  46. vllm/attention/ops/ipex_attn.py +193 -0
  47. vllm/attention/ops/merge_attn_states.py +42 -0
  48. vllm/attention/ops/nki_flash_attn.py +905 -0
  49. vllm/attention/ops/paged_attn.py +255 -0
  50. vllm/attention/ops/prefix_prefill.py +902 -0
  51. vllm/attention/ops/rocm_aiter_mla.py +42 -0
  52. vllm/attention/ops/rocm_aiter_paged_attn.py +101 -0
  53. vllm/attention/ops/triton_decode_attention.py +675 -0
  54. vllm/attention/ops/triton_flash_attention.py +1375 -0
  55. vllm/attention/ops/triton_merge_attn_states.py +96 -0
  56. vllm/attention/selector.py +186 -0
  57. vllm/attention/utils/fa_utils.py +54 -0
  58. vllm/beam_search.py +82 -0
  59. vllm/benchmarks/__init__.py +0 -0
  60. vllm/benchmarks/datasets.py +831 -0
  61. vllm/benchmarks/endpoint_request_func.py +160 -0
  62. vllm/benchmarks/latency.py +181 -0
  63. vllm/benchmarks/serve.py +925 -0
  64. vllm/benchmarks/throughput.py +608 -0
  65. vllm/benchmarks/utils.py +69 -0
  66. vllm/collect_env.py +795 -0
  67. vllm/compilation/__init__.py +0 -0
  68. vllm/compilation/backends.py +715 -0
  69. vllm/compilation/compiler_interface.py +437 -0
  70. vllm/compilation/counter.py +33 -0
  71. vllm/compilation/decorators.py +249 -0
  72. vllm/compilation/fix_functionalization.py +182 -0
  73. vllm/compilation/fusion.py +617 -0
  74. vllm/compilation/fx_utils.py +60 -0
  75. vllm/compilation/inductor_pass.py +114 -0
  76. vllm/compilation/monitor.py +38 -0
  77. vllm/compilation/multi_output_match.py +108 -0
  78. vllm/compilation/noop_elimination.py +135 -0
  79. vllm/compilation/pass_manager.py +74 -0
  80. vllm/compilation/sequence_parallelism.py +266 -0
  81. vllm/compilation/torch25_custom_graph_pass.py +41 -0
  82. vllm/compilation/vllm_inductor_pass.py +68 -0
  83. vllm/compilation/wrapper.py +129 -0
  84. vllm/config.py +4179 -0
  85. vllm/connections.py +170 -0
  86. vllm/core/__init__.py +0 -0
  87. vllm/core/block/__init__.py +0 -0
  88. vllm/core/block/block_table.py +398 -0
  89. vllm/core/block/common.py +370 -0
  90. vllm/core/block/cpu_gpu_block_allocator.py +440 -0
  91. vllm/core/block/interfaces.py +318 -0
  92. vllm/core/block/naive_block.py +465 -0
  93. vllm/core/block/prefix_caching_block.py +1134 -0
  94. vllm/core/block/utils.py +27 -0
  95. vllm/core/block_manager.py +520 -0
  96. vllm/core/evictor.py +156 -0
  97. vllm/core/interfaces.py +134 -0
  98. vllm/core/placeholder_block_space_manager.py +99 -0
  99. vllm/core/scheduler.py +2060 -0
  100. vllm/device_allocator/__init__.py +0 -0
  101. vllm/device_allocator/cumem.py +280 -0
  102. vllm/distributed/__init__.py +5 -0
  103. vllm/distributed/communication_op.py +40 -0
  104. vllm/distributed/device_communicators/__init__.py +0 -0
  105. vllm/distributed/device_communicators/base_device_communicator.py +151 -0
  106. vllm/distributed/device_communicators/cpu_communicator.py +139 -0
  107. vllm/distributed/device_communicators/cuda_communicator.py +131 -0
  108. vllm/distributed/device_communicators/cuda_wrapper.py +179 -0
  109. vllm/distributed/device_communicators/custom_all_reduce.py +301 -0
  110. vllm/distributed/device_communicators/custom_all_reduce_utils.py +257 -0
  111. vllm/distributed/device_communicators/hpu_communicator.py +45 -0
  112. vllm/distributed/device_communicators/neuron_communicator.py +19 -0
  113. vllm/distributed/device_communicators/pynccl.py +217 -0
  114. vllm/distributed/device_communicators/pynccl_wrapper.py +340 -0
  115. vllm/distributed/device_communicators/shm_broadcast.py +557 -0
  116. vllm/distributed/device_communicators/tpu_communicator.py +93 -0
  117. vllm/distributed/device_communicators/xpu_communicator.py +54 -0
  118. vllm/distributed/kv_transfer/README.md +29 -0
  119. vllm/distributed/kv_transfer/__init__.py +11 -0
  120. vllm/distributed/kv_transfer/disagg_prefill_workflow.jpg +0 -0
  121. vllm/distributed/kv_transfer/kv_connector/__init__.py +0 -0
  122. vllm/distributed/kv_transfer/kv_connector/base.py +127 -0
  123. vllm/distributed/kv_transfer/kv_connector/factory.py +107 -0
  124. vllm/distributed/kv_transfer/kv_connector/lmcache_connector.py +98 -0
  125. vllm/distributed/kv_transfer/kv_connector/mooncake_store_connector.py +201 -0
  126. vllm/distributed/kv_transfer/kv_connector/simple_connector.py +328 -0
  127. vllm/distributed/kv_transfer/kv_connector/utils.py +90 -0
  128. vllm/distributed/kv_transfer/kv_connector/v1/__init__.py +8 -0
  129. vllm/distributed/kv_transfer/kv_connector/v1/base.py +209 -0
  130. vllm/distributed/kv_transfer/kv_connector/v1/lmcache_connector.py +131 -0
  131. vllm/distributed/kv_transfer/kv_connector/v1/shared_storage_connector.py +383 -0
  132. vllm/distributed/kv_transfer/kv_connector_agent.py +76 -0
  133. vllm/distributed/kv_transfer/kv_lookup_buffer/__init__.py +0 -0
  134. vllm/distributed/kv_transfer/kv_lookup_buffer/base.py +174 -0
  135. vllm/distributed/kv_transfer/kv_lookup_buffer/mooncake_store.py +160 -0
  136. vllm/distributed/kv_transfer/kv_lookup_buffer/simple_buffer.py +236 -0
  137. vllm/distributed/kv_transfer/kv_pipe/__init__.py +0 -0
  138. vllm/distributed/kv_transfer/kv_pipe/base.py +66 -0
  139. vllm/distributed/kv_transfer/kv_pipe/mooncake_pipe.py +279 -0
  140. vllm/distributed/kv_transfer/kv_pipe/pynccl_pipe.py +279 -0
  141. vllm/distributed/kv_transfer/kv_transfer_state.py +70 -0
  142. vllm/distributed/parallel_state.py +1209 -0
  143. vllm/distributed/utils.py +366 -0
  144. vllm/engine/__init__.py +0 -0
  145. vllm/engine/arg_utils.py +1724 -0
  146. vllm/engine/async_llm_engine.py +1261 -0
  147. vllm/engine/async_timeout.py +191 -0
  148. vllm/engine/llm_engine.py +2150 -0
  149. vllm/engine/metrics.py +717 -0
  150. vllm/engine/metrics_types.py +96 -0
  151. vllm/engine/multiprocessing/__init__.py +183 -0
  152. vllm/engine/multiprocessing/client.py +745 -0
  153. vllm/engine/multiprocessing/engine.py +450 -0
  154. vllm/engine/output_processor/__init__.py +0 -0
  155. vllm/engine/output_processor/interfaces.py +74 -0
  156. vllm/engine/output_processor/multi_step.py +210 -0
  157. vllm/engine/output_processor/single_step.py +136 -0
  158. vllm/engine/output_processor/stop_checker.py +130 -0
  159. vllm/engine/output_processor/util.py +27 -0
  160. vllm/engine/protocol.py +302 -0
  161. vllm/entrypoints/__init__.py +0 -0
  162. vllm/entrypoints/api_server.py +177 -0
  163. vllm/entrypoints/chat_utils.py +1259 -0
  164. vllm/entrypoints/cli/__init__.py +0 -0
  165. vllm/entrypoints/cli/benchmark/__init__.py +0 -0
  166. vllm/entrypoints/cli/benchmark/base.py +38 -0
  167. vllm/entrypoints/cli/benchmark/latency.py +29 -0
  168. vllm/entrypoints/cli/benchmark/main.py +53 -0
  169. vllm/entrypoints/cli/benchmark/serve.py +29 -0
  170. vllm/entrypoints/cli/benchmark/throughput.py +29 -0
  171. vllm/entrypoints/cli/collect_env.py +35 -0
  172. vllm/entrypoints/cli/main.py +59 -0
  173. vllm/entrypoints/cli/openai.py +175 -0
  174. vllm/entrypoints/cli/serve.py +59 -0
  175. vllm/entrypoints/cli/types.py +24 -0
  176. vllm/entrypoints/launcher.py +146 -0
  177. vllm/entrypoints/llm.py +1450 -0
  178. vllm/entrypoints/logger.py +44 -0
  179. vllm/entrypoints/openai/__init__.py +0 -0
  180. vllm/entrypoints/openai/api_server.py +1130 -0
  181. vllm/entrypoints/openai/cli_args.py +296 -0
  182. vllm/entrypoints/openai/logits_processors.py +89 -0
  183. vllm/entrypoints/openai/protocol.py +1806 -0
  184. vllm/entrypoints/openai/run_batch.py +439 -0
  185. vllm/entrypoints/openai/serving_chat.py +1210 -0
  186. vllm/entrypoints/openai/serving_completion.py +557 -0
  187. vllm/entrypoints/openai/serving_embedding.py +245 -0
  188. vllm/entrypoints/openai/serving_engine.py +569 -0
  189. vllm/entrypoints/openai/serving_models.py +314 -0
  190. vllm/entrypoints/openai/serving_pooling.py +237 -0
  191. vllm/entrypoints/openai/serving_score.py +439 -0
  192. vllm/entrypoints/openai/serving_tokenization.py +147 -0
  193. vllm/entrypoints/openai/serving_transcription.py +421 -0
  194. vllm/entrypoints/openai/tool_parsers/__init__.py +19 -0
  195. vllm/entrypoints/openai/tool_parsers/abstract_tool_parser.py +163 -0
  196. vllm/entrypoints/openai/tool_parsers/granite_20b_fc_tool_parser.py +254 -0
  197. vllm/entrypoints/openai/tool_parsers/granite_tool_parser.py +232 -0
  198. vllm/entrypoints/openai/tool_parsers/hermes_tool_parser.py +370 -0
  199. vllm/entrypoints/openai/tool_parsers/internlm2_tool_parser.py +211 -0
  200. vllm/entrypoints/openai/tool_parsers/jamba_tool_parser.py +303 -0
  201. vllm/entrypoints/openai/tool_parsers/llama_tool_parser.py +262 -0
  202. vllm/entrypoints/openai/tool_parsers/mistral_tool_parser.py +342 -0
  203. vllm/entrypoints/openai/tool_parsers/phi4mini_tool_parser.py +110 -0
  204. vllm/entrypoints/openai/tool_parsers/pythonic_tool_parser.py +292 -0
  205. vllm/entrypoints/openai/tool_parsers/utils.py +123 -0
  206. vllm/entrypoints/score_utils.py +49 -0
  207. vllm/entrypoints/ssl.py +74 -0
  208. vllm/entrypoints/utils.py +136 -0
  209. vllm/env_override.py +34 -0
  210. vllm/envs.py +800 -0
  211. vllm/executor/__init__.py +0 -0
  212. vllm/executor/executor_base.py +400 -0
  213. vllm/executor/mp_distributed_executor.py +243 -0
  214. vllm/executor/msgspec_utils.py +29 -0
  215. vllm/executor/multiproc_worker_utils.py +312 -0
  216. vllm/executor/ray_distributed_executor.py +700 -0
  217. vllm/executor/ray_utils.py +400 -0
  218. vllm/executor/uniproc_executor.py +141 -0
  219. vllm/forward_context.py +159 -0
  220. vllm/inputs/__init__.py +37 -0
  221. vllm/inputs/data.py +248 -0
  222. vllm/inputs/parse.py +121 -0
  223. vllm/inputs/preprocess.py +745 -0
  224. vllm/inputs/registry.py +212 -0
  225. vllm/jsontree.py +79 -0
  226. vllm/logger.py +210 -0
  227. vllm/logging_utils/__init__.py +7 -0
  228. vllm/logging_utils/formatter.py +17 -0
  229. vllm/logits_process.py +121 -0
  230. vllm/lora/__init__.py +0 -0
  231. vllm/lora/fully_sharded_layers.py +335 -0
  232. vllm/lora/layers.py +1263 -0
  233. vllm/lora/lora.py +198 -0
  234. vllm/lora/models.py +802 -0
  235. vllm/lora/ops/__init__.py +0 -0
  236. vllm/lora/ops/torch_ops/__init__.py +15 -0
  237. vllm/lora/ops/torch_ops/lora_ops.py +115 -0
  238. vllm/lora/ops/triton_ops/__init__.py +11 -0
  239. vllm/lora/ops/triton_ops/kernel_utils.py +243 -0
  240. vllm/lora/ops/triton_ops/lora_expand.py +293 -0
  241. vllm/lora/ops/triton_ops/lora_kernel_metadata.py +147 -0
  242. vllm/lora/ops/triton_ops/lora_shrink.py +247 -0
  243. vllm/lora/ops/triton_ops/utils.py +121 -0
  244. vllm/lora/peft_helper.py +115 -0
  245. vllm/lora/punica_wrapper/__init__.py +9 -0
  246. vllm/lora/punica_wrapper/punica_base.py +483 -0
  247. vllm/lora/punica_wrapper/punica_cpu.py +348 -0
  248. vllm/lora/punica_wrapper/punica_gpu.py +289 -0
  249. vllm/lora/punica_wrapper/punica_hpu.py +144 -0
  250. vllm/lora/punica_wrapper/punica_selector.py +20 -0
  251. vllm/lora/punica_wrapper/utils.py +161 -0
  252. vllm/lora/request.py +97 -0
  253. vllm/lora/resolver.py +83 -0
  254. vllm/lora/utils.py +237 -0
  255. vllm/lora/worker_manager.py +251 -0
  256. vllm/model_executor/__init__.py +15 -0
  257. vllm/model_executor/custom_op.py +153 -0
  258. vllm/model_executor/guided_decoding/__init__.py +180 -0
  259. vllm/model_executor/guided_decoding/guidance_decoding.py +63 -0
  260. vllm/model_executor/guided_decoding/guidance_logits_processors.py +85 -0
  261. vllm/model_executor/guided_decoding/guided_fields.py +42 -0
  262. vllm/model_executor/guided_decoding/lm_format_enforcer_decoding.py +66 -0
  263. vllm/model_executor/guided_decoding/outlines_decoding.py +154 -0
  264. vllm/model_executor/guided_decoding/outlines_logits_processors.py +271 -0
  265. vllm/model_executor/guided_decoding/reasoner/__init__.py +35 -0
  266. vllm/model_executor/guided_decoding/utils.py +241 -0
  267. vllm/model_executor/guided_decoding/xgrammar_decoding.py +425 -0
  268. vllm/model_executor/layers/__init__.py +0 -0
  269. vllm/model_executor/layers/activation.py +368 -0
  270. vllm/model_executor/layers/fused_moe/__init__.py +51 -0
  271. vllm/model_executor/layers/fused_moe/configs/E=1,N=14336,device_name=NVIDIA_A100-SXM4-80GB,dtype=int8_w8a16.json +146 -0
  272. vllm/model_executor/layers/fused_moe/configs/E=1,N=14336,device_name=NVIDIA_A100-SXM4-80GB.json +146 -0
  273. vllm/model_executor/layers/fused_moe/configs/E=1,N=1792,device_name=NVIDIA_A100-SXM4-80GB,dtype=int8_w8a16.json +218 -0
  274. vllm/model_executor/layers/fused_moe/configs/E=1,N=1792,device_name=NVIDIA_A100-SXM4-80GB.json +218 -0
  275. vllm/model_executor/layers/fused_moe/configs/E=1,N=3072,device_name=NVIDIA_A100-SXM4-80GB,dtype=int8_w8a16.json +218 -0
  276. vllm/model_executor/layers/fused_moe/configs/E=1,N=3072,device_name=NVIDIA_H100_80GB_HBM3,dtype=int8_w8a16.json +218 -0
  277. vllm/model_executor/layers/fused_moe/configs/E=1,N=3072,device_name=NVIDIA_H100_80GB_HBM3.json +218 -0
  278. vllm/model_executor/layers/fused_moe/configs/E=1,N=3584,device_name=NVIDIA_A100-SXM4-80GB,dtype=int8_w8a16.json +218 -0
  279. vllm/model_executor/layers/fused_moe/configs/E=1,N=3584,device_name=NVIDIA_A100-SXM4-80GB.json +218 -0
  280. vllm/model_executor/layers/fused_moe/configs/E=1,N=7168,device_name=NVIDIA_A100-SXM4-80GB,dtype=int8_w8a16.json +218 -0
  281. vllm/model_executor/layers/fused_moe/configs/E=1,N=7168,device_name=NVIDIA_A100-SXM4-80GB.json +218 -0
  282. vllm/model_executor/layers/fused_moe/configs/E=128,N=1024,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8.json +164 -0
  283. vllm/model_executor/layers/fused_moe/configs/E=128,N=192,device_name=NVIDIA_H100_80GB_HBM3.json +146 -0
  284. vllm/model_executor/layers/fused_moe/configs/E=128,N=192,device_name=NVIDIA_H20.json +146 -0
  285. vllm/model_executor/layers/fused_moe/configs/E=128,N=192,device_name=NVIDIA_H200.json +146 -0
  286. 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
  287. vllm/model_executor/layers/fused_moe/configs/E=128,N=384,device_name=NVIDIA_H20.json +146 -0
  288. 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
  289. vllm/model_executor/layers/fused_moe/configs/E=128,N=384,device_name=NVIDIA_H200.json +146 -0
  290. vllm/model_executor/layers/fused_moe/configs/E=128,N=512,device_name=NVIDIA_H100_80GB_HBM3.json +146 -0
  291. 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
  292. vllm/model_executor/layers/fused_moe/configs/E=128,N=768,device_name=NVIDIA_H20.json +146 -0
  293. 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
  294. vllm/model_executor/layers/fused_moe/configs/E=128,N=768,device_name=NVIDIA_H200.json +146 -0
  295. vllm/model_executor/layers/fused_moe/configs/E=128,N=96,device_name=NVIDIA_H20.json +146 -0
  296. vllm/model_executor/layers/fused_moe/configs/E=16,N=1024,device_name=AMD_Instinct_MI300X.json +200 -0
  297. vllm/model_executor/layers/fused_moe/configs/E=16,N=1024,device_name=NVIDIA_H100.json +146 -0
  298. vllm/model_executor/layers/fused_moe/configs/E=16,N=1344,device_name=NVIDIA_A100-SXM4-40GB.json +146 -0
  299. vllm/model_executor/layers/fused_moe/configs/E=16,N=1344,device_name=NVIDIA_A100-SXM4-80GB.json +146 -0
  300. vllm/model_executor/layers/fused_moe/configs/E=16,N=1344,device_name=NVIDIA_H100_80GB_HBM3.json +146 -0
  301. vllm/model_executor/layers/fused_moe/configs/E=16,N=14336,device_name=NVIDIA_A100-SXM4-80GB,dtype=int8_w8a16.json +146 -0
  302. vllm/model_executor/layers/fused_moe/configs/E=16,N=14336,device_name=NVIDIA_A100-SXM4-80GB.json +146 -0
  303. vllm/model_executor/layers/fused_moe/configs/E=16,N=1792,device_name=NVIDIA_A100-SXM4-80GB,dtype=int8_w8a16.json +218 -0
  304. vllm/model_executor/layers/fused_moe/configs/E=16,N=1792,device_name=NVIDIA_A100-SXM4-80GB.json +218 -0
  305. vllm/model_executor/layers/fused_moe/configs/E=16,N=2688,device_name=NVIDIA_A100-SXM4-80GB.json +146 -0
  306. vllm/model_executor/layers/fused_moe/configs/E=16,N=2688,device_name=NVIDIA_H100_80GB_HBM3.json +146 -0
  307. vllm/model_executor/layers/fused_moe/configs/E=16,N=3072,device_name=NVIDIA_A100-SXM4-80GB,dtype=int8_w8a16.json +146 -0
  308. vllm/model_executor/layers/fused_moe/configs/E=16,N=3072,device_name=NVIDIA_H100_80GB_HBM3,dtype=int8_w8a16.json +146 -0
  309. vllm/model_executor/layers/fused_moe/configs/E=16,N=3200,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8.json +130 -0
  310. vllm/model_executor/layers/fused_moe/configs/E=16,N=3584,device_name=NVIDIA_A100-SXM4-80GB,dtype=int8_w8a16.json +146 -0
  311. vllm/model_executor/layers/fused_moe/configs/E=16,N=3584,device_name=NVIDIA_A100-SXM4-80GB.json +218 -0
  312. vllm/model_executor/layers/fused_moe/configs/E=16,N=6400,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8.json +130 -0
  313. vllm/model_executor/layers/fused_moe/configs/E=16,N=7168,device_name=NVIDIA_A100-SXM4-80GB,dtype=int8_w8a16.json +146 -0
  314. vllm/model_executor/layers/fused_moe/configs/E=16,N=7168,device_name=NVIDIA_A100-SXM4-80GB.json +146 -0
  315. vllm/model_executor/layers/fused_moe/configs/E=16,N=7168,device_name=NVIDIA_H100_80GB_HBM3,dtype=int8_w8a16.json +146 -0
  316. vllm/model_executor/layers/fused_moe/configs/E=16,N=800,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8.json +130 -0
  317. vllm/model_executor/layers/fused_moe/configs/E=160,N=192,device_name=NVIDIA_A800-SXM4-80GB.json +146 -0
  318. vllm/model_executor/layers/fused_moe/configs/E=256,N=1024,device_name=AMD_Instinct_MI325X,block_shape=[128,128].json +200 -0
  319. 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
  320. 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
  321. vllm/model_executor/layers/fused_moe/configs/E=256,N=128,device_name=NVIDIA_A100-SXM4-80GB,dtype=int8_w8a8.json +146 -0
  322. 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
  323. vllm/model_executor/layers/fused_moe/configs/E=256,N=128,device_name=NVIDIA_A800-SXM4-80GB,dtype=int8_w8a8.json +146 -0
  324. 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
  325. 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
  326. 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
  327. 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
  328. 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
  329. 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
  330. 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
  331. 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
  332. 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
  333. 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
  334. 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
  335. vllm/model_executor/layers/fused_moe/configs/E=256,N=64,device_name=NVIDIA_A800-SXM4-80GB.json +146 -0
  336. vllm/model_executor/layers/fused_moe/configs/E=60,N=1408,device_name=AMD_Instinct_MI300X.json +200 -0
  337. vllm/model_executor/layers/fused_moe/configs/E=60,N=176,device_name=AMD_Instinct_MI300X.json +200 -0
  338. vllm/model_executor/layers/fused_moe/configs/E=60,N=352,device_name=AMD_Instinct_MI300X.json +200 -0
  339. vllm/model_executor/layers/fused_moe/configs/E=60,N=704,device_name=AMD_Instinct_MI300X.json +200 -0
  340. vllm/model_executor/layers/fused_moe/configs/E=64,N=1280,device_name=NVIDIA_A100-SXM4-80GB.json +146 -0
  341. vllm/model_executor/layers/fused_moe/configs/E=64,N=1280,device_name=NVIDIA_A800-SXM4-80GB.json +146 -0
  342. vllm/model_executor/layers/fused_moe/configs/E=64,N=1280,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8.json +146 -0
  343. vllm/model_executor/layers/fused_moe/configs/E=64,N=1280,device_name=NVIDIA_H100_80GB_HBM3.json +146 -0
  344. vllm/model_executor/layers/fused_moe/configs/E=64,N=1280,device_name=NVIDIA_H200,dtype=fp8_w8a8.json +146 -0
  345. vllm/model_executor/layers/fused_moe/configs/E=64,N=1280,device_name=NVIDIA_H200.json +146 -0
  346. vllm/model_executor/layers/fused_moe/configs/E=64,N=2560,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8.json +146 -0
  347. vllm/model_executor/layers/fused_moe/configs/E=64,N=2560,device_name=NVIDIA_H200,dtype=fp8_w8a8.json +146 -0
  348. vllm/model_executor/layers/fused_moe/configs/E=64,N=2560,device_name=NVIDIA_H200.json +146 -0
  349. vllm/model_executor/layers/fused_moe/configs/E=64,N=320,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8.json +146 -0
  350. vllm/model_executor/layers/fused_moe/configs/E=64,N=320,device_name=NVIDIA_H100_80GB_HBM3.json +146 -0
  351. vllm/model_executor/layers/fused_moe/configs/E=64,N=320,device_name=NVIDIA_H200,dtype=fp8_w8a8.json +146 -0
  352. vllm/model_executor/layers/fused_moe/configs/E=64,N=320,device_name=NVIDIA_H200.json +146 -0
  353. vllm/model_executor/layers/fused_moe/configs/E=64,N=640,device_name=NVIDIA_A100-SXM4-80GB.json +146 -0
  354. vllm/model_executor/layers/fused_moe/configs/E=64,N=640,device_name=NVIDIA_A800-SXM4-80GB.json +146 -0
  355. vllm/model_executor/layers/fused_moe/configs/E=64,N=640,device_name=NVIDIA_GeForce_RTX_4090,dtype=fp8_w8a8.json +146 -0
  356. vllm/model_executor/layers/fused_moe/configs/E=64,N=640,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8.json +146 -0
  357. vllm/model_executor/layers/fused_moe/configs/E=64,N=640,device_name=NVIDIA_H100_80GB_HBM3.json +146 -0
  358. vllm/model_executor/layers/fused_moe/configs/E=64,N=640,device_name=NVIDIA_H200,dtype=fp8_w8a8.json +146 -0
  359. vllm/model_executor/layers/fused_moe/configs/E=64,N=640,device_name=NVIDIA_H200.json +146 -0
  360. vllm/model_executor/layers/fused_moe/configs/E=8,N=14336,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8.json +164 -0
  361. vllm/model_executor/layers/fused_moe/configs/E=8,N=14336,device_name=AMD_Instinct_MI300X.json +200 -0
  362. vllm/model_executor/layers/fused_moe/configs/E=8,N=14336,device_name=AMD_Instinct_MI325X,dtype=fp8_w8a8.json +164 -0
  363. vllm/model_executor/layers/fused_moe/configs/E=8,N=14336,device_name=AMD_Instinct_MI325X.json +200 -0
  364. vllm/model_executor/layers/fused_moe/configs/E=8,N=14336,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8.json +138 -0
  365. vllm/model_executor/layers/fused_moe/configs/E=8,N=14336,device_name=NVIDIA_H200,dtype=fp8_w8a8.json +146 -0
  366. vllm/model_executor/layers/fused_moe/configs/E=8,N=14336,device_name=NVIDIA_H200.json +146 -0
  367. vllm/model_executor/layers/fused_moe/configs/E=8,N=16384,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8.json +164 -0
  368. vllm/model_executor/layers/fused_moe/configs/E=8,N=16384,device_name=AMD_Instinct_MI300X.json +200 -0
  369. vllm/model_executor/layers/fused_moe/configs/E=8,N=16384,device_name=AMD_Instinct_MI325X,dtype=fp8_w8a8.json +164 -0
  370. vllm/model_executor/layers/fused_moe/configs/E=8,N=16384,device_name=AMD_Instinct_MI325X.json +200 -0
  371. vllm/model_executor/layers/fused_moe/configs/E=8,N=1792,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8.json +164 -0
  372. vllm/model_executor/layers/fused_moe/configs/E=8,N=1792,device_name=AMD_Instinct_MI300X.json +200 -0
  373. vllm/model_executor/layers/fused_moe/configs/E=8,N=1792,device_name=AMD_Instinct_MI325X,dtype=fp8_w8a8.json +164 -0
  374. vllm/model_executor/layers/fused_moe/configs/E=8,N=1792,device_name=AMD_Instinct_MI325X.json +200 -0
  375. vllm/model_executor/layers/fused_moe/configs/E=8,N=1792,device_name=NVIDIA_A100-SXM4-40GB.json +146 -0
  376. vllm/model_executor/layers/fused_moe/configs/E=8,N=1792,device_name=NVIDIA_A100-SXM4-80GB.json +146 -0
  377. vllm/model_executor/layers/fused_moe/configs/E=8,N=1792,device_name=NVIDIA_H100_80GB_HBM3.json +146 -0
  378. vllm/model_executor/layers/fused_moe/configs/E=8,N=1792,device_name=NVIDIA_H200,dtype=fp8_w8a8.json +146 -0
  379. vllm/model_executor/layers/fused_moe/configs/E=8,N=1792,device_name=NVIDIA_H200.json +146 -0
  380. vllm/model_executor/layers/fused_moe/configs/E=8,N=2048,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8.json +164 -0
  381. vllm/model_executor/layers/fused_moe/configs/E=8,N=2048,device_name=AMD_Instinct_MI300X.json +200 -0
  382. vllm/model_executor/layers/fused_moe/configs/E=8,N=2048,device_name=AMD_Instinct_MI325X,dtype=fp8_w8a8.json +164 -0
  383. vllm/model_executor/layers/fused_moe/configs/E=8,N=2048,device_name=AMD_Instinct_MI325X.json +200 -0
  384. vllm/model_executor/layers/fused_moe/configs/E=8,N=2048,device_name=NVIDIA_A100-SXM4-80GB.json +146 -0
  385. vllm/model_executor/layers/fused_moe/configs/E=8,N=2048,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8.json +146 -0
  386. vllm/model_executor/layers/fused_moe/configs/E=8,N=2048,device_name=NVIDIA_H100_80GB_HBM3.json +146 -0
  387. vllm/model_executor/layers/fused_moe/configs/E=8,N=2048,device_name=NVIDIA_H200,dtype=fp8_w8a8.json +146 -0
  388. vllm/model_executor/layers/fused_moe/configs/E=8,N=2048,device_name=NVIDIA_H200.json +146 -0
  389. vllm/model_executor/layers/fused_moe/configs/E=8,N=3584,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8.json +164 -0
  390. vllm/model_executor/layers/fused_moe/configs/E=8,N=3584,device_name=AMD_Instinct_MI300X.json +200 -0
  391. vllm/model_executor/layers/fused_moe/configs/E=8,N=3584,device_name=AMD_Instinct_MI325X,dtype=fp8_w8a8.json +164 -0
  392. vllm/model_executor/layers/fused_moe/configs/E=8,N=3584,device_name=AMD_Instinct_MI325X.json +200 -0
  393. vllm/model_executor/layers/fused_moe/configs/E=8,N=3584,device_name=NVIDIA_A100-SXM4-40GB.json +146 -0
  394. vllm/model_executor/layers/fused_moe/configs/E=8,N=3584,device_name=NVIDIA_A100-SXM4-80GB.json +146 -0
  395. vllm/model_executor/layers/fused_moe/configs/E=8,N=3584,device_name=NVIDIA_GeForce_RTX_4090,dtype=fp8_w8a8.json +146 -0
  396. vllm/model_executor/layers/fused_moe/configs/E=8,N=3584,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8.json +146 -0
  397. vllm/model_executor/layers/fused_moe/configs/E=8,N=3584,device_name=NVIDIA_H100_80GB_HBM3.json +146 -0
  398. vllm/model_executor/layers/fused_moe/configs/E=8,N=3584,device_name=NVIDIA_H200,dtype=fp8_w8a8.json +146 -0
  399. vllm/model_executor/layers/fused_moe/configs/E=8,N=3584,device_name=NVIDIA_H200.json +146 -0
  400. vllm/model_executor/layers/fused_moe/configs/E=8,N=3584,device_name=NVIDIA_L40S.json +173 -0
  401. vllm/model_executor/layers/fused_moe/configs/E=8,N=4096,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8.json +164 -0
  402. vllm/model_executor/layers/fused_moe/configs/E=8,N=4096,device_name=AMD_Instinct_MI300X.json +200 -0
  403. vllm/model_executor/layers/fused_moe/configs/E=8,N=4096,device_name=AMD_Instinct_MI325X,dtype=fp8_w8a8.json +164 -0
  404. vllm/model_executor/layers/fused_moe/configs/E=8,N=4096,device_name=AMD_Instinct_MI325X.json +200 -0
  405. vllm/model_executor/layers/fused_moe/configs/E=8,N=4096,device_name=NVIDIA_A100-SXM4-80GB.json +146 -0
  406. vllm/model_executor/layers/fused_moe/configs/E=8,N=4096,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8.json +146 -0
  407. vllm/model_executor/layers/fused_moe/configs/E=8,N=4096,device_name=NVIDIA_H100_80GB_HBM3.json +146 -0
  408. vllm/model_executor/layers/fused_moe/configs/E=8,N=4096,device_name=NVIDIA_H200,dtype=fp8_w8a8.json +146 -0
  409. vllm/model_executor/layers/fused_moe/configs/E=8,N=4096,device_name=NVIDIA_H200.json +146 -0
  410. vllm/model_executor/layers/fused_moe/configs/E=8,N=7168,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8.json +164 -0
  411. vllm/model_executor/layers/fused_moe/configs/E=8,N=7168,device_name=AMD_Instinct_MI300X.json +200 -0
  412. vllm/model_executor/layers/fused_moe/configs/E=8,N=7168,device_name=AMD_Instinct_MI325X,dtype=fp8_w8a8.json +164 -0
  413. vllm/model_executor/layers/fused_moe/configs/E=8,N=7168,device_name=AMD_Instinct_MI325X.json +200 -0
  414. vllm/model_executor/layers/fused_moe/configs/E=8,N=7168,device_name=NVIDIA_A100-SXM4-80GB.json +146 -0
  415. vllm/model_executor/layers/fused_moe/configs/E=8,N=7168,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8.json +146 -0
  416. vllm/model_executor/layers/fused_moe/configs/E=8,N=7168,device_name=NVIDIA_H100_80GB_HBM3.json +146 -0
  417. vllm/model_executor/layers/fused_moe/configs/E=8,N=7168,device_name=NVIDIA_H200,dtype=fp8_w8a8.json +146 -0
  418. vllm/model_executor/layers/fused_moe/configs/E=8,N=7168,device_name=NVIDIA_H200.json +146 -0
  419. vllm/model_executor/layers/fused_moe/configs/E=8,N=8192,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8.json +164 -0
  420. vllm/model_executor/layers/fused_moe/configs/E=8,N=8192,device_name=AMD_Instinct_MI300X.json +200 -0
  421. vllm/model_executor/layers/fused_moe/configs/E=8,N=8192,device_name=AMD_Instinct_MI325X,dtype=fp8_w8a8.json +164 -0
  422. vllm/model_executor/layers/fused_moe/configs/E=8,N=8192,device_name=AMD_Instinct_MI325X.json +200 -0
  423. vllm/model_executor/layers/fused_moe/configs/E=8,N=8192,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8.json +146 -0
  424. vllm/model_executor/layers/fused_moe/configs/E=8,N=8192,device_name=NVIDIA_H200,dtype=fp8_w8a8.json +146 -0
  425. vllm/model_executor/layers/fused_moe/configs/README +12 -0
  426. vllm/model_executor/layers/fused_moe/cutlass_moe.py +180 -0
  427. vllm/model_executor/layers/fused_moe/deep_gemm_moe.py +294 -0
  428. vllm/model_executor/layers/fused_moe/fused_marlin_moe.py +374 -0
  429. vllm/model_executor/layers/fused_moe/fused_moe.py +1539 -0
  430. vllm/model_executor/layers/fused_moe/layer.py +949 -0
  431. vllm/model_executor/layers/fused_moe/moe_align_block_size.py +243 -0
  432. vllm/model_executor/layers/fused_moe/moe_pallas.py +64 -0
  433. vllm/model_executor/layers/fused_moe/moe_torch_iterative.py +59 -0
  434. vllm/model_executor/layers/fused_moe/rocm_aiter_fused_moe.py +416 -0
  435. vllm/model_executor/layers/fused_moe/utils.py +48 -0
  436. vllm/model_executor/layers/layernorm.py +277 -0
  437. vllm/model_executor/layers/lightning_attn.py +651 -0
  438. vllm/model_executor/layers/linear.py +1518 -0
  439. vllm/model_executor/layers/logits_processor.py +196 -0
  440. vllm/model_executor/layers/mamba/__init__.py +0 -0
  441. vllm/model_executor/layers/mamba/mamba2_metadata.py +109 -0
  442. vllm/model_executor/layers/mamba/mamba_mixer.py +244 -0
  443. vllm/model_executor/layers/mamba/mamba_mixer2.py +538 -0
  444. vllm/model_executor/layers/mamba/ops/__init__.py +0 -0
  445. vllm/model_executor/layers/mamba/ops/causal_conv1d.py +104 -0
  446. vllm/model_executor/layers/mamba/ops/mamba_ssm.py +415 -0
  447. vllm/model_executor/layers/mamba/ops/ssd_bmm.py +261 -0
  448. vllm/model_executor/layers/mamba/ops/ssd_chunk_scan.py +588 -0
  449. vllm/model_executor/layers/mamba/ops/ssd_chunk_state.py +750 -0
  450. vllm/model_executor/layers/mamba/ops/ssd_combined.py +231 -0
  451. vllm/model_executor/layers/mamba/ops/ssd_state_passing.py +205 -0
  452. vllm/model_executor/layers/pooler.py +336 -0
  453. vllm/model_executor/layers/quantization/__init__.py +153 -0
  454. vllm/model_executor/layers/quantization/aqlm.py +374 -0
  455. vllm/model_executor/layers/quantization/awq.py +184 -0
  456. vllm/model_executor/layers/quantization/awq_marlin.py +518 -0
  457. vllm/model_executor/layers/quantization/awq_triton.py +319 -0
  458. vllm/model_executor/layers/quantization/base_config.py +145 -0
  459. vllm/model_executor/layers/quantization/bitblas.py +459 -0
  460. vllm/model_executor/layers/quantization/bitsandbytes.py +396 -0
  461. vllm/model_executor/layers/quantization/compressed_tensors/__init__.py +0 -0
  462. vllm/model_executor/layers/quantization/compressed_tensors/compressed_tensors.py +624 -0
  463. vllm/model_executor/layers/quantization/compressed_tensors/compressed_tensors_moe.py +1100 -0
  464. vllm/model_executor/layers/quantization/compressed_tensors/schemes/__init__.py +20 -0
  465. vllm/model_executor/layers/quantization/compressed_tensors/schemes/compressed_tensors_24.py +357 -0
  466. vllm/model_executor/layers/quantization/compressed_tensors/schemes/compressed_tensors_scheme.py +54 -0
  467. vllm/model_executor/layers/quantization/compressed_tensors/schemes/compressed_tensors_w4a16_24.py +159 -0
  468. vllm/model_executor/layers/quantization/compressed_tensors/schemes/compressed_tensors_w8a16_fp8.py +119 -0
  469. vllm/model_executor/layers/quantization/compressed_tensors/schemes/compressed_tensors_w8a8_fp8.py +149 -0
  470. vllm/model_executor/layers/quantization/compressed_tensors/schemes/compressed_tensors_w8a8_int8.py +110 -0
  471. vllm/model_executor/layers/quantization/compressed_tensors/schemes/compressed_tensors_wNa16.py +200 -0
  472. vllm/model_executor/layers/quantization/compressed_tensors/triton_scaled_mm.py +205 -0
  473. vllm/model_executor/layers/quantization/compressed_tensors/utils.py +213 -0
  474. vllm/model_executor/layers/quantization/deepspeedfp.py +193 -0
  475. vllm/model_executor/layers/quantization/experts_int8.py +194 -0
  476. vllm/model_executor/layers/quantization/fbgemm_fp8.py +168 -0
  477. vllm/model_executor/layers/quantization/fp8.py +832 -0
  478. vllm/model_executor/layers/quantization/gguf.py +408 -0
  479. vllm/model_executor/layers/quantization/gptq.py +276 -0
  480. vllm/model_executor/layers/quantization/gptq_bitblas.py +438 -0
  481. vllm/model_executor/layers/quantization/gptq_marlin.py +643 -0
  482. vllm/model_executor/layers/quantization/gptq_marlin_24.py +295 -0
  483. vllm/model_executor/layers/quantization/hqq_marlin.py +328 -0
  484. vllm/model_executor/layers/quantization/ipex_quant.py +250 -0
  485. vllm/model_executor/layers/quantization/kernels/__init__.py +0 -0
  486. vllm/model_executor/layers/quantization/kernels/mixed_precision/MPLinearKernel.py +89 -0
  487. vllm/model_executor/layers/quantization/kernels/mixed_precision/__init__.py +82 -0
  488. vllm/model_executor/layers/quantization/kernels/mixed_precision/allspark.py +115 -0
  489. vllm/model_executor/layers/quantization/kernels/mixed_precision/bitblas.py +299 -0
  490. vllm/model_executor/layers/quantization/kernels/mixed_precision/exllama.py +142 -0
  491. vllm/model_executor/layers/quantization/kernels/mixed_precision/machete.py +119 -0
  492. vllm/model_executor/layers/quantization/kernels/mixed_precision/marlin.py +132 -0
  493. vllm/model_executor/layers/quantization/kernels/scaled_mm/ScaledMMLinearKernel.py +66 -0
  494. vllm/model_executor/layers/quantization/kernels/scaled_mm/__init__.py +86 -0
  495. vllm/model_executor/layers/quantization/kernels/scaled_mm/aiter.py +119 -0
  496. vllm/model_executor/layers/quantization/kernels/scaled_mm/cutlass.py +136 -0
  497. vllm/model_executor/layers/quantization/kernels/scaled_mm/triton.py +40 -0
  498. vllm/model_executor/layers/quantization/kernels/scaled_mm/xla.py +104 -0
  499. vllm/model_executor/layers/quantization/kv_cache.py +137 -0
  500. vllm/model_executor/layers/quantization/marlin.py +259 -0
  501. vllm/model_executor/layers/quantization/modelopt.py +410 -0
  502. vllm/model_executor/layers/quantization/moe_wna16.py +447 -0
  503. vllm/model_executor/layers/quantization/neuron_quant.py +67 -0
  504. vllm/model_executor/layers/quantization/ptpc_fp8.py +125 -0
  505. vllm/model_executor/layers/quantization/qqq.py +273 -0
  506. vllm/model_executor/layers/quantization/quark/__init__.py +0 -0
  507. vllm/model_executor/layers/quantization/quark/quark.py +385 -0
  508. vllm/model_executor/layers/quantization/quark/quark_moe.py +236 -0
  509. vllm/model_executor/layers/quantization/quark/schemes/__init__.py +7 -0
  510. vllm/model_executor/layers/quantization/quark/schemes/quark_scheme.py +54 -0
  511. vllm/model_executor/layers/quantization/quark/schemes/quark_w8a8_fp8.py +142 -0
  512. vllm/model_executor/layers/quantization/quark/schemes/quark_w8a8_int8.py +121 -0
  513. vllm/model_executor/layers/quantization/quark/utils.py +102 -0
  514. vllm/model_executor/layers/quantization/schema.py +85 -0
  515. vllm/model_executor/layers/quantization/torchao.py +127 -0
  516. vllm/model_executor/layers/quantization/tpu_int8.py +119 -0
  517. vllm/model_executor/layers/quantization/utils/__init__.py +5 -0
  518. vllm/model_executor/layers/quantization/utils/allspark_utils.py +51 -0
  519. vllm/model_executor/layers/quantization/utils/bitblas_utils.py +198 -0
  520. 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
  521. 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
  522. 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
  523. 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
  524. 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
  525. 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
  526. 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
  527. 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
  528. 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
  529. 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
  530. 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
  531. 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
  532. 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
  533. 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
  534. 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
  535. 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
  536. 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
  537. 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
  538. 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
  539. 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
  540. 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
  541. 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
  542. 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
  543. 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
  544. 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
  545. 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
  546. 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
  547. 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
  548. 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
  549. 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
  550. 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
  551. 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
  552. 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
  553. 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
  554. 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
  555. 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
  556. 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
  557. 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
  558. 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
  559. 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
  560. 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
  561. 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
  562. 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
  563. 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
  564. 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
  565. 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
  566. 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
  567. 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
  568. 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
  569. 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
  570. 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
  571. 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
  572. 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
  573. 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
  574. 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
  575. 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
  576. 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
  577. 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
  578. 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
  579. 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
  580. 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
  581. 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
  582. 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
  583. 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
  584. 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
  585. 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
  586. 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
  587. 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
  588. 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
  589. 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
  590. 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
  591. 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
  592. 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
  593. 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
  594. 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
  595. 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
  596. 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
  597. 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
  598. 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
  599. 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
  600. 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
  601. 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
  602. 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
  603. 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
  604. 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
  605. 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
  606. 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
  607. 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
  608. 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
  609. 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
  610. 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
  611. 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
  612. 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
  613. 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
  614. 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
  615. 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
  616. 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
  617. 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
  618. 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
  619. 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
  620. 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
  621. 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
  622. 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
  623. 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
  624. 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
  625. 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
  626. 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
  627. 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
  628. 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
  629. 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
  630. 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
  631. 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
  632. 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
  633. 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
  634. 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
  635. 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
  636. 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
  637. 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
  638. 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
  639. 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
  640. 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
  641. 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
  642. 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
  643. 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
  644. 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
  645. 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
  646. 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
  647. 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
  648. 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
  649. 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
  650. 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
  651. 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
  652. 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
  653. 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
  654. 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
  655. 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
  656. 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
  657. 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
  658. 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
  659. 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
  660. 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
  661. 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
  662. 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
  663. 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
  664. 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
  665. 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
  666. 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
  667. 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
  668. 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
  669. 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
  670. 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
  671. 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
  672. 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
  673. 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
  674. 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
  675. 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
  676. 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
  677. 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
  678. 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
  679. 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
  680. 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
  681. 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
  682. 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
  683. 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
  684. 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
  685. 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
  686. 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
  687. 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
  688. 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
  689. 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
  690. 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
  691. 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
  692. 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
  693. 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
  694. 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
  695. 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
  696. 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
  697. 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
  698. 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
  699. 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
  700. 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
  701. 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
  702. 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
  703. 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
  704. 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
  705. 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
  706. 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
  707. 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
  708. 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
  709. 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
  710. 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
  711. 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
  712. 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
  713. 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
  714. 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
  715. 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
  716. 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
  717. 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
  718. 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
  719. 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
  720. 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
  721. 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
  722. vllm/model_executor/layers/quantization/utils/fp8_utils.py +523 -0
  723. vllm/model_executor/layers/quantization/utils/gptq_utils.py +94 -0
  724. vllm/model_executor/layers/quantization/utils/int8_utils.py +459 -0
  725. vllm/model_executor/layers/quantization/utils/layer_utils.py +39 -0
  726. vllm/model_executor/layers/quantization/utils/machete_utils.py +32 -0
  727. vllm/model_executor/layers/quantization/utils/marlin_utils.py +413 -0
  728. vllm/model_executor/layers/quantization/utils/marlin_utils_fp8.py +110 -0
  729. vllm/model_executor/layers/quantization/utils/marlin_utils_test.py +164 -0
  730. vllm/model_executor/layers/quantization/utils/marlin_utils_test_24.py +464 -0
  731. vllm/model_executor/layers/quantization/utils/marlin_utils_test_qqq.py +127 -0
  732. vllm/model_executor/layers/quantization/utils/quant_utils.py +571 -0
  733. vllm/model_executor/layers/quantization/utils/w8a8_utils.py +404 -0
  734. vllm/model_executor/layers/rejection_sampler.py +400 -0
  735. vllm/model_executor/layers/resampler.py +269 -0
  736. vllm/model_executor/layers/rotary_embedding.py +1598 -0
  737. vllm/model_executor/layers/sampler.py +1221 -0
  738. vllm/model_executor/layers/spec_decode_base_sampler.py +258 -0
  739. vllm/model_executor/layers/typical_acceptance_sampler.py +172 -0
  740. vllm/model_executor/layers/utils.py +99 -0
  741. vllm/model_executor/layers/vocab_parallel_embedding.py +485 -0
  742. vllm/model_executor/model_loader/__init__.py +20 -0
  743. vllm/model_executor/model_loader/loader.py +1542 -0
  744. vllm/model_executor/model_loader/neuron.py +243 -0
  745. vllm/model_executor/model_loader/tensorizer.py +468 -0
  746. vllm/model_executor/model_loader/utils.py +171 -0
  747. vllm/model_executor/model_loader/weight_utils.py +749 -0
  748. vllm/model_executor/models/__init__.py +27 -0
  749. vllm/model_executor/models/adapters.py +247 -0
  750. vllm/model_executor/models/arctic.py +559 -0
  751. vllm/model_executor/models/aria.py +656 -0
  752. vllm/model_executor/models/aya_vision.py +461 -0
  753. vllm/model_executor/models/baichuan.py +469 -0
  754. vllm/model_executor/models/bamba.py +542 -0
  755. vllm/model_executor/models/bart.py +936 -0
  756. vllm/model_executor/models/bert.py +725 -0
  757. vllm/model_executor/models/blip.py +337 -0
  758. vllm/model_executor/models/blip2.py +717 -0
  759. vllm/model_executor/models/bloom.py +358 -0
  760. vllm/model_executor/models/chameleon.py +1135 -0
  761. vllm/model_executor/models/chatglm.py +476 -0
  762. vllm/model_executor/models/clip.py +410 -0
  763. vllm/model_executor/models/commandr.py +466 -0
  764. vllm/model_executor/models/constant_size_cache.py +136 -0
  765. vllm/model_executor/models/dbrx.py +469 -0
  766. vllm/model_executor/models/deepseek.py +484 -0
  767. vllm/model_executor/models/deepseek_mtp.py +266 -0
  768. vllm/model_executor/models/deepseek_v2.py +830 -0
  769. vllm/model_executor/models/deepseek_vl2.py +647 -0
  770. vllm/model_executor/models/eagle.py +247 -0
  771. vllm/model_executor/models/exaone.py +548 -0
  772. vllm/model_executor/models/fairseq2_llama.py +153 -0
  773. vllm/model_executor/models/falcon.py +508 -0
  774. vllm/model_executor/models/florence2.py +1102 -0
  775. vllm/model_executor/models/fuyu.py +388 -0
  776. vllm/model_executor/models/gemma.py +423 -0
  777. vllm/model_executor/models/gemma2.py +423 -0
  778. vllm/model_executor/models/gemma3.py +531 -0
  779. vllm/model_executor/models/gemma3_mm.py +716 -0
  780. vllm/model_executor/models/glm.py +22 -0
  781. vllm/model_executor/models/glm4.py +303 -0
  782. vllm/model_executor/models/glm4v.py +647 -0
  783. vllm/model_executor/models/gpt2.py +313 -0
  784. vllm/model_executor/models/gpt_bigcode.py +336 -0
  785. vllm/model_executor/models/gpt_j.py +337 -0
  786. vllm/model_executor/models/gpt_neox.py +330 -0
  787. vllm/model_executor/models/granite.py +494 -0
  788. vllm/model_executor/models/granite_speech.py +777 -0
  789. vllm/model_executor/models/granitemoe.py +435 -0
  790. vllm/model_executor/models/granitemoeshared.py +339 -0
  791. vllm/model_executor/models/gritlm.py +245 -0
  792. vllm/model_executor/models/grok1.py +560 -0
  793. vllm/model_executor/models/h2ovl.py +542 -0
  794. vllm/model_executor/models/idefics2_vision_model.py +387 -0
  795. vllm/model_executor/models/idefics3.py +767 -0
  796. vllm/model_executor/models/interfaces.py +569 -0
  797. vllm/model_executor/models/interfaces_base.py +163 -0
  798. vllm/model_executor/models/intern_vit.py +476 -0
  799. vllm/model_executor/models/internlm2.py +453 -0
  800. vllm/model_executor/models/internlm2_ve.py +146 -0
  801. vllm/model_executor/models/internvl.py +945 -0
  802. vllm/model_executor/models/jais.py +371 -0
  803. vllm/model_executor/models/jamba.py +590 -0
  804. vllm/model_executor/models/kimi_vl.py +577 -0
  805. vllm/model_executor/models/llama.py +619 -0
  806. vllm/model_executor/models/llama4.py +530 -0
  807. vllm/model_executor/models/llama_eagle.py +152 -0
  808. vllm/model_executor/models/llama_eagle3.py +232 -0
  809. vllm/model_executor/models/llava.py +869 -0
  810. vllm/model_executor/models/llava_next.py +582 -0
  811. vllm/model_executor/models/llava_next_video.py +470 -0
  812. vllm/model_executor/models/llava_onevision.py +954 -0
  813. vllm/model_executor/models/mamba.py +271 -0
  814. vllm/model_executor/models/mamba2.py +302 -0
  815. vllm/model_executor/models/mamba_cache.py +76 -0
  816. vllm/model_executor/models/medusa.py +210 -0
  817. vllm/model_executor/models/minicpm.py +592 -0
  818. vllm/model_executor/models/minicpm3.py +229 -0
  819. vllm/model_executor/models/minicpmo.py +725 -0
  820. vllm/model_executor/models/minicpmv.py +1287 -0
  821. vllm/model_executor/models/minimax_cache.py +35 -0
  822. vllm/model_executor/models/minimax_text_01.py +1261 -0
  823. vllm/model_executor/models/mistral3.py +598 -0
  824. vllm/model_executor/models/mixtral.py +485 -0
  825. vllm/model_executor/models/mixtral_quant.py +447 -0
  826. vllm/model_executor/models/mllama.py +1623 -0
  827. vllm/model_executor/models/mllama4.py +838 -0
  828. vllm/model_executor/models/mlp_speculator.py +205 -0
  829. vllm/model_executor/models/modernbert.py +325 -0
  830. vllm/model_executor/models/module_mapping.py +71 -0
  831. vllm/model_executor/models/molmo.py +1567 -0
  832. vllm/model_executor/models/moonvit.py +628 -0
  833. vllm/model_executor/models/mpt.py +329 -0
  834. vllm/model_executor/models/nemotron.py +506 -0
  835. vllm/model_executor/models/nemotron_nas.py +446 -0
  836. vllm/model_executor/models/nvlm_d.py +212 -0
  837. vllm/model_executor/models/olmo.py +390 -0
  838. vllm/model_executor/models/olmo2.py +412 -0
  839. vllm/model_executor/models/olmoe.py +449 -0
  840. vllm/model_executor/models/opt.py +410 -0
  841. vllm/model_executor/models/orion.py +356 -0
  842. vllm/model_executor/models/paligemma.py +397 -0
  843. vllm/model_executor/models/persimmon.py +342 -0
  844. vllm/model_executor/models/phi.py +354 -0
  845. vllm/model_executor/models/phi3.py +18 -0
  846. vllm/model_executor/models/phi3_small.py +463 -0
  847. vllm/model_executor/models/phi3v.py +722 -0
  848. vllm/model_executor/models/phi4mm.py +1263 -0
  849. vllm/model_executor/models/phi4mm_audio.py +1232 -0
  850. vllm/model_executor/models/phi4mm_utils.py +1883 -0
  851. vllm/model_executor/models/phimoe.py +666 -0
  852. vllm/model_executor/models/pixtral.py +1281 -0
  853. vllm/model_executor/models/plamo2.py +736 -0
  854. vllm/model_executor/models/prithvi_geospatial_mae.py +231 -0
  855. vllm/model_executor/models/qwen.py +360 -0
  856. vllm/model_executor/models/qwen2.py +552 -0
  857. vllm/model_executor/models/qwen2_5_omni_thinker.py +901 -0
  858. vllm/model_executor/models/qwen2_5_vl.py +1136 -0
  859. vllm/model_executor/models/qwen2_audio.py +402 -0
  860. vllm/model_executor/models/qwen2_moe.py +531 -0
  861. vllm/model_executor/models/qwen2_rm.py +130 -0
  862. vllm/model_executor/models/qwen2_vl.py +1409 -0
  863. vllm/model_executor/models/qwen3.py +319 -0
  864. vllm/model_executor/models/qwen3_moe.py +528 -0
  865. vllm/model_executor/models/qwen_vl.py +784 -0
  866. vllm/model_executor/models/registry.py +611 -0
  867. vllm/model_executor/models/roberta.py +332 -0
  868. vllm/model_executor/models/siglip.py +522 -0
  869. vllm/model_executor/models/skyworkr1v.py +949 -0
  870. vllm/model_executor/models/smolvlm.py +51 -0
  871. vllm/model_executor/models/solar.py +504 -0
  872. vllm/model_executor/models/stablelm.py +349 -0
  873. vllm/model_executor/models/starcoder2.py +355 -0
  874. vllm/model_executor/models/telechat2.py +139 -0
  875. vllm/model_executor/models/teleflm.py +78 -0
  876. vllm/model_executor/models/transformers.py +442 -0
  877. vllm/model_executor/models/ultravox.py +655 -0
  878. vllm/model_executor/models/utils.py +714 -0
  879. vllm/model_executor/models/vision.py +149 -0
  880. vllm/model_executor/models/whisper.py +746 -0
  881. vllm/model_executor/models/zamba2.py +1008 -0
  882. vllm/model_executor/parameter.py +458 -0
  883. vllm/model_executor/pooling_metadata.py +71 -0
  884. vllm/model_executor/sampling_metadata.py +596 -0
  885. vllm/model_executor/utils.py +53 -0
  886. vllm/multimodal/__init__.py +31 -0
  887. vllm/multimodal/audio.py +105 -0
  888. vllm/multimodal/base.py +218 -0
  889. vllm/multimodal/hasher.py +103 -0
  890. vllm/multimodal/image.py +77 -0
  891. vllm/multimodal/inputs.py +843 -0
  892. vllm/multimodal/parse.py +454 -0
  893. vllm/multimodal/processing.py +1760 -0
  894. vllm/multimodal/profiling.py +274 -0
  895. vllm/multimodal/registry.py +321 -0
  896. vllm/multimodal/utils.py +386 -0
  897. vllm/multimodal/video.py +166 -0
  898. vllm/outputs.py +521 -0
  899. vllm/platforms/__init__.py +286 -0
  900. vllm/platforms/cpu.py +182 -0
  901. vllm/platforms/cuda.py +463 -0
  902. vllm/platforms/hpu.py +94 -0
  903. vllm/platforms/interface.py +427 -0
  904. vllm/platforms/neuron.py +69 -0
  905. vllm/platforms/rocm.py +346 -0
  906. vllm/platforms/tpu.py +174 -0
  907. vllm/platforms/xpu.py +142 -0
  908. vllm/plugins/__init__.py +82 -0
  909. vllm/pooling_params.py +53 -0
  910. vllm/profiler/__init__.py +7 -0
  911. vllm/profiler/layerwise_profile.py +374 -0
  912. vllm/profiler/utils.py +147 -0
  913. vllm/prompt_adapter/__init__.py +0 -0
  914. vllm/prompt_adapter/layers.py +82 -0
  915. vllm/prompt_adapter/models.py +357 -0
  916. vllm/prompt_adapter/request.py +36 -0
  917. vllm/prompt_adapter/utils.py +97 -0
  918. vllm/prompt_adapter/worker_manager.py +178 -0
  919. vllm/py.typed +2 -0
  920. vllm/reasoning/__init__.py +12 -0
  921. vllm/reasoning/abs_reasoning_parsers.py +189 -0
  922. vllm/reasoning/deepseek_r1_reasoning_parser.py +172 -0
  923. vllm/reasoning/granite_reasoning_parser.py +362 -0
  924. vllm/sampling_params.py +598 -0
  925. vllm/scalar_type.py +335 -0
  926. vllm/scripts.py +14 -0
  927. vllm/sequence.py +1486 -0
  928. vllm/spec_decode/__init__.py +0 -0
  929. vllm/spec_decode/batch_expansion.py +505 -0
  930. vllm/spec_decode/draft_model_runner.py +335 -0
  931. vllm/spec_decode/interfaces.py +98 -0
  932. vllm/spec_decode/medusa_worker.py +137 -0
  933. vllm/spec_decode/metrics.py +212 -0
  934. vllm/spec_decode/mlp_speculator_worker.py +93 -0
  935. vllm/spec_decode/mqa_scorer.py +159 -0
  936. vllm/spec_decode/multi_step_worker.py +416 -0
  937. vllm/spec_decode/ngram_worker.py +195 -0
  938. vllm/spec_decode/proposer_worker_base.py +58 -0
  939. vllm/spec_decode/smaller_tp_proposer_worker.py +194 -0
  940. vllm/spec_decode/spec_decode_worker.py +1324 -0
  941. vllm/spec_decode/target_model_runner.py +44 -0
  942. vllm/spec_decode/top1_proposer.py +274 -0
  943. vllm/spec_decode/util.py +276 -0
  944. vllm/test_utils.py +129 -0
  945. vllm/third_party/__init__.py +0 -0
  946. vllm/third_party/pynvml.py +6139 -0
  947. vllm/tracing.py +130 -0
  948. vllm/transformers_utils/__init__.py +19 -0
  949. vllm/transformers_utils/config.py +813 -0
  950. vllm/transformers_utils/configs/__init__.py +52 -0
  951. vllm/transformers_utils/configs/arctic.py +206 -0
  952. vllm/transformers_utils/configs/chatglm.py +71 -0
  953. vllm/transformers_utils/configs/cohere2.py +194 -0
  954. vllm/transformers_utils/configs/dbrx.py +280 -0
  955. vllm/transformers_utils/configs/deepseek_vl2.py +216 -0
  956. vllm/transformers_utils/configs/eagle.py +65 -0
  957. vllm/transformers_utils/configs/exaone.py +191 -0
  958. vllm/transformers_utils/configs/falcon.py +89 -0
  959. vllm/transformers_utils/configs/h2ovl.py +15 -0
  960. vllm/transformers_utils/configs/internvl.py +53 -0
  961. vllm/transformers_utils/configs/jais.py +237 -0
  962. vllm/transformers_utils/configs/kimi_vl.py +36 -0
  963. vllm/transformers_utils/configs/medusa.py +62 -0
  964. vllm/transformers_utils/configs/mllama.py +30 -0
  965. vllm/transformers_utils/configs/mlp_speculator.py +67 -0
  966. vllm/transformers_utils/configs/moonvit.py +32 -0
  967. vllm/transformers_utils/configs/mpt.py +179 -0
  968. vllm/transformers_utils/configs/nemotron.py +204 -0
  969. vllm/transformers_utils/configs/nvlm_d.py +14 -0
  970. vllm/transformers_utils/configs/skyworkr1v.py +53 -0
  971. vllm/transformers_utils/configs/solar.py +246 -0
  972. vllm/transformers_utils/configs/telechat2.py +63 -0
  973. vllm/transformers_utils/configs/ultravox.py +107 -0
  974. vllm/transformers_utils/detokenizer.py +167 -0
  975. vllm/transformers_utils/detokenizer_utils.py +188 -0
  976. vllm/transformers_utils/processor.py +210 -0
  977. vllm/transformers_utils/processors/__init__.py +6 -0
  978. vllm/transformers_utils/processors/deepseek_vl2.py +363 -0
  979. vllm/transformers_utils/s3_utils.py +161 -0
  980. vllm/transformers_utils/tokenizer.py +291 -0
  981. vllm/transformers_utils/tokenizer_base.py +146 -0
  982. vllm/transformers_utils/tokenizer_group.py +110 -0
  983. vllm/transformers_utils/tokenizers/__init__.py +9 -0
  984. vllm/transformers_utils/tokenizers/mistral.py +483 -0
  985. vllm/transformers_utils/utils.py +98 -0
  986. vllm/triton_utils/__init__.py +5 -0
  987. vllm/triton_utils/importing.py +53 -0
  988. vllm/usage/__init__.py +0 -0
  989. vllm/usage/usage_lib.py +255 -0
  990. vllm/utils.py +2692 -0
  991. vllm/v1/__init__.py +0 -0
  992. vllm/v1/attention/__init__.py +0 -0
  993. vllm/v1/attention/backends/__init__.py +0 -0
  994. vllm/v1/attention/backends/flash_attn.py +783 -0
  995. vllm/v1/attention/backends/flashinfer.py +638 -0
  996. vllm/v1/attention/backends/mla/__init__.py +0 -0
  997. vllm/v1/attention/backends/mla/common.py +974 -0
  998. vllm/v1/attention/backends/mla/flashmla.py +149 -0
  999. vllm/v1/attention/backends/mla/triton_mla.py +118 -0
  1000. vllm/v1/attention/backends/pallas.py +221 -0
  1001. vllm/v1/attention/backends/triton_attn.py +198 -0
  1002. vllm/v1/core/__init__.py +0 -0
  1003. vllm/v1/core/block_pool.py +281 -0
  1004. vllm/v1/core/encoder_cache_manager.py +149 -0
  1005. vllm/v1/core/kv_cache_manager.py +385 -0
  1006. vllm/v1/core/kv_cache_utils.py +744 -0
  1007. vllm/v1/core/sched/__init__.py +0 -0
  1008. vllm/v1/core/sched/interface.py +134 -0
  1009. vllm/v1/core/sched/output.py +126 -0
  1010. vllm/v1/core/sched/scheduler.py +838 -0
  1011. vllm/v1/core/sched/utils.py +22 -0
  1012. vllm/v1/core/specialized_manager.py +161 -0
  1013. vllm/v1/engine/__init__.py +166 -0
  1014. vllm/v1/engine/async_llm.py +532 -0
  1015. vllm/v1/engine/core.py +701 -0
  1016. vllm/v1/engine/core_client.py +942 -0
  1017. vllm/v1/engine/detokenizer.py +260 -0
  1018. vllm/v1/engine/exceptions.py +16 -0
  1019. vllm/v1/engine/llm_engine.py +285 -0
  1020. vllm/v1/engine/logprobs.py +198 -0
  1021. vllm/v1/engine/mm_input_cache.py +82 -0
  1022. vllm/v1/engine/output_processor.py +420 -0
  1023. vllm/v1/engine/parallel_sampling.py +132 -0
  1024. vllm/v1/engine/processor.py +387 -0
  1025. vllm/v1/executor/__init__.py +0 -0
  1026. vllm/v1/executor/abstract.py +112 -0
  1027. vllm/v1/executor/multiproc_executor.py +480 -0
  1028. vllm/v1/executor/ray_distributed_executor.py +61 -0
  1029. vllm/v1/kv_cache_interface.py +166 -0
  1030. vllm/v1/metrics/__init__.py +0 -0
  1031. vllm/v1/metrics/loggers.py +498 -0
  1032. vllm/v1/metrics/stats.py +238 -0
  1033. vllm/v1/outputs.py +111 -0
  1034. vllm/v1/request.py +178 -0
  1035. vllm/v1/sample/__init__.py +0 -0
  1036. vllm/v1/sample/metadata.py +43 -0
  1037. vllm/v1/sample/ops/__init__.py +0 -0
  1038. vllm/v1/sample/ops/bad_words.py +38 -0
  1039. vllm/v1/sample/ops/penalties.py +58 -0
  1040. vllm/v1/sample/ops/topk_topp_sampler.py +315 -0
  1041. vllm/v1/sample/rejection_sampler.py +631 -0
  1042. vllm/v1/sample/sampler.py +270 -0
  1043. vllm/v1/sample/tpu/__init__.py +0 -0
  1044. vllm/v1/sample/tpu/metadata.py +118 -0
  1045. vllm/v1/sample/tpu/sampler.py +154 -0
  1046. vllm/v1/serial_utils.py +274 -0
  1047. vllm/v1/spec_decode/__init__.py +0 -0
  1048. vllm/v1/spec_decode/eagle.py +318 -0
  1049. vllm/v1/spec_decode/metadata.py +61 -0
  1050. vllm/v1/spec_decode/metrics.py +164 -0
  1051. vllm/v1/spec_decode/ngram_proposer.py +131 -0
  1052. vllm/v1/spec_decode/utils.py +18 -0
  1053. vllm/v1/stats/__init__.py +0 -0
  1054. vllm/v1/stats/common.py +453 -0
  1055. vllm/v1/structured_output/__init__.py +113 -0
  1056. vllm/v1/structured_output/backend_guidance.py +215 -0
  1057. vllm/v1/structured_output/backend_types.py +96 -0
  1058. vllm/v1/structured_output/backend_xgrammar.py +299 -0
  1059. vllm/v1/structured_output/request.py +84 -0
  1060. vllm/v1/structured_output/utils.py +174 -0
  1061. vllm/v1/utils.py +249 -0
  1062. vllm/v1/worker/__init__.py +0 -0
  1063. vllm/v1/worker/block_table.py +87 -0
  1064. vllm/v1/worker/gpu_input_batch.py +677 -0
  1065. vllm/v1/worker/gpu_model_runner.py +1776 -0
  1066. vllm/v1/worker/gpu_worker.py +349 -0
  1067. vllm/v1/worker/lora_model_runner_mixin.py +145 -0
  1068. vllm/v1/worker/tpu_model_runner.py +1419 -0
  1069. vllm/v1/worker/tpu_worker.py +260 -0
  1070. vllm/v1/worker/utils.py +74 -0
  1071. vllm/v1/worker/worker_base.py +64 -0
  1072. vllm/version.py +40 -0
  1073. vllm/vllm_flash_attn/.gitkeep +0 -0
  1074. vllm/worker/__init__.py +0 -0
  1075. vllm/worker/cache_engine.py +144 -0
  1076. vllm/worker/cpu_enc_dec_model_runner.py +323 -0
  1077. vllm/worker/cpu_model_runner.py +668 -0
  1078. vllm/worker/cpu_pooling_model_runner.py +122 -0
  1079. vllm/worker/cpu_worker.py +400 -0
  1080. vllm/worker/enc_dec_model_runner.py +542 -0
  1081. vllm/worker/hpu_model_runner.py +2221 -0
  1082. vllm/worker/hpu_worker.py +483 -0
  1083. vllm/worker/model_runner.py +2056 -0
  1084. vllm/worker/model_runner_base.py +281 -0
  1085. vllm/worker/multi_step_hpu_worker.py +122 -0
  1086. vllm/worker/multi_step_model_runner.py +908 -0
  1087. vllm/worker/multi_step_tpu_worker.py +107 -0
  1088. vllm/worker/multi_step_worker.py +196 -0
  1089. vllm/worker/neuron_model_runner.py +336 -0
  1090. vllm/worker/neuron_worker.py +138 -0
  1091. vllm/worker/pooling_model_runner.py +200 -0
  1092. vllm/worker/tpu_model_runner.py +908 -0
  1093. vllm/worker/tpu_worker.py +332 -0
  1094. vllm/worker/utils.py +52 -0
  1095. vllm/worker/worker.py +570 -0
  1096. vllm/worker/worker_base.py +644 -0
  1097. vllm/worker/xpu_model_runner.py +603 -0
  1098. vllm/worker/xpu_worker.py +185 -0
  1099. vllm_cpu-0.8.5.post2.dist-info/METADATA +309 -0
  1100. vllm_cpu-0.8.5.post2.dist-info/RECORD +1103 -0
  1101. vllm_cpu-0.8.5.post2.dist-info/WHEEL +5 -0
  1102. vllm_cpu-0.8.5.post2.dist-info/entry_points.txt +2 -0
  1103. vllm_cpu-0.8.5.post2.dist-info/top_level.txt +1 -0
@@ -0,0 +1,1760 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ import json
3
+ import re
4
+ import sys
5
+ from abc import ABC, abstractmethod
6
+ from collections import defaultdict
7
+ from collections.abc import (Callable, Generator, ItemsView, Iterable, Mapping,
8
+ Sequence)
9
+ from dataclasses import dataclass, field
10
+ from enum import Enum
11
+ from functools import lru_cache
12
+ from typing import (TYPE_CHECKING, Generic, NamedTuple, Optional, Protocol,
13
+ TypeVar, Union, cast)
14
+
15
+ import torch
16
+ from transformers import BatchFeature, PretrainedConfig, ProcessorMixin
17
+ from typing_extensions import assert_never
18
+
19
+ from vllm.inputs import InputProcessingContext
20
+ from vllm.jsontree import json_map_leaves, json_reduce_leaves
21
+ from vllm.logger import init_logger
22
+ from vllm.transformers_utils.tokenizer import (AnyTokenizer, decode_tokens,
23
+ encode_tokens)
24
+ from vllm.utils import GiB_bytes, LRUCache, flatten_2d_lists, full_groupby
25
+
26
+ from .hasher import MultiModalHasher
27
+ from .inputs import (MultiModalDataDict, MultiModalEncDecInputs,
28
+ MultiModalFieldConfig, MultiModalInputs, MultiModalKwargs,
29
+ MultiModalKwargsItem, NestedTensors, PlaceholderRange)
30
+ from .parse import (DictEmbeddingItems, EmbeddingItems, MultiModalDataItems,
31
+ MultiModalDataParser)
32
+
33
+ if TYPE_CHECKING:
34
+ from .profiling import BaseDummyInputsBuilder
35
+
36
+ logger = init_logger(__name__)
37
+
38
+ _S = TypeVar("_S", str, list[int])
39
+
40
+ PromptSeq = Union[str, list[int]]
41
+ """A token sequence (list of token IDs) or text."""
42
+
43
+
44
+ @dataclass
45
+ class PromptIndex:
46
+ """Resolves to an index in the prompt."""
47
+ get_match_index: Callable[[AnyTokenizer, PromptSeq], Optional[int]]
48
+
49
+
50
+ class PromptIndexTargets:
51
+
52
+ @staticmethod
53
+ def start() -> PromptIndex:
54
+ """
55
+ Resolves to the start of the prompt (before the first token).
56
+
57
+ This results in a match even if the prompt is empty.
58
+ """
59
+ return PromptIndex(lambda tok, prompt: 0)
60
+
61
+ @staticmethod
62
+ def prefix(seq: PromptSeq) -> PromptIndex:
63
+ """
64
+ Resolves to a location in the prompt after the given prefix.
65
+ """
66
+
67
+ def get_match_index(
68
+ tokenizer: AnyTokenizer,
69
+ prompt: PromptSeq,
70
+ ) -> Optional[int]:
71
+ prefix = seq
72
+
73
+ if isinstance(prompt, str):
74
+ if not isinstance(prefix, str):
75
+ # Make both `str`
76
+ prefix = decode_tokens(tokenizer, prefix)
77
+ else:
78
+ if isinstance(prefix, str):
79
+ # Make both `list[int]`
80
+ prefix = encode_tokens(tokenizer,
81
+ prefix,
82
+ add_special_tokens=False)
83
+
84
+ match_idx = len(prefix)
85
+ return match_idx if prompt[:match_idx] == prefix else None
86
+
87
+ return PromptIndex(get_match_index)
88
+
89
+ @staticmethod
90
+ def end() -> PromptIndex:
91
+ """
92
+ Resolves to the end of the prompt (after the last token).
93
+
94
+ This results in a match even if the prompt is empty.
95
+ """
96
+ return PromptIndex(lambda tok, prompt: len(prompt))
97
+
98
+
99
+ PromptTarget = Union[PromptSeq, PromptIndex]
100
+ """
101
+ The token sequence or text to update.
102
+ """
103
+
104
+
105
+ @dataclass
106
+ class PromptUpdateDetails(Generic[_S]):
107
+ """Details about the token sequence or text that are part of the update."""
108
+
109
+ full: _S
110
+ """The full content."""
111
+
112
+ is_embed: Optional[Callable[["_BoundPromptSequence"], torch.Tensor]] = None
113
+ """
114
+ Given :attr:`full`, return a boolean mask of shape `(len(full),)`
115
+ indicating which positions of `full` to assign embeddings to.
116
+
117
+ `None` (default) means to assign embeddings to all positions of `full`.
118
+
119
+ The embeddings are obtained by calling
120
+ :class:`SupportsMultiModal.get_multimodal_embeddings`.
121
+ """
122
+
123
+ @staticmethod
124
+ def from_seq(seq: _S) -> "PromptUpdateDetails[_S]":
125
+ return PromptUpdateDetails(full=seq)
126
+
127
+ @staticmethod
128
+ def select_text(
129
+ seq: _S,
130
+ embed_text: str,
131
+ ) -> "PromptUpdateDetails[_S]":
132
+
133
+ def is_embed(full: "_BoundPromptSequence") -> torch.Tensor:
134
+ embed_token_ids = encode_tokens(full.tokenizer, embed_text)
135
+
136
+ return torch.isin(
137
+ torch.tensor(full.token_ids),
138
+ torch.tensor(embed_token_ids),
139
+ )
140
+
141
+ return PromptUpdateDetails(full=seq, is_embed=is_embed)
142
+
143
+ @staticmethod
144
+ def select_token_id(
145
+ seq: _S,
146
+ embed_token_id: int,
147
+ ) -> "PromptUpdateDetails[_S]":
148
+ return PromptUpdateDetails(
149
+ full=seq,
150
+ is_embed=lambda f: torch.tensor(f.token_ids) == embed_token_id,
151
+ )
152
+
153
+
154
+ PromptUpdateInfo = Union[PromptSeq, PromptUpdateDetails]
155
+ """
156
+ The token sequence or text that are part of the update.
157
+
158
+ If only part of the content corresponds to feature placeholders, you can
159
+ use :class:`PromptUpdateDetails` to specify which part.
160
+ """
161
+
162
+ PromptUpdateContent = Union[Callable[[int], PromptUpdateInfo],
163
+ PromptUpdateInfo]
164
+ """
165
+ Given the index of the processed item within :attr:`modality`,
166
+ output the corresponding token sequence (or text).
167
+
168
+ For convenience, you can directly pass in the token sequence (or text)
169
+ instead of a function if it does not depend on the input.
170
+ """
171
+
172
+
173
+ class UpdateMode(str, Enum):
174
+ INSERT = "insert"
175
+ REPLACE = "replace"
176
+
177
+
178
+ @dataclass
179
+ class PromptUpdate(ABC):
180
+ """
181
+ Defines how to update a prompt with placeholder tokens.
182
+ """
183
+
184
+ modality: str
185
+ """The modality for which the update is made."""
186
+
187
+ target: PromptTarget
188
+ """The token sequence (or text) to update."""
189
+
190
+ @property
191
+ @abstractmethod
192
+ def content(self) -> PromptUpdateContent:
193
+ """The placeholder tokens that are part of the update."""
194
+ raise NotImplementedError
195
+
196
+ @property
197
+ @abstractmethod
198
+ def mode(self) -> UpdateMode:
199
+ """Defines how to update the prompt."""
200
+ raise NotImplementedError
201
+
202
+ def bind(self, tokenizer: AnyTokenizer) -> "BoundPromptUpdate":
203
+ return BoundPromptUpdate(
204
+ _origin=self,
205
+ tokenizer=tokenizer,
206
+ )
207
+
208
+
209
+ @dataclass
210
+ class PromptInsertion(PromptUpdate):
211
+ """
212
+ Defines how to insert placeholder tokens into a prompt.
213
+
214
+ Example:
215
+
216
+ For each image, insert a number of ``<image>`` feature placeholders
217
+ equal to the feature size of the vision encoder after the ``<s>`` token:
218
+
219
+ .. code-block:: python
220
+
221
+ PromptInsertion(
222
+ modality="image",
223
+ target="<s>",
224
+ insertion="<image>" * image_feature_size,
225
+ )
226
+
227
+ Insert these tokens at the start of the prompt:
228
+
229
+ .. code-block:: python
230
+
231
+ PromptInsertion(
232
+ modality="image",
233
+ target=PromptIndexTargets.start(),
234
+ insertion="<image>" * image_feature_size,
235
+ )
236
+
237
+ Insert these tokens after a prefix ``Images:``:
238
+
239
+ .. code-block:: python
240
+
241
+ PromptInsertion(
242
+ modality="image",
243
+ target=PromptIndexTargets.prefix("Images:"),
244
+ insertion="<image>" * image_feature_size,
245
+ )
246
+
247
+ Insert these tokens at the end of the prompt:
248
+
249
+ .. code-block:: python
250
+
251
+ PromptInsertion(
252
+ modality="image",
253
+ target=PromptIndexTargets.end(),
254
+ insertion="<image>" * image_feature_size,
255
+ )
256
+ """
257
+
258
+ insertion: PromptUpdateContent = field(repr=False)
259
+ """
260
+ Given the index of the processed item within :attr:`modality`,
261
+ output the token sequence (or text) to insert right after :attr:`target`.
262
+
263
+ For convenience, you can directly pass in the token sequence (or text)
264
+ instead of a function if it does not depend on the input.
265
+ """
266
+
267
+ @property
268
+ def content(self) -> PromptUpdateContent:
269
+ return self.insertion
270
+
271
+ @property
272
+ def mode(self) -> UpdateMode:
273
+ return UpdateMode.INSERT
274
+
275
+
276
+ @dataclass
277
+ class PromptReplacement(PromptUpdate):
278
+ """
279
+ Defines how to replace portions of an input prompt with placeholder tokens.
280
+
281
+ Example:
282
+
283
+ For each image, replace one ``<image>`` input placeholder in the prompt
284
+ with a number of ``<image>`` feature placeholders
285
+ equal to the feature size of the vision encoder:
286
+
287
+ .. code-block:: python
288
+
289
+ PromptReplacement(
290
+ modality="image",
291
+ target="<image>",
292
+ replacement="<image>" * image_feature_size,
293
+ )
294
+
295
+ As above, but further pad the feature placeholders with ``<image_bos>``
296
+ and `<image_eos>``, which are not supposed to be passed to the vision
297
+ encoder:
298
+
299
+ .. code-block:: python
300
+
301
+ PromptReplacement(
302
+ modality="image",
303
+ target="<image>",
304
+ replacement=PromptUpdateDetails(
305
+ full="".join([
306
+ "<image_bos>",
307
+ "<image>" * image_feature_size,
308
+ "<image_eos>",
309
+ ]),
310
+ features="<image>" * image_feature_size,
311
+ ),
312
+ )
313
+
314
+ To avoid unnecessary tokenization during prompt replacement,
315
+ we recommended passing token sequences instead of text:
316
+
317
+ .. code-block:: python
318
+
319
+ PromptReplacement(
320
+ modality="image",
321
+ target=[image_token_id],
322
+ replacement=PromptUpdateDetails(
323
+ full=([image_bos_id] + [image_token_id] * image_feature_size
324
+ + [image_eos_id]),
325
+ features=[image_token_id] * image_feature_size,
326
+ ),
327
+ )
328
+ """
329
+
330
+ replacement: PromptUpdateContent = field(repr=False)
331
+ """
332
+ Given the index of the processed item within :attr:`modality`,
333
+ output the token sequence (or text) to replace :attr:`target`.
334
+
335
+ For convenience, you can directly pass in the token sequence (or text)
336
+ instead of a function if it does not depend on the input.
337
+ """
338
+
339
+ @property
340
+ def content(self) -> PromptUpdateContent:
341
+ return self.replacement
342
+
343
+ @property
344
+ def mode(self) -> UpdateMode:
345
+ return UpdateMode.REPLACE
346
+
347
+
348
+ @lru_cache(maxsize=2048)
349
+ def _cached_encode(
350
+ tokenizer: AnyTokenizer,
351
+ text: str,
352
+ *,
353
+ add_special_tokens: Optional[bool] = None,
354
+ ) -> list[int]:
355
+ return encode_tokens(tokenizer,
356
+ text,
357
+ add_special_tokens=add_special_tokens)
358
+
359
+
360
+ @lru_cache(maxsize=2048)
361
+ def _cached_decode(
362
+ tokenizer: AnyTokenizer,
363
+ token_ids: tuple[int, ...],
364
+ *,
365
+ skip_special_tokens: Optional[bool] = None,
366
+ ) -> str:
367
+ return decode_tokens(tokenizer,
368
+ list(token_ids),
369
+ skip_special_tokens=skip_special_tokens)
370
+
371
+
372
+ class _HasModalityAttr(Protocol):
373
+ modality: str
374
+
375
+
376
+ class _HasModalityProp(Protocol):
377
+
378
+ @property
379
+ def modality(self) -> str:
380
+ ...
381
+
382
+
383
+ _M = TypeVar("_M", bound=Union[_HasModalityAttr, _HasModalityProp])
384
+
385
+
386
+ def full_groupby_modality(values: Iterable[_M]) -> ItemsView[str, list[_M]]:
387
+ """Convenience function to apply :func:`full_groupby` based on modality."""
388
+ return full_groupby(values, key=lambda x: x.modality)
389
+
390
+
391
+ @dataclass
392
+ class _BoundPromptSequence:
393
+ """
394
+ A :data:`_PromptSeq` bound to a tokenizer to automatically
395
+ convert between token sequence and text representations.
396
+ """
397
+ tokenizer: AnyTokenizer = field(repr=False)
398
+
399
+ _text: Optional[str]
400
+ _token_ids: Optional[list[int]]
401
+
402
+ @staticmethod
403
+ def from_seq(
404
+ tokenizer: AnyTokenizer,
405
+ seq: PromptSeq,
406
+ ) -> "_BoundPromptSequence":
407
+ return _BoundPromptSequence(
408
+ tokenizer=tokenizer,
409
+ _text=seq if isinstance(seq, str) else None,
410
+ _token_ids=seq if isinstance(seq, list) else None,
411
+ )
412
+
413
+ def __post_init__(self) -> None:
414
+ if self._text is None and self._token_ids is None:
415
+ raise ValueError("At least one of 'text' and 'token_ids' must be "
416
+ "specified")
417
+
418
+ @property
419
+ def text(self) -> str:
420
+ if self._text is None:
421
+ assert self._token_ids is not None
422
+ self._text = _cached_decode(self.tokenizer, tuple(self._token_ids))
423
+
424
+ return self._text
425
+
426
+ @property
427
+ def token_ids(self) -> list[int]:
428
+ if self._token_ids is None:
429
+ assert self._text is not None
430
+ self._token_ids = _cached_encode(self.tokenizer,
431
+ self._text,
432
+ add_special_tokens=False)
433
+
434
+ return self._token_ids
435
+
436
+
437
+ @dataclass
438
+ class _BoundPromptContent:
439
+ full: _BoundPromptSequence
440
+ is_embed: Optional[Callable[["_BoundPromptSequence"], torch.Tensor]]
441
+
442
+
443
+ @dataclass
444
+ class BoundPromptUpdate:
445
+ """
446
+ A :class:`PromptUpdate` bound to a tokenizer to automatically convert
447
+ :attr:`target` and the result of :meth:`get_content` between
448
+ token sequence and text representations.
449
+ """
450
+ _origin: PromptUpdate
451
+ tokenizer: AnyTokenizer = field(repr=False)
452
+
453
+ def __post_init__(self) -> None:
454
+ self._content_cache = dict[int, _BoundPromptContent]()
455
+
456
+ @property
457
+ def modality(self) -> str:
458
+ return self._origin.modality
459
+
460
+ @property
461
+ def target(self) -> Union[_BoundPromptSequence, PromptIndex]:
462
+ """The token sequence (or text) to update."""
463
+ target = self._origin.target
464
+
465
+ if isinstance(target, PromptIndex):
466
+ return target
467
+
468
+ return _BoundPromptSequence.from_seq(self.tokenizer, target)
469
+
470
+ @property
471
+ def content(self) -> PromptUpdateContent:
472
+ """The placeholder tokens that are part of the update."""
473
+ return self._origin.content
474
+
475
+ @property
476
+ def mode(self) -> UpdateMode:
477
+ """Defines how to update the prompt."""
478
+ return self._origin.mode
479
+
480
+ def get_content(self, item_idx: int) -> _BoundPromptContent:
481
+ """
482
+ Given the index of the processed item within :attr:`modality`,
483
+ output the token sequence (or text) to update.
484
+ """
485
+ content = self.content
486
+ if callable(content):
487
+ cache_key = item_idx
488
+ if cache_key in self._content_cache:
489
+ return self._content_cache[cache_key]
490
+
491
+ content = content(item_idx)
492
+ else:
493
+ cache_key = None
494
+
495
+ if not isinstance(content, PromptUpdateDetails):
496
+ content = PromptUpdateDetails.from_seq(content)
497
+
498
+ bound_full = _BoundPromptSequence.from_seq(self.tokenizer,
499
+ content.full)
500
+ bound_content = _BoundPromptContent(full=bound_full,
501
+ is_embed=content.is_embed)
502
+
503
+ if cache_key is not None:
504
+ self._content_cache[cache_key] = bound_content
505
+
506
+ return bound_content
507
+
508
+
509
+ class _TokenMatch(NamedTuple):
510
+ start_idx: int
511
+ end_idx: int
512
+
513
+
514
+ def iter_token_matches(
515
+ token_ids: list[int],
516
+ match_ids: list[int],
517
+ ) -> Generator[_TokenMatch]:
518
+ """
519
+ Yield each occurrence of :code:`match_ids` in :code:`token_ids`.
520
+
521
+ Note that empty matches are ignored.
522
+ """
523
+ prompt_len = len(token_ids)
524
+ match_len = len(match_ids)
525
+
526
+ if match_len == 0:
527
+ return
528
+
529
+ start_idx = 0
530
+ while start_idx < prompt_len - match_len + 1:
531
+ end_idx = start_idx + match_len
532
+
533
+ if token_ids[start_idx:end_idx] == match_ids:
534
+ yield _TokenMatch(start_idx=start_idx, end_idx=end_idx)
535
+
536
+ # Exclude overlapping matches
537
+ start_idx = end_idx
538
+ else:
539
+ start_idx += 1
540
+
541
+
542
+ def replace_token_matches(
543
+ token_ids: list[int],
544
+ match_ids: list[int],
545
+ new_ids: list[int],
546
+ ) -> list[int]:
547
+ """
548
+ Replace each occurrence of :code:`match_ids` in :code:`token_ids`
549
+ with :code:`new_ids`.
550
+
551
+ Note that empty matches are ignored.
552
+ """
553
+ out_seqs = list[list[int]]()
554
+ prev_end_idx = 0
555
+
556
+ for match in iter_token_matches(token_ids, match_ids):
557
+ start_idx = match.start_idx
558
+ end_idx = match.end_idx
559
+
560
+ out_seqs.append(token_ids[prev_end_idx:start_idx])
561
+ out_seqs.append(new_ids)
562
+ prev_end_idx = end_idx
563
+
564
+ out_seqs.append(token_ids[prev_end_idx:])
565
+
566
+ return flatten_2d_lists(out_seqs)
567
+
568
+
569
+ @dataclass(repr=False)
570
+ class PromptTargetMatch(ABC):
571
+ _origin: BoundPromptUpdate
572
+
573
+ @property
574
+ def modality(self) -> str:
575
+ return self._origin.modality
576
+
577
+ @property
578
+ @abstractmethod
579
+ def start_idx(self) -> int:
580
+ raise NotImplementedError
581
+
582
+ @property
583
+ @abstractmethod
584
+ def end_idx(self) -> int:
585
+ raise NotImplementedError
586
+
587
+ def __repr__(self) -> str:
588
+ return (f"{type(self).__name__}(modality={self.modality!r}, "
589
+ f"start_idx={self.start_idx!r}, end_idx={self.end_idx!r})")
590
+
591
+
592
+ @dataclass(repr=False)
593
+ class _PromptTargetIndexMatch(PromptTargetMatch):
594
+ match_idx: int
595
+
596
+ @property
597
+ def start_idx(self) -> int:
598
+ return self.match_idx
599
+
600
+ @property
601
+ def end_idx(self) -> int:
602
+ return self.match_idx
603
+
604
+
605
+ @dataclass(repr=False)
606
+ class _PromptTargetTokenMatch(PromptTargetMatch):
607
+ match: _TokenMatch
608
+
609
+ @property
610
+ def start_idx(self) -> int:
611
+ return self.match.start_idx
612
+
613
+ @property
614
+ def end_idx(self) -> int:
615
+ return self.match.end_idx
616
+
617
+
618
+ @dataclass(repr=False)
619
+ class _PromptTargetTextMatch(PromptTargetMatch):
620
+ match: re.Match[str]
621
+
622
+ @property
623
+ def start_idx(self) -> int:
624
+ return self.match.start()
625
+
626
+ @property
627
+ def end_idx(self) -> int:
628
+ return self.match.end()
629
+
630
+
631
+ @dataclass
632
+ class PlaceholderFeaturesInfo:
633
+ modality: str
634
+ item_idx: int
635
+ start_idx: int
636
+ tokens: list[int]
637
+ is_embed: Optional[torch.Tensor]
638
+
639
+ @property
640
+ def length(self) -> int:
641
+ return len(self.tokens)
642
+
643
+ def to_range(self) -> PlaceholderRange:
644
+ # TODO: Is it worth it to optimize this by stripping the
645
+ # leading and ending positions where `is_embed=False`?
646
+ return PlaceholderRange(
647
+ offset=self.start_idx,
648
+ length=self.length,
649
+ is_embed=self.is_embed,
650
+ )
651
+
652
+
653
+ def find_token_matches(
654
+ prompt: list[int],
655
+ prompt_updates: Sequence[BoundPromptUpdate],
656
+ ) -> Sequence[PromptTargetMatch]:
657
+ """Return each target of :code:`prompt_updates` found in :code:`prompt`."""
658
+
659
+ def get_matches(update: BoundPromptUpdate):
660
+ target = update.target
661
+
662
+ if isinstance(target, PromptIndex):
663
+ match_idx = target.get_match_index(update.tokenizer, prompt)
664
+ if match_idx is None:
665
+ return []
666
+
667
+ return [_PromptTargetIndexMatch(update, match_idx)]
668
+
669
+ return [
670
+ _PromptTargetTokenMatch(update, match)
671
+ for match in iter_token_matches(prompt, target.token_ids)
672
+ ]
673
+
674
+ return [
675
+ match for update in prompt_updates for match in get_matches(update)
676
+ ]
677
+
678
+
679
+ def find_text_matches(
680
+ prompt: str,
681
+ prompt_updates: Sequence[BoundPromptUpdate],
682
+ ) -> Sequence[PromptTargetMatch]:
683
+ """Return each target of :code:`prompt_updates` found in :code:`prompt`."""
684
+
685
+ def get_matches(update: BoundPromptUpdate):
686
+ target = update.target
687
+
688
+ if isinstance(target, PromptIndex):
689
+ match_idx = target.get_match_index(update.tokenizer, prompt)
690
+ if match_idx is None:
691
+ return []
692
+
693
+ return [_PromptTargetIndexMatch(update, match_idx)]
694
+
695
+ return [
696
+ _PromptTargetTextMatch(update, match)
697
+ for match in re.finditer(re.escape(target.text), prompt)
698
+ ]
699
+
700
+ return [
701
+ match for update in prompt_updates for match in get_matches(update)
702
+ ]
703
+
704
+
705
+ def _resolve_matches(
706
+ prompt: PromptSeq,
707
+ mm_matches: Mapping[str, Sequence[PromptTargetMatch]],
708
+ ) -> list[PromptTargetMatch]:
709
+ """
710
+ Resolve :code:`mm_matches` to ensure that there are no overlapping matches,
711
+ and sort them such that earlier matches take priority over later ones.
712
+ """
713
+ matches = [m for matches in mm_matches.values() for m in matches]
714
+
715
+ seen_matches: list[Optional[PromptTargetMatch]] = [None] * len(prompt)
716
+
717
+ for match in matches:
718
+ for idx in range(match.start_idx, match.end_idx):
719
+ if seen_matches[idx] is not None:
720
+ raise ValueError("Found overlapping matches "
721
+ f"({seen_matches[idx]} and {match}) "
722
+ f"at index={idx} of prompt={prompt}")
723
+
724
+ seen_matches[idx] = match
725
+
726
+ return sorted(matches, key=lambda x: x.start_idx)
727
+
728
+
729
+ def _apply_matches(
730
+ prompt: _S,
731
+ mm_matches: Mapping[str, Sequence[PromptTargetMatch]],
732
+ mm_item_counts: Mapping[str, int],
733
+ ) -> list[_S]:
734
+ """Apply the updates in :code:`mm_matches` to :code:`prompt`."""
735
+ out_seqs = list[Union[str, list[int]]]()
736
+ prev_end_idx = 0
737
+ next_idx_by_modality = defaultdict[str, int](lambda: 0)
738
+
739
+ for match in _resolve_matches(prompt, mm_matches):
740
+ modality = match.modality
741
+
742
+ item_start_idx = next_idx_by_modality[modality]
743
+ max_item_count = mm_item_counts.get(modality, 0)
744
+ if item_start_idx >= max_item_count:
745
+ continue
746
+
747
+ start_idx = match.start_idx
748
+ end_idx = match.end_idx
749
+ origin = match._origin
750
+ mode = origin.mode
751
+
752
+ if mode == UpdateMode.INSERT:
753
+ out_seqs.append(prompt[prev_end_idx:end_idx])
754
+ num_inserts = max_item_count
755
+ elif mode == UpdateMode.REPLACE:
756
+ out_seqs.append(prompt[prev_end_idx:start_idx])
757
+ num_inserts = max_item_count if start_idx == end_idx else 1
758
+ else:
759
+ assert_never(mode)
760
+
761
+ item_end_idx = min(item_start_idx + num_inserts, max_item_count)
762
+
763
+ for item_idx in range(item_start_idx, item_end_idx):
764
+ content = origin.get_content(item_idx)
765
+ insert_seq = (content.full.text if isinstance(prompt, str) else
766
+ content.full.token_ids)
767
+
768
+ out_seqs.append(insert_seq)
769
+
770
+ prev_end_idx = end_idx
771
+ next_idx_by_modality[modality] += item_end_idx - item_start_idx
772
+
773
+ out_seqs.append(prompt[prev_end_idx:])
774
+
775
+ return cast(list[_S], out_seqs)
776
+
777
+
778
+ def apply_token_matches(
779
+ prompt: list[int],
780
+ mm_matches: Mapping[str, Sequence[PromptTargetMatch]],
781
+ mm_item_counts: Mapping[str, int],
782
+ ) -> list[int]:
783
+ """Apply the updates in :code:`mm_matches` to :code:`prompt`."""
784
+ if not mm_matches:
785
+ return prompt
786
+
787
+ token_id_seqs = _apply_matches(prompt, mm_matches, mm_item_counts)
788
+
789
+ return flatten_2d_lists(token_id_seqs)
790
+
791
+
792
+ def apply_text_matches(
793
+ prompt: str,
794
+ mm_matches: Mapping[str, Sequence[PromptTargetMatch]],
795
+ mm_item_counts: Mapping[str, int],
796
+ ) -> str:
797
+ """Apply the updates in :code:`mm_matches` to :code:`prompt`."""
798
+ if not mm_matches:
799
+ return prompt
800
+
801
+ texts = _apply_matches(prompt, mm_matches, mm_item_counts)
802
+
803
+ return "".join(texts)
804
+
805
+
806
+ def _iter_placeholders(
807
+ mm_prompt_updates: Mapping[str, Sequence[BoundPromptUpdate]],
808
+ prompt: list[int],
809
+ mm_item_counts: Mapping[str, int],
810
+ ) -> Iterable[PlaceholderFeaturesInfo]:
811
+ """
812
+ Yield each set of placeholder tokens found in :code:`prompt`.
813
+
814
+ Matches are exclusive even when multiple modalities share
815
+ the same placeholder tokens. In that case, the modality that
816
+ appears earlier in `mm_prompt_updates` takes priority.
817
+
818
+ Note that empty matches are ignored.
819
+ """
820
+ prompt_len = len(prompt)
821
+ item_idx_by_modality = defaultdict[str, int](lambda: 0)
822
+
823
+ start_idx = 0
824
+ while start_idx < prompt_len:
825
+ found = False
826
+
827
+ for modality, modality_updates in mm_prompt_updates.items():
828
+ item_idx = item_idx_by_modality[modality]
829
+ if item_idx >= mm_item_counts.get(modality, 0):
830
+ continue
831
+
832
+ for update_info in modality_updates:
833
+ content = update_info.get_content(item_idx)
834
+ content_tokens_full = content.full.token_ids
835
+ content_len_full = len(content_tokens_full)
836
+ end_idx_full = start_idx + content_len_full
837
+
838
+ if content_len_full == 0 or end_idx_full > prompt_len:
839
+ continue
840
+
841
+ if prompt[start_idx:end_idx_full] == content_tokens_full:
842
+ content_is_embed = content.is_embed
843
+ if content_is_embed is not None:
844
+ content_is_embed = content_is_embed(content.full)
845
+
846
+ yield PlaceholderFeaturesInfo(
847
+ modality=modality,
848
+ item_idx=item_idx,
849
+ start_idx=start_idx,
850
+ tokens=content_tokens_full,
851
+ is_embed=content_is_embed,
852
+ )
853
+
854
+ # Exclude overlapping matches
855
+ start_idx = end_idx_full
856
+ item_idx_by_modality[modality] += 1
857
+ found = True
858
+ break
859
+
860
+ if found:
861
+ break # Go back to the outer while loop
862
+
863
+ if not found:
864
+ start_idx += 1
865
+
866
+
867
+ def find_mm_placeholders(
868
+ mm_prompt_updates: Mapping[str, Sequence[BoundPromptUpdate]],
869
+ prompt: list[int],
870
+ mm_item_counts: Mapping[str, int],
871
+ ) -> Mapping[str, list[PlaceholderFeaturesInfo]]:
872
+ it = _iter_placeholders(mm_prompt_updates, prompt, mm_item_counts)
873
+ return dict(full_groupby_modality(it))
874
+
875
+
876
+ _V = TypeVar("_V", bound="Union[MultiModalKwargs, MultiModalKwargsItem]")
877
+
878
+
879
+ class ProcessingCache:
880
+
881
+ @staticmethod
882
+ def get_lru_cache(
883
+ capacity_gb: float,
884
+ value_type: type[_V],
885
+ *,
886
+ debug: bool = False,
887
+ ) -> LRUCache[str, _V]:
888
+
889
+ def get_leaf_size(leaf: object) -> int:
890
+ # MultiModalKwargs is not a subclass of dict
891
+ if isinstance(leaf, MultiModalKwargs):
892
+ return get_item_size(leaf.data)
893
+
894
+ # MultiModalKwargsItem is not a subclass of dict
895
+ if isinstance(leaf, MultiModalKwargsItem):
896
+ leaf_data = {k: v.data for k, v in leaf.items()}
897
+ return get_item_size(leaf_data)
898
+
899
+ # sys.getsizeof doesn't work for tensors
900
+ if isinstance(leaf, torch.Tensor):
901
+ return leaf.nbytes
902
+
903
+ return sys.getsizeof(leaf)
904
+
905
+ def get_item_size(
906
+ value: Union[MultiModalKwargs, MultiModalKwargsItem,
907
+ Mapping[str, NestedTensors]]
908
+ ) -> int:
909
+ size = json_reduce_leaves(
910
+ lambda a, b: a + b,
911
+ json_map_leaves(get_leaf_size, value),
912
+ )
913
+
914
+ if debug:
915
+ logger.debug("Calculated size of %s to be %.2f GiB",
916
+ type(value), size / GiB_bytes)
917
+
918
+ return size
919
+
920
+ return LRUCache(GiB_bytes * capacity_gb, getsizeof=get_item_size)
921
+
922
+ def __init__(
923
+ self,
924
+ capacity_gb: float,
925
+ *,
926
+ debug_cache_hit_ratio_steps: Optional[int] = None,
927
+ ) -> None:
928
+ super().__init__()
929
+
930
+ self.debug_cache_hit_ratio_steps = debug_cache_hit_ratio_steps
931
+ self.debug_cache_hits = 0
932
+ self.debug_cache_total = 0
933
+
934
+ self._cache = self.get_lru_cache(
935
+ capacity_gb,
936
+ MultiModalKwargsItem,
937
+ debug=bool(debug_cache_hit_ratio_steps),
938
+ )
939
+
940
+ def _maybe_log_cache_stats(self) -> None:
941
+ steps = self.debug_cache_hit_ratio_steps
942
+ if not steps:
943
+ return
944
+
945
+ total = self.debug_cache_total
946
+ if total > 0 and total % steps == 0:
947
+ logger.debug("ProcessingCache: hit_ratio = %.2f",
948
+ self.debug_cache_hits / total)
949
+ logger.debug("ProcessingCache: size = %.2f / %.2f GiB",
950
+ self._cache.currsize / GiB_bytes,
951
+ self._cache.maxsize / GiB_bytes)
952
+
953
+ def get(
954
+ self,
955
+ model_id: str,
956
+ modality: str,
957
+ input_item: object,
958
+ input_kwargs: Mapping[str, object],
959
+ ) -> Optional[MultiModalKwargsItem]:
960
+ """
961
+ Get a processed multi-modal item from the cache
962
+ according to its dependencies, including:
963
+
964
+ - The model ID
965
+ - The modality of the item
966
+ - The original data item passed to the HF processor
967
+ - The configuration options of the HF processor
968
+ """
969
+ self._maybe_log_cache_stats()
970
+
971
+ cache_key = MultiModalHasher.hash_kwargs(model_id=model_id,
972
+ **{modality: input_item},
973
+ **input_kwargs)
974
+
975
+ if self.debug_cache_hit_ratio_steps:
976
+ if cache_key in self._cache:
977
+ self.debug_cache_hits += 1
978
+
979
+ self.debug_cache_total += 1
980
+
981
+ return self._cache.get(cache_key)
982
+
983
+ def put(
984
+ self,
985
+ model_id: str,
986
+ modality: str,
987
+ input_item: object,
988
+ input_kwargs: Mapping[str, object],
989
+ output_kwargs: MultiModalKwargsItem,
990
+ ) -> None:
991
+ """
992
+ Put a processed multi-modal item into the cache
993
+ according to its dependencies (see :meth:`get`).
994
+ """
995
+ cache_key = MultiModalHasher.hash_kwargs(model_id=model_id,
996
+ **{modality: input_item},
997
+ **input_kwargs)
998
+ self._cache[cache_key] = output_kwargs
999
+
1000
+
1001
+ class BaseProcessingInfo:
1002
+ """Base class to provide the information necessary for data processing."""
1003
+
1004
+ def __init__(self, ctx: InputProcessingContext) -> None:
1005
+ super().__init__()
1006
+
1007
+ self.ctx = ctx
1008
+
1009
+ @property
1010
+ def model_id(self) -> str:
1011
+ return self.ctx.model_config.model
1012
+
1013
+ def get_tokenizer(self) -> AnyTokenizer:
1014
+ return self.ctx.tokenizer
1015
+
1016
+ def get_hf_config(self) -> PretrainedConfig:
1017
+ return self.ctx.get_hf_config()
1018
+
1019
+ def get_hf_processor(self, **kwargs: object) -> ProcessorMixin:
1020
+ """
1021
+ Subclasses can override this method to handle
1022
+ specific kwargs from model config or user inputs.
1023
+ """
1024
+ return self.ctx.get_hf_processor(**kwargs)
1025
+
1026
+ @abstractmethod
1027
+ def get_supported_mm_limits(self) -> Mapping[str, Optional[int]]:
1028
+ """
1029
+ Return the maximum supported number of items for each modality.
1030
+
1031
+ A value of `None` means unlimited number of items.
1032
+
1033
+ Omitting a modality from the returned dictionary means that
1034
+ it is not supported at all.
1035
+ """
1036
+ raise NotImplementedError
1037
+
1038
+ def get_allowed_mm_limits(self) -> Mapping[str, int]:
1039
+ """Return the maximum allowed number of items for each modality."""
1040
+ supported_mm_limits = self.get_supported_mm_limits()
1041
+ mm_config = self.ctx.get_mm_config()
1042
+
1043
+ allowed_limits = dict[str, int]()
1044
+ for modality, supported_limit in supported_mm_limits.items():
1045
+ user_limit = mm_config.get_limit_per_prompt(modality)
1046
+
1047
+ allowed_limits[modality] = (user_limit if supported_limit is None
1048
+ else min(user_limit, supported_limit))
1049
+
1050
+ return allowed_limits
1051
+
1052
+
1053
+ _I = TypeVar("_I", bound=BaseProcessingInfo)
1054
+
1055
+
1056
+ class BaseMultiModalProcessor(ABC, Generic[_I]):
1057
+ """
1058
+ Abstract base class to process multi-modal inputs to be used in vLLM.
1059
+
1060
+ Not to be confused with :class:`transformers.ProcessorMixin`.
1061
+ """
1062
+
1063
+ def __init__(self,
1064
+ info: _I,
1065
+ dummy_inputs: "BaseDummyInputsBuilder[_I]",
1066
+ *,
1067
+ cache: Optional[ProcessingCache] = None,
1068
+ enable_sanity_checks: bool = True) -> None:
1069
+ super().__init__()
1070
+
1071
+ self.info = info
1072
+ self.dummy_inputs = dummy_inputs
1073
+ self.cache = cache
1074
+ self.enable_sanity_checks = enable_sanity_checks
1075
+
1076
+ self.data_parser = self._get_data_parser()
1077
+
1078
+ def __call__(
1079
+ self,
1080
+ prompt: str,
1081
+ mm_data: MultiModalDataDict,
1082
+ hf_processor_mm_kwargs: Mapping[str, object],
1083
+ ) -> MultiModalInputs:
1084
+ return self.apply(prompt, mm_data, hf_processor_mm_kwargs)
1085
+
1086
+ def _get_data_parser(self) -> MultiModalDataParser:
1087
+ """
1088
+ Construct a parser to preprocess multi-modal data items
1089
+ before passing them to :meth:`_get_hf_mm_data`.
1090
+
1091
+ You can support additional modalities by creating a subclass
1092
+ of :class:`MultiModalDataParser` that has additional subparsers.
1093
+ """
1094
+ return MultiModalDataParser()
1095
+
1096
+ def _to_mm_items(
1097
+ self,
1098
+ mm_data: MultiModalDataDict,
1099
+ ) -> MultiModalDataItems:
1100
+ """
1101
+ Normalize :class:`MultiModalDataDict` to :class:`MultiModalDataItems`
1102
+ before passing them to :meth:`_get_hf_mm_data`.
1103
+ """
1104
+ mm_items = self.data_parser.parse_mm_data(mm_data)
1105
+ supported_mm_limits = self.info.get_supported_mm_limits()
1106
+ allowed_mm_limits = self.info.get_allowed_mm_limits()
1107
+
1108
+ for modality, items in mm_items.items():
1109
+ supported_limit = supported_mm_limits.get(modality, 0)
1110
+ allowed_limit = allowed_mm_limits.get(modality, 0)
1111
+ num_items = len(items)
1112
+
1113
+ if supported_limit is not None and num_items > supported_limit:
1114
+ raise ValueError(
1115
+ f"The model only supports at most {supported_limit} "
1116
+ f"{modality} items, but you passed {num_items} "
1117
+ f"{modality} items in the same prompt.")
1118
+
1119
+ if num_items > allowed_limit:
1120
+ raise ValueError(
1121
+ "You set or defaulted to "
1122
+ f"'{json.dumps({modality: allowed_limit})}' in "
1123
+ f"`--limit-mm-per-prompt`, but passed {num_items} "
1124
+ f"{modality} items in the same prompt.")
1125
+
1126
+ return mm_items
1127
+
1128
+ @abstractmethod
1129
+ def _get_mm_fields_config(
1130
+ self,
1131
+ hf_inputs: BatchFeature,
1132
+ hf_processor_mm_kwargs: Mapping[str, object],
1133
+ ) -> Mapping[str, MultiModalFieldConfig]:
1134
+ """Given the HF-processed data, output the metadata of each field."""
1135
+ raise NotImplementedError
1136
+
1137
+ @abstractmethod
1138
+ def _get_prompt_updates(
1139
+ self,
1140
+ mm_items: MultiModalDataItems,
1141
+ hf_processor_mm_kwargs: Mapping[str, object],
1142
+ out_mm_kwargs: MultiModalKwargs,
1143
+ ) -> Sequence[PromptUpdate]:
1144
+ """
1145
+ Given the original multi-modal items for this modality
1146
+ and HF-processed data, output the updates to perform.
1147
+
1148
+ The information returned by this method is used to update token inputs
1149
+ which bypass the HF processor. It is also used to update the output of
1150
+ HF processor if the HF process does not apply prompt updates to text
1151
+ inputs.
1152
+
1153
+ Moreover, this information is critical to determine the token positions
1154
+ in order to construct :class:`~vllm-multimodal.input.PlaceholderRange`
1155
+ for each multi-modal item.
1156
+ """
1157
+ raise NotImplementedError
1158
+
1159
+ def _find_mm_placeholders(
1160
+ self,
1161
+ mm_prompt_updates: Mapping[str, Sequence[BoundPromptUpdate]],
1162
+ new_token_ids: list[int],
1163
+ mm_item_counts: Mapping[str, int],
1164
+ ) -> Mapping[str, list[PlaceholderFeaturesInfo]]:
1165
+ return find_mm_placeholders(mm_prompt_updates, new_token_ids,
1166
+ mm_item_counts)
1167
+
1168
+ def _get_hf_mm_data(
1169
+ self,
1170
+ mm_items: MultiModalDataItems,
1171
+ ) -> tuple[Mapping[str, object], Mapping[str, object]]:
1172
+ processor_data = dict[str, object]()
1173
+ passthrough_data = dict[str, object]()
1174
+
1175
+ for items in mm_items.values():
1176
+ processor_data.update(items.get_processor_data())
1177
+ passthrough_data.update(items.get_passthrough_data())
1178
+
1179
+ return processor_data, passthrough_data
1180
+
1181
+ def _call_hf_processor(
1182
+ self,
1183
+ prompt: str,
1184
+ # Not to be confused with `mm_data` in `self.apply`.
1185
+ # This refers to the data to be passed to HF processor.
1186
+ mm_data: Mapping[str, object],
1187
+ mm_kwargs: Mapping[str, object],
1188
+ ) -> BatchFeature:
1189
+ """
1190
+ Call the HF processor on the prompt text and
1191
+ associated multi-modal data.
1192
+ """
1193
+ return self.info.ctx.call_hf_processor(
1194
+ self.info.get_hf_processor(**mm_kwargs),
1195
+ dict(text=prompt, **mm_data),
1196
+ mm_kwargs,
1197
+ )
1198
+
1199
+ def _hf_processor_applies_updates(
1200
+ self,
1201
+ prompt_text: str,
1202
+ mm_items: MultiModalDataItems,
1203
+ hf_processor_mm_kwargs: Mapping[str, object],
1204
+ ) -> bool:
1205
+ """
1206
+ Return whether the HF processor applies prompt updates.
1207
+
1208
+ For most HF processors, this should be :code:`True` when multi-modal
1209
+ data items are passed, but :code:`False` when multi-modal embeddings
1210
+ are passed.
1211
+ """
1212
+ return not any(
1213
+ isinstance(items, (EmbeddingItems, DictEmbeddingItems))
1214
+ for items in mm_items.values())
1215
+
1216
+ def _apply_hf_processor_text_mm(
1217
+ self,
1218
+ prompt_text: str,
1219
+ mm_items: MultiModalDataItems,
1220
+ hf_processor_mm_kwargs: Mapping[str, object],
1221
+ ) -> tuple[list[int], MultiModalKwargs, bool]:
1222
+ """
1223
+ Apply the HF processor on the prompt text and multi-modal data
1224
+ together.
1225
+
1226
+ In addition, return whether prompt updates have been applied.
1227
+ """
1228
+ processor_data, passthrough_data = self._get_hf_mm_data(mm_items)
1229
+
1230
+ processed_data = self._call_hf_processor(
1231
+ prompt=prompt_text,
1232
+ mm_data=processor_data,
1233
+ mm_kwargs=hf_processor_mm_kwargs,
1234
+ )
1235
+ processed_data.update(passthrough_data)
1236
+
1237
+ prompt_ids, = processed_data.pop("input_ids").tolist()
1238
+
1239
+ mm_kwargs = MultiModalKwargs.from_hf_inputs(
1240
+ processed_data,
1241
+ self._get_mm_fields_config(processed_data, hf_processor_mm_kwargs),
1242
+ )
1243
+
1244
+ is_update_applied = self._hf_processor_applies_updates(
1245
+ prompt_text=prompt_text,
1246
+ mm_items=mm_items,
1247
+ hf_processor_mm_kwargs=hf_processor_mm_kwargs,
1248
+ )
1249
+
1250
+ return prompt_ids, mm_kwargs, is_update_applied
1251
+
1252
+ def _apply_hf_processor_text_only(self, prompt_text: str) -> list[int]:
1253
+ """
1254
+ Apply the HF processor on the prompt text only.
1255
+
1256
+ Since HF processor requires that text and multi-modal items
1257
+ correspond to each other, we create dummy multi-modal items
1258
+ to go along with the text.
1259
+ """
1260
+ prompt_ids, _, _ = self._apply_hf_processor_text_mm(
1261
+ prompt_text=prompt_text,
1262
+ mm_items=MultiModalDataItems({}),
1263
+ hf_processor_mm_kwargs={},
1264
+ )
1265
+
1266
+ return prompt_ids
1267
+
1268
+ def _apply_hf_processor_tokens_only(
1269
+ self,
1270
+ prompt_tokens: list[int],
1271
+ ) -> list[int]:
1272
+ """
1273
+ Apply the HF processor on the prompt tokens only.
1274
+
1275
+ Most HF processors accept prompt text but not prompt tokens.
1276
+ If the HF processor adds or removes tokens that are not related to
1277
+ multi-modal data, you should override this method so it is consistent
1278
+ with the output of :meth:`_apply_hf_processor_text_only` on the
1279
+ corresponding text.
1280
+ """
1281
+ return prompt_tokens
1282
+
1283
+ def _apply_hf_processor_mm_only(
1284
+ self,
1285
+ mm_items: MultiModalDataItems,
1286
+ hf_processor_mm_kwargs: Mapping[str, object],
1287
+ ) -> MultiModalKwargs:
1288
+ """
1289
+ Apply the HF processor on the multi-modal data only.
1290
+
1291
+ Since HF processor requires that text and multi-modal items
1292
+ correspond to each other, we generate dummy text using
1293
+ :class:`DummyInputsBuilder` to go along with the multi-modal data.
1294
+ """
1295
+ mm_counts = mm_items.get_all_counts()
1296
+
1297
+ _, mm_kwargs, _ = self._apply_hf_processor_text_mm(
1298
+ prompt_text=self.dummy_inputs.get_dummy_text(mm_counts),
1299
+ mm_items=mm_items,
1300
+ hf_processor_mm_kwargs=hf_processor_mm_kwargs,
1301
+ )
1302
+
1303
+ return mm_kwargs
1304
+
1305
+ def _apply_hf_processor_main(
1306
+ self,
1307
+ prompt: Union[str, list[int]],
1308
+ mm_items: MultiModalDataItems,
1309
+ hf_processor_mm_kwargs: Mapping[str, object],
1310
+ *,
1311
+ enable_hf_prompt_update: bool,
1312
+ ) -> tuple[list[int], MultiModalKwargs, bool]:
1313
+ """
1314
+ Apply the HF processor on the prompt text and multi-modal data.
1315
+
1316
+ In addition, return whether prompt updates have been applied
1317
+ (for most HF processors, this should be :code:`True`).
1318
+
1319
+ Note:
1320
+ If :code:`enable_hf_prompt_update=False`, we use HF processor
1321
+ to perform prompt updates if available; HF processor requires
1322
+ that the prompt corresponds to multi-modal items.
1323
+ """
1324
+ if isinstance(prompt, str):
1325
+ if enable_hf_prompt_update:
1326
+ return self._apply_hf_processor_text_mm(
1327
+ prompt_text=prompt,
1328
+ mm_items=mm_items,
1329
+ hf_processor_mm_kwargs=hf_processor_mm_kwargs,
1330
+ )
1331
+
1332
+ prompt_ids = self._apply_hf_processor_text_only(prompt)
1333
+ else:
1334
+ prompt_ids = self._apply_hf_processor_tokens_only(prompt)
1335
+
1336
+ mm_kwargs = self._apply_hf_processor_mm_only(
1337
+ mm_items=mm_items,
1338
+ hf_processor_mm_kwargs=hf_processor_mm_kwargs,
1339
+ )
1340
+
1341
+ return prompt_ids, mm_kwargs, False
1342
+
1343
+ def _cached_apply_hf_processor(
1344
+ self,
1345
+ prompt: Union[str, list[int]],
1346
+ mm_data_items: MultiModalDataItems,
1347
+ hf_processor_mm_kwargs: Mapping[str, object],
1348
+ ) -> tuple[list[int], MultiModalKwargs, bool]:
1349
+ """
1350
+ Apply the HF processor on the full prompt text,
1351
+ caching the results and reusing cached results.
1352
+ """
1353
+ cache = self.cache
1354
+ model_id = self.info.model_id
1355
+
1356
+ _, passthrough_data = self._get_hf_mm_data(mm_data_items)
1357
+ if cache is None or passthrough_data:
1358
+ return self._apply_hf_processor_main(
1359
+ prompt=prompt,
1360
+ mm_items=mm_data_items,
1361
+ hf_processor_mm_kwargs=hf_processor_mm_kwargs,
1362
+ enable_hf_prompt_update=True,
1363
+ )
1364
+
1365
+ mm_maybe_cached_kw_items = {
1366
+ modality: [
1367
+ cache.get(model_id, modality, item, hf_processor_mm_kwargs)
1368
+ for item in items
1369
+ ]
1370
+ for modality, items in mm_data_items.items()
1371
+ }
1372
+
1373
+ mm_missing_idxs = {
1374
+ modality:
1375
+ [idx for idx, item in enumerate(kw_items) if item is None]
1376
+ for modality, kw_items in mm_maybe_cached_kw_items.items()
1377
+ }
1378
+ mm_missing_data = {
1379
+ modality: [mm_data_items[modality][idx] for idx in idxs]
1380
+ for modality, idxs in mm_missing_idxs.items()
1381
+ }
1382
+ mm_missing_data_items = self._to_mm_items(mm_missing_data)
1383
+
1384
+ # NOTE: `prompt` does not correspond to `mm_missing_data_items`,
1385
+ # so we can't apply prompt updates until the new multimodal
1386
+ # items are combined with the cached multimodal items
1387
+ (
1388
+ prompt_ids,
1389
+ mm_missing_kwargs,
1390
+ is_update_applied,
1391
+ ) = self._apply_hf_processor_main(
1392
+ prompt=prompt,
1393
+ mm_items=mm_missing_data_items,
1394
+ hf_processor_mm_kwargs=hf_processor_mm_kwargs,
1395
+ enable_hf_prompt_update=False,
1396
+ )
1397
+
1398
+ mm_missing_next_idx = {
1399
+ modality: 0
1400
+ for modality in mm_missing_data_items
1401
+ }
1402
+
1403
+ merged_kw_items = list[MultiModalKwargsItem]()
1404
+ for modality, kw_items in mm_maybe_cached_kw_items.items():
1405
+ for idx, kw_item in enumerate(kw_items):
1406
+ if kw_item is None:
1407
+ kw_item = mm_missing_kwargs.get_item(
1408
+ modality,
1409
+ mm_missing_next_idx[modality],
1410
+ )
1411
+
1412
+ cache.put(
1413
+ model_id,
1414
+ modality,
1415
+ mm_data_items[modality][idx],
1416
+ hf_processor_mm_kwargs,
1417
+ kw_item,
1418
+ )
1419
+
1420
+ mm_missing_next_idx[modality] += 1
1421
+
1422
+ merged_kw_items.append(kw_item)
1423
+
1424
+ if self.enable_sanity_checks:
1425
+ mm_missing_counts = mm_missing_data_items.get_all_counts()
1426
+ assert all(
1427
+ item_count == mm_missing_counts[modality]
1428
+ for modality, item_count in mm_missing_next_idx.items()), dict(
1429
+ mm_missing_next_idx=mm_missing_next_idx,
1430
+ mm_missing_counts=mm_missing_counts)
1431
+
1432
+ mm_kwargs = MultiModalKwargs.from_items(merged_kw_items)
1433
+
1434
+ return prompt_ids, mm_kwargs, is_update_applied
1435
+
1436
+ def _bind_and_group_updates(
1437
+ self,
1438
+ prompt_updates: Sequence[PromptUpdate],
1439
+ ) -> dict[str, Sequence[BoundPromptUpdate]]:
1440
+ tokenizer = self.info.get_tokenizer()
1441
+
1442
+ it = (update.bind(tokenizer) for update in prompt_updates)
1443
+ return dict(full_groupby_modality(it))
1444
+
1445
+ def _apply_token_matches(
1446
+ self,
1447
+ prompt: list[int],
1448
+ mm_matches: Mapping[str, Sequence[PromptTargetMatch]],
1449
+ mm_item_counts: Mapping[str, int],
1450
+ ) -> list[int]:
1451
+ return apply_token_matches(prompt, mm_matches, mm_item_counts)
1452
+
1453
+ def _apply_text_matches(
1454
+ self,
1455
+ prompt: str,
1456
+ mm_matches: Mapping[str, Sequence[PromptTargetMatch]],
1457
+ mm_item_counts: Mapping[str, int],
1458
+ ) -> str:
1459
+ return apply_text_matches(prompt, mm_matches, mm_item_counts)
1460
+
1461
+ def _apply_prompt_updates(
1462
+ self,
1463
+ token_ids: list[int],
1464
+ mm_prompt_updates: Mapping[str, Sequence[BoundPromptUpdate]],
1465
+ mm_item_counts: Mapping[str, int],
1466
+ ) -> tuple[list[int], str, Mapping[str, list[PlaceholderFeaturesInfo]]]:
1467
+ tokenizer = self.info.get_tokenizer()
1468
+
1469
+ mm_token_matches = {
1470
+ modality: find_token_matches(token_ids, updates)
1471
+ for modality, updates in mm_prompt_updates.items()
1472
+ }
1473
+ mm_match_counts = {
1474
+ modality: len(matches)
1475
+ for modality, matches in mm_token_matches.items()
1476
+ }
1477
+
1478
+ # If the search text does not represent a special token,
1479
+ # it may have different token IDs in the prompt, because
1480
+ # the tokens may go across the boundaries of the search text.
1481
+ # ----
1482
+ # e.g. when searching for "foo" in "food", if "food" itself makes
1483
+ # up a token, then the token ID of "foo" will not appear at all
1484
+ # ----
1485
+ # Since it is inefficient to search for all possible tokenizations
1486
+ # of the search text in the prompt, we instead perform string-based
1487
+ # updates on the decoded token IDs, then encode them back.
1488
+ if all(
1489
+ mm_match_counts.get(modality, 0) >= item_count
1490
+ for modality, item_count in mm_item_counts.items()
1491
+ ): # yapf: disable
1492
+ token_ids = self._apply_token_matches(
1493
+ token_ids,
1494
+ mm_token_matches,
1495
+ mm_item_counts,
1496
+ )
1497
+
1498
+ text = decode_tokens(tokenizer, token_ids)
1499
+ matched_updates = {
1500
+ modality: [match._origin for match in token_matches]
1501
+ for modality, token_matches in mm_token_matches.items()
1502
+ }
1503
+ else:
1504
+ text = decode_tokens(tokenizer, token_ids)
1505
+
1506
+ mm_text_matches = {
1507
+ modality: find_text_matches(text, updates)
1508
+ for modality, updates in mm_prompt_updates.items()
1509
+ }
1510
+ text = self._apply_text_matches(
1511
+ text,
1512
+ mm_text_matches,
1513
+ mm_item_counts,
1514
+ )
1515
+
1516
+ token_ids = encode_tokens(tokenizer,
1517
+ text,
1518
+ add_special_tokens=False)
1519
+ matched_updates = {
1520
+ modality: [match._origin for match in token_matches]
1521
+ for modality, token_matches in mm_text_matches.items()
1522
+ }
1523
+
1524
+ placeholders = self._find_mm_placeholders(
1525
+ matched_updates,
1526
+ token_ids,
1527
+ mm_item_counts,
1528
+ )
1529
+
1530
+ return token_ids, text, placeholders
1531
+
1532
+ def _validate_mm_kwargs(
1533
+ self,
1534
+ mm_kwargs: MultiModalKwargs,
1535
+ mm_item_counts: Mapping[str, int],
1536
+ ) -> None:
1537
+ for modality, item_count in mm_item_counts.items():
1538
+ if modality in mm_kwargs.modalities:
1539
+ items = mm_kwargs.get_items(modality)
1540
+ else:
1541
+ items = []
1542
+
1543
+ if len(items) != item_count:
1544
+ raise RuntimeError(
1545
+ f"Expected there to be {item_count} {modality} items in "
1546
+ f"keyword arguments corresponding to {item_count} "
1547
+ f"{modality} data items, but only found {len(items)}! "
1548
+ "There is likely a problem with your "
1549
+ "implementation of merged multi-modal processor for this "
1550
+ "model (usually arising from an inconsistency between "
1551
+ "`_call_hf_processor` and `_get_mm_fields_config`).")
1552
+
1553
+ def _validate_mm_placeholders(
1554
+ self,
1555
+ mm_placeholders: Mapping[str, list[PlaceholderFeaturesInfo]],
1556
+ mm_item_counts: Mapping[str, int],
1557
+ ) -> None:
1558
+ for modality, item_count in mm_item_counts.items():
1559
+ placeholders = mm_placeholders.get(modality, [])
1560
+
1561
+ if len(placeholders) != item_count:
1562
+ raise RuntimeError(
1563
+ f"Expected there to be {item_count} prompt updates "
1564
+ f"corresponding to {item_count} {modality} items, but "
1565
+ f"instead found {len(placeholders)} prompt updates! "
1566
+ "Either the prompt text has missing/incorrect tokens for "
1567
+ "multi-modal inputs, or there is a problem with your "
1568
+ "implementation of merged multi-modal processor for this "
1569
+ "model (usually arising from an inconsistency between "
1570
+ "`_call_hf_processor` and `_get_prompt_updates`).")
1571
+
1572
+ def _hash_mm_items(
1573
+ self,
1574
+ mm_items: MultiModalDataItems,
1575
+ hf_processor_mm_kwargs: Mapping[str, object],
1576
+ ) -> dict[str, list[str]]:
1577
+ """Create MM hashes to be returned (only used in V1)."""
1578
+
1579
+ # TODO: Use these hash keys for caching operations in apply_hf_processor
1580
+ # instead of rehashing.
1581
+ model_id = self.info.model_id
1582
+
1583
+ return {
1584
+ modality: [
1585
+ MultiModalHasher.hash_kwargs(model_id=model_id,
1586
+ **{modality: item},
1587
+ **hf_processor_mm_kwargs)
1588
+ for item in items
1589
+ ]
1590
+ for modality, items in mm_items.items()
1591
+ }
1592
+
1593
+ def _maybe_apply_prompt_updates(
1594
+ self,
1595
+ mm_items: MultiModalDataItems,
1596
+ hf_processor_mm_kwargs: Mapping[str, object],
1597
+ prompt_ids: list[int],
1598
+ mm_kwargs: MultiModalKwargs,
1599
+ is_update_applied: bool,
1600
+ ) -> tuple[list[int], str, Mapping[str, list[PlaceholderFeaturesInfo]]]:
1601
+ unbound_prompt_updates = self._get_prompt_updates(
1602
+ mm_items,
1603
+ hf_processor_mm_kwargs,
1604
+ mm_kwargs,
1605
+ )
1606
+ mm_prompt_updates = self._bind_and_group_updates(
1607
+ unbound_prompt_updates)
1608
+
1609
+ mm_item_counts = mm_items.get_all_counts()
1610
+ self._validate_mm_kwargs(mm_kwargs, mm_item_counts)
1611
+
1612
+ if is_update_applied:
1613
+ mm_placeholders = self._find_mm_placeholders(
1614
+ mm_prompt_updates,
1615
+ prompt_ids,
1616
+ mm_item_counts,
1617
+ )
1618
+ self._validate_mm_placeholders(mm_placeholders, mm_item_counts)
1619
+
1620
+ tokenizer = self.info.get_tokenizer()
1621
+ prompt = decode_tokens(tokenizer, prompt_ids)
1622
+ else:
1623
+ (
1624
+ prompt_ids,
1625
+ prompt,
1626
+ mm_placeholders,
1627
+ ) = self._apply_prompt_updates(
1628
+ prompt_ids,
1629
+ mm_prompt_updates,
1630
+ mm_item_counts,
1631
+ )
1632
+ self._validate_mm_placeholders(mm_placeholders, mm_item_counts)
1633
+
1634
+ return prompt_ids, prompt, mm_placeholders
1635
+
1636
+ def apply(
1637
+ self,
1638
+ prompt: Union[str, list[int]],
1639
+ mm_data: MultiModalDataDict,
1640
+ hf_processor_mm_kwargs: Mapping[str, object],
1641
+ return_mm_hashes: bool = False,
1642
+ ) -> MultiModalInputs:
1643
+ """
1644
+ Process multi-modal inputs to be used in vLLM.
1645
+
1646
+ The main steps are:
1647
+
1648
+ 1. Apply HF Processor on prompt text and multi-modal data together,
1649
+ outputting token IDs and processed tensors.
1650
+ 2. Find and update sequences in the token IDs with placeholder tokens.
1651
+ The number of placeholder tokens equals the feature size of the
1652
+ multi-modal data outputted by the multi-modal encoder.
1653
+ 3. Extract information about the placeholder tokens from the
1654
+ processed token IDs.
1655
+ """
1656
+ mm_items = self._to_mm_items(mm_data)
1657
+
1658
+ mm_hashes = (self._hash_mm_items(mm_items, hf_processor_mm_kwargs)
1659
+ if return_mm_hashes else None)
1660
+
1661
+ (
1662
+ prompt_ids,
1663
+ mm_kwargs,
1664
+ is_update_applied,
1665
+ ) = self._cached_apply_hf_processor(
1666
+ prompt,
1667
+ mm_items,
1668
+ hf_processor_mm_kwargs,
1669
+ )
1670
+
1671
+ prompt_ids, prompt, mm_placeholders = self._maybe_apply_prompt_updates(
1672
+ mm_items=mm_items,
1673
+ hf_processor_mm_kwargs=hf_processor_mm_kwargs,
1674
+ prompt_ids=prompt_ids,
1675
+ mm_kwargs=mm_kwargs,
1676
+ is_update_applied=is_update_applied,
1677
+ )
1678
+
1679
+ mm_placeholder_ranges = {
1680
+ modality: [item.to_range() for item in placeholders]
1681
+ for modality, placeholders in mm_placeholders.items()
1682
+ }
1683
+
1684
+ return MultiModalInputs(
1685
+ type="multimodal",
1686
+ prompt=prompt,
1687
+ prompt_token_ids=prompt_ids,
1688
+ mm_kwargs=mm_kwargs,
1689
+ mm_hashes=mm_hashes,
1690
+ mm_placeholders=mm_placeholder_ranges,
1691
+ )
1692
+
1693
+
1694
+ class EncDecMultiModalProcessor(BaseMultiModalProcessor[_I]):
1695
+
1696
+ @abstractmethod
1697
+ def create_encoder_prompt(
1698
+ self,
1699
+ prompt: Union[str, list[int]],
1700
+ mm_data: MultiModalDataDict,
1701
+ ) -> Union[str, list[int]]:
1702
+ """
1703
+ Create input prompt for the encoder. HF processor will be applied on
1704
+ this prompt during profiling and generation.
1705
+ """
1706
+ raise NotImplementedError
1707
+
1708
+ @property
1709
+ def pad_dummy_encoder_prompt(self) -> bool:
1710
+ return False
1711
+
1712
+ def create_decoder_prompt(
1713
+ self,
1714
+ prompt: Union[str, list[int]],
1715
+ mm_data: MultiModalDataDict,
1716
+ ) -> Union[str, list[int]]:
1717
+ """Create input prompt for the decoder."""
1718
+ return prompt
1719
+
1720
+ def apply(
1721
+ self,
1722
+ prompt: Union[str, list[int]],
1723
+ mm_data: MultiModalDataDict,
1724
+ hf_processor_mm_kwargs: Mapping[str, object],
1725
+ return_mm_hashes: bool = False,
1726
+ ) -> MultiModalEncDecInputs:
1727
+ """
1728
+ Process multi-modal inputs to be used in vLLM.
1729
+ The main processing steps are modified to fit encoder-decoder model:
1730
+ 1. Create encoder prompt from input prompt text.
1731
+ 2. Apply the HF processor on encoder prompt.
1732
+ 3. Copy the input prompt text as decoder prompt inputs.
1733
+ """
1734
+ encoder_prompt = self.create_encoder_prompt(prompt, mm_data)
1735
+ encoder_inputs = super().apply(
1736
+ encoder_prompt,
1737
+ mm_data,
1738
+ hf_processor_mm_kwargs,
1739
+ return_mm_hashes,
1740
+ )
1741
+
1742
+ tokenizer = self.info.get_tokenizer()
1743
+ decoder_prompt = self.create_decoder_prompt(prompt, mm_data)
1744
+ if isinstance(decoder_prompt, str):
1745
+ decoder_prompt_ids = encode_tokens(tokenizer,
1746
+ decoder_prompt,
1747
+ add_special_tokens=False)
1748
+ else:
1749
+ decoder_prompt_ids = decoder_prompt
1750
+ decoder_prompt = decode_tokens(tokenizer, decoder_prompt)
1751
+
1752
+ mm_inputs = MultiModalEncDecInputs(
1753
+ encoder_prompt=encoder_inputs["prompt"],
1754
+ encoder_prompt_token_ids=encoder_inputs["prompt_token_ids"],
1755
+ **encoder_inputs)
1756
+ mm_inputs.update({
1757
+ "prompt": decoder_prompt,
1758
+ "prompt_token_ids": decoder_prompt_ids
1759
+ })
1760
+ return mm_inputs