vllm-cpu-avx512bf16 0.9.0.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.
Files changed (1175) hide show
  1. vllm/_C.abi3.so +0 -0
  2. vllm/__init__.py +170 -0
  3. vllm/_custom_ops.py +1742 -0
  4. vllm/_ipex_ops.py +243 -0
  5. vllm/_version.py +34 -0
  6. vllm/adapter_commons/__init__.py +0 -0
  7. vllm/adapter_commons/layers.py +15 -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 +44 -0
  14. vllm/assets/base.py +40 -0
  15. vllm/assets/image.py +33 -0
  16. vllm/assets/video.py +114 -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 +305 -0
  22. vllm/attention/backends/dual_chunk_flash_attn.py +1494 -0
  23. vllm/attention/backends/flash_attn.py +999 -0
  24. vllm/attention/backends/flashinfer.py +1100 -0
  25. vllm/attention/backends/flashmla.py +242 -0
  26. vllm/attention/backends/hpu_attn.py +309 -0
  27. vllm/attention/backends/ipex_attn.py +394 -0
  28. vllm/attention/backends/mla/__init__.py +0 -0
  29. vllm/attention/backends/mla/common.py +1381 -0
  30. vllm/attention/backends/pallas.py +347 -0
  31. vllm/attention/backends/placeholder_attn.py +399 -0
  32. vllm/attention/backends/rocm_aiter_mla.py +435 -0
  33. vllm/attention/backends/rocm_flash_attn.py +970 -0
  34. vllm/attention/backends/torch_sdpa.py +691 -0
  35. vllm/attention/backends/triton_mla.py +113 -0
  36. vllm/attention/backends/utils.py +609 -0
  37. vllm/attention/backends/xformers.py +798 -0
  38. vllm/attention/layer.py +452 -0
  39. vllm/attention/ops/__init__.py +0 -0
  40. vllm/attention/ops/blocksparse_attention/__init__.py +0 -0
  41. vllm/attention/ops/blocksparse_attention/blocksparse_attention_kernel.py +432 -0
  42. vllm/attention/ops/blocksparse_attention/interface.py +238 -0
  43. vllm/attention/ops/blocksparse_attention/utils.py +245 -0
  44. vllm/attention/ops/chunked_prefill_paged_decode.py +367 -0
  45. vllm/attention/ops/flashmla.py +115 -0
  46. vllm/attention/ops/hpu_paged_attn.py +87 -0
  47. vllm/attention/ops/ipex_attn.py +194 -0
  48. vllm/attention/ops/merge_attn_states.py +42 -0
  49. vllm/attention/ops/nki_flash_attn.py +905 -0
  50. vllm/attention/ops/paged_attn.py +255 -0
  51. vllm/attention/ops/prefix_prefill.py +901 -0
  52. vllm/attention/ops/rocm_aiter_mla.py +99 -0
  53. vllm/attention/ops/rocm_aiter_paged_attn.py +101 -0
  54. vllm/attention/ops/triton_decode_attention.py +673 -0
  55. vllm/attention/ops/triton_flash_attention.py +1374 -0
  56. vllm/attention/ops/triton_merge_attn_states.py +96 -0
  57. vllm/attention/ops/triton_unified_attention.py +337 -0
  58. vllm/attention/selector.py +186 -0
  59. vllm/attention/utils/fa_utils.py +54 -0
  60. vllm/beam_search.py +82 -0
  61. vllm/benchmarks/__init__.py +0 -0
  62. vllm/benchmarks/datasets.py +921 -0
  63. vllm/benchmarks/endpoint_request_func.py +160 -0
  64. vllm/benchmarks/latency.py +184 -0
  65. vllm/benchmarks/serve.py +925 -0
  66. vllm/benchmarks/throughput.py +609 -0
  67. vllm/benchmarks/utils.py +69 -0
  68. vllm/collect_env.py +818 -0
  69. vllm/compilation/__init__.py +0 -0
  70. vllm/compilation/activation_quant_fusion.py +88 -0
  71. vllm/compilation/backends.py +560 -0
  72. vllm/compilation/base_piecewise_backend.py +71 -0
  73. vllm/compilation/collective_fusion.py +126 -0
  74. vllm/compilation/compiler_interface.py +533 -0
  75. vllm/compilation/counter.py +33 -0
  76. vllm/compilation/cuda_piecewise_backend.py +213 -0
  77. vllm/compilation/decorators.py +249 -0
  78. vllm/compilation/fix_functionalization.py +190 -0
  79. vllm/compilation/fusion.py +617 -0
  80. vllm/compilation/fx_utils.py +61 -0
  81. vllm/compilation/inductor_pass.py +114 -0
  82. vllm/compilation/monitor.py +38 -0
  83. vllm/compilation/multi_output_match.py +108 -0
  84. vllm/compilation/noop_elimination.py +136 -0
  85. vllm/compilation/pass_manager.py +77 -0
  86. vllm/compilation/sequence_parallelism.py +267 -0
  87. vllm/compilation/torch25_custom_graph_pass.py +41 -0
  88. vllm/compilation/vllm_inductor_pass.py +66 -0
  89. vllm/compilation/wrapper.py +129 -0
  90. vllm/config.py +4600 -0
  91. vllm/connections.py +173 -0
  92. vllm/core/__init__.py +0 -0
  93. vllm/core/block/__init__.py +0 -0
  94. vllm/core/block/block_table.py +398 -0
  95. vllm/core/block/common.py +370 -0
  96. vllm/core/block/cpu_gpu_block_allocator.py +440 -0
  97. vllm/core/block/interfaces.py +318 -0
  98. vllm/core/block/naive_block.py +465 -0
  99. vllm/core/block/prefix_caching_block.py +1134 -0
  100. vllm/core/block/utils.py +27 -0
  101. vllm/core/block_manager.py +520 -0
  102. vllm/core/evictor.py +156 -0
  103. vllm/core/interfaces.py +134 -0
  104. vllm/core/placeholder_block_space_manager.py +99 -0
  105. vllm/core/scheduler.py +2092 -0
  106. vllm/device_allocator/__init__.py +0 -0
  107. vllm/device_allocator/cumem.py +280 -0
  108. vllm/distributed/__init__.py +5 -0
  109. vllm/distributed/communication_op.py +40 -0
  110. vllm/distributed/device_communicators/__init__.py +0 -0
  111. vllm/distributed/device_communicators/all2all.py +126 -0
  112. vllm/distributed/device_communicators/base_device_communicator.py +260 -0
  113. vllm/distributed/device_communicators/cpu_communicator.py +144 -0
  114. vllm/distributed/device_communicators/cuda_communicator.py +167 -0
  115. vllm/distributed/device_communicators/cuda_wrapper.py +179 -0
  116. vllm/distributed/device_communicators/custom_all_reduce.py +303 -0
  117. vllm/distributed/device_communicators/custom_all_reduce_utils.py +258 -0
  118. vllm/distributed/device_communicators/hpu_communicator.py +45 -0
  119. vllm/distributed/device_communicators/neuron_communicator.py +19 -0
  120. vllm/distributed/device_communicators/pynccl.py +217 -0
  121. vllm/distributed/device_communicators/pynccl_wrapper.py +340 -0
  122. vllm/distributed/device_communicators/shm_broadcast.py +541 -0
  123. vllm/distributed/device_communicators/tpu_communicator.py +102 -0
  124. vllm/distributed/device_communicators/xpu_communicator.py +54 -0
  125. vllm/distributed/kv_events.py +296 -0
  126. vllm/distributed/kv_transfer/README.md +29 -0
  127. vllm/distributed/kv_transfer/__init__.py +11 -0
  128. vllm/distributed/kv_transfer/disagg_prefill_workflow.jpg +0 -0
  129. vllm/distributed/kv_transfer/kv_connector/__init__.py +0 -0
  130. vllm/distributed/kv_transfer/kv_connector/base.py +127 -0
  131. vllm/distributed/kv_transfer/kv_connector/factory.py +126 -0
  132. vllm/distributed/kv_transfer/kv_connector/lmcache_connector.py +98 -0
  133. vllm/distributed/kv_transfer/kv_connector/mooncake_store_connector.py +202 -0
  134. vllm/distributed/kv_transfer/kv_connector/simple_connector.py +328 -0
  135. vllm/distributed/kv_transfer/kv_connector/utils.py +91 -0
  136. vllm/distributed/kv_transfer/kv_connector/v1/__init__.py +5 -0
  137. vllm/distributed/kv_transfer/kv_connector/v1/base.py +259 -0
  138. vllm/distributed/kv_transfer/kv_connector/v1/lmcache_connector.py +133 -0
  139. vllm/distributed/kv_transfer/kv_connector/v1/multi_connector.py +189 -0
  140. vllm/distributed/kv_transfer/kv_connector/v1/nixl_connector.py +851 -0
  141. vllm/distributed/kv_transfer/kv_connector/v1/shared_storage_connector.py +383 -0
  142. vllm/distributed/kv_transfer/kv_connector_agent.py +76 -0
  143. vllm/distributed/kv_transfer/kv_lookup_buffer/__init__.py +0 -0
  144. vllm/distributed/kv_transfer/kv_lookup_buffer/base.py +174 -0
  145. vllm/distributed/kv_transfer/kv_lookup_buffer/mooncake_store.py +160 -0
  146. vllm/distributed/kv_transfer/kv_lookup_buffer/simple_buffer.py +236 -0
  147. vllm/distributed/kv_transfer/kv_pipe/__init__.py +0 -0
  148. vllm/distributed/kv_transfer/kv_pipe/base.py +66 -0
  149. vllm/distributed/kv_transfer/kv_pipe/mooncake_pipe.py +279 -0
  150. vllm/distributed/kv_transfer/kv_pipe/pynccl_pipe.py +279 -0
  151. vllm/distributed/kv_transfer/kv_transfer_state.py +70 -0
  152. vllm/distributed/parallel_state.py +1294 -0
  153. vllm/distributed/utils.py +520 -0
  154. vllm/engine/__init__.py +0 -0
  155. vllm/engine/arg_utils.py +1649 -0
  156. vllm/engine/async_llm_engine.py +1274 -0
  157. vllm/engine/async_timeout.py +191 -0
  158. vllm/engine/llm_engine.py +2153 -0
  159. vllm/engine/metrics.py +717 -0
  160. vllm/engine/metrics_types.py +96 -0
  161. vllm/engine/multiprocessing/__init__.py +188 -0
  162. vllm/engine/multiprocessing/client.py +755 -0
  163. vllm/engine/multiprocessing/engine.py +459 -0
  164. vllm/engine/output_processor/__init__.py +0 -0
  165. vllm/engine/output_processor/interfaces.py +74 -0
  166. vllm/engine/output_processor/multi_step.py +215 -0
  167. vllm/engine/output_processor/single_step.py +144 -0
  168. vllm/engine/output_processor/stop_checker.py +130 -0
  169. vllm/engine/output_processor/util.py +27 -0
  170. vllm/engine/protocol.py +310 -0
  171. vllm/entrypoints/__init__.py +0 -0
  172. vllm/entrypoints/api_server.py +177 -0
  173. vllm/entrypoints/chat_utils.py +1298 -0
  174. vllm/entrypoints/cli/__init__.py +0 -0
  175. vllm/entrypoints/cli/benchmark/__init__.py +0 -0
  176. vllm/entrypoints/cli/benchmark/base.py +38 -0
  177. vllm/entrypoints/cli/benchmark/latency.py +29 -0
  178. vllm/entrypoints/cli/benchmark/main.py +53 -0
  179. vllm/entrypoints/cli/benchmark/serve.py +29 -0
  180. vllm/entrypoints/cli/benchmark/throughput.py +29 -0
  181. vllm/entrypoints/cli/collect_env.py +34 -0
  182. vllm/entrypoints/cli/main.py +62 -0
  183. vllm/entrypoints/cli/openai.py +204 -0
  184. vllm/entrypoints/cli/serve.py +141 -0
  185. vllm/entrypoints/cli/types.py +24 -0
  186. vllm/entrypoints/launcher.py +146 -0
  187. vllm/entrypoints/llm.py +1503 -0
  188. vllm/entrypoints/logger.py +49 -0
  189. vllm/entrypoints/openai/__init__.py +0 -0
  190. vllm/entrypoints/openai/api_server.py +1376 -0
  191. vllm/entrypoints/openai/cli_args.py +306 -0
  192. vllm/entrypoints/openai/logits_processors.py +89 -0
  193. vllm/entrypoints/openai/protocol.py +1890 -0
  194. vllm/entrypoints/openai/run_batch.py +439 -0
  195. vllm/entrypoints/openai/serving_chat.py +1192 -0
  196. vllm/entrypoints/openai/serving_classification.py +159 -0
  197. vllm/entrypoints/openai/serving_completion.py +590 -0
  198. vllm/entrypoints/openai/serving_embedding.py +200 -0
  199. vllm/entrypoints/openai/serving_engine.py +985 -0
  200. vllm/entrypoints/openai/serving_models.py +314 -0
  201. vllm/entrypoints/openai/serving_pooling.py +231 -0
  202. vllm/entrypoints/openai/serving_score.py +432 -0
  203. vllm/entrypoints/openai/serving_tokenization.py +151 -0
  204. vllm/entrypoints/openai/serving_transcription.py +421 -0
  205. vllm/entrypoints/openai/tool_parsers/__init__.py +22 -0
  206. vllm/entrypoints/openai/tool_parsers/abstract_tool_parser.py +163 -0
  207. vllm/entrypoints/openai/tool_parsers/deepseekv3_tool_parser.py +369 -0
  208. vllm/entrypoints/openai/tool_parsers/granite_20b_fc_tool_parser.py +258 -0
  209. vllm/entrypoints/openai/tool_parsers/granite_tool_parser.py +236 -0
  210. vllm/entrypoints/openai/tool_parsers/hermes_tool_parser.py +370 -0
  211. vllm/entrypoints/openai/tool_parsers/internlm2_tool_parser.py +215 -0
  212. vllm/entrypoints/openai/tool_parsers/jamba_tool_parser.py +307 -0
  213. vllm/entrypoints/openai/tool_parsers/llama4_pythonic_tool_parser.py +302 -0
  214. vllm/entrypoints/openai/tool_parsers/llama_tool_parser.py +266 -0
  215. vllm/entrypoints/openai/tool_parsers/mistral_tool_parser.py +342 -0
  216. vllm/entrypoints/openai/tool_parsers/phi4mini_tool_parser.py +111 -0
  217. vllm/entrypoints/openai/tool_parsers/pythonic_tool_parser.py +296 -0
  218. vllm/entrypoints/openai/tool_parsers/utils.py +123 -0
  219. vllm/entrypoints/score_utils.py +49 -0
  220. vllm/entrypoints/ssl.py +74 -0
  221. vllm/entrypoints/utils.py +219 -0
  222. vllm/env_override.py +34 -0
  223. vllm/envs.py +896 -0
  224. vllm/executor/__init__.py +0 -0
  225. vllm/executor/executor_base.py +400 -0
  226. vllm/executor/mp_distributed_executor.py +243 -0
  227. vllm/executor/msgspec_utils.py +29 -0
  228. vllm/executor/multiproc_worker_utils.py +312 -0
  229. vllm/executor/ray_distributed_executor.py +700 -0
  230. vllm/executor/ray_utils.py +398 -0
  231. vllm/executor/uniproc_executor.py +138 -0
  232. vllm/forward_context.py +147 -0
  233. vllm/inputs/__init__.py +40 -0
  234. vllm/inputs/data.py +330 -0
  235. vllm/inputs/parse.py +150 -0
  236. vllm/inputs/preprocess.py +908 -0
  237. vllm/inputs/registry.py +214 -0
  238. vllm/jsontree.py +79 -0
  239. vllm/logger.py +211 -0
  240. vllm/logging_utils/__init__.py +7 -0
  241. vllm/logging_utils/dump_input.py +84 -0
  242. vllm/logging_utils/formatter.py +17 -0
  243. vllm/logits_process.py +118 -0
  244. vllm/lora/__init__.py +0 -0
  245. vllm/lora/fully_sharded_layers.py +354 -0
  246. vllm/lora/layers.py +1284 -0
  247. vllm/lora/lora.py +198 -0
  248. vllm/lora/models.py +817 -0
  249. vllm/lora/ops/__init__.py +0 -0
  250. vllm/lora/ops/torch_ops/__init__.py +15 -0
  251. vllm/lora/ops/torch_ops/lora_ops.py +115 -0
  252. vllm/lora/ops/triton_ops/__init__.py +11 -0
  253. vllm/lora/ops/triton_ops/kernel_utils.py +242 -0
  254. vllm/lora/ops/triton_ops/lora_expand_op.py +289 -0
  255. vllm/lora/ops/triton_ops/lora_kernel_metadata.py +147 -0
  256. vllm/lora/ops/triton_ops/lora_shrink_op.py +243 -0
  257. vllm/lora/ops/triton_ops/utils.py +119 -0
  258. vllm/lora/ops/xla_ops/__init__.py +6 -0
  259. vllm/lora/ops/xla_ops/lora_ops.py +106 -0
  260. vllm/lora/ops/xla_ops/pallas.py +133 -0
  261. vllm/lora/peft_helper.py +135 -0
  262. vllm/lora/punica_wrapper/__init__.py +9 -0
  263. vllm/lora/punica_wrapper/punica_base.py +484 -0
  264. vllm/lora/punica_wrapper/punica_cpu.py +348 -0
  265. vllm/lora/punica_wrapper/punica_gpu.py +289 -0
  266. vllm/lora/punica_wrapper/punica_hpu.py +144 -0
  267. vllm/lora/punica_wrapper/punica_selector.py +19 -0
  268. vllm/lora/punica_wrapper/punica_tpu.py +325 -0
  269. vllm/lora/punica_wrapper/utils.py +163 -0
  270. vllm/lora/request.py +98 -0
  271. vllm/lora/resolver.py +84 -0
  272. vllm/lora/utils.py +239 -0
  273. vllm/lora/worker_manager.py +253 -0
  274. vllm/model_executor/__init__.py +15 -0
  275. vllm/model_executor/custom_op.py +151 -0
  276. vllm/model_executor/guided_decoding/__init__.py +180 -0
  277. vllm/model_executor/guided_decoding/guidance_decoding.py +62 -0
  278. vllm/model_executor/guided_decoding/guidance_logits_processors.py +103 -0
  279. vllm/model_executor/guided_decoding/guided_fields.py +42 -0
  280. vllm/model_executor/guided_decoding/lm_format_enforcer_decoding.py +66 -0
  281. vllm/model_executor/guided_decoding/outlines_decoding.py +154 -0
  282. vllm/model_executor/guided_decoding/outlines_logits_processors.py +283 -0
  283. vllm/model_executor/guided_decoding/utils.py +241 -0
  284. vllm/model_executor/guided_decoding/xgrammar_decoding.py +425 -0
  285. vllm/model_executor/layers/__init__.py +0 -0
  286. vllm/model_executor/layers/activation.py +368 -0
  287. vllm/model_executor/layers/fused_moe/__init__.py +53 -0
  288. vllm/model_executor/layers/fused_moe/configs/E=1,N=14336,device_name=NVIDIA_A100-SXM4-80GB,dtype=int8_w8a16.json +146 -0
  289. vllm/model_executor/layers/fused_moe/configs/E=1,N=14336,device_name=NVIDIA_A100-SXM4-80GB.json +146 -0
  290. vllm/model_executor/layers/fused_moe/configs/E=1,N=1792,device_name=NVIDIA_A100-SXM4-80GB,dtype=int8_w8a16.json +218 -0
  291. vllm/model_executor/layers/fused_moe/configs/E=1,N=1792,device_name=NVIDIA_A100-SXM4-80GB.json +218 -0
  292. vllm/model_executor/layers/fused_moe/configs/E=1,N=3072,device_name=NVIDIA_A100-SXM4-80GB,dtype=int8_w8a16.json +218 -0
  293. vllm/model_executor/layers/fused_moe/configs/E=1,N=3072,device_name=NVIDIA_H100_80GB_HBM3,dtype=int8_w8a16.json +218 -0
  294. vllm/model_executor/layers/fused_moe/configs/E=1,N=3072,device_name=NVIDIA_H100_80GB_HBM3.json +218 -0
  295. vllm/model_executor/layers/fused_moe/configs/E=1,N=3584,device_name=NVIDIA_A100-SXM4-80GB,dtype=int8_w8a16.json +218 -0
  296. vllm/model_executor/layers/fused_moe/configs/E=1,N=3584,device_name=NVIDIA_A100-SXM4-80GB.json +218 -0
  297. vllm/model_executor/layers/fused_moe/configs/E=1,N=7168,device_name=NVIDIA_A100-SXM4-80GB,dtype=int8_w8a16.json +218 -0
  298. vllm/model_executor/layers/fused_moe/configs/E=1,N=7168,device_name=NVIDIA_A100-SXM4-80GB.json +218 -0
  299. vllm/model_executor/layers/fused_moe/configs/E=128,N=1024,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8.json +164 -0
  300. vllm/model_executor/layers/fused_moe/configs/E=128,N=1024,device_name=AMD_Instinct_MI300X.json +200 -0
  301. vllm/model_executor/layers/fused_moe/configs/E=128,N=192,device_name=NVIDIA_A100-SXM4-80GB.json +146 -0
  302. vllm/model_executor/layers/fused_moe/configs/E=128,N=192,device_name=NVIDIA_H100_80GB_HBM3.json +146 -0
  303. vllm/model_executor/layers/fused_moe/configs/E=128,N=192,device_name=NVIDIA_H20.json +146 -0
  304. vllm/model_executor/layers/fused_moe/configs/E=128,N=192,device_name=NVIDIA_H200.json +146 -0
  305. vllm/model_executor/layers/fused_moe/configs/E=128,N=384,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  306. 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
  307. vllm/model_executor/layers/fused_moe/configs/E=128,N=384,device_name=NVIDIA_H20.json +146 -0
  308. 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
  309. vllm/model_executor/layers/fused_moe/configs/E=128,N=384,device_name=NVIDIA_H200.json +146 -0
  310. vllm/model_executor/layers/fused_moe/configs/E=128,N=512,device_name=NVIDIA_H100_80GB_HBM3.json +146 -0
  311. vllm/model_executor/layers/fused_moe/configs/E=128,N=768,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8,block_shape=[128,128].json +164 -0
  312. 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
  313. vllm/model_executor/layers/fused_moe/configs/E=128,N=768,device_name=NVIDIA_H20.json +146 -0
  314. 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
  315. vllm/model_executor/layers/fused_moe/configs/E=128,N=768,device_name=NVIDIA_H200.json +146 -0
  316. vllm/model_executor/layers/fused_moe/configs/E=128,N=96,device_name=NVIDIA_H20.json +146 -0
  317. vllm/model_executor/layers/fused_moe/configs/E=16,N=1024,device_name=AMD_Instinct_MI300X.json +200 -0
  318. vllm/model_executor/layers/fused_moe/configs/E=16,N=1024,device_name=NVIDIA_H100.json +146 -0
  319. vllm/model_executor/layers/fused_moe/configs/E=16,N=1344,device_name=NVIDIA_A100-SXM4-40GB.json +146 -0
  320. vllm/model_executor/layers/fused_moe/configs/E=16,N=1344,device_name=NVIDIA_A100-SXM4-80GB.json +146 -0
  321. vllm/model_executor/layers/fused_moe/configs/E=16,N=1344,device_name=NVIDIA_H100_80GB_HBM3.json +146 -0
  322. vllm/model_executor/layers/fused_moe/configs/E=16,N=14336,device_name=NVIDIA_A100-SXM4-80GB,dtype=int8_w8a16.json +146 -0
  323. vllm/model_executor/layers/fused_moe/configs/E=16,N=14336,device_name=NVIDIA_A100-SXM4-80GB.json +146 -0
  324. vllm/model_executor/layers/fused_moe/configs/E=16,N=1792,device_name=NVIDIA_A100-SXM4-80GB,dtype=int8_w8a16.json +218 -0
  325. vllm/model_executor/layers/fused_moe/configs/E=16,N=1792,device_name=NVIDIA_A100-SXM4-80GB.json +218 -0
  326. vllm/model_executor/layers/fused_moe/configs/E=16,N=2688,device_name=NVIDIA_A100-SXM4-80GB.json +146 -0
  327. vllm/model_executor/layers/fused_moe/configs/E=16,N=2688,device_name=NVIDIA_H100_80GB_HBM3.json +146 -0
  328. vllm/model_executor/layers/fused_moe/configs/E=16,N=3072,device_name=NVIDIA_A100-SXM4-80GB,dtype=int8_w8a16.json +146 -0
  329. vllm/model_executor/layers/fused_moe/configs/E=16,N=3072,device_name=NVIDIA_H100_80GB_HBM3,dtype=int8_w8a16.json +146 -0
  330. vllm/model_executor/layers/fused_moe/configs/E=16,N=3200,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8.json +130 -0
  331. vllm/model_executor/layers/fused_moe/configs/E=16,N=3584,device_name=NVIDIA_A100-SXM4-80GB,dtype=int8_w8a16.json +146 -0
  332. vllm/model_executor/layers/fused_moe/configs/E=16,N=3584,device_name=NVIDIA_A100-SXM4-80GB.json +218 -0
  333. vllm/model_executor/layers/fused_moe/configs/E=16,N=6400,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8.json +130 -0
  334. vllm/model_executor/layers/fused_moe/configs/E=16,N=7168,device_name=NVIDIA_A100-SXM4-80GB,dtype=int8_w8a16.json +146 -0
  335. vllm/model_executor/layers/fused_moe/configs/E=16,N=7168,device_name=NVIDIA_A100-SXM4-80GB.json +146 -0
  336. vllm/model_executor/layers/fused_moe/configs/E=16,N=7168,device_name=NVIDIA_H100_80GB_HBM3,dtype=int8_w8a16.json +146 -0
  337. vllm/model_executor/layers/fused_moe/configs/E=16,N=800,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8.json +130 -0
  338. vllm/model_executor/layers/fused_moe/configs/E=160,N=192,device_name=NVIDIA_A800-SXM4-80GB.json +146 -0
  339. vllm/model_executor/layers/fused_moe/configs/E=256,N=1024,device_name=AMD_Instinct_MI325X,block_shape=[128,128].json +200 -0
  340. 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
  341. 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
  342. vllm/model_executor/layers/fused_moe/configs/E=256,N=128,device_name=NVIDIA_A100-SXM4-80GB,dtype=int8_w8a8.json +146 -0
  343. 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
  344. vllm/model_executor/layers/fused_moe/configs/E=256,N=128,device_name=NVIDIA_A800-SXM4-80GB,dtype=int8_w8a8.json +146 -0
  345. 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
  346. 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
  347. 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
  348. 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
  349. 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
  350. 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
  351. 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
  352. vllm/model_executor/layers/fused_moe/configs/E=256,N=256,device_name=NVIDIA_H20,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
  353. 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
  354. 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
  355. 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
  356. 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
  357. vllm/model_executor/layers/fused_moe/configs/E=256,N=64,device_name=NVIDIA_A800-SXM4-80GB.json +146 -0
  358. vllm/model_executor/layers/fused_moe/configs/E=60,N=1408,device_name=AMD_Instinct_MI300X.json +200 -0
  359. vllm/model_executor/layers/fused_moe/configs/E=60,N=176,device_name=AMD_Instinct_MI300X.json +200 -0
  360. vllm/model_executor/layers/fused_moe/configs/E=60,N=352,device_name=AMD_Instinct_MI300X.json +200 -0
  361. vllm/model_executor/layers/fused_moe/configs/E=60,N=704,device_name=AMD_Instinct_MI300X.json +200 -0
  362. vllm/model_executor/layers/fused_moe/configs/E=64,N=1280,device_name=NVIDIA_A100-SXM4-80GB.json +146 -0
  363. vllm/model_executor/layers/fused_moe/configs/E=64,N=1280,device_name=NVIDIA_A800-SXM4-80GB.json +146 -0
  364. vllm/model_executor/layers/fused_moe/configs/E=64,N=1280,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8.json +146 -0
  365. vllm/model_executor/layers/fused_moe/configs/E=64,N=1280,device_name=NVIDIA_H100_80GB_HBM3.json +146 -0
  366. vllm/model_executor/layers/fused_moe/configs/E=64,N=1280,device_name=NVIDIA_H200,dtype=fp8_w8a8.json +146 -0
  367. vllm/model_executor/layers/fused_moe/configs/E=64,N=1280,device_name=NVIDIA_H200.json +146 -0
  368. vllm/model_executor/layers/fused_moe/configs/E=64,N=2560,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8.json +146 -0
  369. vllm/model_executor/layers/fused_moe/configs/E=64,N=2560,device_name=NVIDIA_H200,dtype=fp8_w8a8.json +146 -0
  370. vllm/model_executor/layers/fused_moe/configs/E=64,N=2560,device_name=NVIDIA_H200.json +146 -0
  371. vllm/model_executor/layers/fused_moe/configs/E=64,N=320,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8.json +146 -0
  372. vllm/model_executor/layers/fused_moe/configs/E=64,N=320,device_name=NVIDIA_H100_80GB_HBM3.json +146 -0
  373. vllm/model_executor/layers/fused_moe/configs/E=64,N=320,device_name=NVIDIA_H200,dtype=fp8_w8a8.json +146 -0
  374. vllm/model_executor/layers/fused_moe/configs/E=64,N=320,device_name=NVIDIA_H200.json +146 -0
  375. vllm/model_executor/layers/fused_moe/configs/E=64,N=640,device_name=NVIDIA_A100-SXM4-80GB.json +146 -0
  376. vllm/model_executor/layers/fused_moe/configs/E=64,N=640,device_name=NVIDIA_A800-SXM4-80GB.json +146 -0
  377. vllm/model_executor/layers/fused_moe/configs/E=64,N=640,device_name=NVIDIA_GeForce_RTX_4090,dtype=fp8_w8a8.json +146 -0
  378. vllm/model_executor/layers/fused_moe/configs/E=64,N=640,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8.json +146 -0
  379. vllm/model_executor/layers/fused_moe/configs/E=64,N=640,device_name=NVIDIA_H100_80GB_HBM3.json +146 -0
  380. vllm/model_executor/layers/fused_moe/configs/E=64,N=640,device_name=NVIDIA_H200,dtype=fp8_w8a8.json +146 -0
  381. vllm/model_executor/layers/fused_moe/configs/E=64,N=640,device_name=NVIDIA_H200.json +146 -0
  382. vllm/model_executor/layers/fused_moe/configs/E=64,N=896,device_name=NVIDIA_H20.json +146 -0
  383. vllm/model_executor/layers/fused_moe/configs/E=8,N=14336,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8.json +164 -0
  384. vllm/model_executor/layers/fused_moe/configs/E=8,N=14336,device_name=AMD_Instinct_MI300X.json +200 -0
  385. vllm/model_executor/layers/fused_moe/configs/E=8,N=14336,device_name=AMD_Instinct_MI325X,dtype=fp8_w8a8.json +164 -0
  386. vllm/model_executor/layers/fused_moe/configs/E=8,N=14336,device_name=AMD_Instinct_MI325X.json +200 -0
  387. vllm/model_executor/layers/fused_moe/configs/E=8,N=14336,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8.json +138 -0
  388. vllm/model_executor/layers/fused_moe/configs/E=8,N=14336,device_name=NVIDIA_H200,dtype=fp8_w8a8.json +146 -0
  389. vllm/model_executor/layers/fused_moe/configs/E=8,N=14336,device_name=NVIDIA_H200.json +146 -0
  390. vllm/model_executor/layers/fused_moe/configs/E=8,N=16384,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8.json +164 -0
  391. vllm/model_executor/layers/fused_moe/configs/E=8,N=16384,device_name=AMD_Instinct_MI300X.json +200 -0
  392. vllm/model_executor/layers/fused_moe/configs/E=8,N=16384,device_name=AMD_Instinct_MI325X,dtype=fp8_w8a8.json +164 -0
  393. vllm/model_executor/layers/fused_moe/configs/E=8,N=16384,device_name=AMD_Instinct_MI325X.json +200 -0
  394. vllm/model_executor/layers/fused_moe/configs/E=8,N=1792,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8.json +164 -0
  395. vllm/model_executor/layers/fused_moe/configs/E=8,N=1792,device_name=AMD_Instinct_MI300X.json +200 -0
  396. vllm/model_executor/layers/fused_moe/configs/E=8,N=1792,device_name=AMD_Instinct_MI325X,dtype=fp8_w8a8.json +164 -0
  397. vllm/model_executor/layers/fused_moe/configs/E=8,N=1792,device_name=AMD_Instinct_MI325X.json +200 -0
  398. vllm/model_executor/layers/fused_moe/configs/E=8,N=1792,device_name=NVIDIA_A100-SXM4-40GB.json +146 -0
  399. vllm/model_executor/layers/fused_moe/configs/E=8,N=1792,device_name=NVIDIA_A100-SXM4-80GB.json +146 -0
  400. vllm/model_executor/layers/fused_moe/configs/E=8,N=1792,device_name=NVIDIA_H100_80GB_HBM3.json +146 -0
  401. vllm/model_executor/layers/fused_moe/configs/E=8,N=1792,device_name=NVIDIA_H200,dtype=fp8_w8a8.json +146 -0
  402. vllm/model_executor/layers/fused_moe/configs/E=8,N=1792,device_name=NVIDIA_H200.json +146 -0
  403. vllm/model_executor/layers/fused_moe/configs/E=8,N=2048,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8.json +164 -0
  404. vllm/model_executor/layers/fused_moe/configs/E=8,N=2048,device_name=AMD_Instinct_MI300X.json +200 -0
  405. vllm/model_executor/layers/fused_moe/configs/E=8,N=2048,device_name=AMD_Instinct_MI325X,dtype=fp8_w8a8.json +164 -0
  406. vllm/model_executor/layers/fused_moe/configs/E=8,N=2048,device_name=AMD_Instinct_MI325X.json +200 -0
  407. vllm/model_executor/layers/fused_moe/configs/E=8,N=2048,device_name=NVIDIA_A100-SXM4-80GB.json +146 -0
  408. vllm/model_executor/layers/fused_moe/configs/E=8,N=2048,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8.json +146 -0
  409. vllm/model_executor/layers/fused_moe/configs/E=8,N=2048,device_name=NVIDIA_H100_80GB_HBM3.json +146 -0
  410. vllm/model_executor/layers/fused_moe/configs/E=8,N=2048,device_name=NVIDIA_H200,dtype=fp8_w8a8.json +146 -0
  411. vllm/model_executor/layers/fused_moe/configs/E=8,N=2048,device_name=NVIDIA_H200.json +146 -0
  412. vllm/model_executor/layers/fused_moe/configs/E=8,N=3584,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8.json +164 -0
  413. vllm/model_executor/layers/fused_moe/configs/E=8,N=3584,device_name=AMD_Instinct_MI300X.json +200 -0
  414. vllm/model_executor/layers/fused_moe/configs/E=8,N=3584,device_name=AMD_Instinct_MI325X,dtype=fp8_w8a8.json +164 -0
  415. vllm/model_executor/layers/fused_moe/configs/E=8,N=3584,device_name=AMD_Instinct_MI325X.json +200 -0
  416. vllm/model_executor/layers/fused_moe/configs/E=8,N=3584,device_name=NVIDIA_A100-SXM4-40GB.json +146 -0
  417. vllm/model_executor/layers/fused_moe/configs/E=8,N=3584,device_name=NVIDIA_A100-SXM4-80GB.json +146 -0
  418. vllm/model_executor/layers/fused_moe/configs/E=8,N=3584,device_name=NVIDIA_GeForce_RTX_4090,dtype=fp8_w8a8.json +146 -0
  419. vllm/model_executor/layers/fused_moe/configs/E=8,N=3584,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8.json +146 -0
  420. vllm/model_executor/layers/fused_moe/configs/E=8,N=3584,device_name=NVIDIA_H100_80GB_HBM3.json +146 -0
  421. vllm/model_executor/layers/fused_moe/configs/E=8,N=3584,device_name=NVIDIA_H200,dtype=fp8_w8a8.json +146 -0
  422. vllm/model_executor/layers/fused_moe/configs/E=8,N=3584,device_name=NVIDIA_H200.json +146 -0
  423. vllm/model_executor/layers/fused_moe/configs/E=8,N=3584,device_name=NVIDIA_L40S.json +173 -0
  424. vllm/model_executor/layers/fused_moe/configs/E=8,N=4096,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8.json +164 -0
  425. vllm/model_executor/layers/fused_moe/configs/E=8,N=4096,device_name=AMD_Instinct_MI300X.json +200 -0
  426. vllm/model_executor/layers/fused_moe/configs/E=8,N=4096,device_name=AMD_Instinct_MI325X,dtype=fp8_w8a8.json +164 -0
  427. vllm/model_executor/layers/fused_moe/configs/E=8,N=4096,device_name=AMD_Instinct_MI325X.json +200 -0
  428. vllm/model_executor/layers/fused_moe/configs/E=8,N=4096,device_name=NVIDIA_A100-SXM4-80GB.json +146 -0
  429. vllm/model_executor/layers/fused_moe/configs/E=8,N=4096,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8.json +146 -0
  430. vllm/model_executor/layers/fused_moe/configs/E=8,N=4096,device_name=NVIDIA_H100_80GB_HBM3.json +146 -0
  431. vllm/model_executor/layers/fused_moe/configs/E=8,N=4096,device_name=NVIDIA_H200,dtype=fp8_w8a8.json +146 -0
  432. vllm/model_executor/layers/fused_moe/configs/E=8,N=4096,device_name=NVIDIA_H200.json +146 -0
  433. vllm/model_executor/layers/fused_moe/configs/E=8,N=7168,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8.json +164 -0
  434. vllm/model_executor/layers/fused_moe/configs/E=8,N=7168,device_name=AMD_Instinct_MI300X.json +200 -0
  435. vllm/model_executor/layers/fused_moe/configs/E=8,N=7168,device_name=AMD_Instinct_MI325X,dtype=fp8_w8a8.json +164 -0
  436. vllm/model_executor/layers/fused_moe/configs/E=8,N=7168,device_name=AMD_Instinct_MI325X.json +200 -0
  437. vllm/model_executor/layers/fused_moe/configs/E=8,N=7168,device_name=NVIDIA_A100-SXM4-80GB.json +146 -0
  438. vllm/model_executor/layers/fused_moe/configs/E=8,N=7168,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8.json +146 -0
  439. vllm/model_executor/layers/fused_moe/configs/E=8,N=7168,device_name=NVIDIA_H100_80GB_HBM3.json +146 -0
  440. vllm/model_executor/layers/fused_moe/configs/E=8,N=7168,device_name=NVIDIA_H200,dtype=fp8_w8a8.json +146 -0
  441. vllm/model_executor/layers/fused_moe/configs/E=8,N=7168,device_name=NVIDIA_H200.json +146 -0
  442. vllm/model_executor/layers/fused_moe/configs/E=8,N=8192,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8.json +164 -0
  443. vllm/model_executor/layers/fused_moe/configs/E=8,N=8192,device_name=AMD_Instinct_MI300X.json +200 -0
  444. vllm/model_executor/layers/fused_moe/configs/E=8,N=8192,device_name=AMD_Instinct_MI325X,dtype=fp8_w8a8.json +164 -0
  445. vllm/model_executor/layers/fused_moe/configs/E=8,N=8192,device_name=AMD_Instinct_MI325X.json +200 -0
  446. vllm/model_executor/layers/fused_moe/configs/E=8,N=8192,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8.json +146 -0
  447. vllm/model_executor/layers/fused_moe/configs/E=8,N=8192,device_name=NVIDIA_H200,dtype=fp8_w8a8.json +146 -0
  448. vllm/model_executor/layers/fused_moe/configs/README +12 -0
  449. vllm/model_executor/layers/fused_moe/cutlass_moe.py +382 -0
  450. vllm/model_executor/layers/fused_moe/deep_gemm_moe.py +227 -0
  451. vllm/model_executor/layers/fused_moe/fused_batched_moe.py +755 -0
  452. vllm/model_executor/layers/fused_moe/fused_marlin_moe.py +231 -0
  453. vllm/model_executor/layers/fused_moe/fused_moe.py +1722 -0
  454. vllm/model_executor/layers/fused_moe/layer.py +1366 -0
  455. vllm/model_executor/layers/fused_moe/modular_kernel.py +364 -0
  456. vllm/model_executor/layers/fused_moe/moe_align_block_size.py +242 -0
  457. vllm/model_executor/layers/fused_moe/moe_pallas.py +83 -0
  458. vllm/model_executor/layers/fused_moe/moe_permute_unpermute.py +188 -0
  459. vllm/model_executor/layers/fused_moe/moe_torch_iterative.py +59 -0
  460. vllm/model_executor/layers/fused_moe/pplx_prepare_finalize.py +146 -0
  461. vllm/model_executor/layers/fused_moe/prepare_finalize.py +60 -0
  462. vllm/model_executor/layers/fused_moe/rocm_aiter_fused_moe.py +372 -0
  463. vllm/model_executor/layers/fused_moe/triton_deep_gemm_moe.py +112 -0
  464. vllm/model_executor/layers/fused_moe/utils.py +97 -0
  465. vllm/model_executor/layers/layernorm.py +287 -0
  466. vllm/model_executor/layers/lightning_attn.py +651 -0
  467. vllm/model_executor/layers/linear.py +1523 -0
  468. vllm/model_executor/layers/logits_processor.py +196 -0
  469. vllm/model_executor/layers/mamba/__init__.py +0 -0
  470. vllm/model_executor/layers/mamba/mamba2_metadata.py +124 -0
  471. vllm/model_executor/layers/mamba/mamba_mixer.py +244 -0
  472. vllm/model_executor/layers/mamba/mamba_mixer2.py +615 -0
  473. vllm/model_executor/layers/mamba/ops/__init__.py +0 -0
  474. vllm/model_executor/layers/mamba/ops/causal_conv1d.py +104 -0
  475. vllm/model_executor/layers/mamba/ops/mamba_ssm.py +413 -0
  476. vllm/model_executor/layers/mamba/ops/ssd_bmm.py +261 -0
  477. vllm/model_executor/layers/mamba/ops/ssd_chunk_scan.py +588 -0
  478. vllm/model_executor/layers/mamba/ops/ssd_chunk_state.py +750 -0
  479. vllm/model_executor/layers/mamba/ops/ssd_combined.py +231 -0
  480. vllm/model_executor/layers/mamba/ops/ssd_state_passing.py +205 -0
  481. vllm/model_executor/layers/pooler.py +343 -0
  482. vllm/model_executor/layers/quantization/__init__.py +156 -0
  483. vllm/model_executor/layers/quantization/aqlm.py +375 -0
  484. vllm/model_executor/layers/quantization/auto_round.py +308 -0
  485. vllm/model_executor/layers/quantization/awq.py +185 -0
  486. vllm/model_executor/layers/quantization/awq_marlin.py +518 -0
  487. vllm/model_executor/layers/quantization/awq_triton.py +319 -0
  488. vllm/model_executor/layers/quantization/base_config.py +150 -0
  489. vllm/model_executor/layers/quantization/bitblas.py +460 -0
  490. vllm/model_executor/layers/quantization/bitsandbytes.py +397 -0
  491. vllm/model_executor/layers/quantization/compressed_tensors/__init__.py +0 -0
  492. vllm/model_executor/layers/quantization/compressed_tensors/compressed_tensors.py +644 -0
  493. vllm/model_executor/layers/quantization/compressed_tensors/compressed_tensors_moe.py +1252 -0
  494. vllm/model_executor/layers/quantization/compressed_tensors/schemes/__init__.py +21 -0
  495. vllm/model_executor/layers/quantization/compressed_tensors/schemes/compressed_tensors_24.py +357 -0
  496. vllm/model_executor/layers/quantization/compressed_tensors/schemes/compressed_tensors_scheme.py +54 -0
  497. vllm/model_executor/layers/quantization/compressed_tensors/schemes/compressed_tensors_w4a16_24.py +159 -0
  498. vllm/model_executor/layers/quantization/compressed_tensors/schemes/compressed_tensors_w4a16_nvfp4.py +92 -0
  499. vllm/model_executor/layers/quantization/compressed_tensors/schemes/compressed_tensors_w8a16_fp8.py +120 -0
  500. vllm/model_executor/layers/quantization/compressed_tensors/schemes/compressed_tensors_w8a8_fp8.py +149 -0
  501. vllm/model_executor/layers/quantization/compressed_tensors/schemes/compressed_tensors_w8a8_int8.py +110 -0
  502. vllm/model_executor/layers/quantization/compressed_tensors/schemes/compressed_tensors_wNa16.py +200 -0
  503. vllm/model_executor/layers/quantization/compressed_tensors/triton_scaled_mm.py +205 -0
  504. vllm/model_executor/layers/quantization/compressed_tensors/utils.py +214 -0
  505. vllm/model_executor/layers/quantization/deepspeedfp.py +194 -0
  506. vllm/model_executor/layers/quantization/experts_int8.py +195 -0
  507. vllm/model_executor/layers/quantization/fbgemm_fp8.py +171 -0
  508. vllm/model_executor/layers/quantization/fp8.py +876 -0
  509. vllm/model_executor/layers/quantization/gguf.py +564 -0
  510. vllm/model_executor/layers/quantization/gptq.py +277 -0
  511. vllm/model_executor/layers/quantization/gptq_bitblas.py +444 -0
  512. vllm/model_executor/layers/quantization/gptq_marlin.py +647 -0
  513. vllm/model_executor/layers/quantization/gptq_marlin_24.py +296 -0
  514. vllm/model_executor/layers/quantization/hqq_marlin.py +331 -0
  515. vllm/model_executor/layers/quantization/ipex_quant.py +249 -0
  516. vllm/model_executor/layers/quantization/kernels/__init__.py +0 -0
  517. vllm/model_executor/layers/quantization/kernels/mixed_precision/MPLinearKernel.py +89 -0
  518. vllm/model_executor/layers/quantization/kernels/mixed_precision/__init__.py +82 -0
  519. vllm/model_executor/layers/quantization/kernels/mixed_precision/allspark.py +115 -0
  520. vllm/model_executor/layers/quantization/kernels/mixed_precision/bitblas.py +299 -0
  521. vllm/model_executor/layers/quantization/kernels/mixed_precision/exllama.py +142 -0
  522. vllm/model_executor/layers/quantization/kernels/mixed_precision/machete.py +119 -0
  523. vllm/model_executor/layers/quantization/kernels/mixed_precision/marlin.py +130 -0
  524. vllm/model_executor/layers/quantization/kernels/scaled_mm/ScaledMMLinearKernel.py +66 -0
  525. vllm/model_executor/layers/quantization/kernels/scaled_mm/__init__.py +86 -0
  526. vllm/model_executor/layers/quantization/kernels/scaled_mm/aiter.py +119 -0
  527. vllm/model_executor/layers/quantization/kernels/scaled_mm/cutlass.py +136 -0
  528. vllm/model_executor/layers/quantization/kernels/scaled_mm/triton.py +40 -0
  529. vllm/model_executor/layers/quantization/kernels/scaled_mm/xla.py +104 -0
  530. vllm/model_executor/layers/quantization/kv_cache.py +138 -0
  531. vllm/model_executor/layers/quantization/marlin.py +260 -0
  532. vllm/model_executor/layers/quantization/modelopt.py +734 -0
  533. vllm/model_executor/layers/quantization/moe_wna16.py +448 -0
  534. vllm/model_executor/layers/quantization/neuron_quant.py +68 -0
  535. vllm/model_executor/layers/quantization/ptpc_fp8.py +126 -0
  536. vllm/model_executor/layers/quantization/qqq.py +274 -0
  537. vllm/model_executor/layers/quantization/quark/__init__.py +0 -0
  538. vllm/model_executor/layers/quantization/quark/quark.py +440 -0
  539. vllm/model_executor/layers/quantization/quark/quark_moe.py +236 -0
  540. vllm/model_executor/layers/quantization/quark/schemes/__init__.py +8 -0
  541. vllm/model_executor/layers/quantization/quark/schemes/quark_scheme.py +54 -0
  542. vllm/model_executor/layers/quantization/quark/schemes/quark_w4a4_mxfp4.py +125 -0
  543. vllm/model_executor/layers/quantization/quark/schemes/quark_w8a8_fp8.py +145 -0
  544. vllm/model_executor/layers/quantization/quark/schemes/quark_w8a8_int8.py +121 -0
  545. vllm/model_executor/layers/quantization/quark/utils.py +104 -0
  546. vllm/model_executor/layers/quantization/schema.py +85 -0
  547. vllm/model_executor/layers/quantization/torchao.py +143 -0
  548. vllm/model_executor/layers/quantization/tpu_int8.py +120 -0
  549. vllm/model_executor/layers/quantization/utils/__init__.py +5 -0
  550. vllm/model_executor/layers/quantization/utils/allspark_utils.py +51 -0
  551. vllm/model_executor/layers/quantization/utils/bitblas_utils.py +207 -0
  552. 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
  553. 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
  554. 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
  555. 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
  556. 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
  557. 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
  558. 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
  559. 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
  560. 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
  561. 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
  562. 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
  563. 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
  564. 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
  565. 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
  566. 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
  567. 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
  568. 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
  569. 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
  570. 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
  571. 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
  572. 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
  573. 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
  574. 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
  575. 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
  576. 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
  577. 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
  578. 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
  579. 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
  580. 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
  581. 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
  582. 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
  583. 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
  584. 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
  585. 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
  586. 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
  587. 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
  588. 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
  589. 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
  590. 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
  591. 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
  592. 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
  593. 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
  594. 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
  595. 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
  596. 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
  597. 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
  598. 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
  599. 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
  600. 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
  601. 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
  602. 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
  603. 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
  604. 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
  605. 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
  606. 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
  607. 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
  608. 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
  609. 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
  610. 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
  611. 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
  612. 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
  613. 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
  614. 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
  615. 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
  616. 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
  617. 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
  618. 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
  619. 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
  620. 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
  621. 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
  622. 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
  623. 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
  624. 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
  625. 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
  626. 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
  627. 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
  628. 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
  629. 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
  630. 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
  631. 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
  632. 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
  633. 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
  634. 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
  635. 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
  636. 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
  637. 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
  638. 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
  639. 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
  640. 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
  641. 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
  642. 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
  643. 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
  644. 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
  645. 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
  646. 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
  647. 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
  648. 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
  649. 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
  650. 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
  651. 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
  652. 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
  653. 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
  654. 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
  655. 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
  656. 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
  657. 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
  658. 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
  659. 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
  660. 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
  661. 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
  662. 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
  663. 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
  664. 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
  665. 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
  666. 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
  667. 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
  668. 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
  669. 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
  670. 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
  671. 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
  672. 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
  673. 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
  674. 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
  675. 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
  676. 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
  677. 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
  678. 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
  679. 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
  680. 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
  681. 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
  682. 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
  683. 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
  684. 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
  685. 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
  686. 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
  687. 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
  688. 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
  689. 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
  690. 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
  691. 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
  692. 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
  693. 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
  694. 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
  695. 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
  696. 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
  697. 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
  698. 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
  699. 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
  700. 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
  701. 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
  702. 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
  703. 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
  704. 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
  705. 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
  706. 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
  707. 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
  708. 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
  709. 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
  710. 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
  711. 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
  712. 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
  713. 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
  714. 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
  715. 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
  716. 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
  717. 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
  718. 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
  719. 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
  720. 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
  721. 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
  722. 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
  723. 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
  724. 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
  725. 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
  726. 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
  727. 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
  728. 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
  729. 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
  730. 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
  731. 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
  732. 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
  733. 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
  734. 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
  735. 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
  736. 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
  737. 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
  738. 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
  739. 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
  740. 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
  741. 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
  742. 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
  743. 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
  744. 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
  745. 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
  746. 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
  747. 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
  748. 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
  749. 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
  750. 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
  751. 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
  752. 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
  753. 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
  754. vllm/model_executor/layers/quantization/utils/fp8_utils.py +611 -0
  755. vllm/model_executor/layers/quantization/utils/gptq_utils.py +94 -0
  756. vllm/model_executor/layers/quantization/utils/int8_utils.py +484 -0
  757. vllm/model_executor/layers/quantization/utils/layer_utils.py +39 -0
  758. vllm/model_executor/layers/quantization/utils/machete_utils.py +32 -0
  759. vllm/model_executor/layers/quantization/utils/marlin_utils.py +475 -0
  760. vllm/model_executor/layers/quantization/utils/marlin_utils_fp4.py +277 -0
  761. vllm/model_executor/layers/quantization/utils/marlin_utils_fp8.py +324 -0
  762. vllm/model_executor/layers/quantization/utils/marlin_utils_test.py +164 -0
  763. vllm/model_executor/layers/quantization/utils/marlin_utils_test_24.py +463 -0
  764. vllm/model_executor/layers/quantization/utils/marlin_utils_test_qqq.py +125 -0
  765. vllm/model_executor/layers/quantization/utils/mxfp4_utils.py +44 -0
  766. vllm/model_executor/layers/quantization/utils/nvfp4_emulation_utils.py +61 -0
  767. vllm/model_executor/layers/quantization/utils/quant_utils.py +572 -0
  768. vllm/model_executor/layers/quantization/utils/w8a8_utils.py +404 -0
  769. vllm/model_executor/layers/rejection_sampler.py +405 -0
  770. vllm/model_executor/layers/resampler.py +269 -0
  771. vllm/model_executor/layers/rotary_embedding.py +1861 -0
  772. vllm/model_executor/layers/sampler.py +1203 -0
  773. vllm/model_executor/layers/spec_decode_base_sampler.py +258 -0
  774. vllm/model_executor/layers/typical_acceptance_sampler.py +165 -0
  775. vllm/model_executor/layers/utils.py +99 -0
  776. vllm/model_executor/layers/vocab_parallel_embedding.py +486 -0
  777. vllm/model_executor/model_loader/__init__.py +75 -0
  778. vllm/model_executor/model_loader/base_loader.py +24 -0
  779. vllm/model_executor/model_loader/bitsandbytes_loader.py +582 -0
  780. vllm/model_executor/model_loader/default_loader.py +295 -0
  781. vllm/model_executor/model_loader/dummy_loader.py +37 -0
  782. vllm/model_executor/model_loader/gguf_loader.py +113 -0
  783. vllm/model_executor/model_loader/neuron.py +475 -0
  784. vllm/model_executor/model_loader/neuronx_distributed.py +622 -0
  785. vllm/model_executor/model_loader/runai_streamer_loader.py +120 -0
  786. vllm/model_executor/model_loader/sharded_state_loader.py +211 -0
  787. vllm/model_executor/model_loader/tensorizer.py +632 -0
  788. vllm/model_executor/model_loader/tensorizer_loader.py +122 -0
  789. vllm/model_executor/model_loader/utils.py +301 -0
  790. vllm/model_executor/model_loader/weight_utils.py +781 -0
  791. vllm/model_executor/models/__init__.py +27 -0
  792. vllm/model_executor/models/adapters.py +247 -0
  793. vllm/model_executor/models/aimv2.py +199 -0
  794. vllm/model_executor/models/arctic.py +558 -0
  795. vllm/model_executor/models/aria.py +656 -0
  796. vllm/model_executor/models/aya_vision.py +461 -0
  797. vllm/model_executor/models/baichuan.py +473 -0
  798. vllm/model_executor/models/bamba.py +542 -0
  799. vllm/model_executor/models/bart.py +937 -0
  800. vllm/model_executor/models/bert.py +517 -0
  801. vllm/model_executor/models/bert_with_rope.py +714 -0
  802. vllm/model_executor/models/blip.py +338 -0
  803. vllm/model_executor/models/blip2.py +717 -0
  804. vllm/model_executor/models/bloom.py +372 -0
  805. vllm/model_executor/models/chameleon.py +1135 -0
  806. vllm/model_executor/models/chatglm.py +477 -0
  807. vllm/model_executor/models/clip.py +411 -0
  808. vllm/model_executor/models/commandr.py +471 -0
  809. vllm/model_executor/models/constant_size_cache.py +136 -0
  810. vllm/model_executor/models/dbrx.py +471 -0
  811. vllm/model_executor/models/deepseek.py +485 -0
  812. vllm/model_executor/models/deepseek_mtp.py +268 -0
  813. vllm/model_executor/models/deepseek_v2.py +842 -0
  814. vllm/model_executor/models/deepseek_vl2.py +647 -0
  815. vllm/model_executor/models/eagle.py +259 -0
  816. vllm/model_executor/models/exaone.py +550 -0
  817. vllm/model_executor/models/fairseq2_llama.py +153 -0
  818. vllm/model_executor/models/falcon.py +509 -0
  819. vllm/model_executor/models/falcon_h1.py +684 -0
  820. vllm/model_executor/models/florence2.py +1102 -0
  821. vllm/model_executor/models/fuyu.py +388 -0
  822. vllm/model_executor/models/gemma.py +424 -0
  823. vllm/model_executor/models/gemma2.py +424 -0
  824. vllm/model_executor/models/gemma3.py +532 -0
  825. vllm/model_executor/models/gemma3_mm.py +708 -0
  826. vllm/model_executor/models/glm.py +22 -0
  827. vllm/model_executor/models/glm4.py +304 -0
  828. vllm/model_executor/models/glm4v.py +647 -0
  829. vllm/model_executor/models/gpt2.py +327 -0
  830. vllm/model_executor/models/gpt_bigcode.py +334 -0
  831. vllm/model_executor/models/gpt_j.py +338 -0
  832. vllm/model_executor/models/gpt_neox.py +331 -0
  833. vllm/model_executor/models/granite.py +492 -0
  834. vllm/model_executor/models/granite_speech.py +778 -0
  835. vllm/model_executor/models/granitemoe.py +436 -0
  836. vllm/model_executor/models/granitemoehybrid.py +585 -0
  837. vllm/model_executor/models/granitemoeshared.py +340 -0
  838. vllm/model_executor/models/gritlm.py +223 -0
  839. vllm/model_executor/models/grok1.py +545 -0
  840. vllm/model_executor/models/h2ovl.py +545 -0
  841. vllm/model_executor/models/idefics2_vision_model.py +388 -0
  842. vllm/model_executor/models/idefics3.py +767 -0
  843. vllm/model_executor/models/interfaces.py +571 -0
  844. vllm/model_executor/models/interfaces_base.py +163 -0
  845. vllm/model_executor/models/intern_vit.py +475 -0
  846. vllm/model_executor/models/internlm2.py +454 -0
  847. vllm/model_executor/models/internlm2_ve.py +146 -0
  848. vllm/model_executor/models/internvl.py +1405 -0
  849. vllm/model_executor/models/jais.py +372 -0
  850. vllm/model_executor/models/jamba.py +591 -0
  851. vllm/model_executor/models/kimi_vl.py +576 -0
  852. vllm/model_executor/models/llama.py +643 -0
  853. vllm/model_executor/models/llama4.py +531 -0
  854. vllm/model_executor/models/llama_eagle.py +166 -0
  855. vllm/model_executor/models/llama_eagle3.py +257 -0
  856. vllm/model_executor/models/llava.py +865 -0
  857. vllm/model_executor/models/llava_next.py +585 -0
  858. vllm/model_executor/models/llava_next_video.py +470 -0
  859. vllm/model_executor/models/llava_onevision.py +955 -0
  860. vllm/model_executor/models/mamba.py +272 -0
  861. vllm/model_executor/models/mamba2.py +302 -0
  862. vllm/model_executor/models/mamba_cache.py +75 -0
  863. vllm/model_executor/models/medusa.py +218 -0
  864. vllm/model_executor/models/mimo.py +191 -0
  865. vllm/model_executor/models/mimo_mtp.py +284 -0
  866. vllm/model_executor/models/minicpm.py +590 -0
  867. vllm/model_executor/models/minicpm3.py +229 -0
  868. vllm/model_executor/models/minicpmo.py +758 -0
  869. vllm/model_executor/models/minicpmv.py +1286 -0
  870. vllm/model_executor/models/minimax_cache.py +35 -0
  871. vllm/model_executor/models/minimax_text_01.py +1303 -0
  872. vllm/model_executor/models/minimax_vl_01.py +363 -0
  873. vllm/model_executor/models/mistral3.py +603 -0
  874. vllm/model_executor/models/mixtral.py +487 -0
  875. vllm/model_executor/models/mixtral_quant.py +452 -0
  876. vllm/model_executor/models/mllama.py +1623 -0
  877. vllm/model_executor/models/mllama4.py +838 -0
  878. vllm/model_executor/models/mlp_speculator.py +205 -0
  879. vllm/model_executor/models/modernbert.py +329 -0
  880. vllm/model_executor/models/module_mapping.py +71 -0
  881. vllm/model_executor/models/molmo.py +1567 -0
  882. vllm/model_executor/models/moonvit.py +629 -0
  883. vllm/model_executor/models/mpt.py +330 -0
  884. vllm/model_executor/models/nemotron.py +507 -0
  885. vllm/model_executor/models/nemotron_nas.py +483 -0
  886. vllm/model_executor/models/nvlm_d.py +215 -0
  887. vllm/model_executor/models/olmo.py +388 -0
  888. vllm/model_executor/models/olmo2.py +413 -0
  889. vllm/model_executor/models/olmoe.py +446 -0
  890. vllm/model_executor/models/opt.py +411 -0
  891. vllm/model_executor/models/orion.py +348 -0
  892. vllm/model_executor/models/ovis.py +554 -0
  893. vllm/model_executor/models/paligemma.py +397 -0
  894. vllm/model_executor/models/persimmon.py +343 -0
  895. vllm/model_executor/models/phi.py +355 -0
  896. vllm/model_executor/models/phi3.py +18 -0
  897. vllm/model_executor/models/phi3_small.py +464 -0
  898. vllm/model_executor/models/phi3v.py +722 -0
  899. vllm/model_executor/models/phi4mm.py +1245 -0
  900. vllm/model_executor/models/phi4mm_audio.py +1232 -0
  901. vllm/model_executor/models/phi4mm_utils.py +1883 -0
  902. vllm/model_executor/models/phimoe.py +664 -0
  903. vllm/model_executor/models/pixtral.py +1315 -0
  904. vllm/model_executor/models/plamo2.py +737 -0
  905. vllm/model_executor/models/prithvi_geospatial_mae.py +231 -0
  906. vllm/model_executor/models/qwen.py +361 -0
  907. vllm/model_executor/models/qwen2.py +567 -0
  908. vllm/model_executor/models/qwen2_5_omni_thinker.py +903 -0
  909. vllm/model_executor/models/qwen2_5_vl.py +1171 -0
  910. vllm/model_executor/models/qwen2_audio.py +409 -0
  911. vllm/model_executor/models/qwen2_moe.py +539 -0
  912. vllm/model_executor/models/qwen2_rm.py +131 -0
  913. vllm/model_executor/models/qwen2_vl.py +1410 -0
  914. vllm/model_executor/models/qwen3.py +320 -0
  915. vllm/model_executor/models/qwen3_moe.py +534 -0
  916. vllm/model_executor/models/qwen_vl.py +784 -0
  917. vllm/model_executor/models/registry.py +618 -0
  918. vllm/model_executor/models/roberta.py +273 -0
  919. vllm/model_executor/models/siglip.py +523 -0
  920. vllm/model_executor/models/skyworkr1v.py +950 -0
  921. vllm/model_executor/models/smolvlm.py +51 -0
  922. vllm/model_executor/models/solar.py +505 -0
  923. vllm/model_executor/models/stablelm.py +342 -0
  924. vllm/model_executor/models/starcoder2.py +355 -0
  925. vllm/model_executor/models/telechat2.py +139 -0
  926. vllm/model_executor/models/teleflm.py +78 -0
  927. vllm/model_executor/models/transformers.py +507 -0
  928. vllm/model_executor/models/ultravox.py +655 -0
  929. vllm/model_executor/models/utils.py +730 -0
  930. vllm/model_executor/models/vision.py +146 -0
  931. vllm/model_executor/models/whisper.py +746 -0
  932. vllm/model_executor/models/zamba2.py +1008 -0
  933. vllm/model_executor/parameter.py +458 -0
  934. vllm/model_executor/pooling_metadata.py +71 -0
  935. vllm/model_executor/sampling_metadata.py +596 -0
  936. vllm/model_executor/utils.py +53 -0
  937. vllm/multimodal/__init__.py +32 -0
  938. vllm/multimodal/audio.py +105 -0
  939. vllm/multimodal/base.py +218 -0
  940. vllm/multimodal/hasher.py +117 -0
  941. vllm/multimodal/image.py +96 -0
  942. vllm/multimodal/inputs.py +872 -0
  943. vllm/multimodal/parse.py +460 -0
  944. vllm/multimodal/processing.py +1894 -0
  945. vllm/multimodal/profiling.py +273 -0
  946. vllm/multimodal/registry.py +330 -0
  947. vllm/multimodal/utils.py +392 -0
  948. vllm/multimodal/video.py +197 -0
  949. vllm/outputs.py +525 -0
  950. vllm/platforms/__init__.py +290 -0
  951. vllm/platforms/cpu.py +205 -0
  952. vllm/platforms/cuda.py +461 -0
  953. vllm/platforms/hpu.py +105 -0
  954. vllm/platforms/interface.py +492 -0
  955. vllm/platforms/neuron.py +152 -0
  956. vllm/platforms/rocm.py +388 -0
  957. vllm/platforms/tpu.py +215 -0
  958. vllm/platforms/xpu.py +155 -0
  959. vllm/plugins/__init__.py +86 -0
  960. vllm/plugins/lora_resolvers/README.md +15 -0
  961. vllm/plugins/lora_resolvers/__init__.py +0 -0
  962. vllm/plugins/lora_resolvers/filesystem_resolver.py +49 -0
  963. vllm/pooling_params.py +53 -0
  964. vllm/profiler/__init__.py +0 -0
  965. vllm/profiler/layerwise_profile.py +374 -0
  966. vllm/profiler/utils.py +147 -0
  967. vllm/prompt_adapter/__init__.py +0 -0
  968. vllm/prompt_adapter/layers.py +82 -0
  969. vllm/prompt_adapter/models.py +357 -0
  970. vllm/prompt_adapter/request.py +36 -0
  971. vllm/prompt_adapter/utils.py +97 -0
  972. vllm/prompt_adapter/worker_manager.py +178 -0
  973. vllm/py.typed +2 -0
  974. vllm/reasoning/__init__.py +14 -0
  975. vllm/reasoning/abs_reasoning_parsers.py +191 -0
  976. vllm/reasoning/deepseek_r1_reasoning_parser.py +172 -0
  977. vllm/reasoning/granite_reasoning_parser.py +362 -0
  978. vllm/reasoning/qwen3_reasoning_parser.py +150 -0
  979. vllm/sampling_params.py +590 -0
  980. vllm/scalar_type.py +346 -0
  981. vllm/scripts.py +14 -0
  982. vllm/sequence.py +1567 -0
  983. vllm/spec_decode/__init__.py +0 -0
  984. vllm/spec_decode/batch_expansion.py +505 -0
  985. vllm/spec_decode/draft_model_runner.py +349 -0
  986. vllm/spec_decode/interfaces.py +98 -0
  987. vllm/spec_decode/medusa_worker.py +137 -0
  988. vllm/spec_decode/metrics.py +212 -0
  989. vllm/spec_decode/mlp_speculator_worker.py +93 -0
  990. vllm/spec_decode/mqa_scorer.py +159 -0
  991. vllm/spec_decode/multi_step_worker.py +422 -0
  992. vllm/spec_decode/ngram_worker.py +195 -0
  993. vllm/spec_decode/proposer_worker_base.py +58 -0
  994. vllm/spec_decode/smaller_tp_proposer_worker.py +195 -0
  995. vllm/spec_decode/spec_decode_worker.py +1325 -0
  996. vllm/spec_decode/target_model_runner.py +44 -0
  997. vllm/spec_decode/top1_proposer.py +274 -0
  998. vllm/spec_decode/util.py +276 -0
  999. vllm/test_utils.py +129 -0
  1000. vllm/third_party/__init__.py +0 -0
  1001. vllm/third_party/pynvml.py +6139 -0
  1002. vllm/tracing.py +130 -0
  1003. vllm/transformers_utils/__init__.py +23 -0
  1004. vllm/transformers_utils/chat_templates/__init__.py +4 -0
  1005. vllm/transformers_utils/chat_templates/registry.py +59 -0
  1006. vllm/transformers_utils/chat_templates/template_basic.jinja +3 -0
  1007. vllm/transformers_utils/chat_templates/template_blip2.jinja +11 -0
  1008. vllm/transformers_utils/chat_templates/template_chatml.jinja +10 -0
  1009. vllm/transformers_utils/chat_templates/template_deepseek_vl2.jinja +23 -0
  1010. vllm/transformers_utils/chat_templates/template_fuyu.jinja +3 -0
  1011. vllm/transformers_utils/config.py +835 -0
  1012. vllm/transformers_utils/configs/__init__.py +58 -0
  1013. vllm/transformers_utils/configs/arctic.py +206 -0
  1014. vllm/transformers_utils/configs/chatglm.py +71 -0
  1015. vllm/transformers_utils/configs/cohere2.py +194 -0
  1016. vllm/transformers_utils/configs/dbrx.py +279 -0
  1017. vllm/transformers_utils/configs/deepseek_vl2.py +215 -0
  1018. vllm/transformers_utils/configs/eagle.py +84 -0
  1019. vllm/transformers_utils/configs/exaone.py +189 -0
  1020. vllm/transformers_utils/configs/falcon.py +89 -0
  1021. vllm/transformers_utils/configs/h2ovl.py +15 -0
  1022. vllm/transformers_utils/configs/internvl.py +53 -0
  1023. vllm/transformers_utils/configs/jais.py +237 -0
  1024. vllm/transformers_utils/configs/kimi_vl.py +36 -0
  1025. vllm/transformers_utils/configs/medusa.py +62 -0
  1026. vllm/transformers_utils/configs/minimax_text_01.py +69 -0
  1027. vllm/transformers_utils/configs/minimax_vl_01.py +70 -0
  1028. vllm/transformers_utils/configs/mllama.py +30 -0
  1029. vllm/transformers_utils/configs/mlp_speculator.py +67 -0
  1030. vllm/transformers_utils/configs/moonvit.py +32 -0
  1031. vllm/transformers_utils/configs/mpt.py +179 -0
  1032. vllm/transformers_utils/configs/nemotron.py +204 -0
  1033. vllm/transformers_utils/configs/nvlm_d.py +14 -0
  1034. vllm/transformers_utils/configs/ovis.py +183 -0
  1035. vllm/transformers_utils/configs/skyworkr1v.py +53 -0
  1036. vllm/transformers_utils/configs/solar.py +246 -0
  1037. vllm/transformers_utils/configs/telechat2.py +63 -0
  1038. vllm/transformers_utils/configs/ultravox.py +107 -0
  1039. vllm/transformers_utils/detokenizer.py +167 -0
  1040. vllm/transformers_utils/detokenizer_utils.py +188 -0
  1041. vllm/transformers_utils/processor.py +220 -0
  1042. vllm/transformers_utils/processors/__init__.py +7 -0
  1043. vllm/transformers_utils/processors/deepseek_vl2.py +362 -0
  1044. vllm/transformers_utils/processors/ovis.py +419 -0
  1045. vllm/transformers_utils/s3_utils.py +161 -0
  1046. vllm/transformers_utils/tokenizer.py +301 -0
  1047. vllm/transformers_utils/tokenizer_base.py +148 -0
  1048. vllm/transformers_utils/tokenizer_group.py +119 -0
  1049. vllm/transformers_utils/tokenizers/__init__.py +9 -0
  1050. vllm/transformers_utils/tokenizers/mistral.py +490 -0
  1051. vllm/transformers_utils/utils.py +98 -0
  1052. vllm/triton_utils/__init__.py +13 -0
  1053. vllm/triton_utils/importing.py +49 -0
  1054. vllm/usage/__init__.py +0 -0
  1055. vllm/usage/usage_lib.py +255 -0
  1056. vllm/utils.py +2844 -0
  1057. vllm/v1/__init__.py +0 -0
  1058. vllm/v1/attention/__init__.py +0 -0
  1059. vllm/v1/attention/backends/__init__.py +0 -0
  1060. vllm/v1/attention/backends/flash_attn.py +833 -0
  1061. vllm/v1/attention/backends/flashinfer.py +639 -0
  1062. vllm/v1/attention/backends/mla/__init__.py +0 -0
  1063. vllm/v1/attention/backends/mla/common.py +926 -0
  1064. vllm/v1/attention/backends/mla/flashmla.py +150 -0
  1065. vllm/v1/attention/backends/mla/rocm_aiter_mla.py +221 -0
  1066. vllm/v1/attention/backends/mla/triton_mla.py +118 -0
  1067. vllm/v1/attention/backends/pallas.py +235 -0
  1068. vllm/v1/attention/backends/triton_attn.py +279 -0
  1069. vllm/v1/attention/backends/utils.py +18 -0
  1070. vllm/v1/core/__init__.py +0 -0
  1071. vllm/v1/core/block_pool.py +328 -0
  1072. vllm/v1/core/encoder_cache_manager.py +149 -0
  1073. vllm/v1/core/kv_cache_manager.py +372 -0
  1074. vllm/v1/core/kv_cache_utils.py +748 -0
  1075. vllm/v1/core/sched/__init__.py +0 -0
  1076. vllm/v1/core/sched/interface.py +143 -0
  1077. vllm/v1/core/sched/output.py +153 -0
  1078. vllm/v1/core/sched/scheduler.py +1015 -0
  1079. vllm/v1/core/sched/utils.py +22 -0
  1080. vllm/v1/core/single_type_kv_cache_manager.py +358 -0
  1081. vllm/v1/engine/__init__.py +171 -0
  1082. vllm/v1/engine/async_llm.py +546 -0
  1083. vllm/v1/engine/core.py +801 -0
  1084. vllm/v1/engine/core_client.py +1020 -0
  1085. vllm/v1/engine/detokenizer.py +260 -0
  1086. vllm/v1/engine/exceptions.py +16 -0
  1087. vllm/v1/engine/llm_engine.py +316 -0
  1088. vllm/v1/engine/logprobs.py +198 -0
  1089. vllm/v1/engine/mm_input_cache.py +90 -0
  1090. vllm/v1/engine/output_processor.py +427 -0
  1091. vllm/v1/engine/parallel_sampling.py +132 -0
  1092. vllm/v1/engine/processor.py +398 -0
  1093. vllm/v1/executor/__init__.py +0 -0
  1094. vllm/v1/executor/abstract.py +112 -0
  1095. vllm/v1/executor/multiproc_executor.py +532 -0
  1096. vllm/v1/executor/ray_distributed_executor.py +61 -0
  1097. vllm/v1/kv_cache_interface.py +208 -0
  1098. vllm/v1/metrics/__init__.py +0 -0
  1099. vllm/v1/metrics/loggers.py +511 -0
  1100. vllm/v1/metrics/ray_wrappers.py +120 -0
  1101. vllm/v1/metrics/reader.py +245 -0
  1102. vllm/v1/metrics/stats.py +238 -0
  1103. vllm/v1/outputs.py +115 -0
  1104. vllm/v1/request.py +191 -0
  1105. vllm/v1/sample/__init__.py +0 -0
  1106. vllm/v1/sample/metadata.py +43 -0
  1107. vllm/v1/sample/ops/__init__.py +0 -0
  1108. vllm/v1/sample/ops/bad_words.py +38 -0
  1109. vllm/v1/sample/ops/penalties.py +58 -0
  1110. vllm/v1/sample/ops/topk_topp_sampler.py +292 -0
  1111. vllm/v1/sample/rejection_sampler.py +630 -0
  1112. vllm/v1/sample/sampler.py +270 -0
  1113. vllm/v1/sample/tpu/__init__.py +0 -0
  1114. vllm/v1/sample/tpu/metadata.py +123 -0
  1115. vllm/v1/sample/tpu/sampler.py +144 -0
  1116. vllm/v1/serial_utils.py +313 -0
  1117. vllm/v1/spec_decode/__init__.py +0 -0
  1118. vllm/v1/spec_decode/eagle.py +424 -0
  1119. vllm/v1/spec_decode/medusa.py +61 -0
  1120. vllm/v1/spec_decode/metadata.py +61 -0
  1121. vllm/v1/spec_decode/metrics.py +177 -0
  1122. vllm/v1/spec_decode/ngram_proposer.py +131 -0
  1123. vllm/v1/spec_decode/utils.py +45 -0
  1124. vllm/v1/structured_output/__init__.py +215 -0
  1125. vllm/v1/structured_output/backend_guidance.py +244 -0
  1126. vllm/v1/structured_output/backend_types.py +133 -0
  1127. vllm/v1/structured_output/backend_xgrammar.py +317 -0
  1128. vllm/v1/structured_output/request.py +85 -0
  1129. vllm/v1/structured_output/utils.py +174 -0
  1130. vllm/v1/utils.py +294 -0
  1131. vllm/v1/worker/__init__.py +0 -0
  1132. vllm/v1/worker/block_table.py +139 -0
  1133. vllm/v1/worker/gpu_input_batch.py +680 -0
  1134. vllm/v1/worker/gpu_model_runner.py +2084 -0
  1135. vllm/v1/worker/gpu_worker.py +373 -0
  1136. vllm/v1/worker/lora_model_runner_mixin.py +145 -0
  1137. vllm/v1/worker/tpu_model_runner.py +1510 -0
  1138. vllm/v1/worker/tpu_worker.py +276 -0
  1139. vllm/v1/worker/utils.py +74 -0
  1140. vllm/v1/worker/worker_base.py +64 -0
  1141. vllm/version.py +40 -0
  1142. vllm/vllm_flash_attn/.gitkeep +0 -0
  1143. vllm/worker/__init__.py +0 -0
  1144. vllm/worker/cache_engine.py +144 -0
  1145. vllm/worker/cpu_enc_dec_model_runner.py +326 -0
  1146. vllm/worker/cpu_model_runner.py +671 -0
  1147. vllm/worker/cpu_pooling_model_runner.py +125 -0
  1148. vllm/worker/cpu_worker.py +400 -0
  1149. vllm/worker/enc_dec_model_runner.py +555 -0
  1150. vllm/worker/hpu_model_runner.py +2319 -0
  1151. vllm/worker/hpu_worker.py +483 -0
  1152. vllm/worker/model_runner.py +2178 -0
  1153. vllm/worker/model_runner_base.py +281 -0
  1154. vllm/worker/multi_step_hpu_worker.py +122 -0
  1155. vllm/worker/multi_step_model_runner.py +910 -0
  1156. vllm/worker/multi_step_neuron_model_runner.py +84 -0
  1157. vllm/worker/multi_step_neuronx_distributed_model_runner.py +63 -0
  1158. vllm/worker/multi_step_tpu_worker.py +107 -0
  1159. vllm/worker/multi_step_worker.py +196 -0
  1160. vllm/worker/neuron_model_runner.py +418 -0
  1161. vllm/worker/neuron_worker.py +158 -0
  1162. vllm/worker/neuronx_distributed_model_runner.py +136 -0
  1163. vllm/worker/pooling_model_runner.py +211 -0
  1164. vllm/worker/tpu_model_runner.py +908 -0
  1165. vllm/worker/tpu_worker.py +336 -0
  1166. vllm/worker/utils.py +52 -0
  1167. vllm/worker/worker.py +574 -0
  1168. vllm/worker/worker_base.py +644 -0
  1169. vllm/worker/xpu_model_runner.py +606 -0
  1170. vllm/worker/xpu_worker.py +185 -0
  1171. vllm_cpu_avx512bf16-0.9.0.post2.dist-info/METADATA +335 -0
  1172. vllm_cpu_avx512bf16-0.9.0.post2.dist-info/RECORD +1175 -0
  1173. vllm_cpu_avx512bf16-0.9.0.post2.dist-info/WHEEL +5 -0
  1174. vllm_cpu_avx512bf16-0.9.0.post2.dist-info/entry_points.txt +5 -0
  1175. vllm_cpu_avx512bf16-0.9.0.post2.dist-info/top_level.txt +1 -0
@@ -0,0 +1,1494 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ """Attention layer with Dual chunk flash attention and sparse attention.
3
+ """
4
+ import math
5
+ from dataclasses import dataclass
6
+ from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Type
7
+
8
+ import torch
9
+ import torch.distributed
10
+ import torch.nn.functional as F
11
+
12
+ from vllm import _custom_ops as ops
13
+ from vllm.attention.backends.abstract import AttentionLayer, AttentionType
14
+ from vllm.attention.backends.flash_attn import (FlashAttentionBackend,
15
+ FlashAttentionImpl,
16
+ FlashAttentionMetadata,
17
+ FlashAttentionMetadataBuilder)
18
+ from vllm.distributed.parallel_state import get_tensor_model_parallel_rank
19
+ from vllm.logger import init_logger
20
+ from vllm.utils import async_tensor_h2d
21
+ from vllm.vllm_flash_attn import (flash_attn_varlen_func,
22
+ flash_attn_with_kvcache, sparse_attn_func)
23
+
24
+ if TYPE_CHECKING:
25
+ from vllm.worker.model_runner import ModelInputForGPUBuilder
26
+
27
+ logger = init_logger(__name__)
28
+
29
+
30
+ class DualChunkFlashAttentionBackend(FlashAttentionBackend):
31
+
32
+ accept_output_buffer: bool = False
33
+
34
+ @staticmethod
35
+ def get_name() -> str:
36
+ return "DUAL_CHUNK_FLASH_ATTN"
37
+
38
+ @staticmethod
39
+ def get_impl_cls() -> Type["DualChunkFlashAttentionImpl"]:
40
+ return DualChunkFlashAttentionImpl
41
+
42
+ @staticmethod
43
+ def get_metadata_cls() -> Type["DualChunkFlashAttentionMetadata"]:
44
+ return DualChunkFlashAttentionMetadata
45
+
46
+ @staticmethod
47
+ def get_builder_cls() -> Type["DualChunkFlashAttentionMetadataBuilder"]:
48
+ return DualChunkFlashAttentionMetadataBuilder
49
+
50
+
51
+ @dataclass
52
+ class DualChunkFlashAttentionMetadata(FlashAttentionMetadata):
53
+ # Block size of the paged kv cache.
54
+ block_size: int = 16
55
+
56
+ # Original max position embeddings.
57
+ original_max_position_embeddings: int = 0
58
+
59
+ # Chunk size
60
+ chunk_size: int = 8192
61
+
62
+ # Local size
63
+ local_size: int = 1024
64
+
65
+ # (batch_size,). The orig sequence length per sequence.
66
+ orig_seq_lens: Optional[List[int]] = None
67
+
68
+ # orig_seq_lens stored as a tensor.
69
+ orig_seq_lens_tensor: Optional[torch.Tensor] = None
70
+
71
+ # Length scaling factor
72
+ scaling_factor: Optional[torch.Tensor] = None
73
+
74
+ # (batch_size,). Sequence lengths for intra attention.
75
+ seq_lens_intra: Optional[torch.Tensor] = None
76
+
77
+ # Max sequence length for intra attention.
78
+ max_seq_len_intra: Optional[int] = None
79
+
80
+ # (batch_size, num_blocks). Block table for intra attention.
81
+ block_tables_intra: Optional[torch.Tensor] = None
82
+
83
+ # (batch_size,). Sequence lengths for succ attention.
84
+ seq_lens_succ: Optional[torch.Tensor] = None
85
+
86
+ # Max sequence length for succ attention.
87
+ max_seq_len_succ: Optional[int] = None
88
+
89
+ # (batch_size, num_blocks). Block table for succ attention.
90
+ block_tables_succ: Optional[torch.Tensor] = None
91
+
92
+ # (batch_size,). Sequence lengths for inter attention.
93
+ seq_lens_inter: Optional[torch.Tensor] = None
94
+
95
+ # Max sequence length for inter attention.
96
+ max_seq_len_inter: Optional[int] = None
97
+
98
+ _cached_prefill_metadata: Optional[
99
+ "DualChunkFlashAttentionMetadata"] = None
100
+ _cached_decode_metadata: Optional["DualChunkFlashAttentionMetadata"] = None
101
+
102
+ @property
103
+ def prefill_metadata(self) -> Optional["DualChunkFlashAttentionMetadata"]:
104
+ if self.num_prefills == 0:
105
+ return None
106
+
107
+ if self._cached_prefill_metadata is not None:
108
+ return self._cached_prefill_metadata
109
+
110
+ prefill_metadata = super().prefill_metadata
111
+ if prefill_metadata is None:
112
+ return None
113
+
114
+ prefill_metadata = DualChunkFlashAttentionMetadata(
115
+ **prefill_metadata.asdict_zerocopy())
116
+
117
+ prefill_metadata.orig_seq_lens = (
118
+ None if self.orig_seq_lens is None else
119
+ self.orig_seq_lens[:self.num_prefills])
120
+ prefill_metadata.orig_seq_lens_tensor = (
121
+ None if self.orig_seq_lens_tensor is None else
122
+ self.orig_seq_lens_tensor[:self.num_prefills])
123
+
124
+ if self.original_max_position_embeddings > 0:
125
+ assert prefill_metadata.orig_seq_lens_tensor is not None
126
+ prefill_metadata.scaling_factor = (
127
+ 0.1 * torch.log(prefill_metadata.orig_seq_lens_tensor /
128
+ self.original_max_position_embeddings) +
129
+ 1.0).clip(min=1)
130
+
131
+ self._cached_prefill_metadata = prefill_metadata
132
+ return prefill_metadata
133
+
134
+ @property
135
+ def decode_metadata(self) -> Optional["DualChunkFlashAttentionMetadata"]:
136
+ if self.num_decode_tokens == 0:
137
+ return None
138
+
139
+ if self._cached_decode_metadata is not None:
140
+ return self._cached_decode_metadata
141
+
142
+ decode_metadata = super().decode_metadata
143
+ if decode_metadata is None:
144
+ return None
145
+
146
+ decode_metadata = DualChunkFlashAttentionMetadata(
147
+ **decode_metadata.asdict_zerocopy())
148
+
149
+ decode_metadata.orig_seq_lens_tensor = (
150
+ None if self.orig_seq_lens_tensor is None else
151
+ self.orig_seq_lens_tensor[self.num_prefills:])
152
+
153
+ assert decode_metadata.orig_seq_lens_tensor is not None
154
+ assert decode_metadata.block_tables is not None
155
+
156
+ cache_seq_lens = decode_metadata.orig_seq_lens_tensor
157
+ chunk_len = self.chunk_size - self.local_size
158
+ chunk_num_curr = (cache_seq_lens - 1) // chunk_len
159
+ batch_size = decode_metadata.num_decode_tokens
160
+
161
+ if self.original_max_position_embeddings > 0:
162
+ decode_metadata.scaling_factor = (0.1 * torch.log(
163
+ cache_seq_lens / self.original_max_position_embeddings) +
164
+ 1.0).clip(min=1)
165
+
166
+ seq_lens_intra = cache_seq_lens - chunk_num_curr * chunk_len
167
+ max_seq_len_intra = seq_lens_intra.max().item()
168
+ decode_metadata.seq_lens_intra = seq_lens_intra
169
+ decode_metadata.max_seq_len_intra = max_seq_len_intra
170
+
171
+ block_tables_intra = torch.zeros(
172
+ batch_size,
173
+ (max_seq_len_intra - 1) // self.block_size + 1,
174
+ dtype=decode_metadata.block_tables.dtype,
175
+ device=decode_metadata.block_tables.device,
176
+ )
177
+ for i in range(batch_size):
178
+ st = chunk_num_curr[i] * chunk_len // self.block_size
179
+ ed = min(
180
+ st + (max_seq_len_intra - 1) // self.block_size + 1,
181
+ (cache_seq_lens[i] - 1) // self.block_size + 1,
182
+ )
183
+ block_tables_intra[i, :ed -
184
+ st] = decode_metadata.block_tables[i, st:ed]
185
+ decode_metadata.block_tables_intra = block_tables_intra
186
+
187
+ seq_lens_succ = (chunk_num_curr -
188
+ (chunk_num_curr - 1).clip(min=0)) * chunk_len
189
+ max_seq_len_succ = seq_lens_succ.max().item()
190
+ decode_metadata.seq_lens_succ = seq_lens_succ
191
+ decode_metadata.max_seq_len_succ = max_seq_len_succ
192
+ if max_seq_len_succ:
193
+ block_tables_succ = torch.zeros(
194
+ batch_size,
195
+ (max_seq_len_succ - 1) // self.block_size + 1,
196
+ dtype=decode_metadata.block_tables.dtype,
197
+ device=decode_metadata.block_tables.device,
198
+ )
199
+ for i in range(batch_size):
200
+ start = ((chunk_num_curr[i] - 1).clip(min=0) * chunk_len //
201
+ self.block_size)
202
+ end = min(
203
+ start + (max_seq_len_succ - 1) // self.block_size + 1,
204
+ (cache_seq_lens[i] - 1) // self.block_size + 1,
205
+ )
206
+ block_tables_succ[
207
+ i, :end - start] = decode_metadata.block_tables[i,
208
+ start:end]
209
+ decode_metadata.block_tables_succ = block_tables_succ
210
+
211
+ seq_lens_inter = (chunk_num_curr - 1).clip(min=0) * chunk_len
212
+ max_seq_len_inter = seq_lens_inter.max().item()
213
+ decode_metadata.seq_lens_inter = seq_lens_inter
214
+ decode_metadata.max_seq_len_inter = max_seq_len_inter
215
+
216
+ self._cached_decode_metadata = decode_metadata
217
+ return decode_metadata
218
+
219
+
220
+ class DualChunkFlashAttentionMetadataBuilder(FlashAttentionMetadataBuilder):
221
+
222
+ def prepare(self):
223
+ super().prepare()
224
+ self.orig_seq_lens: List[int] = []
225
+
226
+ def _add_seq_group(
227
+ self, inter_data: "ModelInputForGPUBuilder.InterDataForSeqGroup",
228
+ chunked_prefill_enabled: bool, prefix_cache_hit: bool):
229
+ super()._add_seq_group(inter_data, chunked_prefill_enabled,
230
+ prefix_cache_hit)
231
+ for prompt_len, seq_len in zip(inter_data.prompt_lens,
232
+ inter_data.seq_lens):
233
+ self.orig_seq_lens.append(max(prompt_len, seq_len))
234
+
235
+ def build(self, seq_lens: List[int], query_lens: List[int],
236
+ cuda_graph_pad_size: int, batch_size: int):
237
+ attn_metadata = super().build(seq_lens, query_lens,
238
+ cuda_graph_pad_size, batch_size)
239
+ attn_metadata = DualChunkFlashAttentionMetadata(
240
+ **attn_metadata.asdict_zerocopy())
241
+
242
+ device = self.runner.device
243
+ attn_metadata.orig_seq_lens = self.orig_seq_lens
244
+ attn_metadata.orig_seq_lens_tensor = async_tensor_h2d(
245
+ self.orig_seq_lens, torch.int, device, self.runner.pin_memory)
246
+
247
+ attn_metadata.block_size = self.runner.block_size
248
+ dual_chunk_attn_config = getattr(self.runner.model_config.hf_config,
249
+ "dual_chunk_attention_config", {})
250
+ attn_metadata.original_max_position_embeddings = \
251
+ dual_chunk_attn_config.get("original_max_position_embeddings", 0)
252
+ attn_metadata.chunk_size = dual_chunk_attn_config.get(
253
+ "chunk_size", 8192)
254
+ attn_metadata.local_size = dual_chunk_attn_config.get(
255
+ "local_size", 1024)
256
+
257
+ return attn_metadata
258
+
259
+
260
+ class DualChunkFlashAttentionImpl(FlashAttentionImpl):
261
+ """
262
+ If the input tensors contain prompt tokens, the layout is as follows:
263
+ |<--------------- num_prefill_tokens ----------------->|
264
+ |<--prefill_0-->|<--prefill_1-->|...|<--prefill_N-1--->|
265
+ Otherwise, the layout is as follows:
266
+ |<----------------- num_decode_tokens ------------------>|
267
+ |<--decode_0-->|..........|<--decode_M-1-->|<--padding-->|
268
+ Generation tokens can contain padding when cuda-graph is used.
269
+ Currently, prompt tokens don't contain any padding.
270
+ The prompts might have different lengths, while the generation tokens
271
+ always have length 1.
272
+ If chunked prefill is enabled, prefill tokens and decode tokens can be
273
+ batched together in a flattened 1D query.
274
+ |<----- num_prefill_tokens ---->|<------- num_decode_tokens --------->|
275
+ |<-prefill_0->|...|<-prefill_N-1->|<--decode_0-->|...|<--decode_M-1-->|
276
+ Currently, cuda graph is disabled for chunked prefill, meaning there's no
277
+ padding between prefill and decode tokens.
278
+ """
279
+
280
+ def __init__(
281
+ self,
282
+ num_heads: int,
283
+ head_size: int,
284
+ scale: float,
285
+ num_kv_heads: int,
286
+ alibi_slopes: Optional[List[float]],
287
+ sliding_window: Optional[int],
288
+ kv_cache_dtype: str,
289
+ blocksparse_params: Optional[Dict[str, Any]] = None,
290
+ logits_soft_cap: Optional[float] = None,
291
+ attn_type: str = AttentionType.DECODER,
292
+ layer_idx: int = -1,
293
+ dual_chunk_attention_config: Optional[Dict[str, Any]] = None,
294
+ ) -> None:
295
+ self.num_heads = num_heads
296
+ self.head_size = head_size
297
+ self.scale = float(scale)
298
+ self.num_kv_heads = num_kv_heads
299
+ if alibi_slopes is not None:
300
+ alibi_slopes = torch.tensor(alibi_slopes, dtype=torch.float32)
301
+ self.alibi_slopes = alibi_slopes
302
+ self.sliding_window = ((sliding_window, sliding_window)
303
+ if sliding_window is not None else (-1, -1))
304
+ self.kv_cache_dtype = kv_cache_dtype
305
+
306
+ assert self.num_heads % self.num_kv_heads == 0
307
+ self.num_queries_per_kv = self.num_heads // self.num_kv_heads
308
+ if sliding_window is not None:
309
+ # NOTE(woosuk): flash-attn's sliding window does not work with
310
+ # paged KV cache.
311
+ raise ValueError(
312
+ "Sliding window is not supported in FlashAttention.")
313
+
314
+ support_head_sizes = (
315
+ DualChunkFlashAttentionBackend.get_supported_head_sizes())
316
+
317
+ if head_size not in support_head_sizes:
318
+ raise ValueError(
319
+ f"Head size {head_size} is not supported by FlashAttention. "
320
+ f"Supported head sizes are: {support_head_sizes}.")
321
+
322
+ assert dual_chunk_attention_config is not None
323
+ self.chunk_size = dual_chunk_attention_config.get("chunk_size", 8192)
324
+ self.local_size = dual_chunk_attention_config.get("local_size", 1024)
325
+ self.original_max_position_embeddings = dual_chunk_attention_config.get(
326
+ "original_max_position_embeddings", 0)
327
+ self.sparse_attention_config = dual_chunk_attention_config.get(
328
+ "sparse_attention_config", None)
329
+ if not self.sparse_attention_config:
330
+ logger.warning_once("Sparse attention will not be enabled as "
331
+ "sparse attention config is not provided.")
332
+ self.sparse_attention_enabled = dual_chunk_attention_config.get(
333
+ "sparse_attention_enabled", self.sparse_attention_config
334
+ is not None)
335
+ self.sparse_attention_threshold = dual_chunk_attention_config.get(
336
+ "sparse_attention_threshold", 32768)
337
+ self.sparse_attention_last_q = dual_chunk_attention_config.get(
338
+ "sparse_attention_last_q", 64)
339
+ self.layer_idx = layer_idx
340
+ self.dual_chunk_attention_config = dual_chunk_attention_config
341
+
342
+ if self.sparse_attention_config:
343
+ self.sparse_attention_config = {
344
+ int(i): j
345
+ for i, j in self.sparse_attention_config[
346
+ self.layer_idx].items()
347
+ }
348
+ start_head = self.num_heads * get_tensor_model_parallel_rank()
349
+ end_head = start_head + self.num_heads
350
+ self.sparse_attention_config = [
351
+ self.sparse_attention_config[i]
352
+ for i in range(start_head, end_head)
353
+ ]
354
+
355
+ if self.sparse_attention_enabled:
356
+ self.arange = torch.arange(self.sparse_attention_last_q,
357
+ device="cuda")
358
+ self.last_q_mask = (self.arange[None, None, :, None]
359
+ >= self.arange[None, None, None, :])
360
+
361
+ def forward( # type: ignore
362
+ self,
363
+ layer: AttentionLayer,
364
+ query: torch.Tensor,
365
+ key: torch.Tensor,
366
+ value: torch.Tensor,
367
+ kv_cache: torch.Tensor,
368
+ attn_metadata: DualChunkFlashAttentionMetadata,
369
+ ) -> torch.Tensor:
370
+ """Forward pass with DualChunkFlashAttention.
371
+ Args:
372
+ query: shape = [num_tokens, num_heads * head_size]
373
+ query_succ: shape = [num_tokens, num_heads * head_size]
374
+ query_inter: shape = [num_tokens, num_heads * head_size]
375
+ key: shape = [num_tokens, num_kv_heads * head_size]
376
+ value: shape = [num_tokens, num_kv_heads * head_size]
377
+ kv_cache = [2, num_blocks, block_size, num_kv_heads * head_size]
378
+ attn_metadata: Metadata for attention.
379
+ Returns:
380
+ shape = [num_tokens, num_heads * head_size]
381
+ """
382
+ (
383
+ query,
384
+ query_succ,
385
+ query_inter,
386
+ query_succ_critical,
387
+ query_inter_critical,
388
+ ) = torch.split(query, query.shape[-1] // 5, dim=-1)
389
+
390
+ assert (
391
+ query_succ is not None and query_inter is not None
392
+ ), "query_succ and query_inter are required in Dual Chunk Attention."
393
+
394
+ num_tokens, hidden_size = query.shape
395
+
396
+ # Reshape the query, key, and value tensors.
397
+ query = query.view(-1, self.num_heads, self.head_size)
398
+ query_succ = query_succ.view(-1, self.num_heads, self.head_size)
399
+ query_inter = query_inter.view(-1, self.num_heads, self.head_size)
400
+ query_succ_critical = query_succ_critical.view(-1, self.num_heads,
401
+ self.head_size)
402
+ query_inter_critical = query_inter_critical.view(
403
+ -1, self.num_heads, self.head_size)
404
+ key = key.view(-1, self.num_kv_heads, self.head_size)
405
+ value = value.view(-1, self.num_kv_heads, self.head_size)
406
+
407
+ if self.original_max_position_embeddings > 0:
408
+ if prefill_meta := attn_metadata.prefill_metadata:
409
+ assert prefill_meta.scaling_factor is not None
410
+ assert prefill_meta.query_start_loc is not None
411
+ assert prefill_meta.orig_seq_lens is not None
412
+ current_start = 0
413
+ query_start_loc_cpu = prefill_meta.query_start_loc.cpu()
414
+ for i in range(len(prefill_meta.orig_seq_lens)):
415
+ current_end = (current_start +
416
+ (query_start_loc_cpu[i + 1] -
417
+ query_start_loc_cpu[i]).item())
418
+ key[current_start:current_end].mul_(
419
+ prefill_meta.scaling_factor[i])
420
+ current_start = current_end
421
+ assert current_end <= attn_metadata.num_prefill_tokens
422
+ if decode_meta := attn_metadata.decode_metadata:
423
+ assert decode_meta.scaling_factor is not None
424
+ scaling_factor = decode_meta.scaling_factor
425
+ key[attn_metadata.num_prefill_tokens:].mul_(
426
+ scaling_factor.unsqueeze(-1).unsqueeze(-1))
427
+
428
+ if kv_cache is not None and kv_cache.numel() > 0:
429
+ key_cache = kv_cache[0]
430
+ value_cache = kv_cache[1]
431
+
432
+ # Reshape the input keys and values and store them in the cache.
433
+ # If kv_cache is not provided, the new key and value tensors are
434
+ # not cached. This happens during the initial memory profiling run.
435
+ ops.reshape_and_cache_flash(
436
+ key,
437
+ value,
438
+ key_cache,
439
+ value_cache,
440
+ attn_metadata.slot_mapping.flatten(),
441
+ self.kv_cache_dtype,
442
+ layer._k_scale,
443
+ layer._v_scale,
444
+ )
445
+
446
+ num_prefill_tokens = attn_metadata.num_prefill_tokens
447
+ num_decode_tokens = attn_metadata.num_decode_tokens
448
+ assert key.shape[0] == num_prefill_tokens + num_decode_tokens
449
+ assert value.shape[0] == num_prefill_tokens + num_decode_tokens
450
+ output = torch.empty_like(query)
451
+
452
+ # Query for decode. KV is not needed because it is already cached.
453
+ decode_query = query[num_prefill_tokens:]
454
+ decode_query_succ = query_succ[num_prefill_tokens:]
455
+ decode_query_inter = query_inter[num_prefill_tokens:]
456
+
457
+ # QKV for prefill.
458
+ query = query[:num_prefill_tokens]
459
+ query_succ = query_succ[:num_prefill_tokens]
460
+ query_inter = query_inter[:num_prefill_tokens]
461
+ query_succ_critical = query_succ_critical[:num_prefill_tokens]
462
+ query_inter_critical = query_inter_critical[:num_prefill_tokens]
463
+ key = key[:num_prefill_tokens]
464
+ value = value[:num_prefill_tokens]
465
+ assert query.shape[0] == num_prefill_tokens
466
+ assert decode_query.shape[0] == num_decode_tokens
467
+
468
+ if prefill_meta := attn_metadata.prefill_metadata:
469
+ # Prompt run.
470
+ if (kv_cache is None or prefill_meta.block_tables is None
471
+ or prefill_meta.block_tables.numel() == 0):
472
+ # normal attention, called during the profiling run.
473
+ out = flash_attn_varlen_func(
474
+ q=query,
475
+ k=key,
476
+ v=value,
477
+ cu_seqlens_q=prefill_meta.seq_start_loc,
478
+ cu_seqlens_k=prefill_meta.seq_start_loc,
479
+ max_seqlen_q=prefill_meta.max_prefill_seq_len,
480
+ max_seqlen_k=prefill_meta.max_prefill_seq_len,
481
+ softmax_scale=self.scale,
482
+ causal=True,
483
+ window_size=self.sliding_window,
484
+ alibi_slopes=self.alibi_slopes,
485
+ )
486
+ assert output[:num_prefill_tokens].shape == out.shape
487
+ output[:num_prefill_tokens] = out
488
+ else:
489
+ # prefix-enabled attention
490
+ assert prefill_meta.seq_lens is not None
491
+ assert prefill_meta.orig_seq_lens is not None
492
+ output[:num_prefill_tokens] = (
493
+ self._dual_chunk_flash_attn_prefill(
494
+ q=query,
495
+ q_succ=query_succ,
496
+ q_inter=query_inter,
497
+ q_succ_critical=query_succ_critical,
498
+ q_inter_critical=query_inter_critical,
499
+ k=key_cache,
500
+ v=value_cache,
501
+ cu_seqlens_q=prefill_meta.query_start_loc,
502
+ cu_seqlens_k=prefill_meta.seq_start_loc,
503
+ orig_seq_lens=prefill_meta.orig_seq_lens,
504
+ scaling_factor=prefill_meta.scaling_factor,
505
+ softmax_scale=self.scale,
506
+ causal=True,
507
+ window_size=(-1, -1),
508
+ alibi_slopes=self.alibi_slopes,
509
+ block_table=prefill_meta.block_tables,
510
+ chunk_size=self.chunk_size,
511
+ local_size=self.local_size,
512
+ ))
513
+
514
+ if decode_meta := attn_metadata.decode_metadata:
515
+ # Decoding run.
516
+ output[num_prefill_tokens:] = (
517
+ self._dual_chunk_flash_attn_decoding(
518
+ decode_query.unsqueeze(1),
519
+ decode_query_succ.unsqueeze(1),
520
+ decode_query_inter.unsqueeze(1),
521
+ key_cache,
522
+ value_cache,
523
+ block_table=decode_meta.block_tables,
524
+ cache_seqlens=decode_meta.seq_lens_tensor,
525
+ softmax_scale=self.scale,
526
+ causal=True,
527
+ alibi_slopes=self.alibi_slopes,
528
+ chunk_size=self.chunk_size,
529
+ local_size=self.local_size,
530
+ original_max_position_embeddings=self.
531
+ original_max_position_embeddings,
532
+ decode_meta=decode_meta,
533
+ ).squeeze(1))
534
+ # Reshape the output tensor.
535
+ return output.view(num_tokens, hidden_size)
536
+
537
+ def _dual_chunk_flash_attn_prefill(
538
+ self,
539
+ q,
540
+ q_succ,
541
+ q_inter,
542
+ q_succ_critical,
543
+ q_inter_critical,
544
+ k,
545
+ v,
546
+ cu_seqlens_q,
547
+ cu_seqlens_k,
548
+ orig_seq_lens: List[int],
549
+ scaling_factor: torch.Tensor,
550
+ softmax_scale: float,
551
+ causal: Optional[bool] = True,
552
+ window_size: Tuple[int, int] = (-1, -1),
553
+ alibi_slopes: Optional[torch.Tensor] = None,
554
+ block_table: Optional[torch.Tensor] = None,
555
+ chunk_size: int = 8192,
556
+ local_size: int = 1024,
557
+ ):
558
+ if alibi_slopes is not None:
559
+ raise ValueError(
560
+ "Dual Chunk Attention does not support alibi_slopes")
561
+ if not causal:
562
+ raise ValueError(
563
+ "Dual Chunk Attention does not support causal=False")
564
+ if window_size != (-1, -1):
565
+ raise ValueError(
566
+ "Dual Chunk Attention does not support window_size")
567
+
568
+ cu_seqlens_q_cpu = cu_seqlens_q.cpu().tolist()
569
+ cu_seqlens_k_cpu = cu_seqlens_k.cpu().tolist()
570
+ all_outputs = []
571
+
572
+ for i in range(0, len(cu_seqlens_q_cpu) - 1):
573
+ qs = cu_seqlens_q_cpu[i]
574
+ qe = cu_seqlens_q_cpu[i:i + 2][-1]
575
+ ks = cu_seqlens_k_cpu[i]
576
+ ke = cu_seqlens_k_cpu[i:i + 2][-1]
577
+
578
+ current_q = q[qs:qe]
579
+ current_q_succ = q_succ[qs:qe]
580
+ current_q_inter = q_inter[qs:qe]
581
+ current_q_succ_critical = q_succ_critical[qs:qe]
582
+ current_q_inter_critical = q_inter_critical[qs:qe]
583
+
584
+ if block_table is None:
585
+ current_k = k[ks:ke]
586
+ current_v = v[ks:ke]
587
+ current_block_table = None
588
+ current_orig_seq_len = orig_seq_lens[i]
589
+ else:
590
+ current_block_table = block_table[i]
591
+ current_orig_seq_len = orig_seq_lens[i]
592
+ current_k = k
593
+ current_v = v
594
+ sparse_attn_enabled = (self.sparse_attention_enabled
595
+ and current_orig_seq_len
596
+ > self.sparse_attention_threshold)
597
+
598
+ if current_q.shape[0] == 0:
599
+ continue
600
+
601
+ if current_k.shape[0] == 0:
602
+ all_outputs.append(
603
+ torch.zeros(
604
+ (current_q.shape[0], current_q.shape[1], v.shape[2]),
605
+ device=q.device,
606
+ dtype=q.dtype,
607
+ ))
608
+ continue
609
+
610
+ current_output = torch.empty_like(current_q)
611
+ group_size = int(current_q.size(-2) / current_k.size(-2))
612
+
613
+ if sparse_attn_enabled:
614
+ num_device_q_heads = current_q.size(-2)
615
+ heads_vertical_size = torch.empty(size=(num_device_q_heads, ),
616
+ dtype=torch.int32)
617
+ heads_slash_size = torch.empty(size=(num_device_q_heads, ),
618
+ dtype=torch.int32)
619
+ for head_id in range(current_q.size(-2)):
620
+ (
621
+ ty,
622
+ vertical_size,
623
+ slash_size,
624
+ _,
625
+ ) = self.sparse_attention_config[head_id]
626
+ assert ty == "vertical_and_slash", "only support slash mode"
627
+
628
+ if vertical_size == 30:
629
+ vertical_size += 100
630
+ heads_vertical_size[head_id] = vertical_size
631
+ heads_slash_size[head_id] = slash_size
632
+
633
+ current_output = self._dual_chunk_flash_attn_prefill_func(
634
+ current_q, # allheads
635
+ current_q_succ,
636
+ current_q_inter,
637
+ current_q_succ_critical,
638
+ current_q_inter_critical,
639
+ current_k,
640
+ current_v,
641
+ current_block_table,
642
+ softmax_scale,
643
+ chunk_size,
644
+ local_size,
645
+ scaling_factor[i].item(),
646
+ ke - ks,
647
+ sparse_attn_enabled=sparse_attn_enabled,
648
+ heads_vertical_size=heads_vertical_size,
649
+ heads_slash_size=heads_slash_size,
650
+ group_size=group_size)
651
+ else:
652
+ for head_id in range(current_q.size(-2)):
653
+ # (seq_len, num_heads, head_size)
654
+ current_q_head = current_q[:, head_id, :].unsqueeze(1)
655
+ current_q_succ_head = \
656
+ current_q_succ[:, head_id, :].unsqueeze(1)
657
+ current_q_inter_head = \
658
+ current_q_inter[:, head_id, :].unsqueeze(1)
659
+ current_q_succ_head_critical = \
660
+ current_q_succ_critical[:, head_id, :].unsqueeze(1)
661
+ current_q_inter_head_critical = \
662
+ current_q_inter_critical[:, head_id, :].unsqueeze(1)
663
+ if block_table is not None:
664
+ current_k_head = current_k[..., head_id //
665
+ group_size, :].unsqueeze(2)
666
+ current_v_head = current_v[..., head_id //
667
+ group_size, :].unsqueeze(2)
668
+
669
+ else:
670
+ current_k_head = current_k[:, head_id, :].unsqueeze(1)
671
+ current_v_head = current_v[:, head_id, :].unsqueeze(1)
672
+
673
+ current_out = self._dual_chunk_flash_attn_prefill_func(
674
+ current_q_head,
675
+ current_q_succ_head,
676
+ current_q_inter_head,
677
+ current_q_succ_head_critical,
678
+ current_q_inter_head_critical,
679
+ current_k_head,
680
+ current_v_head,
681
+ current_block_table,
682
+ softmax_scale,
683
+ chunk_size,
684
+ local_size,
685
+ scaling_factor[i].item(),
686
+ ke - ks,
687
+ sparse_attn_enabled=sparse_attn_enabled,
688
+ )
689
+ current_output[:, head_id:head_id + 1, :] = current_out
690
+ all_outputs.append(current_output)
691
+ return torch.cat(all_outputs, dim=0)
692
+
693
+ def _dual_chunk_flash_attn_prefill_func(
694
+ self,
695
+ q,
696
+ q_succ,
697
+ q_inter,
698
+ q_succ_critical,
699
+ q_inter_critical,
700
+ k,
701
+ v,
702
+ block_table,
703
+ softmax_scale: float,
704
+ chunk_size: int,
705
+ local_size: int,
706
+ scaling_factor: float,
707
+ k_length: int,
708
+ sparse_attn_enabled: Optional[bool] = True,
709
+ heads_vertical_size=None,
710
+ heads_slash_size=None,
711
+ group_size=None,
712
+ ):
713
+ flash_results = []
714
+ chunk_len = chunk_size - local_size
715
+
716
+ if block_table is not None:
717
+ block_size = v.shape[1]
718
+ if chunk_len % block_size != 0:
719
+ raise ValueError("chunk_len must be divisible by block_size.")
720
+ else:
721
+ block_size = 1
722
+
723
+ if self.original_max_position_embeddings > 0:
724
+ softmax_scale = softmax_scale * scaling_factor
725
+
726
+ begin = k_length - q.shape[0]
727
+ while begin < k_length:
728
+ flash_per_chunk = []
729
+
730
+ prev_chunk_end_pos = (begin // chunk_len) * chunk_len
731
+ next_chunk_end_pos = prev_chunk_end_pos + chunk_len
732
+ end = min(next_chunk_end_pos, k_length)
733
+ qbegin = begin - (k_length - q.shape[0])
734
+ qend = end - (k_length - q.shape[0])
735
+
736
+ qk_chunks = []
737
+ q_states_intra = q[qbegin:qend]
738
+ # choose critical token
739
+ if block_table is not None:
740
+ block_tables_intra = _get_block(block_table, block_size,
741
+ prev_chunk_end_pos, end)
742
+ k_states_intra = k[block_tables_intra].view(
743
+ -1, *k.shape[-2:])[:(end - prev_chunk_end_pos)]
744
+ v_states_intra = v[block_tables_intra].view(
745
+ -1, *v.shape[-2:])[:(end - prev_chunk_end_pos)]
746
+ else:
747
+ block_tables_intra = None
748
+ k_states_intra = k[prev_chunk_end_pos:end]
749
+ v_states_intra = v[prev_chunk_end_pos:end]
750
+
751
+ if sparse_attn_enabled:
752
+ last_q_size = min(qend - qbegin, self.sparse_attention_last_q)
753
+ _, num_device_k_heads, head_dim = k_states_intra.shape
754
+ k_states_intra = (k_states_intra.unsqueeze(2).repeat(
755
+ 1, 1, group_size,
756
+ 1).reshape(-1, num_device_k_heads * group_size, head_dim))
757
+ v_states_intra = (v_states_intra.unsqueeze(2).repeat(
758
+ 1, 1, group_size,
759
+ 1).reshape(-1, num_device_k_heads * group_size, head_dim))
760
+ qk_chunks.append(
761
+ (q_states_intra.transpose(0, 1)[:, -last_q_size:] *
762
+ softmax_scale) @ k_states_intra.permute(1, 2, 0))
763
+
764
+ if prev_chunk_end_pos - chunk_len >= 0:
765
+ q_states_succ = q_succ[qbegin:qend]
766
+ q_states_succ_critical = q_succ_critical[qbegin:qend]
767
+ if block_table is not None:
768
+ block_tables_succ = _get_block(
769
+ block_table, block_size,
770
+ prev_chunk_end_pos - chunk_len, prev_chunk_end_pos)
771
+ k_states_succ = k[block_tables_succ].view(
772
+ -1, *k.shape[-2:])[:chunk_len]
773
+ v_states_succ = v[block_tables_succ].view(
774
+ -1, *v.shape[-2:])[:chunk_len]
775
+ else:
776
+ k_states_succ = k[prev_chunk_end_pos -
777
+ chunk_len:prev_chunk_end_pos]
778
+ v_states_succ = v[prev_chunk_end_pos -
779
+ chunk_len:prev_chunk_end_pos]
780
+
781
+ if sparse_attn_enabled:
782
+ k_states_succ = (k_states_succ.unsqueeze(2).repeat(
783
+ 1, 1, group_size,
784
+ 1).reshape(-1, num_device_k_heads * group_size,
785
+ head_dim))
786
+ v_states_succ = (v_states_succ.unsqueeze(2).repeat(
787
+ 1, 1, group_size,
788
+ 1).reshape(-1, num_device_k_heads * group_size,
789
+ head_dim))
790
+ qk_chunks.append((q_states_succ_critical.transpose(
791
+ 0, 1)[:, -last_q_size:] * softmax_scale)
792
+ @ k_states_succ.permute(1, 2, 0))
793
+
794
+ if prev_chunk_end_pos - chunk_len * 2 >= 0:
795
+ q_states_inter = q_inter[qbegin:qend]
796
+ q_states_inter_critical = q_inter_critical[qbegin:qend]
797
+ if block_table is not None:
798
+ block_tables_inter = _get_block(
799
+ block_table, block_size, 0,
800
+ prev_chunk_end_pos - chunk_len)
801
+ k_states_inter = k[block_tables_inter].view(
802
+ -1, *k.shape[-2:])[:(prev_chunk_end_pos - chunk_len)]
803
+ v_states_inter = v[block_tables_inter].view(
804
+ -1, *v.shape[-2:])[:(prev_chunk_end_pos - chunk_len)]
805
+ else:
806
+ k_states_inter = k[:prev_chunk_end_pos - chunk_len]
807
+ v_states_inter = v[:prev_chunk_end_pos - chunk_len]
808
+
809
+ if sparse_attn_enabled:
810
+ k_states_inter = (k_states_inter.unsqueeze(2).repeat(
811
+ 1, 1, group_size,
812
+ 1).reshape(-1, num_device_k_heads * group_size,
813
+ head_dim))
814
+ v_states_inter = (v_states_inter.unsqueeze(2).repeat(
815
+ 1, 1, group_size,
816
+ 1).reshape(-1, num_device_k_heads * group_size,
817
+ head_dim))
818
+ qk_chunks.append((q_states_inter_critical.transpose(
819
+ 0, 1)[:, -last_q_size:] * softmax_scale)
820
+ @ k_states_inter.permute(1, 2, 0))
821
+
822
+ if sparse_attn_enabled:
823
+ reversed_qk = qk_chunks[::-1]
824
+ qk = torch.cat(reversed_qk, dim=-1)
825
+
826
+ qk[:, :, -last_q_size:] = torch.where(
827
+ self.last_q_mask[..., -last_q_size:,
828
+ -last_q_size:].to(qk.device),
829
+ qk[:, :, -last_q_size:], -torch.inf)
830
+ qk = F.softmax(qk, dim=-1, dtype=torch.float32)
831
+
832
+ vertical = qk.sum(-2, keepdim=True)
833
+ vertical[..., :30] = torch.inf
834
+
835
+ # Avoid sorting by using the min/max ints to fill the indexer
836
+ # buffers.
837
+ int32_max = torch.iinfo(torch.int32).max
838
+ int32_min = torch.iinfo(torch.int32).min
839
+ n_heads = qk.size()[0]
840
+ max_slash_topk = torch.max(heads_slash_size).item()
841
+ max_vertical_topk = torch.max(heads_vertical_size).item()
842
+ # store each head's slash topk, vertical topk
843
+ vertical = vertical.reshape((n_heads, -1))
844
+ # prevent out of range when prompt size < max_vertical_topk
845
+ max_vertical_topk = min(vertical.shape[-1], max_vertical_topk)
846
+ vertical_topk_buffer = torch.topk(vertical, max_vertical_topk,
847
+ -1).indices
848
+ slash_topk_buffer = torch.empty(size=(n_heads, max_slash_topk),
849
+ dtype=torch.int64,
850
+ device=qk.device)
851
+ for head_i in range(n_heads):
852
+ # (nqheads=1, lastq, k_len)
853
+ head_score = qk[head_i:head_i + 1, :, :]
854
+ slash_scores = _sum_all_diagonal_matrix(head_score)
855
+ if head_score.size(1) != 1:
856
+ # drop right up corner
857
+ slash_scores = slash_scores[..., :-last_q_size + 1]
858
+ slash_scores[..., -100:] = torch.inf
859
+
860
+ head_slash_size = heads_slash_size[head_i]
861
+ head_slash_size = min(head_slash_size, vertical.size(-1))
862
+ slash_topk = torch.topk(slash_scores, head_slash_size,
863
+ -1).indices
864
+ #(nheads, max_topk)
865
+ slash_topk_buffer[head_i, :head_slash_size] = slash_topk
866
+
867
+ # reset heads topk
868
+ heads_slash_size[head_i] = head_slash_size
869
+ heads_vertical_size[head_i] = min(
870
+ heads_vertical_size[head_i], max_vertical_topk)
871
+
872
+ # store
873
+ vertical_buffer = torch.full((n_heads, max_vertical_topk),
874
+ int32_max,
875
+ dtype=torch.int64,
876
+ device=q.device)
877
+ slash_buffer = torch.full((n_heads, max_slash_topk),
878
+ int32_min,
879
+ dtype=torch.int64,
880
+ device=q.device)
881
+ succ_vertical_buffer = torch.full((n_heads, max_vertical_topk),
882
+ int32_max,
883
+ dtype=torch.int64,
884
+ device=q.device)
885
+ succ_slash_buffer = torch.full((n_heads, max_slash_topk),
886
+ int32_min,
887
+ dtype=torch.int64,
888
+ device=q.device)
889
+ inter_vertical_buffer = torch.full(
890
+ (n_heads, max_vertical_topk),
891
+ int32_max,
892
+ dtype=torch.int64,
893
+ device=q.device)
894
+ inter_slash_buffer = torch.full((n_heads, max_slash_topk),
895
+ int32_min,
896
+ dtype=torch.int64,
897
+ device=q.device)
898
+
899
+ vertical_size_buffer = torch.empty(size=(n_heads, ),
900
+ dtype=torch.int32,
901
+ device=q.device)
902
+ slash_sizes_buffer = torch.empty(size=(n_heads, ),
903
+ dtype=torch.int32,
904
+ device=q.device)
905
+ succ_vertical_size_buffer = torch.empty(size=(n_heads, ),
906
+ dtype=torch.int32,
907
+ device=q.device)
908
+ succ_slash_sizes_buffer = torch.empty(size=(n_heads, ),
909
+ dtype=torch.int32,
910
+ device=q.device)
911
+ inter_vertical_size_buffer = torch.empty(size=(n_heads, ),
912
+ dtype=torch.int32,
913
+ device=q.device)
914
+ inter_slash_sizes_buffer = torch.empty(size=(n_heads, ),
915
+ dtype=torch.int32,
916
+ device=q.device)
917
+
918
+ for head_i in range(n_heads):
919
+ vertical_topk = vertical_topk_buffer[
920
+ head_i, :heads_vertical_size[head_i]]
921
+ # intra
922
+ intra_vertical_indices = vertical_topk[
923
+ vertical_topk >=
924
+ prev_chunk_end_pos] - prev_chunk_end_pos
925
+ if intra_vertical_indices.nelement() == 0:
926
+ intra_vertical_indices = torch.cat([
927
+ intra_vertical_indices,
928
+ torch.arange(0,
929
+ k_states_intra.size(0),
930
+ max(1,
931
+ k_states_intra.size(0) / 5),
932
+ dtype=torch.int32,
933
+ device=intra_vertical_indices.device)
934
+ ])
935
+ slash_topk = slash_topk_buffer[
936
+ head_i, :heads_slash_size[head_i]]
937
+ intra_slash_indices = (
938
+ (qk.size(-1) - 1) -
939
+ slash_topk[slash_topk >= prev_chunk_end_pos])
940
+ # fill buffer
941
+ v_count = intra_vertical_indices.nelement()
942
+ s_count = intra_slash_indices.nelement()
943
+ vertical_size_buffer[head_i] = v_count
944
+ slash_sizes_buffer[head_i] = s_count
945
+ vertical_buffer[head_i, :v_count].copy_(
946
+ intra_vertical_indices)
947
+ slash_buffer[head_i, :s_count].copy_(intra_slash_indices)
948
+ # succ
949
+ if prev_chunk_end_pos - chunk_len >= 0:
950
+ succ_vertical_indices = vertical_topk[
951
+ (vertical_topk < prev_chunk_end_pos)
952
+ & (vertical_topk >= prev_chunk_end_pos -
953
+ chunk_len)] - (prev_chunk_end_pos - chunk_len)
954
+ # TODO: support no vertical
955
+ if succ_vertical_indices.nelement() == 0:
956
+ succ_vertical_indices = torch.cat([
957
+ succ_vertical_indices,
958
+ torch.arange(
959
+ 0,
960
+ k_states_succ.size(0),
961
+ max(1,
962
+ k_states_succ.size(0) / 5),
963
+ dtype=torch.int32,
964
+ device=intra_vertical_indices.device)
965
+ ])
966
+ succ_slash_indices = (
967
+ (prev_chunk_end_pos + (qend - qbegin) - 1) -
968
+ slash_topk[((slash_topk >=
969
+ (prev_chunk_end_pos - chunk_len)) &
970
+ (slash_topk < (prev_chunk_end_pos +
971
+ (qend - qbegin))))])
972
+ if succ_slash_indices.nelement() == 0:
973
+ succ_slash_indices = torch.cat([
974
+ succ_slash_indices,
975
+ torch.arange(
976
+ 0,
977
+ k_states_succ.size(0),
978
+ max(1,
979
+ k_states_succ.size(0) / 5),
980
+ dtype=torch.int32,
981
+ device=intra_vertical_indices.device)
982
+ ])
983
+ # fill buffer
984
+ v_count = succ_vertical_indices.nelement()
985
+ s_count = succ_slash_indices.nelement()
986
+ succ_vertical_size_buffer[head_i] = v_count
987
+ succ_slash_sizes_buffer[head_i] = s_count
988
+ succ_vertical_buffer[head_i, :v_count].copy_(
989
+ succ_vertical_indices)
990
+ succ_slash_buffer[head_i, :s_count].copy_(
991
+ succ_slash_indices)
992
+
993
+ if prev_chunk_end_pos - 2 * chunk_len >= 0:
994
+ inter_vertical_indices = vertical_topk[
995
+ vertical_topk < prev_chunk_end_pos - chunk_len]
996
+
997
+ if inter_vertical_indices.nelement() == 0:
998
+ inter_vertical_indices = torch.cat([
999
+ inter_vertical_indices,
1000
+ torch.arange(
1001
+ 0,
1002
+ k_states_inter.size(0),
1003
+ max(1,
1004
+ k_states_inter.size(0) / 5),
1005
+ dtype=torch.int32,
1006
+ device=intra_vertical_indices.device)
1007
+ ])
1008
+ inter_slash_indices = (
1009
+ (prev_chunk_end_pos - chunk_len +
1010
+ (qend - qbegin) - 1) -
1011
+ slash_topk[slash_topk < (prev_chunk_end_pos -
1012
+ chunk_len +
1013
+ (qend - qbegin))])
1014
+ if inter_slash_indices.nelement() == 0:
1015
+ inter_slash_indices = torch.cat([
1016
+ inter_slash_indices,
1017
+ torch.arange(
1018
+ 0,
1019
+ k_states_inter.size(0),
1020
+ max(1,
1021
+ k_states_inter.size(0) / 5),
1022
+ dtype=torch.int32,
1023
+ device=intra_vertical_indices.device)
1024
+ ])
1025
+ # fill buffer
1026
+ v_count = inter_vertical_indices.nelement()
1027
+ s_count = inter_slash_indices.nelement()
1028
+ inter_vertical_size_buffer[head_i] = v_count
1029
+ inter_slash_sizes_buffer[head_i] = s_count
1030
+ inter_vertical_buffer[head_i, :v_count].copy_(
1031
+ inter_vertical_indices)
1032
+ inter_slash_buffer[head_i, :s_count].copy_(
1033
+ inter_slash_indices)
1034
+ else:
1035
+ intra_vertical_indices, intra_slash_indices = None, None
1036
+ succ_vertical_indices, succ_slash_indices = None, None
1037
+ inter_vertical_indices, inter_slash_indices = None, None
1038
+
1039
+ if sparse_attn_enabled:
1040
+ flash_result = self._do_flash_attn(
1041
+ q_states_intra,
1042
+ k_states_intra,
1043
+ v_states_intra,
1044
+ softmax_scale=softmax_scale,
1045
+ causal=True,
1046
+ block_table=block_table,
1047
+ stage="intra",
1048
+ vertical_indices=vertical_buffer,
1049
+ slash_indices=slash_buffer,
1050
+ vertical_indices_count=vertical_size_buffer,
1051
+ slash_indices_count=slash_sizes_buffer,
1052
+ mergehead_softmax_scale=softmax_scale,
1053
+ sparse_attn_enabled=sparse_attn_enabled)
1054
+ else:
1055
+ flash_result = self._do_flash_attn(
1056
+ q_states_intra,
1057
+ k_states_intra,
1058
+ v_states_intra,
1059
+ softmax_scale=softmax_scale,
1060
+ causal=True,
1061
+ block_table=block_table,
1062
+ stage="intra",
1063
+ vertical_indices=intra_vertical_indices,
1064
+ slash_indices=intra_slash_indices,
1065
+ sparse_attn_enabled=sparse_attn_enabled)
1066
+ flash_per_chunk.append(flash_result)
1067
+
1068
+ if prev_chunk_end_pos - chunk_len >= 0:
1069
+ if sparse_attn_enabled:
1070
+ flash_result = self._do_flash_attn(
1071
+ q_states_succ,
1072
+ k_states_succ,
1073
+ v_states_succ,
1074
+ softmax_scale=softmax_scale,
1075
+ causal=False,
1076
+ block_table=block_table,
1077
+ stage="succ",
1078
+ vertical_indices=succ_vertical_buffer,
1079
+ slash_indices=succ_slash_buffer,
1080
+ vertical_indices_count=succ_vertical_size_buffer,
1081
+ slash_indices_count=succ_slash_sizes_buffer,
1082
+ mergehead_softmax_scale=softmax_scale,
1083
+ sparse_attn_enabled=sparse_attn_enabled)
1084
+ else:
1085
+ flash_result = self._do_flash_attn(
1086
+ q_states_succ,
1087
+ k_states_succ,
1088
+ v_states_succ,
1089
+ softmax_scale=softmax_scale,
1090
+ causal=False,
1091
+ block_table=block_table,
1092
+ stage="succ",
1093
+ vertical_indices=succ_vertical_indices,
1094
+ slash_indices=succ_slash_indices,
1095
+ sparse_attn_enabled=sparse_attn_enabled)
1096
+ flash_per_chunk.append(flash_result)
1097
+
1098
+ if prev_chunk_end_pos - chunk_len * 2 >= 0:
1099
+ if sparse_attn_enabled:
1100
+ flash_result = self._do_flash_attn(
1101
+ q_states_inter,
1102
+ k_states_inter,
1103
+ v_states_inter,
1104
+ softmax_scale=softmax_scale,
1105
+ causal=False,
1106
+ block_table=block_table,
1107
+ stage="inter",
1108
+ vertical_indices=inter_vertical_buffer,
1109
+ slash_indices=inter_slash_buffer,
1110
+ vertical_indices_count=inter_vertical_size_buffer,
1111
+ slash_indices_count=inter_slash_sizes_buffer,
1112
+ mergehead_softmax_scale=softmax_scale,
1113
+ sparse_attn_enabled=sparse_attn_enabled)
1114
+ else:
1115
+ flash_result = self._do_flash_attn(
1116
+ q_states_inter,
1117
+ k_states_inter,
1118
+ v_states_inter,
1119
+ softmax_scale=softmax_scale,
1120
+ causal=False,
1121
+ block_table=block_table,
1122
+ stage="inter",
1123
+ vertical_indices=inter_vertical_indices,
1124
+ slash_indices=inter_slash_indices,
1125
+ sparse_attn_enabled=sparse_attn_enabled)
1126
+ flash_per_chunk.append(flash_result)
1127
+
1128
+ flash_results.append(flash_per_chunk)
1129
+ begin = end
1130
+
1131
+ attn_output = self._merge_attn_outputs(flash_results)
1132
+ del flash_results
1133
+ return attn_output
1134
+
1135
+ def _do_flash_attn(
1136
+ self,
1137
+ query_states: torch.Tensor,
1138
+ key_states: torch.Tensor,
1139
+ value_states: torch.Tensor,
1140
+ softmax_scale: float,
1141
+ causal: bool = True,
1142
+ block_table: torch.Tensor = None,
1143
+ max_seqlen_k: Optional[int] = None,
1144
+ stage: str = "intra",
1145
+ vertical_indices: Optional[torch.Tensor] = None,
1146
+ slash_indices: Optional[torch.Tensor] = None,
1147
+ vertical_indices_count: Optional[torch.Tensor] = None,
1148
+ slash_indices_count: Optional[torch.Tensor] = None,
1149
+ mergehead_softmax_scale: Optional[float] = None,
1150
+ sparse_attn_enabled: Optional[bool] = False,
1151
+ ):
1152
+ if max_seqlen_k is None:
1153
+ max_seqlen_k = key_states.shape[0]
1154
+
1155
+ q_len = query_states.shape[0]
1156
+ q_heads = query_states.shape[1]
1157
+ h_dim = query_states.shape[-1]
1158
+
1159
+ if sparse_attn_enabled:
1160
+ assert slash_indices is not None
1161
+ if stage == "intra":
1162
+ assert causal
1163
+ else:
1164
+ assert not causal
1165
+
1166
+ query_states = query_states.unsqueeze(0).transpose(1, 2)
1167
+ key_states = key_states.unsqueeze(0).transpose(1, 2)
1168
+ value_states = value_states.unsqueeze(0).transpose(1, 2)
1169
+
1170
+ q = query_states
1171
+ k = key_states
1172
+ v = value_states
1173
+
1174
+ if (vertical_indices_count is not None and \
1175
+ slash_indices_count is not None):
1176
+ assert mergehead_softmax_scale is not None
1177
+
1178
+ res, s_lse = _vertical_slash_sparse_attention(
1179
+ q,
1180
+ k,
1181
+ v,
1182
+ vertical_indices,
1183
+ slash_indices,
1184
+ mergehead_softmax_scale,
1185
+ causal=causal,
1186
+ stage=stage,
1187
+ vertical_indices_count=vertical_indices_count,
1188
+ slash_indices_count=slash_indices_count)
1189
+ res = res.view(q_heads, q_len,
1190
+ h_dim).transpose(0, 1) # (qlen,nhead,h_dim)
1191
+ s_lse = s_lse.view(
1192
+ q_heads, q_len,
1193
+ 1).squeeze(-1).unsqueeze(0).float() # (1, nhead,qlen)
1194
+ else:
1195
+ res, s_lse = _vertical_slash_sparse_attention(q,
1196
+ k,
1197
+ v,
1198
+ vertical_indices,
1199
+ slash_indices,
1200
+ softmax_scale,
1201
+ causal=causal,
1202
+ stage=stage)
1203
+ res = res.view(q_len, q_heads, h_dim)
1204
+ s_lse = s_lse.view(q_len, q_heads, 1).transpose(0, 2).float()
1205
+ return res, s_lse
1206
+
1207
+ output, softmax_lse = flash_attn_varlen_func(
1208
+ q=query_states,
1209
+ k=key_states,
1210
+ v=value_states,
1211
+ softmax_scale=softmax_scale,
1212
+ cu_seqlens_q=torch.tensor([0, query_states.shape[0]],
1213
+ dtype=torch.int32,
1214
+ device=query_states.device),
1215
+ max_seqlen_q=query_states.shape[0],
1216
+ cu_seqlens_k=torch.tensor([0, max_seqlen_k],
1217
+ dtype=torch.int32,
1218
+ device=query_states.device),
1219
+ max_seqlen_k=max_seqlen_k,
1220
+ causal=causal,
1221
+ block_table=block_table.unsqueeze(0),
1222
+ return_softmax_lse=True,
1223
+ )
1224
+ softmax_lse = softmax_lse.view(q_len, q_heads, 1).transpose(0,
1225
+ 2).float()
1226
+ return output, softmax_lse
1227
+
1228
+ def _merge_attn_outputs(
1229
+ self,
1230
+ flash_results: List[List[Tuple[torch.Tensor, torch.Tensor]]],
1231
+ return_lse: Optional[bool] = False,
1232
+ ) -> torch.Tensor:
1233
+ attn_outputs_all = []
1234
+ logits_all = []
1235
+
1236
+ for flash_per_chunk in flash_results:
1237
+ if len(flash_per_chunk) == 1:
1238
+ attn_outputs_all.append(flash_per_chunk[0][0])
1239
+ if return_lse:
1240
+ logits_all.append(flash_per_chunk[0][1])
1241
+ continue
1242
+
1243
+ attn_outputs = torch.stack([
1244
+ flash_attn_output[0] for flash_attn_output in flash_per_chunk
1245
+ ])
1246
+ logits = torch.stack([
1247
+ flash_attn_output[1] for flash_attn_output in flash_per_chunk
1248
+ ])
1249
+ logits = logits.to(torch.float32)
1250
+
1251
+ if return_lse:
1252
+ max_val = torch.max(logits, dim=0).values
1253
+ diff = torch.abs(logits[0] - logits[1])
1254
+ log_sum_exp = max_val + torch.log1p(torch.exp(-diff))
1255
+ logits_all.append(log_sum_exp)
1256
+
1257
+ max_logits = torch.max(logits, dim=0).values
1258
+ stable_logits = logits - max_logits.unsqueeze(0)
1259
+ lse_s = torch.exp(stable_logits).detach()
1260
+ lse_sum = torch.sum(lse_s, dim=0)
1261
+ lse_s /= lse_sum
1262
+ attn_outputs *= lse_s.unsqueeze(-1).transpose(2, 3).squeeze(1)
1263
+ attn_outputs_all.append(attn_outputs.sum(dim=0))
1264
+
1265
+ if return_lse:
1266
+ return (torch.cat(attn_outputs_all,
1267
+ dim=0), torch.cat(logits_all, dim=-1))
1268
+ else:
1269
+ return torch.cat(attn_outputs_all, dim=0)
1270
+
1271
+ def _dual_chunk_flash_attn_decoding(
1272
+ self,
1273
+ query: torch.Tensor,
1274
+ query_succ: torch.Tensor,
1275
+ query_inter: torch.Tensor,
1276
+ key_cache: torch.Tensor,
1277
+ value_cache: torch.Tensor,
1278
+ block_table: torch.Tensor,
1279
+ cache_seqlens: torch.Tensor,
1280
+ softmax_scale: float,
1281
+ causal: bool,
1282
+ alibi_slopes: Optional[torch.Tensor],
1283
+ chunk_size: int,
1284
+ local_size: int,
1285
+ original_max_position_embeddings: int,
1286
+ decode_meta: DualChunkFlashAttentionMetadata,
1287
+ ):
1288
+ if not causal:
1289
+ raise ValueError(
1290
+ "Dual Chunk Attention does not support causal=False")
1291
+
1292
+ block_size = value_cache.shape[1]
1293
+ chunk_len = chunk_size - local_size
1294
+ if chunk_len % block_size != 0:
1295
+ raise ValueError("chunk_len must be divisible by block_size.")
1296
+ if original_max_position_embeddings > 0:
1297
+ assert decode_meta.scaling_factor is not None
1298
+ scaling_factor = decode_meta.scaling_factor
1299
+ query = (query * scaling_factor.view(-1, 1, 1, 1)).to(
1300
+ query.dtype
1301
+ ) # possible for numerical issue, need to fused in the kernel
1302
+ query_succ = (query_succ * scaling_factor.view(-1, 1, 1, 1)).to(
1303
+ query.dtype)
1304
+ query_inter = (query_inter * scaling_factor.view(-1, 1, 1, 1)).to(
1305
+ query.dtype)
1306
+ outputs_list = []
1307
+ softmax_lses_list = []
1308
+
1309
+ # intra-attention
1310
+ intra_output, intra_softmax_lse = (
1311
+ self._dual_chunk_flash_attn_decoding_with_exp_sums(
1312
+ query,
1313
+ key_cache,
1314
+ value_cache,
1315
+ decode_meta.block_tables_intra,
1316
+ decode_meta.seq_lens_intra,
1317
+ softmax_scale,
1318
+ alibi_slopes,
1319
+ causal=False,
1320
+ ))
1321
+ outputs_list.append(intra_output)
1322
+ softmax_lses_list.append(intra_softmax_lse)
1323
+
1324
+ # succ-attention
1325
+ if decode_meta.max_seq_len_succ:
1326
+ succ_output, succ_softmax_lse = (
1327
+ self._dual_chunk_flash_attn_decoding_with_exp_sums(
1328
+ query_succ,
1329
+ key_cache,
1330
+ value_cache,
1331
+ decode_meta.block_tables_succ,
1332
+ decode_meta.seq_lens_succ,
1333
+ softmax_scale,
1334
+ alibi_slopes,
1335
+ causal=False,
1336
+ ))
1337
+ outputs_list.append(succ_output)
1338
+ softmax_lses_list.append(succ_softmax_lse)
1339
+
1340
+ # inter-attention
1341
+ if decode_meta.max_seq_len_inter:
1342
+ inter_output, inter_softmax_lse = (
1343
+ self._dual_chunk_flash_attn_decoding_with_exp_sums(
1344
+ query_inter,
1345
+ key_cache,
1346
+ value_cache,
1347
+ block_table[:, :decode_meta.max_seq_len_inter],
1348
+ decode_meta.seq_lens_inter,
1349
+ softmax_scale,
1350
+ alibi_slopes,
1351
+ causal=False,
1352
+ ))
1353
+ outputs_list.append(inter_output)
1354
+ softmax_lses_list.append(inter_softmax_lse)
1355
+ outputs = torch.stack(outputs_list, dim=0)
1356
+ del outputs_list
1357
+ softmax_lses = torch.stack(softmax_lses_list, dim=0).to(torch.float32)
1358
+ del softmax_lses_list
1359
+ max_logits = torch.max(softmax_lses, dim=0).values
1360
+ stable_logits = softmax_lses - max_logits.unsqueeze(0)
1361
+ lse_s = torch.exp(stable_logits).detach()
1362
+ lse_sum = torch.sum(lse_s, dim=0)
1363
+ lse_s /= lse_sum
1364
+ outputs *= lse_s.unsqueeze(-1).transpose(2, 3)
1365
+ return outputs.sum(0)
1366
+
1367
+ def _dual_chunk_flash_attn_decoding_with_exp_sums(
1368
+ self,
1369
+ query: torch.Tensor,
1370
+ key_cache: torch.Tensor,
1371
+ value_cache: torch.Tensor,
1372
+ block_table: torch.Tensor,
1373
+ cache_seqlens: torch.Tensor,
1374
+ softmax_scale: float,
1375
+ alibi_slopes: Optional[torch.Tensor],
1376
+ causal: bool,
1377
+ ):
1378
+ out, softmax_lse = flash_attn_with_kvcache(
1379
+ q=query,
1380
+ k_cache=key_cache,
1381
+ v_cache=value_cache,
1382
+ block_table=block_table,
1383
+ cache_seqlens=cache_seqlens,
1384
+ softmax_scale=softmax_scale,
1385
+ alibi_slopes=alibi_slopes,
1386
+ causal=causal,
1387
+ return_softmax_lse=True,
1388
+ )
1389
+ mask = (cache_seqlens == 0)
1390
+ out[mask] = 0
1391
+ softmax_lse[mask] = -float("inf")
1392
+ return out, softmax_lse
1393
+
1394
+
1395
+ def _vertical_slash_sparse_attention(
1396
+ query: torch.Tensor, # [BATCH, N_HEADS, N_CTX, D_HEAD]
1397
+ key: torch.Tensor, # [BATCH, N_HEADS, N_KV_CTX, D_HEAD]
1398
+ value: torch.Tensor, # [BATCH, N_HEADS, N_KV_CTX, D_HEAD]
1399
+ v_idx: torch.Tensor, # [BATCH, N_HEADS, NNZ_V]
1400
+ s_idx: torch.Tensor, # [BATCH, N_HEADS, NNZ_S]
1401
+ softmax_scale: float,
1402
+ causal: bool = True,
1403
+ stage: str = "intra",
1404
+ block_size_M: int = 64,
1405
+ block_size_N: int = 64,
1406
+ vertical_indices_count: torch.Tensor = None, # [N_HEADS,]
1407
+ slash_indices_count: torch.Tensor = None,
1408
+ ):
1409
+ if stage == "intra":
1410
+ assert causal
1411
+ else:
1412
+ assert not causal
1413
+
1414
+ batch_size, num_heads, context_size, head_dim = query.shape
1415
+ _, _, kv_seq_len, _ = key.shape
1416
+
1417
+ if head_dim not in [16, 32, 64, 128, 256, 512]:
1418
+ target_dim = 2**math.ceil(math.log2(head_dim)) - head_dim
1419
+ query = F.pad(query, [0, target_dim, 0, 0, 0, 0, 0, 0])
1420
+ key = F.pad(key, [0, target_dim, 0, 0, 0, 0, 0, 0])
1421
+ value = F.pad(value, [0, target_dim, 0, 0, 0, 0, 0, 0])
1422
+
1423
+ v_idx = v_idx.to(torch.int32).reshape(
1424
+ (batch_size, num_heads, -1)).sort(dim=-1, descending=False)[0]
1425
+ s_idx = s_idx.to(torch.int32).reshape(
1426
+ (batch_size, num_heads, -1)).sort(dim=-1, descending=True)[0]
1427
+ q_seqlens = torch.tensor([context_size],
1428
+ dtype=torch.int32,
1429
+ device=query.device)
1430
+ kv_seqlens = torch.tensor([kv_seq_len],
1431
+ dtype=torch.int32,
1432
+ device=query.device)
1433
+
1434
+ if vertical_indices_count is not None and slash_indices_count is not None:
1435
+ (
1436
+ block_count,
1437
+ block_offset,
1438
+ column_count,
1439
+ column_index,
1440
+ ) = ops.convert_vertical_slash_indexes_mergehead(
1441
+ q_seqlens, kv_seqlens, v_idx, s_idx, vertical_indices_count,
1442
+ slash_indices_count, context_size, block_size_M, block_size_N,
1443
+ causal)
1444
+ else:
1445
+ (
1446
+ block_count,
1447
+ block_offset,
1448
+ column_count,
1449
+ column_index,
1450
+ ) = ops.convert_vertical_slash_indexes(q_seqlens, kv_seqlens, v_idx,
1451
+ s_idx, context_size,
1452
+ block_size_M, block_size_N,
1453
+ causal)
1454
+
1455
+ q = query.transpose(1, 2).contiguous()
1456
+ k = key.transpose(1, 2).contiguous()
1457
+ v = value.transpose(1, 2).contiguous()
1458
+ out, lse = sparse_attn_func(
1459
+ q,
1460
+ k,
1461
+ v,
1462
+ block_count,
1463
+ block_offset,
1464
+ column_count,
1465
+ column_index,
1466
+ causal=causal,
1467
+ softmax_scale=softmax_scale,
1468
+ return_softmax_lse=True,
1469
+ )
1470
+ out = out.transpose(1, 2).contiguous()
1471
+ softmax_lse = lse.reshape(*lse.shape, 1)
1472
+ return (out[..., :context_size, :head_dim],
1473
+ softmax_lse[..., :context_size, :])
1474
+
1475
+
1476
+ def _sum_all_diagonal_matrix(mat: torch.tensor):
1477
+ h, n, m = mat.shape
1478
+ # Zero matrix used for padding
1479
+ zero_mat = torch.zeros((h, n, n), device=mat.device)
1480
+ # pads the matrix on left and right
1481
+ mat_padded = torch.cat((zero_mat, mat, zero_mat), -1)
1482
+ # Change the strides
1483
+ mat_strided = mat_padded.as_strided((1, n, n + m),
1484
+ (n * (2 * n + m), 2 * n + m + 1, 1))
1485
+ # Sums the resulting matrix's columns
1486
+ sum_diags = torch.sum(mat_strided, 1)
1487
+ return sum_diags[:, 1:] # drop left bottom corner
1488
+
1489
+
1490
+ def _get_block(block_table: torch.Tensor, block_size: int, begin: int,
1491
+ end: int):
1492
+ begin_block = begin // block_size
1493
+ end_block = (end - 1) // block_size + 1
1494
+ return block_table[begin_block:end_block]