vllm-cpu-amxbf16 0.9.1__cp312-cp312-manylinux_2_17_x86_64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- vllm/_C.abi3.so +0 -0
- vllm/__init__.py +53 -0
- vllm/_custom_ops.py +1828 -0
- vllm/_ipex_ops.py +244 -0
- vllm/_version.py +34 -0
- vllm/adapter_commons/__init__.py +0 -0
- vllm/adapter_commons/layers.py +16 -0
- vllm/adapter_commons/models.py +106 -0
- vllm/adapter_commons/request.py +26 -0
- vllm/adapter_commons/utils.py +93 -0
- vllm/adapter_commons/worker_manager.py +39 -0
- vllm/assets/__init__.py +0 -0
- vllm/assets/audio.py +45 -0
- vllm/assets/base.py +41 -0
- vllm/assets/image.py +34 -0
- vllm/assets/video.py +115 -0
- vllm/attention/__init__.py +20 -0
- vllm/attention/backends/__init__.py +0 -0
- vllm/attention/backends/abstract.py +308 -0
- vllm/attention/backends/blocksparse_attn.py +461 -0
- vllm/attention/backends/cpu_mla.py +307 -0
- vllm/attention/backends/dual_chunk_flash_attn.py +1498 -0
- vllm/attention/backends/flash_attn.py +1003 -0
- vllm/attention/backends/flashinfer.py +1104 -0
- vllm/attention/backends/flashmla.py +244 -0
- vllm/attention/backends/hpu_attn.py +313 -0
- vllm/attention/backends/ipex_attn.py +398 -0
- vllm/attention/backends/mla/__init__.py +0 -0
- vllm/attention/backends/mla/common.py +1385 -0
- vllm/attention/backends/pallas.py +351 -0
- vllm/attention/backends/placeholder_attn.py +400 -0
- vllm/attention/backends/rocm_aiter_mla.py +435 -0
- vllm/attention/backends/rocm_flash_attn.py +975 -0
- vllm/attention/backends/torch_sdpa.py +703 -0
- vllm/attention/backends/triton_mla.py +115 -0
- vllm/attention/backends/utils.py +610 -0
- vllm/attention/backends/xformers.py +802 -0
- vllm/attention/layer.py +468 -0
- vllm/attention/ops/__init__.py +0 -0
- vllm/attention/ops/blocksparse_attention/__init__.py +0 -0
- vllm/attention/ops/blocksparse_attention/blocksparse_attention_kernel.py +433 -0
- vllm/attention/ops/blocksparse_attention/interface.py +239 -0
- vllm/attention/ops/blocksparse_attention/utils.py +246 -0
- vllm/attention/ops/chunked_prefill_paged_decode.py +368 -0
- vllm/attention/ops/flashmla.py +116 -0
- vllm/attention/ops/hpu_paged_attn.py +88 -0
- vllm/attention/ops/ipex_attn.py +195 -0
- vllm/attention/ops/merge_attn_states.py +43 -0
- vllm/attention/ops/nki_flash_attn.py +906 -0
- vllm/attention/ops/paged_attn.py +256 -0
- vllm/attention/ops/prefix_prefill.py +902 -0
- vllm/attention/ops/rocm_aiter_mla.py +100 -0
- vllm/attention/ops/rocm_aiter_paged_attn.py +102 -0
- vllm/attention/ops/triton_decode_attention.py +674 -0
- vllm/attention/ops/triton_flash_attention.py +979 -0
- vllm/attention/ops/triton_merge_attn_states.py +97 -0
- vllm/attention/ops/triton_unified_attention.py +334 -0
- vllm/attention/selector.py +187 -0
- vllm/attention/utils/fa_utils.py +55 -0
- vllm/beam_search.py +87 -0
- vllm/benchmarks/__init__.py +0 -0
- vllm/benchmarks/datasets.py +1185 -0
- vllm/benchmarks/endpoint_request_func.py +381 -0
- vllm/benchmarks/latency.py +168 -0
- vllm/benchmarks/serve.py +1135 -0
- vllm/benchmarks/throughput.py +609 -0
- vllm/benchmarks/utils.py +70 -0
- vllm/collect_env.py +820 -0
- vllm/compilation/__init__.py +0 -0
- vllm/compilation/activation_quant_fusion.py +89 -0
- vllm/compilation/backends.py +563 -0
- vllm/compilation/base_piecewise_backend.py +72 -0
- vllm/compilation/collective_fusion.py +127 -0
- vllm/compilation/compiler_interface.py +544 -0
- vllm/compilation/counter.py +38 -0
- vllm/compilation/cuda_piecewise_backend.py +214 -0
- vllm/compilation/decorators.py +250 -0
- vllm/compilation/fix_functionalization.py +191 -0
- vllm/compilation/fusion.py +618 -0
- vllm/compilation/fx_utils.py +62 -0
- vllm/compilation/inductor_pass.py +115 -0
- vllm/compilation/monitor.py +39 -0
- vllm/compilation/multi_output_match.py +109 -0
- vllm/compilation/noop_elimination.py +137 -0
- vllm/compilation/pass_manager.py +78 -0
- vllm/compilation/sequence_parallelism.py +268 -0
- vllm/compilation/torch25_custom_graph_pass.py +42 -0
- vllm/compilation/vllm_inductor_pass.py +67 -0
- vllm/compilation/wrapper.py +135 -0
- vllm/config.py +4746 -0
- vllm/connections.py +174 -0
- vllm/core/__init__.py +0 -0
- vllm/core/block/__init__.py +0 -0
- vllm/core/block/block_table.py +399 -0
- vllm/core/block/common.py +371 -0
- vllm/core/block/cpu_gpu_block_allocator.py +441 -0
- vllm/core/block/interfaces.py +319 -0
- vllm/core/block/naive_block.py +466 -0
- vllm/core/block/prefix_caching_block.py +1135 -0
- vllm/core/block/utils.py +28 -0
- vllm/core/block_manager.py +521 -0
- vllm/core/evictor.py +157 -0
- vllm/core/interfaces.py +135 -0
- vllm/core/placeholder_block_space_manager.py +100 -0
- vllm/core/scheduler.py +2093 -0
- vllm/device_allocator/__init__.py +0 -0
- vllm/device_allocator/cumem.py +281 -0
- vllm/distributed/__init__.py +6 -0
- vllm/distributed/communication_op.py +41 -0
- vllm/distributed/device_communicators/__init__.py +0 -0
- vllm/distributed/device_communicators/all2all.py +264 -0
- vllm/distributed/device_communicators/base_device_communicator.py +260 -0
- vllm/distributed/device_communicators/cpu_communicator.py +145 -0
- vllm/distributed/device_communicators/cuda_communicator.py +176 -0
- vllm/distributed/device_communicators/cuda_wrapper.py +180 -0
- vllm/distributed/device_communicators/custom_all_reduce.py +304 -0
- vllm/distributed/device_communicators/custom_all_reduce_utils.py +259 -0
- vllm/distributed/device_communicators/hpu_communicator.py +46 -0
- vllm/distributed/device_communicators/neuron_communicator.py +20 -0
- vllm/distributed/device_communicators/pynccl.py +218 -0
- vllm/distributed/device_communicators/pynccl_wrapper.py +341 -0
- vllm/distributed/device_communicators/shm_broadcast.py +585 -0
- vllm/distributed/device_communicators/tpu_communicator.py +103 -0
- vllm/distributed/device_communicators/xpu_communicator.py +55 -0
- vllm/distributed/kv_events.py +356 -0
- vllm/distributed/kv_transfer/README.md +29 -0
- vllm/distributed/kv_transfer/__init__.py +12 -0
- vllm/distributed/kv_transfer/disagg_prefill_workflow.jpg +0 -0
- vllm/distributed/kv_transfer/kv_connector/__init__.py +0 -0
- vllm/distributed/kv_transfer/kv_connector/base.py +128 -0
- vllm/distributed/kv_transfer/kv_connector/factory.py +128 -0
- vllm/distributed/kv_transfer/kv_connector/lmcache_connector.py +99 -0
- vllm/distributed/kv_transfer/kv_connector/mooncake_store_connector.py +203 -0
- vllm/distributed/kv_transfer/kv_connector/simple_connector.py +329 -0
- vllm/distributed/kv_transfer/kv_connector/utils.py +108 -0
- vllm/distributed/kv_transfer/kv_connector/v1/__init__.py +6 -0
- vllm/distributed/kv_transfer/kv_connector/v1/base.py +283 -0
- vllm/distributed/kv_transfer/kv_connector/v1/lmcache_connector.py +134 -0
- vllm/distributed/kv_transfer/kv_connector/v1/multi_connector.py +201 -0
- vllm/distributed/kv_transfer/kv_connector/v1/nixl_connector.py +1030 -0
- vllm/distributed/kv_transfer/kv_connector/v1/shared_storage_connector.py +384 -0
- vllm/distributed/kv_transfer/kv_connector_agent.py +77 -0
- vllm/distributed/kv_transfer/kv_lookup_buffer/__init__.py +0 -0
- vllm/distributed/kv_transfer/kv_lookup_buffer/base.py +175 -0
- vllm/distributed/kv_transfer/kv_lookup_buffer/mooncake_store.py +161 -0
- vllm/distributed/kv_transfer/kv_lookup_buffer/simple_buffer.py +237 -0
- vllm/distributed/kv_transfer/kv_pipe/__init__.py +0 -0
- vllm/distributed/kv_transfer/kv_pipe/base.py +67 -0
- vllm/distributed/kv_transfer/kv_pipe/mooncake_pipe.py +280 -0
- vllm/distributed/kv_transfer/kv_pipe/pynccl_pipe.py +280 -0
- vllm/distributed/kv_transfer/kv_transfer_state.py +71 -0
- vllm/distributed/parallel_state.py +1296 -0
- vllm/distributed/tpu_distributed_utils.py +177 -0
- vllm/distributed/utils.py +536 -0
- vllm/engine/__init__.py +0 -0
- vllm/engine/arg_utils.py +1708 -0
- vllm/engine/async_llm_engine.py +1200 -0
- vllm/engine/async_timeout.py +173 -0
- vllm/engine/llm_engine.py +2097 -0
- vllm/engine/metrics.py +629 -0
- vllm/engine/metrics_types.py +94 -0
- vllm/engine/multiprocessing/__init__.py +148 -0
- vllm/engine/multiprocessing/client.py +681 -0
- vllm/engine/multiprocessing/engine.py +460 -0
- vllm/engine/output_processor/__init__.py +0 -0
- vllm/engine/output_processor/interfaces.py +75 -0
- vllm/engine/output_processor/multi_step.py +216 -0
- vllm/engine/output_processor/single_step.py +145 -0
- vllm/engine/output_processor/stop_checker.py +131 -0
- vllm/engine/output_processor/util.py +28 -0
- vllm/engine/protocol.py +317 -0
- vllm/entrypoints/__init__.py +0 -0
- vllm/entrypoints/api_server.py +178 -0
- vllm/entrypoints/chat_utils.py +1299 -0
- vllm/entrypoints/cli/__init__.py +0 -0
- vllm/entrypoints/cli/benchmark/__init__.py +0 -0
- vllm/entrypoints/cli/benchmark/base.py +39 -0
- vllm/entrypoints/cli/benchmark/latency.py +30 -0
- vllm/entrypoints/cli/benchmark/main.py +54 -0
- vllm/entrypoints/cli/benchmark/serve.py +30 -0
- vllm/entrypoints/cli/benchmark/throughput.py +30 -0
- vllm/entrypoints/cli/collect_env.py +35 -0
- vllm/entrypoints/cli/main.py +65 -0
- vllm/entrypoints/cli/openai.py +205 -0
- vllm/entrypoints/cli/run_batch.py +62 -0
- vllm/entrypoints/cli/serve.py +328 -0
- vllm/entrypoints/cli/types.py +25 -0
- vllm/entrypoints/launcher.py +147 -0
- vllm/entrypoints/llm.py +1544 -0
- vllm/entrypoints/logger.py +50 -0
- vllm/entrypoints/openai/__init__.py +0 -0
- vllm/entrypoints/openai/api_server.py +1387 -0
- vllm/entrypoints/openai/cli_args.py +315 -0
- vllm/entrypoints/openai/logits_processors.py +90 -0
- vllm/entrypoints/openai/protocol.py +1913 -0
- vllm/entrypoints/openai/run_batch.py +463 -0
- vllm/entrypoints/openai/serving_chat.py +1221 -0
- vllm/entrypoints/openai/serving_classification.py +160 -0
- vllm/entrypoints/openai/serving_completion.py +592 -0
- vllm/entrypoints/openai/serving_embedding.py +201 -0
- vllm/entrypoints/openai/serving_engine.py +986 -0
- vllm/entrypoints/openai/serving_models.py +315 -0
- vllm/entrypoints/openai/serving_pooling.py +232 -0
- vllm/entrypoints/openai/serving_score.py +433 -0
- vllm/entrypoints/openai/serving_tokenization.py +157 -0
- vllm/entrypoints/openai/serving_transcription.py +424 -0
- vllm/entrypoints/openai/tool_parsers/__init__.py +23 -0
- vllm/entrypoints/openai/tool_parsers/abstract_tool_parser.py +164 -0
- vllm/entrypoints/openai/tool_parsers/deepseekv3_tool_parser.py +370 -0
- vllm/entrypoints/openai/tool_parsers/granite_20b_fc_tool_parser.py +259 -0
- vllm/entrypoints/openai/tool_parsers/granite_tool_parser.py +237 -0
- vllm/entrypoints/openai/tool_parsers/hermes_tool_parser.py +371 -0
- vllm/entrypoints/openai/tool_parsers/internlm2_tool_parser.py +216 -0
- vllm/entrypoints/openai/tool_parsers/jamba_tool_parser.py +308 -0
- vllm/entrypoints/openai/tool_parsers/llama4_pythonic_tool_parser.py +316 -0
- vllm/entrypoints/openai/tool_parsers/llama_tool_parser.py +267 -0
- vllm/entrypoints/openai/tool_parsers/mistral_tool_parser.py +369 -0
- vllm/entrypoints/openai/tool_parsers/phi4mini_tool_parser.py +112 -0
- vllm/entrypoints/openai/tool_parsers/pythonic_tool_parser.py +308 -0
- vllm/entrypoints/openai/tool_parsers/utils.py +124 -0
- vllm/entrypoints/score_utils.py +50 -0
- vllm/entrypoints/ssl.py +75 -0
- vllm/entrypoints/utils.py +233 -0
- vllm/env_override.py +41 -0
- vllm/envs.py +944 -0
- vllm/executor/__init__.py +0 -0
- vllm/executor/executor_base.py +401 -0
- vllm/executor/mp_distributed_executor.py +244 -0
- vllm/executor/msgspec_utils.py +30 -0
- vllm/executor/multiproc_worker_utils.py +313 -0
- vllm/executor/ray_distributed_executor.py +701 -0
- vllm/executor/ray_utils.py +399 -0
- vllm/executor/uniproc_executor.py +139 -0
- vllm/forward_context.py +179 -0
- vllm/inputs/__init__.py +41 -0
- vllm/inputs/data.py +331 -0
- vllm/inputs/parse.py +151 -0
- vllm/inputs/preprocess.py +909 -0
- vllm/inputs/registry.py +237 -0
- vllm/jsontree.py +80 -0
- vllm/logger.py +212 -0
- vllm/logging_utils/__init__.py +8 -0
- vllm/logging_utils/dump_input.py +85 -0
- vllm/logging_utils/formatter.py +18 -0
- vllm/logits_process.py +119 -0
- vllm/lora/__init__.py +0 -0
- vllm/lora/fully_sharded_layers.py +355 -0
- vllm/lora/layers.py +1285 -0
- vllm/lora/lora.py +199 -0
- vllm/lora/models.py +818 -0
- vllm/lora/ops/__init__.py +0 -0
- vllm/lora/ops/torch_ops/__init__.py +16 -0
- vllm/lora/ops/torch_ops/lora_ops.py +119 -0
- vllm/lora/ops/triton_ops/__init__.py +12 -0
- vllm/lora/ops/triton_ops/kernel_utils.py +243 -0
- vllm/lora/ops/triton_ops/lora_expand_op.py +290 -0
- vllm/lora/ops/triton_ops/lora_kernel_metadata.py +148 -0
- vllm/lora/ops/triton_ops/lora_shrink_op.py +244 -0
- vllm/lora/ops/triton_ops/utils.py +120 -0
- vllm/lora/ops/xla_ops/__init__.py +7 -0
- vllm/lora/ops/xla_ops/lora_ops.py +145 -0
- vllm/lora/peft_helper.py +136 -0
- vllm/lora/punica_wrapper/__init__.py +10 -0
- vllm/lora/punica_wrapper/punica_base.py +485 -0
- vllm/lora/punica_wrapper/punica_cpu.py +349 -0
- vllm/lora/punica_wrapper/punica_gpu.py +290 -0
- vllm/lora/punica_wrapper/punica_hpu.py +145 -0
- vllm/lora/punica_wrapper/punica_selector.py +20 -0
- vllm/lora/punica_wrapper/punica_tpu.py +405 -0
- vllm/lora/punica_wrapper/utils.py +164 -0
- vllm/lora/request.py +99 -0
- vllm/lora/resolver.py +85 -0
- vllm/lora/utils.py +240 -0
- vllm/lora/worker_manager.py +259 -0
- vllm/model_executor/__init__.py +16 -0
- vllm/model_executor/custom_op.py +152 -0
- vllm/model_executor/guided_decoding/__init__.py +181 -0
- vllm/model_executor/guided_decoding/guidance_decoding.py +63 -0
- vllm/model_executor/guided_decoding/guidance_logits_processors.py +104 -0
- vllm/model_executor/guided_decoding/guided_fields.py +41 -0
- vllm/model_executor/guided_decoding/lm_format_enforcer_decoding.py +67 -0
- vllm/model_executor/guided_decoding/outlines_decoding.py +155 -0
- vllm/model_executor/guided_decoding/outlines_logits_processors.py +284 -0
- vllm/model_executor/guided_decoding/utils.py +242 -0
- vllm/model_executor/guided_decoding/xgrammar_decoding.py +426 -0
- vllm/model_executor/layers/__init__.py +0 -0
- vllm/model_executor/layers/activation.py +369 -0
- vllm/model_executor/layers/fused_moe/__init__.py +54 -0
- vllm/model_executor/layers/fused_moe/batched_deep_gemm_moe.py +125 -0
- vllm/model_executor/layers/fused_moe/batched_triton_or_deep_gemm_moe.py +117 -0
- vllm/model_executor/layers/fused_moe/configs/E=1,N=14336,device_name=NVIDIA_A100-SXM4-80GB,dtype=int8_w8a16.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=1,N=14336,device_name=NVIDIA_A100-SXM4-80GB.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=1,N=1792,device_name=NVIDIA_A100-SXM4-80GB,dtype=int8_w8a16.json +218 -0
- vllm/model_executor/layers/fused_moe/configs/E=1,N=1792,device_name=NVIDIA_A100-SXM4-80GB.json +218 -0
- vllm/model_executor/layers/fused_moe/configs/E=1,N=3072,device_name=NVIDIA_A100-SXM4-80GB,dtype=int8_w8a16.json +218 -0
- vllm/model_executor/layers/fused_moe/configs/E=1,N=3072,device_name=NVIDIA_H100_80GB_HBM3,dtype=int8_w8a16.json +218 -0
- vllm/model_executor/layers/fused_moe/configs/E=1,N=3072,device_name=NVIDIA_H100_80GB_HBM3.json +218 -0
- vllm/model_executor/layers/fused_moe/configs/E=1,N=3584,device_name=NVIDIA_A100-SXM4-80GB,dtype=int8_w8a16.json +218 -0
- vllm/model_executor/layers/fused_moe/configs/E=1,N=3584,device_name=NVIDIA_A100-SXM4-80GB.json +218 -0
- vllm/model_executor/layers/fused_moe/configs/E=1,N=7168,device_name=NVIDIA_A100-SXM4-80GB,dtype=int8_w8a16.json +218 -0
- vllm/model_executor/layers/fused_moe/configs/E=1,N=7168,device_name=NVIDIA_A100-SXM4-80GB.json +218 -0
- vllm/model_executor/layers/fused_moe/configs/E=128,N=1024,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8.json +164 -0
- vllm/model_executor/layers/fused_moe/configs/E=128,N=1024,device_name=AMD_Instinct_MI300X.json +200 -0
- vllm/model_executor/layers/fused_moe/configs/E=128,N=192,device_name=NVIDIA_A100-SXM4-80GB.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=128,N=192,device_name=NVIDIA_H100_80GB_HBM3.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=128,N=192,device_name=NVIDIA_H20-3e.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=128,N=192,device_name=NVIDIA_H20.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=128,N=192,device_name=NVIDIA_H200.json +146 -0
- 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
- 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
- vllm/model_executor/layers/fused_moe/configs/E=128,N=384,device_name=NVIDIA_H20-3e.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=128,N=384,device_name=NVIDIA_H20.json +146 -0
- 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
- vllm/model_executor/layers/fused_moe/configs/E=128,N=384,device_name=NVIDIA_H200.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=128,N=512,device_name=NVIDIA_H100_80GB_HBM3.json +146 -0
- 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
- 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
- vllm/model_executor/layers/fused_moe/configs/E=128,N=768,device_name=NVIDIA_H20.json +146 -0
- 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
- vllm/model_executor/layers/fused_moe/configs/E=128,N=768,device_name=NVIDIA_H200.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=128,N=96,device_name=NVIDIA_H20.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=16,N=1024,device_name=AMD_Instinct_MI300X.json +200 -0
- vllm/model_executor/layers/fused_moe/configs/E=16,N=1024,device_name=NVIDIA_H100.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=16,N=1344,device_name=NVIDIA_A100-SXM4-40GB.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=16,N=1344,device_name=NVIDIA_A100-SXM4-80GB.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=16,N=1344,device_name=NVIDIA_H100_80GB_HBM3.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=16,N=14336,device_name=NVIDIA_A100-SXM4-80GB,dtype=int8_w8a16.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=16,N=14336,device_name=NVIDIA_A100-SXM4-80GB.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=16,N=1792,device_name=NVIDIA_A100-SXM4-80GB,dtype=int8_w8a16.json +218 -0
- vllm/model_executor/layers/fused_moe/configs/E=16,N=1792,device_name=NVIDIA_A100-SXM4-80GB.json +218 -0
- vllm/model_executor/layers/fused_moe/configs/E=16,N=2688,device_name=NVIDIA_A100-SXM4-80GB.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=16,N=2688,device_name=NVIDIA_H100_80GB_HBM3.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=16,N=3072,device_name=NVIDIA_A100-SXM4-80GB,dtype=int8_w8a16.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=16,N=3072,device_name=NVIDIA_H100_80GB_HBM3,dtype=int8_w8a16.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=16,N=3200,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8.json +130 -0
- vllm/model_executor/layers/fused_moe/configs/E=16,N=3584,device_name=NVIDIA_A100-SXM4-80GB,dtype=int8_w8a16.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=16,N=3584,device_name=NVIDIA_A100-SXM4-80GB.json +218 -0
- vllm/model_executor/layers/fused_moe/configs/E=16,N=6400,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8.json +130 -0
- vllm/model_executor/layers/fused_moe/configs/E=16,N=7168,device_name=NVIDIA_A100-SXM4-80GB,dtype=int8_w8a16.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=16,N=7168,device_name=NVIDIA_A100-SXM4-80GB.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=16,N=7168,device_name=NVIDIA_H100_80GB_HBM3,dtype=int8_w8a16.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=16,N=800,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8.json +130 -0
- vllm/model_executor/layers/fused_moe/configs/E=160,N=192,device_name=NVIDIA_A800-SXM4-80GB.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=256,N=1024,device_name=AMD_Instinct_MI325X,block_shape=[128,128].json +200 -0
- 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
- 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
- vllm/model_executor/layers/fused_moe/configs/E=256,N=128,device_name=NVIDIA_A100-SXM4-80GB,dtype=int8_w8a8.json +146 -0
- 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
- vllm/model_executor/layers/fused_moe/configs/E=256,N=128,device_name=NVIDIA_A800-SXM4-80GB,dtype=int8_w8a8.json +146 -0
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- vllm/model_executor/layers/fused_moe/configs/E=256,N=256,device_name=NVIDIA_H20-3e,dtype=fp8_w8a8,block_shape=[128,128].json +146 -0
- 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
- 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
- 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
- vllm/model_executor/layers/fused_moe/configs/E=256,N=64,device_name=NVIDIA_A800-SXM4-80GB.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=60,N=1408,device_name=AMD_Instinct_MI300X.json +200 -0
- vllm/model_executor/layers/fused_moe/configs/E=60,N=176,device_name=AMD_Instinct_MI300X.json +200 -0
- vllm/model_executor/layers/fused_moe/configs/E=60,N=352,device_name=AMD_Instinct_MI300X.json +200 -0
- vllm/model_executor/layers/fused_moe/configs/E=60,N=704,device_name=AMD_Instinct_MI300X.json +200 -0
- vllm/model_executor/layers/fused_moe/configs/E=64,N=1280,device_name=NVIDIA_A100-SXM4-80GB.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=64,N=1280,device_name=NVIDIA_A800-SXM4-80GB.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=64,N=1280,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=64,N=1280,device_name=NVIDIA_H100_80GB_HBM3.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=64,N=1280,device_name=NVIDIA_H200,dtype=fp8_w8a8.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=64,N=1280,device_name=NVIDIA_H200.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=64,N=2560,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=64,N=2560,device_name=NVIDIA_H200,dtype=fp8_w8a8.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=64,N=2560,device_name=NVIDIA_H200.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=64,N=320,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=64,N=320,device_name=NVIDIA_H100_80GB_HBM3.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=64,N=320,device_name=NVIDIA_H200,dtype=fp8_w8a8.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=64,N=320,device_name=NVIDIA_H200.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=64,N=640,device_name=NVIDIA_A100-SXM4-80GB.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=64,N=640,device_name=NVIDIA_A800-SXM4-80GB.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=64,N=640,device_name=NVIDIA_GeForce_RTX_4090,dtype=fp8_w8a8.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=64,N=640,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=64,N=640,device_name=NVIDIA_H100_80GB_HBM3.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=64,N=640,device_name=NVIDIA_H200,dtype=fp8_w8a8.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=64,N=640,device_name=NVIDIA_H200.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=64,N=896,device_name=NVIDIA_H20.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=14336,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8.json +164 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=14336,device_name=AMD_Instinct_MI300X.json +200 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=14336,device_name=AMD_Instinct_MI325X,dtype=fp8_w8a8.json +164 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=14336,device_name=AMD_Instinct_MI325X.json +200 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=14336,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8.json +138 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=14336,device_name=NVIDIA_H200,dtype=fp8_w8a8.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=14336,device_name=NVIDIA_H200.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=16384,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8.json +164 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=16384,device_name=AMD_Instinct_MI300X.json +200 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=16384,device_name=AMD_Instinct_MI325X,dtype=fp8_w8a8.json +164 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=16384,device_name=AMD_Instinct_MI325X.json +200 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=1792,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8.json +164 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=1792,device_name=AMD_Instinct_MI300X.json +200 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=1792,device_name=AMD_Instinct_MI325X,dtype=fp8_w8a8.json +164 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=1792,device_name=AMD_Instinct_MI325X.json +200 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=1792,device_name=NVIDIA_A100-SXM4-40GB.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=1792,device_name=NVIDIA_A100-SXM4-80GB.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=1792,device_name=NVIDIA_H100_80GB_HBM3.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=1792,device_name=NVIDIA_H200,dtype=fp8_w8a8.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=1792,device_name=NVIDIA_H200.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=2048,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8.json +164 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=2048,device_name=AMD_Instinct_MI300X.json +200 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=2048,device_name=AMD_Instinct_MI325X,dtype=fp8_w8a8.json +164 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=2048,device_name=AMD_Instinct_MI325X.json +200 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=2048,device_name=NVIDIA_A100-SXM4-80GB.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=2048,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=2048,device_name=NVIDIA_H100_80GB_HBM3.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=2048,device_name=NVIDIA_H200,dtype=fp8_w8a8.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=2048,device_name=NVIDIA_H200.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=3584,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8.json +164 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=3584,device_name=AMD_Instinct_MI300X.json +200 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=3584,device_name=AMD_Instinct_MI325X,dtype=fp8_w8a8.json +164 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=3584,device_name=AMD_Instinct_MI325X.json +200 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=3584,device_name=NVIDIA_A100-SXM4-40GB.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=3584,device_name=NVIDIA_A100-SXM4-80GB.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=3584,device_name=NVIDIA_GeForce_RTX_4090,dtype=fp8_w8a8.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=3584,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=3584,device_name=NVIDIA_H100_80GB_HBM3.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=3584,device_name=NVIDIA_H200,dtype=fp8_w8a8.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=3584,device_name=NVIDIA_H200.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=3584,device_name=NVIDIA_L40S.json +173 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=4096,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8.json +164 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=4096,device_name=AMD_Instinct_MI300X.json +200 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=4096,device_name=AMD_Instinct_MI325X,dtype=fp8_w8a8.json +164 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=4096,device_name=AMD_Instinct_MI325X.json +200 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=4096,device_name=NVIDIA_A100-SXM4-80GB.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=4096,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=4096,device_name=NVIDIA_H100_80GB_HBM3.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=4096,device_name=NVIDIA_H200,dtype=fp8_w8a8.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=4096,device_name=NVIDIA_H200.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=7168,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8.json +164 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=7168,device_name=AMD_Instinct_MI300X.json +200 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=7168,device_name=AMD_Instinct_MI325X,dtype=fp8_w8a8.json +164 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=7168,device_name=AMD_Instinct_MI325X.json +200 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=7168,device_name=NVIDIA_A100-SXM4-80GB.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=7168,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=7168,device_name=NVIDIA_H100_80GB_HBM3.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=7168,device_name=NVIDIA_H200,dtype=fp8_w8a8.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=7168,device_name=NVIDIA_H200.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=8192,device_name=AMD_Instinct_MI300X,dtype=fp8_w8a8.json +164 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=8192,device_name=AMD_Instinct_MI300X.json +200 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=8192,device_name=AMD_Instinct_MI325X,dtype=fp8_w8a8.json +164 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=8192,device_name=AMD_Instinct_MI325X.json +200 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=8192,device_name=NVIDIA_H100_80GB_HBM3,dtype=fp8_w8a8.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/E=8,N=8192,device_name=NVIDIA_H200,dtype=fp8_w8a8.json +146 -0
- vllm/model_executor/layers/fused_moe/configs/README +12 -0
- vllm/model_executor/layers/fused_moe/cutlass_moe.py +461 -0
- vllm/model_executor/layers/fused_moe/deep_gemm_moe.py +240 -0
- vllm/model_executor/layers/fused_moe/deepep_ht_prepare_finalize.py +240 -0
- vllm/model_executor/layers/fused_moe/deepep_ll_prepare_finalize.py +186 -0
- vllm/model_executor/layers/fused_moe/fused_batched_moe.py +775 -0
- vllm/model_executor/layers/fused_moe/fused_marlin_moe.py +232 -0
- vllm/model_executor/layers/fused_moe/fused_moe.py +1724 -0
- vllm/model_executor/layers/fused_moe/layer.py +1535 -0
- vllm/model_executor/layers/fused_moe/modular_kernel.py +446 -0
- vllm/model_executor/layers/fused_moe/moe_align_block_size.py +243 -0
- vllm/model_executor/layers/fused_moe/moe_pallas.py +80 -0
- vllm/model_executor/layers/fused_moe/moe_permute_unpermute.py +190 -0
- vllm/model_executor/layers/fused_moe/moe_torch_iterative.py +60 -0
- vllm/model_executor/layers/fused_moe/pplx_prepare_finalize.py +159 -0
- vllm/model_executor/layers/fused_moe/prepare_finalize.py +69 -0
- vllm/model_executor/layers/fused_moe/rocm_aiter_fused_moe.py +421 -0
- vllm/model_executor/layers/fused_moe/triton_deep_gemm_moe.py +117 -0
- vllm/model_executor/layers/fused_moe/utils.py +98 -0
- vllm/model_executor/layers/layernorm.py +288 -0
- vllm/model_executor/layers/lightning_attn.py +652 -0
- vllm/model_executor/layers/linear.py +1524 -0
- vllm/model_executor/layers/logits_processor.py +197 -0
- vllm/model_executor/layers/mamba/__init__.py +0 -0
- vllm/model_executor/layers/mamba/mamba2_metadata.py +125 -0
- vllm/model_executor/layers/mamba/mamba_mixer.py +245 -0
- vllm/model_executor/layers/mamba/mamba_mixer2.py +616 -0
- vllm/model_executor/layers/mamba/ops/__init__.py +0 -0
- vllm/model_executor/layers/mamba/ops/causal_conv1d.py +105 -0
- vllm/model_executor/layers/mamba/ops/mamba_ssm.py +414 -0
- vllm/model_executor/layers/mamba/ops/ssd_bmm.py +262 -0
- vllm/model_executor/layers/mamba/ops/ssd_chunk_scan.py +589 -0
- vllm/model_executor/layers/mamba/ops/ssd_chunk_state.py +751 -0
- vllm/model_executor/layers/mamba/ops/ssd_combined.py +232 -0
- vllm/model_executor/layers/mamba/ops/ssd_state_passing.py +206 -0
- vllm/model_executor/layers/pooler.py +350 -0
- vllm/model_executor/layers/quantization/__init__.py +157 -0
- vllm/model_executor/layers/quantization/aqlm.py +376 -0
- vllm/model_executor/layers/quantization/auto_round.py +310 -0
- vllm/model_executor/layers/quantization/awq.py +194 -0
- vllm/model_executor/layers/quantization/awq_marlin.py +519 -0
- vllm/model_executor/layers/quantization/awq_triton.py +320 -0
- vllm/model_executor/layers/quantization/base_config.py +151 -0
- vllm/model_executor/layers/quantization/bitblas.py +461 -0
- vllm/model_executor/layers/quantization/bitsandbytes.py +396 -0
- vllm/model_executor/layers/quantization/compressed_tensors/__init__.py +0 -0
- vllm/model_executor/layers/quantization/compressed_tensors/compressed_tensors.py +668 -0
- vllm/model_executor/layers/quantization/compressed_tensors/compressed_tensors_moe.py +1260 -0
- vllm/model_executor/layers/quantization/compressed_tensors/schemes/__init__.py +24 -0
- vllm/model_executor/layers/quantization/compressed_tensors/schemes/compressed_tensors_24.py +358 -0
- vllm/model_executor/layers/quantization/compressed_tensors/schemes/compressed_tensors_scheme.py +55 -0
- vllm/model_executor/layers/quantization/compressed_tensors/schemes/compressed_tensors_w4a16_24.py +160 -0
- vllm/model_executor/layers/quantization/compressed_tensors/schemes/compressed_tensors_w4a16_nvfp4.py +93 -0
- vllm/model_executor/layers/quantization/compressed_tensors/schemes/compressed_tensors_w4a4_nvfp4.py +178 -0
- vllm/model_executor/layers/quantization/compressed_tensors/schemes/compressed_tensors_w8a16_fp8.py +121 -0
- vllm/model_executor/layers/quantization/compressed_tensors/schemes/compressed_tensors_w8a8_fp8.py +150 -0
- vllm/model_executor/layers/quantization/compressed_tensors/schemes/compressed_tensors_w8a8_int8.py +111 -0
- vllm/model_executor/layers/quantization/compressed_tensors/schemes/compressed_tensors_wNa16.py +201 -0
- vllm/model_executor/layers/quantization/compressed_tensors/triton_scaled_mm.py +206 -0
- vllm/model_executor/layers/quantization/compressed_tensors/utils.py +216 -0
- vllm/model_executor/layers/quantization/deepspeedfp.py +195 -0
- vllm/model_executor/layers/quantization/experts_int8.py +196 -0
- vllm/model_executor/layers/quantization/fbgemm_fp8.py +172 -0
- vllm/model_executor/layers/quantization/fp8.py +906 -0
- vllm/model_executor/layers/quantization/gguf.py +565 -0
- vllm/model_executor/layers/quantization/gptq.py +278 -0
- vllm/model_executor/layers/quantization/gptq_bitblas.py +445 -0
- vllm/model_executor/layers/quantization/gptq_marlin.py +648 -0
- vllm/model_executor/layers/quantization/gptq_marlin_24.py +297 -0
- vllm/model_executor/layers/quantization/hqq_marlin.py +332 -0
- vllm/model_executor/layers/quantization/ipex_quant.py +250 -0
- vllm/model_executor/layers/quantization/kernels/__init__.py +0 -0
- vllm/model_executor/layers/quantization/kernels/mixed_precision/MPLinearKernel.py +90 -0
- vllm/model_executor/layers/quantization/kernels/mixed_precision/__init__.py +83 -0
- vllm/model_executor/layers/quantization/kernels/mixed_precision/allspark.py +116 -0
- vllm/model_executor/layers/quantization/kernels/mixed_precision/bitblas.py +300 -0
- vllm/model_executor/layers/quantization/kernels/mixed_precision/exllama.py +143 -0
- vllm/model_executor/layers/quantization/kernels/mixed_precision/machete.py +120 -0
- vllm/model_executor/layers/quantization/kernels/mixed_precision/marlin.py +131 -0
- vllm/model_executor/layers/quantization/kernels/scaled_mm/ScaledMMLinearKernel.py +67 -0
- vllm/model_executor/layers/quantization/kernels/scaled_mm/__init__.py +87 -0
- vllm/model_executor/layers/quantization/kernels/scaled_mm/aiter.py +120 -0
- vllm/model_executor/layers/quantization/kernels/scaled_mm/cutlass.py +137 -0
- vllm/model_executor/layers/quantization/kernels/scaled_mm/triton.py +41 -0
- vllm/model_executor/layers/quantization/kernels/scaled_mm/xla.py +105 -0
- vllm/model_executor/layers/quantization/kv_cache.py +139 -0
- vllm/model_executor/layers/quantization/marlin.py +261 -0
- vllm/model_executor/layers/quantization/modelopt.py +737 -0
- vllm/model_executor/layers/quantization/moe_wna16.py +449 -0
- vllm/model_executor/layers/quantization/neuron_quant.py +76 -0
- vllm/model_executor/layers/quantization/ptpc_fp8.py +127 -0
- vllm/model_executor/layers/quantization/qqq.py +275 -0
- vllm/model_executor/layers/quantization/quark/__init__.py +0 -0
- vllm/model_executor/layers/quantization/quark/quark.py +441 -0
- vllm/model_executor/layers/quantization/quark/quark_moe.py +237 -0
- vllm/model_executor/layers/quantization/quark/schemes/__init__.py +9 -0
- vllm/model_executor/layers/quantization/quark/schemes/quark_scheme.py +55 -0
- vllm/model_executor/layers/quantization/quark/schemes/quark_w4a4_mxfp4.py +126 -0
- vllm/model_executor/layers/quantization/quark/schemes/quark_w8a8_fp8.py +146 -0
- vllm/model_executor/layers/quantization/quark/schemes/quark_w8a8_int8.py +122 -0
- vllm/model_executor/layers/quantization/quark/utils.py +105 -0
- vllm/model_executor/layers/quantization/schema.py +86 -0
- vllm/model_executor/layers/quantization/torchao.py +161 -0
- vllm/model_executor/layers/quantization/tpu_int8.py +121 -0
- vllm/model_executor/layers/quantization/utils/__init__.py +6 -0
- vllm/model_executor/layers/quantization/utils/allspark_utils.py +52 -0
- vllm/model_executor/layers/quantization/utils/bitblas_utils.py +208 -0
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- vllm/model_executor/layers/quantization/utils/fp8_utils.py +618 -0
- vllm/model_executor/layers/quantization/utils/gptq_utils.py +95 -0
- vllm/model_executor/layers/quantization/utils/int8_utils.py +485 -0
- vllm/model_executor/layers/quantization/utils/layer_utils.py +40 -0
- vllm/model_executor/layers/quantization/utils/machete_utils.py +33 -0
- vllm/model_executor/layers/quantization/utils/marlin_utils.py +476 -0
- vllm/model_executor/layers/quantization/utils/marlin_utils_fp4.py +283 -0
- vllm/model_executor/layers/quantization/utils/marlin_utils_fp8.py +325 -0
- vllm/model_executor/layers/quantization/utils/marlin_utils_test.py +165 -0
- vllm/model_executor/layers/quantization/utils/marlin_utils_test_24.py +464 -0
- vllm/model_executor/layers/quantization/utils/marlin_utils_test_qqq.py +126 -0
- vllm/model_executor/layers/quantization/utils/mxfp4_utils.py +45 -0
- vllm/model_executor/layers/quantization/utils/nvfp4_emulation_utils.py +104 -0
- vllm/model_executor/layers/quantization/utils/quant_utils.py +573 -0
- vllm/model_executor/layers/quantization/utils/w8a8_utils.py +405 -0
- vllm/model_executor/layers/rejection_sampler.py +406 -0
- vllm/model_executor/layers/resampler.py +270 -0
- vllm/model_executor/layers/rotary_embedding.py +1862 -0
- vllm/model_executor/layers/sampler.py +1204 -0
- vllm/model_executor/layers/spec_decode_base_sampler.py +259 -0
- vllm/model_executor/layers/typical_acceptance_sampler.py +166 -0
- vllm/model_executor/layers/utils.py +95 -0
- vllm/model_executor/layers/vocab_parallel_embedding.py +487 -0
- vllm/model_executor/model_loader/__init__.py +76 -0
- vllm/model_executor/model_loader/base_loader.py +43 -0
- vllm/model_executor/model_loader/bitsandbytes_loader.py +570 -0
- vllm/model_executor/model_loader/default_loader.py +282 -0
- vllm/model_executor/model_loader/dummy_loader.py +27 -0
- vllm/model_executor/model_loader/gguf_loader.py +120 -0
- vllm/model_executor/model_loader/neuron.py +476 -0
- vllm/model_executor/model_loader/neuronx_distributed.py +685 -0
- vllm/model_executor/model_loader/runai_streamer_loader.py +109 -0
- vllm/model_executor/model_loader/sharded_state_loader.py +201 -0
- vllm/model_executor/model_loader/tensorizer.py +600 -0
- vllm/model_executor/model_loader/tensorizer_loader.py +123 -0
- vllm/model_executor/model_loader/tpu.py +112 -0
- vllm/model_executor/model_loader/utils.py +302 -0
- vllm/model_executor/model_loader/weight_utils.py +782 -0
- vllm/model_executor/models/__init__.py +28 -0
- vllm/model_executor/models/adapters.py +248 -0
- vllm/model_executor/models/aimv2.py +246 -0
- vllm/model_executor/models/arctic.py +559 -0
- vllm/model_executor/models/aria.py +657 -0
- vllm/model_executor/models/aya_vision.py +466 -0
- vllm/model_executor/models/baichuan.py +474 -0
- vllm/model_executor/models/bamba.py +543 -0
- vllm/model_executor/models/bart.py +938 -0
- vllm/model_executor/models/bert.py +523 -0
- vllm/model_executor/models/bert_with_rope.py +769 -0
- vllm/model_executor/models/blip.py +339 -0
- vllm/model_executor/models/blip2.py +718 -0
- vllm/model_executor/models/bloom.py +373 -0
- vllm/model_executor/models/chameleon.py +1136 -0
- vllm/model_executor/models/chatglm.py +478 -0
- vllm/model_executor/models/clip.py +407 -0
- vllm/model_executor/models/commandr.py +472 -0
- vllm/model_executor/models/constant_size_cache.py +137 -0
- vllm/model_executor/models/dbrx.py +472 -0
- vllm/model_executor/models/deepseek.py +486 -0
- vllm/model_executor/models/deepseek_mtp.py +269 -0
- vllm/model_executor/models/deepseek_v2.py +843 -0
- vllm/model_executor/models/deepseek_vl2.py +648 -0
- vllm/model_executor/models/eagle.py +260 -0
- vllm/model_executor/models/exaone.py +551 -0
- vllm/model_executor/models/fairseq2_llama.py +154 -0
- vllm/model_executor/models/falcon.py +510 -0
- vllm/model_executor/models/falcon_h1.py +685 -0
- vllm/model_executor/models/florence2.py +1103 -0
- vllm/model_executor/models/fuyu.py +389 -0
- vllm/model_executor/models/gemma.py +425 -0
- vllm/model_executor/models/gemma2.py +425 -0
- vllm/model_executor/models/gemma3.py +533 -0
- vllm/model_executor/models/gemma3_mm.py +709 -0
- vllm/model_executor/models/glm.py +23 -0
- vllm/model_executor/models/glm4.py +305 -0
- vllm/model_executor/models/glm4v.py +648 -0
- vllm/model_executor/models/gpt2.py +328 -0
- vllm/model_executor/models/gpt_bigcode.py +335 -0
- vllm/model_executor/models/gpt_j.py +339 -0
- vllm/model_executor/models/gpt_neox.py +332 -0
- vllm/model_executor/models/granite.py +493 -0
- vllm/model_executor/models/granite_speech.py +779 -0
- vllm/model_executor/models/granitemoe.py +437 -0
- vllm/model_executor/models/granitemoehybrid.py +586 -0
- vllm/model_executor/models/granitemoeshared.py +341 -0
- vllm/model_executor/models/gritlm.py +224 -0
- vllm/model_executor/models/grok1.py +546 -0
- vllm/model_executor/models/h2ovl.py +546 -0
- vllm/model_executor/models/idefics2_vision_model.py +389 -0
- vllm/model_executor/models/idefics3.py +776 -0
- vllm/model_executor/models/interfaces.py +572 -0
- vllm/model_executor/models/interfaces_base.py +164 -0
- vllm/model_executor/models/intern_vit.py +480 -0
- vllm/model_executor/models/internlm2.py +455 -0
- vllm/model_executor/models/internlm2_ve.py +147 -0
- vllm/model_executor/models/internvl.py +1418 -0
- vllm/model_executor/models/jais.py +373 -0
- vllm/model_executor/models/jamba.py +592 -0
- vllm/model_executor/models/kimi_vl.py +577 -0
- vllm/model_executor/models/llama.py +644 -0
- vllm/model_executor/models/llama4.py +532 -0
- vllm/model_executor/models/llama_eagle.py +165 -0
- vllm/model_executor/models/llama_eagle3.py +263 -0
- vllm/model_executor/models/llava.py +866 -0
- vllm/model_executor/models/llava_next.py +586 -0
- vllm/model_executor/models/llava_next_video.py +471 -0
- vllm/model_executor/models/llava_onevision.py +956 -0
- vllm/model_executor/models/mamba.py +273 -0
- vllm/model_executor/models/mamba2.py +308 -0
- vllm/model_executor/models/mamba_cache.py +76 -0
- vllm/model_executor/models/medusa.py +219 -0
- vllm/model_executor/models/mimo.py +192 -0
- vllm/model_executor/models/mimo_mtp.py +285 -0
- vllm/model_executor/models/minicpm.py +592 -0
- vllm/model_executor/models/minicpm3.py +230 -0
- vllm/model_executor/models/minicpm_eagle.py +391 -0
- vllm/model_executor/models/minicpmo.py +759 -0
- vllm/model_executor/models/minicpmv.py +1287 -0
- vllm/model_executor/models/minimax_cache.py +36 -0
- vllm/model_executor/models/minimax_text_01.py +1301 -0
- vllm/model_executor/models/minimax_vl_01.py +364 -0
- vllm/model_executor/models/mistral3.py +604 -0
- vllm/model_executor/models/mixtral.py +488 -0
- vllm/model_executor/models/mixtral_quant.py +453 -0
- vllm/model_executor/models/mllama.py +1624 -0
- vllm/model_executor/models/mllama4.py +938 -0
- vllm/model_executor/models/mlp_speculator.py +206 -0
- vllm/model_executor/models/modernbert.py +331 -0
- vllm/model_executor/models/module_mapping.py +72 -0
- vllm/model_executor/models/molmo.py +1568 -0
- vllm/model_executor/models/moonvit.py +630 -0
- vllm/model_executor/models/mpt.py +331 -0
- vllm/model_executor/models/nemotron.py +508 -0
- vllm/model_executor/models/nemotron_h.py +573 -0
- vllm/model_executor/models/nemotron_nas.py +484 -0
- vllm/model_executor/models/nvlm_d.py +216 -0
- vllm/model_executor/models/olmo.py +389 -0
- vllm/model_executor/models/olmo2.py +414 -0
- vllm/model_executor/models/olmoe.py +468 -0
- vllm/model_executor/models/opt.py +412 -0
- vllm/model_executor/models/orion.py +349 -0
- vllm/model_executor/models/ovis.py +567 -0
- vllm/model_executor/models/paligemma.py +398 -0
- vllm/model_executor/models/persimmon.py +344 -0
- vllm/model_executor/models/phi.py +356 -0
- vllm/model_executor/models/phi3.py +19 -0
- vllm/model_executor/models/phi3_small.py +465 -0
- vllm/model_executor/models/phi3v.py +723 -0
- vllm/model_executor/models/phi4mm.py +1246 -0
- vllm/model_executor/models/phi4mm_audio.py +1233 -0
- vllm/model_executor/models/phi4mm_utils.py +1884 -0
- vllm/model_executor/models/phimoe.py +665 -0
- vllm/model_executor/models/pixtral.py +1316 -0
- vllm/model_executor/models/plamo2.py +738 -0
- vllm/model_executor/models/prithvi_geospatial_mae.py +232 -0
- vllm/model_executor/models/qwen.py +362 -0
- vllm/model_executor/models/qwen2.py +497 -0
- vllm/model_executor/models/qwen2_5_omni_thinker.py +904 -0
- vllm/model_executor/models/qwen2_5_vl.py +1166 -0
- vllm/model_executor/models/qwen2_audio.py +410 -0
- vllm/model_executor/models/qwen2_moe.py +540 -0
- vllm/model_executor/models/qwen2_rm.py +132 -0
- vllm/model_executor/models/qwen2_vl.py +1405 -0
- vllm/model_executor/models/qwen3.py +321 -0
- vllm/model_executor/models/qwen3_moe.py +535 -0
- vllm/model_executor/models/qwen_vl.py +785 -0
- vllm/model_executor/models/registry.py +622 -0
- vllm/model_executor/models/roberta.py +276 -0
- vllm/model_executor/models/siglip.py +524 -0
- vllm/model_executor/models/skyworkr1v.py +951 -0
- vllm/model_executor/models/smolvlm.py +52 -0
- vllm/model_executor/models/solar.py +506 -0
- vllm/model_executor/models/stablelm.py +343 -0
- vllm/model_executor/models/starcoder2.py +356 -0
- vllm/model_executor/models/tarsier.py +643 -0
- vllm/model_executor/models/telechat2.py +140 -0
- vllm/model_executor/models/teleflm.py +79 -0
- vllm/model_executor/models/transformers.py +508 -0
- vllm/model_executor/models/ultravox.py +656 -0
- vllm/model_executor/models/utils.py +731 -0
- vllm/model_executor/models/vision.py +147 -0
- vllm/model_executor/models/whisper.py +747 -0
- vllm/model_executor/models/zamba2.py +1009 -0
- vllm/model_executor/parameter.py +459 -0
- vllm/model_executor/pooling_metadata.py +72 -0
- vllm/model_executor/sampling_metadata.py +597 -0
- vllm/model_executor/utils.py +77 -0
- vllm/multimodal/__init__.py +33 -0
- vllm/multimodal/audio.py +106 -0
- vllm/multimodal/base.py +219 -0
- vllm/multimodal/hasher.py +118 -0
- vllm/multimodal/image.py +97 -0
- vllm/multimodal/inputs.py +876 -0
- vllm/multimodal/parse.py +461 -0
- vllm/multimodal/processing.py +1895 -0
- vllm/multimodal/profiling.py +258 -0
- vllm/multimodal/registry.py +331 -0
- vllm/multimodal/utils.py +436 -0
- vllm/multimodal/video.py +198 -0
- vllm/outputs.py +512 -0
- vllm/platforms/__init__.py +291 -0
- vllm/platforms/cpu.py +266 -0
- vllm/platforms/cuda.py +526 -0
- vllm/platforms/hpu.py +106 -0
- vllm/platforms/interface.py +538 -0
- vllm/platforms/neuron.py +150 -0
- vllm/platforms/rocm.py +435 -0
- vllm/platforms/tpu.py +216 -0
- vllm/platforms/xpu.py +156 -0
- vllm/plugins/__init__.py +94 -0
- vllm/plugins/lora_resolvers/README.md +15 -0
- vllm/plugins/lora_resolvers/__init__.py +0 -0
- vllm/plugins/lora_resolvers/filesystem_resolver.py +50 -0
- vllm/pooling_params.py +54 -0
- vllm/profiler/__init__.py +0 -0
- vllm/profiler/layerwise_profile.py +375 -0
- vllm/profiler/utils.py +148 -0
- vllm/prompt_adapter/__init__.py +0 -0
- vllm/prompt_adapter/layers.py +83 -0
- vllm/prompt_adapter/models.py +358 -0
- vllm/prompt_adapter/request.py +37 -0
- vllm/prompt_adapter/utils.py +98 -0
- vllm/prompt_adapter/worker_manager.py +179 -0
- vllm/py.typed +2 -0
- vllm/reasoning/__init__.py +15 -0
- vllm/reasoning/abs_reasoning_parsers.py +192 -0
- vllm/reasoning/deepseek_r1_reasoning_parser.py +173 -0
- vllm/reasoning/granite_reasoning_parser.py +363 -0
- vllm/reasoning/qwen3_reasoning_parser.py +151 -0
- vllm/sampling_params.py +602 -0
- vllm/scalar_type.py +347 -0
- vllm/scripts.py +15 -0
- vllm/sequence.py +1568 -0
- vllm/spec_decode/__init__.py +0 -0
- vllm/spec_decode/batch_expansion.py +506 -0
- vllm/spec_decode/draft_model_runner.py +349 -0
- vllm/spec_decode/interfaces.py +99 -0
- vllm/spec_decode/medusa_worker.py +138 -0
- vllm/spec_decode/metrics.py +213 -0
- vllm/spec_decode/mlp_speculator_worker.py +94 -0
- vllm/spec_decode/mqa_scorer.py +160 -0
- vllm/spec_decode/multi_step_worker.py +423 -0
- vllm/spec_decode/ngram_worker.py +196 -0
- vllm/spec_decode/proposer_worker_base.py +59 -0
- vllm/spec_decode/smaller_tp_proposer_worker.py +196 -0
- vllm/spec_decode/spec_decode_worker.py +1326 -0
- vllm/spec_decode/target_model_runner.py +45 -0
- vllm/spec_decode/top1_proposer.py +275 -0
- vllm/spec_decode/util.py +277 -0
- vllm/test_utils.py +130 -0
- vllm/third_party/__init__.py +0 -0
- vllm/third_party/pynvml.py +6140 -0
- vllm/tracing.py +131 -0
- vllm/transformers_utils/__init__.py +24 -0
- vllm/transformers_utils/chat_templates/__init__.py +5 -0
- vllm/transformers_utils/chat_templates/registry.py +60 -0
- vllm/transformers_utils/chat_templates/template_basic.jinja +3 -0
- vllm/transformers_utils/chat_templates/template_blip2.jinja +11 -0
- vllm/transformers_utils/chat_templates/template_chatml.jinja +10 -0
- vllm/transformers_utils/chat_templates/template_deepseek_vl2.jinja +23 -0
- vllm/transformers_utils/chat_templates/template_fuyu.jinja +3 -0
- vllm/transformers_utils/config.py +887 -0
- vllm/transformers_utils/configs/__init__.py +61 -0
- vllm/transformers_utils/configs/arctic.py +207 -0
- vllm/transformers_utils/configs/chatglm.py +72 -0
- vllm/transformers_utils/configs/cohere2.py +195 -0
- vllm/transformers_utils/configs/dbrx.py +280 -0
- vllm/transformers_utils/configs/deepseek_vl2.py +216 -0
- vllm/transformers_utils/configs/eagle.py +85 -0
- vllm/transformers_utils/configs/exaone.py +190 -0
- vllm/transformers_utils/configs/falcon.py +90 -0
- vllm/transformers_utils/configs/h2ovl.py +16 -0
- vllm/transformers_utils/configs/internvl.py +54 -0
- vllm/transformers_utils/configs/jais.py +238 -0
- vllm/transformers_utils/configs/kimi_vl.py +37 -0
- vllm/transformers_utils/configs/medusa.py +63 -0
- vllm/transformers_utils/configs/minimax_text_01.py +70 -0
- vllm/transformers_utils/configs/minimax_vl_01.py +71 -0
- vllm/transformers_utils/configs/mllama.py +31 -0
- vllm/transformers_utils/configs/mlp_speculator.py +68 -0
- vllm/transformers_utils/configs/moonvit.py +33 -0
- vllm/transformers_utils/configs/mpt.py +180 -0
- vllm/transformers_utils/configs/nemotron.py +205 -0
- vllm/transformers_utils/configs/nemotron_h.py +258 -0
- vllm/transformers_utils/configs/nvlm_d.py +15 -0
- vllm/transformers_utils/configs/ovis.py +184 -0
- vllm/transformers_utils/configs/skyworkr1v.py +54 -0
- vllm/transformers_utils/configs/solar.py +247 -0
- vllm/transformers_utils/configs/telechat2.py +64 -0
- vllm/transformers_utils/configs/ultravox.py +108 -0
- vllm/transformers_utils/detokenizer.py +168 -0
- vllm/transformers_utils/detokenizer_utils.py +189 -0
- vllm/transformers_utils/processor.py +221 -0
- vllm/transformers_utils/processors/__init__.py +8 -0
- vllm/transformers_utils/processors/deepseek_vl2.py +363 -0
- vllm/transformers_utils/processors/ovis.py +420 -0
- vllm/transformers_utils/s3_utils.py +162 -0
- vllm/transformers_utils/tokenizer.py +302 -0
- vllm/transformers_utils/tokenizer_base.py +149 -0
- vllm/transformers_utils/tokenizer_group.py +120 -0
- vllm/transformers_utils/tokenizers/__init__.py +10 -0
- vllm/transformers_utils/tokenizers/mistral.py +493 -0
- vllm/transformers_utils/utils.py +99 -0
- vllm/triton_utils/__init__.py +14 -0
- vllm/triton_utils/importing.py +50 -0
- vllm/usage/__init__.py +0 -0
- vllm/usage/usage_lib.py +256 -0
- vllm/utils.py +2910 -0
- vllm/v1/__init__.py +0 -0
- vllm/v1/attention/__init__.py +0 -0
- vllm/v1/attention/backends/__init__.py +0 -0
- vllm/v1/attention/backends/cpu_attn.py +163 -0
- vllm/v1/attention/backends/flash_attn.py +869 -0
- vllm/v1/attention/backends/flashinfer.py +651 -0
- vllm/v1/attention/backends/flex_attention.py +477 -0
- vllm/v1/attention/backends/mla/__init__.py +0 -0
- vllm/v1/attention/backends/mla/common.py +931 -0
- vllm/v1/attention/backends/mla/cutlass_mla.py +97 -0
- vllm/v1/attention/backends/mla/flashmla.py +152 -0
- vllm/v1/attention/backends/mla/rocm_aiter_mla.py +220 -0
- vllm/v1/attention/backends/mla/triton_mla.py +120 -0
- vllm/v1/attention/backends/pallas.py +240 -0
- vllm/v1/attention/backends/triton_attn.py +285 -0
- vllm/v1/attention/backends/utils.py +52 -0
- vllm/v1/core/__init__.py +0 -0
- vllm/v1/core/block_pool.py +349 -0
- vllm/v1/core/encoder_cache_manager.py +150 -0
- vllm/v1/core/kv_cache_coordinator.py +363 -0
- vllm/v1/core/kv_cache_manager.py +392 -0
- vllm/v1/core/kv_cache_utils.py +996 -0
- vllm/v1/core/sched/__init__.py +0 -0
- vllm/v1/core/sched/interface.py +150 -0
- vllm/v1/core/sched/output.py +154 -0
- vllm/v1/core/sched/scheduler.py +1044 -0
- vllm/v1/core/sched/utils.py +23 -0
- vllm/v1/core/single_type_kv_cache_manager.py +403 -0
- vllm/v1/engine/__init__.py +173 -0
- vllm/v1/engine/async_llm.py +558 -0
- vllm/v1/engine/coordinator.py +253 -0
- vllm/v1/engine/core.py +961 -0
- vllm/v1/engine/core_client.py +1129 -0
- vllm/v1/engine/detokenizer.py +261 -0
- vllm/v1/engine/exceptions.py +17 -0
- vllm/v1/engine/llm_engine.py +317 -0
- vllm/v1/engine/logprobs.py +199 -0
- vllm/v1/engine/mm_input_cache.py +91 -0
- vllm/v1/engine/output_processor.py +428 -0
- vllm/v1/engine/parallel_sampling.py +133 -0
- vllm/v1/engine/processor.py +407 -0
- vllm/v1/executor/__init__.py +0 -0
- vllm/v1/executor/abstract.py +113 -0
- vllm/v1/executor/multiproc_executor.py +537 -0
- vllm/v1/executor/ray_distributed_executor.py +62 -0
- vllm/v1/kv_cache_interface.py +194 -0
- vllm/v1/metrics/__init__.py +0 -0
- vllm/v1/metrics/loggers.py +523 -0
- vllm/v1/metrics/prometheus.py +82 -0
- vllm/v1/metrics/ray_wrappers.py +131 -0
- vllm/v1/metrics/reader.py +246 -0
- vllm/v1/metrics/stats.py +239 -0
- vllm/v1/outputs.py +116 -0
- vllm/v1/request.py +193 -0
- vllm/v1/sample/__init__.py +0 -0
- vllm/v1/sample/metadata.py +44 -0
- vllm/v1/sample/ops/__init__.py +0 -0
- vllm/v1/sample/ops/bad_words.py +39 -0
- vllm/v1/sample/ops/penalties.py +59 -0
- vllm/v1/sample/ops/topk_topp_sampler.py +293 -0
- vllm/v1/sample/rejection_sampler.py +631 -0
- vllm/v1/sample/sampler.py +286 -0
- vllm/v1/sample/tpu/__init__.py +0 -0
- vllm/v1/sample/tpu/metadata.py +124 -0
- vllm/v1/sample/tpu/sampler.py +145 -0
- vllm/v1/serial_utils.py +315 -0
- vllm/v1/spec_decode/__init__.py +0 -0
- vllm/v1/spec_decode/eagle.py +432 -0
- vllm/v1/spec_decode/medusa.py +62 -0
- vllm/v1/spec_decode/metadata.py +62 -0
- vllm/v1/spec_decode/metrics.py +178 -0
- vllm/v1/spec_decode/ngram_proposer.py +132 -0
- vllm/v1/spec_decode/utils.py +46 -0
- vllm/v1/structured_output/__init__.py +222 -0
- vllm/v1/structured_output/backend_guidance.py +245 -0
- vllm/v1/structured_output/backend_types.py +134 -0
- vllm/v1/structured_output/backend_xgrammar.py +318 -0
- vllm/v1/structured_output/request.py +86 -0
- vllm/v1/structured_output/utils.py +175 -0
- vllm/v1/utils.py +743 -0
- vllm/v1/worker/__init__.py +0 -0
- vllm/v1/worker/block_table.py +142 -0
- vllm/v1/worker/cpu_model_runner.py +86 -0
- vllm/v1/worker/cpu_worker.py +152 -0
- vllm/v1/worker/gpu_input_batch.py +681 -0
- vllm/v1/worker/gpu_model_runner.py +2320 -0
- vllm/v1/worker/gpu_worker.py +393 -0
- vllm/v1/worker/lora_model_runner_mixin.py +173 -0
- vllm/v1/worker/tpu_model_runner.py +1673 -0
- vllm/v1/worker/tpu_worker.py +299 -0
- vllm/v1/worker/utils.py +111 -0
- vllm/v1/worker/worker_base.py +65 -0
- vllm/version.py +41 -0
- vllm/vllm_flash_attn/.gitkeep +0 -0
- vllm/worker/__init__.py +0 -0
- vllm/worker/cache_engine.py +145 -0
- vllm/worker/cpu_enc_dec_model_runner.py +326 -0
- vllm/worker/cpu_model_runner.py +671 -0
- vllm/worker/cpu_pooling_model_runner.py +125 -0
- vllm/worker/cpu_worker.py +450 -0
- vllm/worker/enc_dec_model_runner.py +555 -0
- vllm/worker/hpu_model_runner.py +2320 -0
- vllm/worker/hpu_worker.py +484 -0
- vllm/worker/model_runner.py +2178 -0
- vllm/worker/model_runner_base.py +282 -0
- vllm/worker/multi_step_hpu_worker.py +123 -0
- vllm/worker/multi_step_model_runner.py +911 -0
- vllm/worker/multi_step_neuron_model_runner.py +84 -0
- vllm/worker/multi_step_neuronx_distributed_model_runner.py +63 -0
- vllm/worker/multi_step_tpu_worker.py +108 -0
- vllm/worker/multi_step_worker.py +197 -0
- vllm/worker/neuron_model_runner.py +460 -0
- vllm/worker/neuron_worker.py +193 -0
- vllm/worker/neuronx_distributed_model_runner.py +294 -0
- vllm/worker/pooling_model_runner.py +211 -0
- vllm/worker/tpu_model_runner.py +909 -0
- vllm/worker/tpu_worker.py +337 -0
- vllm/worker/utils.py +53 -0
- vllm/worker/worker.py +577 -0
- vllm/worker/worker_base.py +646 -0
- vllm/worker/xpu_model_runner.py +606 -0
- vllm/worker/xpu_worker.py +186 -0
- vllm_cpu_amxbf16-0.9.1.dist-info/METADATA +305 -0
- vllm_cpu_amxbf16-0.9.1.dist-info/RECORD +1197 -0
- vllm_cpu_amxbf16-0.9.1.dist-info/WHEEL +5 -0
- vllm_cpu_amxbf16-0.9.1.dist-info/entry_points.txt +5 -0
- vllm_cpu_amxbf16-0.9.1.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,1246 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
|
3
|
+
import math
|
|
4
|
+
from collections.abc import Iterable, Mapping, Sequence
|
|
5
|
+
from typing import Any, Literal, Optional, TypedDict, Union
|
|
6
|
+
|
|
7
|
+
import numpy as np
|
|
8
|
+
import torch
|
|
9
|
+
import torch.nn as nn
|
|
10
|
+
from transformers import (BatchFeature, PretrainedConfig, ProcessorMixin,
|
|
11
|
+
SequenceFeatureExtractor, SiglipVisionConfig)
|
|
12
|
+
|
|
13
|
+
from vllm.config import VllmConfig
|
|
14
|
+
from vllm.distributed import get_pp_group
|
|
15
|
+
from vllm.model_executor.layers.logits_processor import LogitsProcessor
|
|
16
|
+
from vllm.model_executor.layers.quantization import QuantizationConfig
|
|
17
|
+
from vllm.model_executor.layers.vocab_parallel_embedding import (
|
|
18
|
+
DEFAULT_VOCAB_PADDING_SIZE, ParallelLMHead)
|
|
19
|
+
from vllm.model_executor.models.llama import LlamaModel
|
|
20
|
+
from vllm.model_executor.models.module_mapping import MultiModelKeys
|
|
21
|
+
from vllm.model_executor.sampling_metadata import SamplingMetadata
|
|
22
|
+
from vllm.multimodal import MULTIMODAL_REGISTRY
|
|
23
|
+
from vllm.multimodal.inputs import (MultiModalDataDict, MultiModalFieldConfig,
|
|
24
|
+
MultiModalKwargs, NestedTensors)
|
|
25
|
+
from vllm.multimodal.parse import (AudioProcessorItems, ImageEmbeddingItems,
|
|
26
|
+
ImageProcessorItems, ImageSize,
|
|
27
|
+
MultiModalDataItems, MultiModalDataParser)
|
|
28
|
+
from vllm.multimodal.processing import (BaseMultiModalProcessor,
|
|
29
|
+
BaseProcessingInfo, PromptReplacement,
|
|
30
|
+
PromptUpdate)
|
|
31
|
+
from vllm.multimodal.profiling import BaseDummyInputsBuilder
|
|
32
|
+
from vllm.sequence import IntermediateTensors
|
|
33
|
+
from vllm.utils import is_list_of
|
|
34
|
+
|
|
35
|
+
from .idefics2_vision_model import Idefics2VisionTransformer
|
|
36
|
+
from .interfaces import MultiModalEmbeddings, SupportsLoRA, SupportsMultiModal
|
|
37
|
+
from .phi4mm_audio import AudioEmbedding
|
|
38
|
+
from .utils import (AutoWeightsLoader, WeightsMapper, flatten_bn, maybe_prefix,
|
|
39
|
+
merge_multimodal_embeddings)
|
|
40
|
+
|
|
41
|
+
# <|endoftext10|> (see vocab.json in hf model)
|
|
42
|
+
_IMAGE_PLACEHOLDER_TOKEN_ID = 200010
|
|
43
|
+
# <|endoftext11|>
|
|
44
|
+
_AUDIO_PLACEHOLDER_TOKEN_ID = 200011
|
|
45
|
+
|
|
46
|
+
_AUDIO_MAX_SOUNDFILE_SIZE = 241_000
|
|
47
|
+
|
|
48
|
+
SIGLIP_NAME = "siglip-so400m-patch14-448"
|
|
49
|
+
VISION_ENCODER_TO_PROCESSING_CONFIG = {
|
|
50
|
+
'siglip-so400m-patch14-448': {
|
|
51
|
+
'vit_image_size': 448,
|
|
52
|
+
'vit_patch_size': 14,
|
|
53
|
+
'token_compression_factor': 2,
|
|
54
|
+
},
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def _get_padding_size(orig_width: int, orig_height: int, target_height: int,
|
|
59
|
+
target_width: int):
|
|
60
|
+
ratio_width = target_width / orig_width
|
|
61
|
+
ratio_height = target_height / orig_height
|
|
62
|
+
|
|
63
|
+
if ratio_width < ratio_height:
|
|
64
|
+
padding_width = 0
|
|
65
|
+
padding_height = target_height - int(orig_height * ratio_width)
|
|
66
|
+
else:
|
|
67
|
+
padding_width = target_width - int(orig_width * ratio_height)
|
|
68
|
+
padding_height = 0
|
|
69
|
+
return padding_height, padding_width
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def get_navit_vision_model(layer_idx: int = -1, **kwargs):
|
|
73
|
+
vision_config = {
|
|
74
|
+
"hidden_size": 1152,
|
|
75
|
+
"image_size": 448,
|
|
76
|
+
"intermediate_size": 4304,
|
|
77
|
+
"model_type": "siglip_vision_model",
|
|
78
|
+
"num_attention_heads": 16,
|
|
79
|
+
"num_hidden_layers": 27,
|
|
80
|
+
"patch_size": 14,
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
model_config = SiglipVisionConfig(**vision_config, **kwargs)
|
|
84
|
+
if layer_idx < 0:
|
|
85
|
+
num_hidden_layers = model_config.num_hidden_layers \
|
|
86
|
+
+ layer_idx + 1
|
|
87
|
+
else:
|
|
88
|
+
num_hidden_layers = layer_idx + 1
|
|
89
|
+
|
|
90
|
+
vision_model = Idefics2VisionTransformer(
|
|
91
|
+
config=model_config,
|
|
92
|
+
require_post_norm=False,
|
|
93
|
+
num_hidden_layers_override=num_hidden_layers,
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
return vision_model
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
class Phi4MMImageEncoder(nn.Module):
|
|
100
|
+
"""Image embedding."""
|
|
101
|
+
|
|
102
|
+
def __init__(self,
|
|
103
|
+
config: PretrainedConfig,
|
|
104
|
+
quant_config: Optional[QuantizationConfig],
|
|
105
|
+
prefix: str = "",
|
|
106
|
+
model_dir: str = "") -> None:
|
|
107
|
+
super().__init__()
|
|
108
|
+
|
|
109
|
+
# n_embed or hidden_size
|
|
110
|
+
hidden_size = config.n_embd if hasattr(
|
|
111
|
+
config, 'n_embd') else config.hidden_size
|
|
112
|
+
|
|
113
|
+
# layer_idx to output the img features
|
|
114
|
+
if isinstance(config.img_processor, dict):
|
|
115
|
+
self.layer_idx = config.img_processor.get('layer_idx', -2)
|
|
116
|
+
self.type_feature = config.img_processor.get(
|
|
117
|
+
'type_feature', 'patch')
|
|
118
|
+
else:
|
|
119
|
+
self.layer_idx = -2
|
|
120
|
+
self.type_feature = 'patch'
|
|
121
|
+
|
|
122
|
+
self.img_processor = get_navit_vision_model(layer_idx=self.layer_idx)
|
|
123
|
+
|
|
124
|
+
pe_weight = self.img_processor.embeddings.position_embedding.weight
|
|
125
|
+
L, D = pe_weight.size()
|
|
126
|
+
H = int(math.sqrt(L))
|
|
127
|
+
assert H**2 == L, f'position embedding size {L} is not square'
|
|
128
|
+
if H % 2 != 0:
|
|
129
|
+
self.img_processor_padding = nn.ReflectionPad2d((0, 1, 0, 1))
|
|
130
|
+
H += 1
|
|
131
|
+
image_dim_out = D
|
|
132
|
+
# ((448/14)//2)**2
|
|
133
|
+
self.num_img_tokens = (H // 2)**2
|
|
134
|
+
self.base_feat_height_target = H
|
|
135
|
+
|
|
136
|
+
self.image_dim_out = image_dim_out
|
|
137
|
+
self.img_sizes = None
|
|
138
|
+
self.image_attention_mask = None
|
|
139
|
+
|
|
140
|
+
# global_gn and sub_gn for hd transform, serves as line separator
|
|
141
|
+
self.use_hd_transform = True
|
|
142
|
+
self.with_learnable_separator = True
|
|
143
|
+
self.hd_transform_order = "sub_glb"
|
|
144
|
+
self.freeze_img_processor = False
|
|
145
|
+
self.crop_size = 448
|
|
146
|
+
|
|
147
|
+
# image token compression
|
|
148
|
+
self.image_token_compression_cls = 'avg_pool_2d'
|
|
149
|
+
self.image_token_compression = nn.AvgPool2d(kernel_size=2, stride=2)
|
|
150
|
+
self.base_feat_height_reduction = 1
|
|
151
|
+
self.base_feat_height_target = self.base_feat_height_target // 2
|
|
152
|
+
|
|
153
|
+
# with_hd_transform and with_learnable_separator should have same value
|
|
154
|
+
assert self.use_hd_transform == self.with_learnable_separator, \
|
|
155
|
+
'use_hd_transform and with_learnable_separator should have same value'
|
|
156
|
+
assert self.use_hd_transform, \
|
|
157
|
+
'learnable separator is only for hd transform'
|
|
158
|
+
# 1024 * 4, merge spatial to channel dimension
|
|
159
|
+
self.glb_GN = nn.Parameter(
|
|
160
|
+
torch.zeros([
|
|
161
|
+
1, 1, self.image_dim_out * self.base_feat_height_reduction**2
|
|
162
|
+
]))
|
|
163
|
+
self.sub_GN = nn.Parameter(
|
|
164
|
+
torch.zeros([
|
|
165
|
+
1, 1, 1,
|
|
166
|
+
self.image_dim_out * self.base_feat_height_reduction**2
|
|
167
|
+
]))
|
|
168
|
+
|
|
169
|
+
dim_projection = hidden_size
|
|
170
|
+
depth = 2
|
|
171
|
+
layers = [
|
|
172
|
+
nn.Linear(image_dim_out * self.base_feat_height_reduction**2,
|
|
173
|
+
dim_projection)
|
|
174
|
+
]
|
|
175
|
+
for _ in range(1, depth):
|
|
176
|
+
layers.extend(
|
|
177
|
+
[nn.GELU(),
|
|
178
|
+
nn.Linear(dim_projection, dim_projection)])
|
|
179
|
+
self.img_projection = nn.Sequential(*layers)
|
|
180
|
+
|
|
181
|
+
self.vocab_size = config.vocab_size
|
|
182
|
+
self.img_features = None
|
|
183
|
+
|
|
184
|
+
self.use_out_place_operations = False
|
|
185
|
+
|
|
186
|
+
def get_img_features(self,
|
|
187
|
+
img_embeds: torch.FloatTensor,
|
|
188
|
+
attention_mask=None) -> torch.FloatTensor:
|
|
189
|
+
|
|
190
|
+
img_feature = self.img_processor(img_embeds,
|
|
191
|
+
patch_attention_mask=attention_mask)
|
|
192
|
+
|
|
193
|
+
if self.type_feature == "patch":
|
|
194
|
+
patch_feature = img_feature
|
|
195
|
+
|
|
196
|
+
use_token_compression = self.image_token_compression is not None
|
|
197
|
+
use_padding = getattr(self, 'img_processor_padding',
|
|
198
|
+
None) is not None
|
|
199
|
+
if use_token_compression or use_padding:
|
|
200
|
+
# reshape to 2D tensor
|
|
201
|
+
width = int(math.sqrt(patch_feature.size(1)))
|
|
202
|
+
patch_feature = patch_feature.view(-1, width, width,
|
|
203
|
+
patch_feature.size(-1))
|
|
204
|
+
# convert to NCHW
|
|
205
|
+
patch_feature = patch_feature.permute(0, 3, 1, 2)
|
|
206
|
+
|
|
207
|
+
if use_padding:
|
|
208
|
+
patch_feature = self.img_processor_padding(patch_feature)
|
|
209
|
+
if use_token_compression:
|
|
210
|
+
patch_feature = self.image_token_compression(patch_feature)
|
|
211
|
+
|
|
212
|
+
# convert to NHWC
|
|
213
|
+
patch_feature = patch_feature.permute(0, 2, 3, 1)
|
|
214
|
+
patch_feature = patch_feature.view(
|
|
215
|
+
-1,
|
|
216
|
+
patch_feature.size(1) * patch_feature.size(2),
|
|
217
|
+
patch_feature.size(-1))
|
|
218
|
+
|
|
219
|
+
return patch_feature
|
|
220
|
+
|
|
221
|
+
raise NotImplementedError
|
|
222
|
+
|
|
223
|
+
def forward(self, pixel_values: torch.FloatTensor,
|
|
224
|
+
image_sizes: torch.Tensor,
|
|
225
|
+
image_attention_mask: torch.Tensor) -> list[torch.FloatTensor]:
|
|
226
|
+
"""
|
|
227
|
+
process image and return vision embeddings.
|
|
228
|
+
|
|
229
|
+
pixel_values: (num_images, num_crops, c, h, w)
|
|
230
|
+
image_sizes: [[h1, w1], [h2, w2]]
|
|
231
|
+
image_attention_mask: num_images x num_crops x 32 x 32
|
|
232
|
+
output: (num_images, num_img_tokens, hidden_size)
|
|
233
|
+
"""
|
|
234
|
+
|
|
235
|
+
# eg
|
|
236
|
+
# pixel_values: torch.Size([1, 7, 3, 448, 448])
|
|
237
|
+
# image_sizes: tensor([[ 896, 1344]], device='cuda:0')
|
|
238
|
+
# output: torch.Size([1, 1841, 3072])
|
|
239
|
+
|
|
240
|
+
if isinstance(self.img_projection, nn.Sequential):
|
|
241
|
+
target_device = self.img_projection[0].bias.device
|
|
242
|
+
target_dtype = self.img_projection[0].bias.dtype
|
|
243
|
+
else: # It's a single nn.Linear layer
|
|
244
|
+
target_device = self.img_projection.bias.device
|
|
245
|
+
target_dtype = self.img_projection.bias.dtype
|
|
246
|
+
|
|
247
|
+
img_sizes = image_sizes
|
|
248
|
+
num_images, num_crops, c, h, w = pixel_values.shape
|
|
249
|
+
bs = num_images
|
|
250
|
+
pixel_values = pixel_values.flatten(0, 1)
|
|
251
|
+
|
|
252
|
+
img_features = self.get_img_features(
|
|
253
|
+
pixel_values,
|
|
254
|
+
image_attention_mask.type(torch.BoolTensor).flatten(
|
|
255
|
+
0, 1).to(target_device))
|
|
256
|
+
|
|
257
|
+
base_feat_height_target = self.base_feat_height_target
|
|
258
|
+
base_resolution = self.crop_size
|
|
259
|
+
base_feat_height_reduction = self.base_feat_height_reduction
|
|
260
|
+
|
|
261
|
+
base_feat_height = base_feat_width = int(np.sqrt(
|
|
262
|
+
img_features.shape[1]))
|
|
263
|
+
assert base_feat_height == base_feat_height_target \
|
|
264
|
+
and base_feat_width == base_feat_height_target, \
|
|
265
|
+
f'base_feat_height: {base_feat_height},"\
|
|
266
|
+
f" base_feat_width: {base_feat_width}, "\
|
|
267
|
+
f"expect {base_feat_height_target} features for hd transform'
|
|
268
|
+
|
|
269
|
+
# bs x max_num_crops x (24x24) x C
|
|
270
|
+
img_features = img_features.view(bs, -1,
|
|
271
|
+
base_feat_height * base_feat_width,
|
|
272
|
+
self.image_dim_out)
|
|
273
|
+
C = self.image_dim_out
|
|
274
|
+
H = base_feat_height
|
|
275
|
+
|
|
276
|
+
output_imgs = []
|
|
277
|
+
output_len = []
|
|
278
|
+
# training is tensor, inference is list
|
|
279
|
+
if isinstance(img_sizes, torch.Tensor):
|
|
280
|
+
img_sizes = img_sizes.view(-1, 2)
|
|
281
|
+
for _bs in range(bs):
|
|
282
|
+
h, w = img_sizes[_bs]
|
|
283
|
+
h = h // base_resolution
|
|
284
|
+
w = w // base_resolution
|
|
285
|
+
B_ = h * w
|
|
286
|
+
|
|
287
|
+
# 1 x (24x24) x 1024
|
|
288
|
+
global_img_feature = img_features[_bs, :1]
|
|
289
|
+
|
|
290
|
+
# 1 x 12 x 12 x 4096
|
|
291
|
+
glb_img = global_img_feature.reshape(1, H, H, C).reshape(
|
|
292
|
+
1, H // base_feat_height_reduction, base_feat_height_reduction,
|
|
293
|
+
H // base_feat_height_reduction, base_feat_height_reduction,
|
|
294
|
+
C).contiguous().permute(0, 1, 3, 2, 4, 5).reshape(
|
|
295
|
+
1, H // base_feat_height_reduction,
|
|
296
|
+
H // base_feat_height_reduction,
|
|
297
|
+
base_feat_height_reduction * base_feat_height_reduction *
|
|
298
|
+
C).contiguous()
|
|
299
|
+
temp_glb_GN = self.sub_GN.repeat(1,
|
|
300
|
+
H // base_feat_height_reduction,
|
|
301
|
+
1, 1)
|
|
302
|
+
|
|
303
|
+
# 1 x 156 x 4096
|
|
304
|
+
glb_img = torch.cat([glb_img, temp_glb_GN], dim=2).reshape(
|
|
305
|
+
1, -1,
|
|
306
|
+
base_feat_height_reduction * base_feat_height_reduction * C)
|
|
307
|
+
|
|
308
|
+
# (max_num_crops-1) x (12x12) x C
|
|
309
|
+
sub_img = img_features[_bs, 1:]
|
|
310
|
+
# 16x574x1024
|
|
311
|
+
# get rid of padding sub_img
|
|
312
|
+
sub_img = sub_img[:B_]
|
|
313
|
+
|
|
314
|
+
# (num_crops, 12, 2, 12, 2, 1024) ->
|
|
315
|
+
# (num_crops, 12, 12, 2, 2, 1024) -> (num_crops, 12*12, 4*1024)
|
|
316
|
+
sub_img = sub_img.reshape(B_, H, H, C).reshape(
|
|
317
|
+
B_, H // base_feat_height_reduction,
|
|
318
|
+
base_feat_height_reduction, H // base_feat_height_reduction,
|
|
319
|
+
base_feat_height_reduction,
|
|
320
|
+
C).contiguous().permute(0, 1, 3, 2, 4, 5).reshape(
|
|
321
|
+
B_, -1, base_feat_height_reduction *
|
|
322
|
+
base_feat_height_reduction * C).contiguous()
|
|
323
|
+
sub_img = sub_img.reshape(
|
|
324
|
+
1, h, w, base_feat_height // base_feat_height_reduction,
|
|
325
|
+
base_feat_width // base_feat_height_reduction,
|
|
326
|
+
-1).permute(0, 1, 3, 2, 4, 5).reshape(
|
|
327
|
+
1, h * base_feat_height // base_feat_height_reduction,
|
|
328
|
+
w * base_feat_width // base_feat_height_reduction,
|
|
329
|
+
base_feat_height_reduction * base_feat_height_reduction *
|
|
330
|
+
C)
|
|
331
|
+
|
|
332
|
+
if image_attention_mask is not None and len(
|
|
333
|
+
image_attention_mask) > 0:
|
|
334
|
+
reshaped_image_attention_mask = image_attention_mask[
|
|
335
|
+
_bs, 1:B_ + 1, 0::2, 0::2].reshape(
|
|
336
|
+
1, h, w,
|
|
337
|
+
base_feat_height // base_feat_height_reduction,
|
|
338
|
+
base_feat_width // base_feat_height_reduction).permute(
|
|
339
|
+
0, 1, 3, 2, 4).reshape(
|
|
340
|
+
1, h * base_feat_height //
|
|
341
|
+
base_feat_height_reduction, w *
|
|
342
|
+
base_feat_width // base_feat_height_reduction)
|
|
343
|
+
useful_height = int(
|
|
344
|
+
reshaped_image_attention_mask[0, :, 0].sum().item())
|
|
345
|
+
useful_width = int(
|
|
346
|
+
reshaped_image_attention_mask[0, 0, :].sum().item())
|
|
347
|
+
sub_img = sub_img[:, :useful_height, :useful_width]
|
|
348
|
+
temp_sub_GN = self.sub_GN.repeat(1, useful_height, 1, 1)
|
|
349
|
+
temp_len = int(
|
|
350
|
+
image_attention_mask[_bs, :B_ + 1, 0::2, 0::2].sum().item(
|
|
351
|
+
)) + (useful_height +
|
|
352
|
+
1) + base_feat_height // base_feat_height_reduction
|
|
353
|
+
else:
|
|
354
|
+
temp_sub_GN = self.sub_GN.repeat(
|
|
355
|
+
1, h * base_feat_height // base_feat_height_reduction, 1,
|
|
356
|
+
1)
|
|
357
|
+
temp_len = int((h * w + 1) * self.num_img_tokens + 1 +
|
|
358
|
+
(h + 1) * base_feat_height //
|
|
359
|
+
base_feat_height_reduction)
|
|
360
|
+
|
|
361
|
+
sub_img = torch.cat([sub_img, temp_sub_GN], dim=2).reshape(
|
|
362
|
+
1, -1,
|
|
363
|
+
base_feat_height_reduction * base_feat_height_reduction * C)
|
|
364
|
+
# (1, num_img_tokens, 1024*4)
|
|
365
|
+
|
|
366
|
+
# glb + sub
|
|
367
|
+
if self.hd_transform_order == 'glb_sub':
|
|
368
|
+
output_imgs.append(
|
|
369
|
+
torch.cat([glb_img, self.glb_GN, sub_img], dim=1))
|
|
370
|
+
elif self.hd_transform_order == 'sub_glb':
|
|
371
|
+
output_imgs.append(
|
|
372
|
+
torch.cat([sub_img, self.glb_GN, glb_img], dim=1))
|
|
373
|
+
else:
|
|
374
|
+
raise NotImplementedError(
|
|
375
|
+
f'hd_transform_order = {self.hd_transform_order}, "\
|
|
376
|
+
"not implemented')
|
|
377
|
+
|
|
378
|
+
#temp_len = int((h*w+1)*144 + 1 + (h+1)*12)
|
|
379
|
+
assert temp_len == output_imgs[-1].shape[
|
|
380
|
+
1], f'temp_len: {temp_len}, output_imgs[-1].shape[1]: "\
|
|
381
|
+
"{output_imgs[-1].shape[1]}'
|
|
382
|
+
|
|
383
|
+
output_len.append(temp_len)
|
|
384
|
+
|
|
385
|
+
img_set_tensor = []
|
|
386
|
+
for _output_img in output_imgs:
|
|
387
|
+
img_feature_proj = self.img_projection(
|
|
388
|
+
_output_img.to(target_device).to(target_dtype))
|
|
389
|
+
img_set_tensor.append(img_feature_proj.squeeze(0))
|
|
390
|
+
|
|
391
|
+
return img_set_tensor
|
|
392
|
+
|
|
393
|
+
|
|
394
|
+
class Phi4MMImagePixelInputs(TypedDict):
|
|
395
|
+
type: Literal["pixel_values"]
|
|
396
|
+
data: Union[torch.Tensor, list[torch.Tensor]]
|
|
397
|
+
"""
|
|
398
|
+
Shape:
|
|
399
|
+
`(batch_size * num_images, 1 + num_patches, num_channels, height, width)`
|
|
400
|
+
|
|
401
|
+
Note that `num_patches` may be different per batch and image,
|
|
402
|
+
in which case the data is passed as a list instead of a batched tensor.
|
|
403
|
+
"""
|
|
404
|
+
|
|
405
|
+
image_sizes: torch.Tensor
|
|
406
|
+
"""
|
|
407
|
+
Shape: `(batch_size * num_images, 2)`
|
|
408
|
+
|
|
409
|
+
This should be in `(height, width)` format.
|
|
410
|
+
"""
|
|
411
|
+
|
|
412
|
+
num_img_tokens: list[int]
|
|
413
|
+
"""Shape: `(batch_size * num_images)`"""
|
|
414
|
+
|
|
415
|
+
image_attention_mask: torch.Tensor
|
|
416
|
+
"""Shape: `(batch_size * num_images, H_mask, W_mask)`"""
|
|
417
|
+
|
|
418
|
+
|
|
419
|
+
class Phi4MMAudioFeatureInputs(TypedDict):
|
|
420
|
+
type: Literal["audio_features"]
|
|
421
|
+
data: Union[torch.Tensor, list[torch.Tensor]]
|
|
422
|
+
"""Shape: `(batch_size * num_audios, 80, M)"""
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
class Phi4MMAudioEmbeddingInputs(TypedDict):
|
|
426
|
+
type: Literal["audio_embeds"]
|
|
427
|
+
data: NestedTensors
|
|
428
|
+
"""Shape: `(batch_size, num_audios, audio_feature_size, hidden_size)"""
|
|
429
|
+
|
|
430
|
+
|
|
431
|
+
Phi4MMAudioInputs = Union[Phi4MMAudioFeatureInputs, Phi4MMAudioEmbeddingInputs]
|
|
432
|
+
|
|
433
|
+
|
|
434
|
+
def cat_with_pad(tensors, dim, padding_value=0):
|
|
435
|
+
"""
|
|
436
|
+
cat along dim, while pad to max for all other dims
|
|
437
|
+
"""
|
|
438
|
+
ndim = tensors[0].dim()
|
|
439
|
+
assert all(
|
|
440
|
+
t.dim() == ndim for t in
|
|
441
|
+
tensors[1:]), "All tensors must have the same number of dimensions"
|
|
442
|
+
|
|
443
|
+
out_size = [max(t.shape[i] for t in tensors) for i in range(ndim)]
|
|
444
|
+
out_size[dim] = sum(t.shape[dim] for t in tensors)
|
|
445
|
+
output = tensors[0].new_full(out_size, padding_value)
|
|
446
|
+
|
|
447
|
+
index = 0
|
|
448
|
+
for t in tensors:
|
|
449
|
+
# Create a slice list where every dimension except dim is full slice
|
|
450
|
+
slices = [slice(0, t.shape[d]) for d in range(ndim)]
|
|
451
|
+
# Update only the concat dimension slice
|
|
452
|
+
slices[dim] = slice(index, index + t.shape[dim])
|
|
453
|
+
|
|
454
|
+
output[slices] = t
|
|
455
|
+
index += t.shape[dim]
|
|
456
|
+
|
|
457
|
+
return output
|
|
458
|
+
|
|
459
|
+
|
|
460
|
+
class Phi4MMProcessingInfo(BaseProcessingInfo):
|
|
461
|
+
|
|
462
|
+
def get_hf_processor(
|
|
463
|
+
self,
|
|
464
|
+
*,
|
|
465
|
+
dynamic_hd: Optional[int] = None,
|
|
466
|
+
**kwargs: object,
|
|
467
|
+
) -> ProcessorMixin:
|
|
468
|
+
if dynamic_hd is not None:
|
|
469
|
+
kwargs["dynamic_hd"] = dynamic_hd
|
|
470
|
+
|
|
471
|
+
return self.ctx.get_hf_processor(**kwargs)
|
|
472
|
+
|
|
473
|
+
@property
|
|
474
|
+
def image_tokens(self) -> list[str]:
|
|
475
|
+
return [f"<|image_{i+1}|>" for i in range(100)]
|
|
476
|
+
|
|
477
|
+
@property
|
|
478
|
+
def audio_tokens(self) -> list[str]:
|
|
479
|
+
return [f"<|audio_{i+1}|>" for i in range(100)]
|
|
480
|
+
|
|
481
|
+
def get_dynamic_hd(
|
|
482
|
+
self,
|
|
483
|
+
processor: Optional[ProcessorMixin] = None,
|
|
484
|
+
) -> int:
|
|
485
|
+
if processor is None:
|
|
486
|
+
processor = self.get_hf_processor()
|
|
487
|
+
image_processor = processor.image_processor
|
|
488
|
+
return image_processor.dynamic_hd
|
|
489
|
+
|
|
490
|
+
def get_feature_extractor(self) -> SequenceFeatureExtractor:
|
|
491
|
+
return self.get_hf_processor().audio_processor
|
|
492
|
+
|
|
493
|
+
def get_supported_mm_limits(self) -> Mapping[str, Optional[int]]:
|
|
494
|
+
return {"audio": None, "image": None}
|
|
495
|
+
|
|
496
|
+
def _find_target_aspect_ratio(
|
|
497
|
+
self,
|
|
498
|
+
orig_width: int,
|
|
499
|
+
orig_height: int,
|
|
500
|
+
image_size: int,
|
|
501
|
+
max_num: int,
|
|
502
|
+
min_num: int,
|
|
503
|
+
):
|
|
504
|
+
w_crop_num = math.ceil(orig_width / float(image_size))
|
|
505
|
+
h_crop_num = math.ceil(orig_height / float(image_size))
|
|
506
|
+
if w_crop_num * h_crop_num > max_num:
|
|
507
|
+
aspect_ratio = orig_width / orig_height
|
|
508
|
+
|
|
509
|
+
# calculate the existing image aspect ratio
|
|
510
|
+
target_ratios = set((i, j) for i in range(1, max_num + 1)
|
|
511
|
+
for j in range(1, max_num + 1)
|
|
512
|
+
if i * j <= max_num and i * j >= min_num)
|
|
513
|
+
target_ratios = sorted(target_ratios, key=lambda x: x[0] * x[1])
|
|
514
|
+
|
|
515
|
+
# find the closest aspect ratio to the target
|
|
516
|
+
image_processor = self.get_hf_processor().image_processor
|
|
517
|
+
target_aspect_ratio = image_processor.find_closest_aspect_ratio(
|
|
518
|
+
aspect_ratio,
|
|
519
|
+
target_ratios,
|
|
520
|
+
orig_width,
|
|
521
|
+
orig_height,
|
|
522
|
+
image_size,
|
|
523
|
+
)
|
|
524
|
+
|
|
525
|
+
# calculate the target width and height
|
|
526
|
+
target_width = image_size * target_aspect_ratio[0]
|
|
527
|
+
target_height = image_size * target_aspect_ratio[1]
|
|
528
|
+
else:
|
|
529
|
+
target_width = image_size * w_crop_num
|
|
530
|
+
target_height = image_size * h_crop_num
|
|
531
|
+
target_aspect_ratio = (w_crop_num, h_crop_num)
|
|
532
|
+
return target_aspect_ratio, target_height, target_width
|
|
533
|
+
|
|
534
|
+
def _compute_num_image_tokens(
|
|
535
|
+
self,
|
|
536
|
+
orig_width: int,
|
|
537
|
+
orig_height: int,
|
|
538
|
+
dynamic_hd_size: int,
|
|
539
|
+
vit_image_size: int,
|
|
540
|
+
vit_patch_size: int,
|
|
541
|
+
token_compression_factor: int = 2,
|
|
542
|
+
):
|
|
543
|
+
"""
|
|
544
|
+
compute the number of tokens an image is expected to take up considering
|
|
545
|
+
the image encoder architecture and exclude output features containing
|
|
546
|
+
only padding pixels
|
|
547
|
+
|
|
548
|
+
for siglip, vit_image_size=448, vit_patch_size=14, so output will be
|
|
549
|
+
32x32 feature map
|
|
550
|
+
NOTE right now, Phi4MM uses hard-coded token_compression_factor=2
|
|
551
|
+
"""
|
|
552
|
+
assert vit_image_size % vit_patch_size == 0, (
|
|
553
|
+
"vit_image_size must be divisible by vit_patch_size")
|
|
554
|
+
assert (vit_image_size // vit_patch_size %
|
|
555
|
+
token_compression_factor == 0), (
|
|
556
|
+
"vit_image_size // vit_patch_size must be divisible by "
|
|
557
|
+
"token_compression_factor")
|
|
558
|
+
|
|
559
|
+
target_aspect_ratio, target_height, target_width = (
|
|
560
|
+
self._find_target_aspect_ratio(orig_width,
|
|
561
|
+
orig_height,
|
|
562
|
+
vit_image_size,
|
|
563
|
+
dynamic_hd_size,
|
|
564
|
+
min_num=1))
|
|
565
|
+
assert target_aspect_ratio[0] * vit_image_size == target_width, (
|
|
566
|
+
f"{target_aspect_ratio[0]} * {vit_image_size} != {target_width}")
|
|
567
|
+
assert target_aspect_ratio[1] * vit_image_size == target_height, (
|
|
568
|
+
f"{target_aspect_ratio[1]} * {vit_image_size} != {target_height}")
|
|
569
|
+
assert (target_height % vit_image_size == 0
|
|
570
|
+
and target_width % vit_image_size == 0)
|
|
571
|
+
|
|
572
|
+
padding_height, padding_width = _get_padding_size(
|
|
573
|
+
orig_width, orig_height, target_height, target_width)
|
|
574
|
+
assert padding_width == 0 or padding_height == 0, \
|
|
575
|
+
"padding_width or padding_height must be 0"
|
|
576
|
+
|
|
577
|
+
target_feat_width = target_width // vit_patch_size
|
|
578
|
+
target_feat_height = target_height // vit_patch_size
|
|
579
|
+
if padding_width >= vit_patch_size:
|
|
580
|
+
assert padding_height == 0, "padding_height not 0"
|
|
581
|
+
non_pad_feat_width = target_feat_width - math.floor(
|
|
582
|
+
padding_width / vit_patch_size)
|
|
583
|
+
non_pad_feat_height = target_feat_height
|
|
584
|
+
elif padding_height >= vit_patch_size:
|
|
585
|
+
assert padding_width == 0, "padding_width not 0"
|
|
586
|
+
non_pad_feat_height = target_feat_height - math.floor(
|
|
587
|
+
padding_height / vit_patch_size)
|
|
588
|
+
non_pad_feat_width = target_feat_width
|
|
589
|
+
else:
|
|
590
|
+
# small padding shorter than a vit patch
|
|
591
|
+
non_pad_feat_width = target_feat_width
|
|
592
|
+
non_pad_feat_height = target_feat_height
|
|
593
|
+
|
|
594
|
+
feat_width = non_pad_feat_width // token_compression_factor
|
|
595
|
+
feat_height = non_pad_feat_height // token_compression_factor
|
|
596
|
+
# NOTE it's possible that the non-padding feature is not divisible
|
|
597
|
+
if non_pad_feat_width % token_compression_factor != 0:
|
|
598
|
+
feat_width += 1
|
|
599
|
+
if non_pad_feat_height % token_compression_factor != 0:
|
|
600
|
+
feat_height += 1
|
|
601
|
+
num_hd_patch_tokens = feat_width * feat_height
|
|
602
|
+
num_hd_newline_tokens = feat_height
|
|
603
|
+
vit_feature_size = vit_image_size // vit_patch_size
|
|
604
|
+
num_global_image_tokens = (vit_feature_size //
|
|
605
|
+
token_compression_factor)**2
|
|
606
|
+
num_sep_tokens = 1
|
|
607
|
+
num_global_image_newline_tokens = \
|
|
608
|
+
vit_feature_size // token_compression_factor
|
|
609
|
+
|
|
610
|
+
return (num_global_image_tokens + num_sep_tokens +
|
|
611
|
+
num_hd_patch_tokens + num_hd_newline_tokens +
|
|
612
|
+
num_global_image_newline_tokens)
|
|
613
|
+
|
|
614
|
+
def get_num_image_tokens(
|
|
615
|
+
self,
|
|
616
|
+
*,
|
|
617
|
+
image_width: int,
|
|
618
|
+
image_height: int,
|
|
619
|
+
processor: Optional[ProcessorMixin] = None,
|
|
620
|
+
) -> int:
|
|
621
|
+
hf_config = self.get_hf_config()
|
|
622
|
+
vision_encoder_name = hf_config.img_processor
|
|
623
|
+
if vision_encoder_name is None:
|
|
624
|
+
vision_encoder_name = SIGLIP_NAME
|
|
625
|
+
prepro_config = VISION_ENCODER_TO_PROCESSING_CONFIG[
|
|
626
|
+
vision_encoder_name]
|
|
627
|
+
vit_image_size = prepro_config['vit_image_size']
|
|
628
|
+
vit_patch_size = prepro_config['vit_patch_size']
|
|
629
|
+
token_compression_factor = prepro_config['token_compression_factor']
|
|
630
|
+
|
|
631
|
+
dynamic_hd_size = self.get_dynamic_hd(processor=processor)
|
|
632
|
+
|
|
633
|
+
image_num_tokens = self._compute_num_image_tokens(
|
|
634
|
+
image_width,
|
|
635
|
+
image_height,
|
|
636
|
+
dynamic_hd_size=dynamic_hd_size,
|
|
637
|
+
vit_image_size=vit_image_size,
|
|
638
|
+
vit_patch_size=vit_patch_size,
|
|
639
|
+
token_compression_factor=token_compression_factor,
|
|
640
|
+
)
|
|
641
|
+
|
|
642
|
+
return image_num_tokens
|
|
643
|
+
|
|
644
|
+
def get_image_size_with_most_features(
|
|
645
|
+
self,
|
|
646
|
+
processor: Optional[ProcessorMixin] = None,
|
|
647
|
+
) -> ImageSize:
|
|
648
|
+
hf_config = self.get_hf_config()
|
|
649
|
+
vision_encoder_name = hf_config.img_processor
|
|
650
|
+
if vision_encoder_name is None:
|
|
651
|
+
vision_encoder_name = SIGLIP_NAME
|
|
652
|
+
prepro_config = VISION_ENCODER_TO_PROCESSING_CONFIG[
|
|
653
|
+
vision_encoder_name]
|
|
654
|
+
vit_image_size = prepro_config['vit_image_size']
|
|
655
|
+
|
|
656
|
+
max_side = vit_image_size * self.get_dynamic_hd(processor=processor)
|
|
657
|
+
return ImageSize(height=max_side, width=vit_image_size)
|
|
658
|
+
|
|
659
|
+
def get_audio_num_frames(self, audio_len: int, sr: float) -> int:
|
|
660
|
+
"""
|
|
661
|
+
Compute the output size of the `extract_features` method.
|
|
662
|
+
|
|
663
|
+
Args:
|
|
664
|
+
audio_len (int): Length of the input waveform in samples.
|
|
665
|
+
sr (float): Sampling rate of the waveform, either 16000 or 8000.
|
|
666
|
+
|
|
667
|
+
Returns:
|
|
668
|
+
tuple (int, int): Output size as (T, D), where:
|
|
669
|
+
T: Number of time frames.
|
|
670
|
+
D: Number of Mel filterbank bins (80).
|
|
671
|
+
"""
|
|
672
|
+
|
|
673
|
+
# Resample to 16000 or 8000 if needed
|
|
674
|
+
if sr > 16000:
|
|
675
|
+
audio_len //= sr // 16000
|
|
676
|
+
elif 8000 <= sr < 16000:
|
|
677
|
+
# We'll resample to 16K from 8K
|
|
678
|
+
audio_len *= 2
|
|
679
|
+
elif sr < 8000:
|
|
680
|
+
raise RuntimeError(f"Unsupported sample rate {sr}")
|
|
681
|
+
|
|
682
|
+
# Spectrogram parameters for 16 kHz
|
|
683
|
+
win_length = 400 # Frame length in samples
|
|
684
|
+
hop_length = 160 # Frame shift in samples
|
|
685
|
+
|
|
686
|
+
# Calculate number of frames (T)
|
|
687
|
+
num_frames = (audio_len - win_length) // hop_length + 1
|
|
688
|
+
if num_frames < 1:
|
|
689
|
+
raise ValueError("Waveform too short for given parameters.")
|
|
690
|
+
|
|
691
|
+
# Return time frames (T)
|
|
692
|
+
return num_frames
|
|
693
|
+
|
|
694
|
+
def _compute_audio_embed_size(self, audio_frames: int) -> int:
|
|
695
|
+
"""
|
|
696
|
+
Compute the audio embedding size based on the audio frames and
|
|
697
|
+
compression rate.
|
|
698
|
+
"""
|
|
699
|
+
hf_config = self.get_hf_config()
|
|
700
|
+
compression_rate = hf_config.embd_layer['audio_embd_layer'][
|
|
701
|
+
'compression_rate']
|
|
702
|
+
# NOTE: this is a hard-coded value but might be configurable
|
|
703
|
+
# in the future
|
|
704
|
+
qformer_compression_rate = 1
|
|
705
|
+
integer = audio_frames // compression_rate
|
|
706
|
+
remainder = audio_frames % compression_rate
|
|
707
|
+
|
|
708
|
+
result = integer if remainder == 0 else integer + 1
|
|
709
|
+
|
|
710
|
+
integer = result // qformer_compression_rate
|
|
711
|
+
remainder = result % qformer_compression_rate
|
|
712
|
+
# qformer compression
|
|
713
|
+
result = integer if remainder == 0 else integer + 1
|
|
714
|
+
|
|
715
|
+
return result
|
|
716
|
+
|
|
717
|
+
|
|
718
|
+
class Phi4MMDummyInputsBuilder(BaseDummyInputsBuilder[Phi4MMProcessingInfo]):
|
|
719
|
+
|
|
720
|
+
def get_dummy_text(self, mm_counts: Mapping[str, int]) -> str:
|
|
721
|
+
num_audios = mm_counts.get("audio", 0)
|
|
722
|
+
num_images = mm_counts.get("image", 0)
|
|
723
|
+
|
|
724
|
+
image_tokens: list[str] = self.info.image_tokens[:num_images]
|
|
725
|
+
audio_tokens: list[str] = self.info.audio_tokens[:num_audios]
|
|
726
|
+
|
|
727
|
+
return "".join(image_tokens + audio_tokens)
|
|
728
|
+
|
|
729
|
+
def get_dummy_mm_data(
|
|
730
|
+
self,
|
|
731
|
+
seq_len: int,
|
|
732
|
+
mm_counts: Mapping[str, int],
|
|
733
|
+
) -> MultiModalDataDict:
|
|
734
|
+
num_audios = mm_counts.get("audio", 0)
|
|
735
|
+
num_images = mm_counts.get("image", 0)
|
|
736
|
+
|
|
737
|
+
target_width, target_height = \
|
|
738
|
+
self.info.get_image_size_with_most_features()
|
|
739
|
+
|
|
740
|
+
mm_data = {
|
|
741
|
+
"image":
|
|
742
|
+
self._get_dummy_images(width=target_width,
|
|
743
|
+
height=target_height,
|
|
744
|
+
num_images=num_images),
|
|
745
|
+
"audio":
|
|
746
|
+
self._get_dummy_audios(length=_AUDIO_MAX_SOUNDFILE_SIZE,
|
|
747
|
+
num_audios=num_audios),
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
return mm_data
|
|
751
|
+
|
|
752
|
+
|
|
753
|
+
class Phi4MMMultiModalProcessor(BaseMultiModalProcessor[Phi4MMProcessingInfo]):
|
|
754
|
+
|
|
755
|
+
def _get_data_parser(self) -> MultiModalDataParser:
|
|
756
|
+
feature_extractor = self.info.get_feature_extractor()
|
|
757
|
+
return MultiModalDataParser(target_sr=feature_extractor.sampling_rate,
|
|
758
|
+
audio_resample_method="scipy")
|
|
759
|
+
|
|
760
|
+
def _call_hf_processor(
|
|
761
|
+
self,
|
|
762
|
+
prompt: str,
|
|
763
|
+
mm_data: Mapping[str, object],
|
|
764
|
+
mm_kwargs: Mapping[str, object],
|
|
765
|
+
) -> BatchFeature:
|
|
766
|
+
if not mm_data:
|
|
767
|
+
prompt_ids = self.info.get_tokenizer().encode(prompt)
|
|
768
|
+
prompt_ids = self._apply_hf_processor_tokens_only(prompt_ids)
|
|
769
|
+
return BatchFeature(dict(input_ids=[prompt_ids]), tensor_type="pt")
|
|
770
|
+
|
|
771
|
+
sr = self.info.get_feature_extractor().sampling_rate
|
|
772
|
+
if (audio_data := mm_data.get("audios", [])):
|
|
773
|
+
mm_data['audios'] = [(data, sr) for data in audio_data]
|
|
774
|
+
|
|
775
|
+
processed_outputs = super()._call_hf_processor(prompt, mm_data,
|
|
776
|
+
mm_kwargs)
|
|
777
|
+
|
|
778
|
+
num_img_tokens = [
|
|
779
|
+
self.info.get_num_image_tokens(image_width=img_size[0],
|
|
780
|
+
image_height=img_size[1])
|
|
781
|
+
for img_size in processed_outputs["image_sizes"]
|
|
782
|
+
]
|
|
783
|
+
processed_outputs["num_img_tokens"] = num_img_tokens
|
|
784
|
+
|
|
785
|
+
audio_features = processed_outputs['input_audio_embeds']
|
|
786
|
+
feature_sizes = [
|
|
787
|
+
self.info.get_audio_num_frames(len(audio), sr)
|
|
788
|
+
for audio in audio_data
|
|
789
|
+
]
|
|
790
|
+
processed_outputs['input_audio_embeds'] = [
|
|
791
|
+
audio_features[idx, :size]
|
|
792
|
+
for idx, size in enumerate(feature_sizes)
|
|
793
|
+
]
|
|
794
|
+
|
|
795
|
+
return processed_outputs
|
|
796
|
+
|
|
797
|
+
def _get_mm_fields_config(
|
|
798
|
+
self,
|
|
799
|
+
hf_inputs: BatchFeature,
|
|
800
|
+
hf_processor_mm_kwargs: Mapping[str, object],
|
|
801
|
+
) -> Mapping[str, MultiModalFieldConfig]:
|
|
802
|
+
return dict(
|
|
803
|
+
input_image_embeds=MultiModalFieldConfig.batched("image"),
|
|
804
|
+
image_attention_mask=MultiModalFieldConfig.batched("image"),
|
|
805
|
+
image_sizes=MultiModalFieldConfig.batched("image"),
|
|
806
|
+
num_img_tokens=MultiModalFieldConfig.batched("image"),
|
|
807
|
+
input_audio_embeds=MultiModalFieldConfig.batched("audio"),
|
|
808
|
+
)
|
|
809
|
+
|
|
810
|
+
def _get_prompt_updates(
|
|
811
|
+
self,
|
|
812
|
+
mm_items: MultiModalDataItems,
|
|
813
|
+
hf_processor_mm_kwargs: Mapping[str, Any],
|
|
814
|
+
out_mm_kwargs: MultiModalKwargs,
|
|
815
|
+
) -> Sequence[PromptUpdate]:
|
|
816
|
+
image_tokens: list[str] = self.info.image_tokens # type: ignore
|
|
817
|
+
audio_tokens: list[str] = self.info.audio_tokens # type: ignore
|
|
818
|
+
feature_extractor = self.info.get_feature_extractor()
|
|
819
|
+
hf_processor = self.info.get_hf_processor(**hf_processor_mm_kwargs)
|
|
820
|
+
|
|
821
|
+
def get_image_replacement_phi4mm(item_idx: int):
|
|
822
|
+
images = mm_items.get_items(
|
|
823
|
+
"image", (ImageEmbeddingItems, ImageProcessorItems))
|
|
824
|
+
|
|
825
|
+
if isinstance(images, ImageEmbeddingItems):
|
|
826
|
+
num_image_tokens = images.get_feature_size(item_idx)
|
|
827
|
+
else:
|
|
828
|
+
image_size = images.get_image_size(item_idx)
|
|
829
|
+
num_image_tokens = self.info.get_num_image_tokens(
|
|
830
|
+
image_width=image_size.width,
|
|
831
|
+
image_height=image_size.height,
|
|
832
|
+
processor=hf_processor,
|
|
833
|
+
)
|
|
834
|
+
|
|
835
|
+
image_tokens = [_IMAGE_PLACEHOLDER_TOKEN_ID] * num_image_tokens
|
|
836
|
+
|
|
837
|
+
return image_tokens
|
|
838
|
+
|
|
839
|
+
def get_audio_replacement_phi4mm(item_idx: int):
|
|
840
|
+
audios = mm_items.get_items("audio", AudioProcessorItems)
|
|
841
|
+
# TODO(Isotr0py): support embedding inputs
|
|
842
|
+
audio_len = audios.get_audio_length(item_idx)
|
|
843
|
+
audio_frames = self.info.get_audio_num_frames(
|
|
844
|
+
audio_len, feature_extractor.sampling_rate)
|
|
845
|
+
audio_embed_size = self.info._compute_audio_embed_size(
|
|
846
|
+
audio_frames)
|
|
847
|
+
|
|
848
|
+
audio_tokens = [_AUDIO_PLACEHOLDER_TOKEN_ID] * audio_embed_size
|
|
849
|
+
|
|
850
|
+
return audio_tokens
|
|
851
|
+
|
|
852
|
+
num_images = mm_items.get_count("image", strict=False)
|
|
853
|
+
num_audios = mm_items.get_count("audio", strict=False)
|
|
854
|
+
|
|
855
|
+
image_repl = [
|
|
856
|
+
PromptReplacement(
|
|
857
|
+
modality="image",
|
|
858
|
+
target=image_token,
|
|
859
|
+
replacement=get_image_replacement_phi4mm,
|
|
860
|
+
) for image_token in image_tokens[:num_images]
|
|
861
|
+
]
|
|
862
|
+
audio_repl = [
|
|
863
|
+
PromptReplacement(
|
|
864
|
+
modality="audio",
|
|
865
|
+
target=audio_token,
|
|
866
|
+
replacement=get_audio_replacement_phi4mm,
|
|
867
|
+
) for audio_token in audio_tokens[:num_audios]
|
|
868
|
+
]
|
|
869
|
+
return image_repl + audio_repl
|
|
870
|
+
|
|
871
|
+
|
|
872
|
+
@MULTIMODAL_REGISTRY.register_processor(
|
|
873
|
+
Phi4MMMultiModalProcessor,
|
|
874
|
+
info=Phi4MMProcessingInfo,
|
|
875
|
+
dummy_inputs=Phi4MMDummyInputsBuilder,
|
|
876
|
+
)
|
|
877
|
+
class Phi4MMForCausalLM(nn.Module, SupportsLoRA, SupportsMultiModal):
|
|
878
|
+
"""
|
|
879
|
+
Implements the Phi-4-multimodal-instruct model in vLLM.
|
|
880
|
+
"""
|
|
881
|
+
packed_modules_mapping = {
|
|
882
|
+
"qkv_proj": [
|
|
883
|
+
"qkv_proj",
|
|
884
|
+
],
|
|
885
|
+
"gate_up_proj": [
|
|
886
|
+
"gate_up_proj",
|
|
887
|
+
],
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
hf_to_vllm_mapper = WeightsMapper(
|
|
891
|
+
orig_to_new_substr={
|
|
892
|
+
"base_layer.": "",
|
|
893
|
+
},
|
|
894
|
+
orig_to_new_prefix={
|
|
895
|
+
"model.embed_tokens_extend.audio_embed.audio_projection.vision.":
|
|
896
|
+
"embed_tokens_extend.audio_projection_for_vision.",
|
|
897
|
+
"model.embed_tokens_extend.audio_embed.audio_projection.speech.":
|
|
898
|
+
"embed_tokens_extend.audio_projection.",
|
|
899
|
+
"model.embed_tokens_extend.audio_embed.": "embed_tokens_extend.",
|
|
900
|
+
"model.embed_tokens_extend.image_embed.": "vision_encoder.",
|
|
901
|
+
},
|
|
902
|
+
)
|
|
903
|
+
|
|
904
|
+
def __init__(self, *, vllm_config: VllmConfig, prefix: str = ""):
|
|
905
|
+
super().__init__()
|
|
906
|
+
config = vllm_config.model_config.hf_config
|
|
907
|
+
multimodal_config = vllm_config.model_config.multimodal_config
|
|
908
|
+
assert multimodal_config, "multimodal_config is required"
|
|
909
|
+
quant_config = vllm_config.quant_config
|
|
910
|
+
lora_config = vllm_config.lora_config
|
|
911
|
+
|
|
912
|
+
self.config = config
|
|
913
|
+
self.multimodal_config = multimodal_config
|
|
914
|
+
self.quant_config = quant_config
|
|
915
|
+
self.lora_config = lora_config
|
|
916
|
+
|
|
917
|
+
# Tensor/Pipeline parallel not supported for now.
|
|
918
|
+
assert get_pp_group(
|
|
919
|
+
).world_size == 1, "pipeline parallel is not supported"
|
|
920
|
+
|
|
921
|
+
self.vision_encoder = Phi4MMImageEncoder(
|
|
922
|
+
config,
|
|
923
|
+
quant_config,
|
|
924
|
+
prefix="model.vision_embed_tokens",
|
|
925
|
+
model_dir=config._name_or_path)
|
|
926
|
+
|
|
927
|
+
if isinstance(config.embd_layer["audio_embd_layer"], dict):
|
|
928
|
+
embedding_config = {
|
|
929
|
+
"embedding_cls":
|
|
930
|
+
config.embd_layer["audio_embd_layer"]["embedding_cls"],
|
|
931
|
+
**config.embd_layer["audio_embd_layer"],
|
|
932
|
+
}
|
|
933
|
+
else:
|
|
934
|
+
embedding_config = {
|
|
935
|
+
"embedding_cls": self.config.embd_layer["embedding_cls"]
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
self.embed_tokens_extend = AudioEmbedding(config, **embedding_config)
|
|
939
|
+
self.model = LlamaModel(vllm_config=vllm_config,
|
|
940
|
+
prefix=maybe_prefix(prefix, "model"))
|
|
941
|
+
|
|
942
|
+
self.unpadded_vocab_size = config.vocab_size
|
|
943
|
+
if lora_config:
|
|
944
|
+
self.unpadded_vocab_size += lora_config.lora_extra_vocab_size
|
|
945
|
+
self.lm_head = ParallelLMHead(
|
|
946
|
+
self.unpadded_vocab_size,
|
|
947
|
+
config.hidden_size,
|
|
948
|
+
org_num_embeddings=config.vocab_size,
|
|
949
|
+
padding_size=DEFAULT_VOCAB_PADDING_SIZE,
|
|
950
|
+
quant_config=quant_config,
|
|
951
|
+
)
|
|
952
|
+
if config.tie_word_embeddings:
|
|
953
|
+
self.lm_head = self.lm_head.tie_weights(self.model.embed_tokens)
|
|
954
|
+
logit_scale = getattr(config, "logit_scale", 1.0)
|
|
955
|
+
self.logits_processor = LogitsProcessor(self.unpadded_vocab_size,
|
|
956
|
+
config.vocab_size, logit_scale)
|
|
957
|
+
|
|
958
|
+
def _parse_and_validate_audio_input(
|
|
959
|
+
self, **kwargs: object) -> Optional[Phi4MMAudioInputs]:
|
|
960
|
+
"""
|
|
961
|
+
Parse and validate the audio input to the model. This handles both
|
|
962
|
+
audio features and audio embeddings, but only the former is used for
|
|
963
|
+
now.
|
|
964
|
+
|
|
965
|
+
Args:
|
|
966
|
+
kwargs (object): Keyword arguments.
|
|
967
|
+
|
|
968
|
+
Returns:
|
|
969
|
+
Optional[Phi4MMAudioInputs]: Parsed and validated audio inputs.
|
|
970
|
+
"""
|
|
971
|
+
audio_features = kwargs.pop("input_audio_embeds", None)
|
|
972
|
+
audio_embeds = kwargs.pop("audio_embeds", None)
|
|
973
|
+
|
|
974
|
+
if audio_features is None and audio_embeds is None:
|
|
975
|
+
return None
|
|
976
|
+
|
|
977
|
+
if audio_features is not None:
|
|
978
|
+
if not isinstance(audio_features, (torch.Tensor, list)):
|
|
979
|
+
raise ValueError("Incorrect type of audio features. "
|
|
980
|
+
f"Got type: {type(audio_features)}")
|
|
981
|
+
|
|
982
|
+
return Phi4MMAudioFeatureInputs(type="audio_features",
|
|
983
|
+
data=flatten_bn(audio_features))
|
|
984
|
+
|
|
985
|
+
if audio_embeds is not None:
|
|
986
|
+
if not isinstance(audio_embeds, (torch.Tensor, list)):
|
|
987
|
+
raise ValueError("Incorrect type of audio embeds. "
|
|
988
|
+
f"Got type: {type(audio_embeds)}")
|
|
989
|
+
|
|
990
|
+
return Phi4MMAudioEmbeddingInputs(type="audio_embeds",
|
|
991
|
+
data=audio_embeds)
|
|
992
|
+
|
|
993
|
+
raise AssertionError("This line should be unreachable.")
|
|
994
|
+
|
|
995
|
+
def _process_audio_input(self, audio_input: Phi4MMAudioInputs,
|
|
996
|
+
audio_projection_mode: str) -> NestedTensors:
|
|
997
|
+
"""
|
|
998
|
+
Create the audio embeddings from the audio input, where the audio input
|
|
999
|
+
is pairs of audio features and audio embed lengths. The audio input is
|
|
1000
|
+
created by `input_mapper_for_phi4mm_audio`.
|
|
1001
|
+
|
|
1002
|
+
Args:
|
|
1003
|
+
audio_input (Phi4MMAudioInputs): Audio input.
|
|
1004
|
+
|
|
1005
|
+
Returns:
|
|
1006
|
+
NestedTensors: Audio embeddings
|
|
1007
|
+
"""
|
|
1008
|
+
if audio_input["type"] == "audio_embeds":
|
|
1009
|
+
return audio_input["data"]
|
|
1010
|
+
|
|
1011
|
+
audio_features = audio_input["data"]
|
|
1012
|
+
# (e.g. multiple examples) and the second dim is the multi-audio dim
|
|
1013
|
+
# (e.g. multiple audios in the same example)
|
|
1014
|
+
|
|
1015
|
+
dtype = next(self.embed_tokens_extend.parameters()).dtype
|
|
1016
|
+
audio_embeds = [
|
|
1017
|
+
self.embed_tokens_extend(
|
|
1018
|
+
features.to(dtype),
|
|
1019
|
+
audio_projection_mode=audio_projection_mode,
|
|
1020
|
+
) for features in audio_features
|
|
1021
|
+
]
|
|
1022
|
+
return audio_embeds
|
|
1023
|
+
|
|
1024
|
+
def _parse_and_validate_image_input(self,
|
|
1025
|
+
**kwargs: object) -> Optional[dict]:
|
|
1026
|
+
input_image_embeds: NestedTensors = kwargs.get("input_image_embeds")
|
|
1027
|
+
if input_image_embeds is None:
|
|
1028
|
+
return None
|
|
1029
|
+
|
|
1030
|
+
image_sizes = kwargs.get("image_sizes")
|
|
1031
|
+
image_attention_mask = kwargs.get("image_attention_mask")
|
|
1032
|
+
num_img_tokens = kwargs.get("num_img_tokens")
|
|
1033
|
+
assert image_sizes is not None and image_attention_mask is not None\
|
|
1034
|
+
and num_img_tokens is not None, "Missing image inputs"
|
|
1035
|
+
|
|
1036
|
+
if is_list_of(input_image_embeds, torch.Tensor):
|
|
1037
|
+
assert all(p.dim() == 5
|
|
1038
|
+
for p in input_image_embeds), "Incorrect image inputs"
|
|
1039
|
+
# list len is batch_size.
|
|
1040
|
+
# each tensor has dimension: num_img_per_example, num_hd_patches,
|
|
1041
|
+
# channels, height, width.
|
|
1042
|
+
# need to pad along num_hd_patches.
|
|
1043
|
+
# mask size num_img_per_prompt, num_hd_patches, feat_h, heat_w.
|
|
1044
|
+
input_image_embeds = cat_with_pad(input_image_embeds, dim=0)
|
|
1045
|
+
elif isinstance(input_image_embeds, torch.Tensor):
|
|
1046
|
+
# dimension: batch_size, num_img_per_example, num_hd_patches,
|
|
1047
|
+
# channels, height, width.
|
|
1048
|
+
# we flatten first 2 dims to make it a single large batch for
|
|
1049
|
+
# SigLIP Encoder.
|
|
1050
|
+
assert input_image_embeds.dim() == 6, "Incorrect image inputs"
|
|
1051
|
+
input_image_embeds = input_image_embeds.flatten(0, 1)
|
|
1052
|
+
else:
|
|
1053
|
+
raise ValueError("Incorrect input_image_embeds inputs")
|
|
1054
|
+
|
|
1055
|
+
if isinstance(image_attention_mask, list):
|
|
1056
|
+
image_attention_mask = cat_with_pad(image_attention_mask, dim=0)
|
|
1057
|
+
elif isinstance(image_attention_mask, torch.Tensor):
|
|
1058
|
+
image_attention_mask = image_attention_mask.flatten(0, 1)
|
|
1059
|
+
else:
|
|
1060
|
+
raise ValueError("Incorrect image_attention_mask inputs")
|
|
1061
|
+
|
|
1062
|
+
if isinstance(image_sizes, list):
|
|
1063
|
+
image_sizes = torch.cat(image_sizes, dim=0)
|
|
1064
|
+
elif isinstance(image_sizes, torch.Tensor):
|
|
1065
|
+
image_sizes = image_sizes.flatten(0, 1)
|
|
1066
|
+
else:
|
|
1067
|
+
raise ValueError("Incorrect image_attention_mask inputs")
|
|
1068
|
+
|
|
1069
|
+
if isinstance(num_img_tokens, list):
|
|
1070
|
+
num_img_tokens = [
|
|
1071
|
+
n for num_tensor in num_img_tokens
|
|
1072
|
+
for n in num_tensor.tolist()
|
|
1073
|
+
]
|
|
1074
|
+
elif isinstance(num_img_tokens, torch.Tensor):
|
|
1075
|
+
num_img_tokens = num_img_tokens.flatten(0, 1).tolist()
|
|
1076
|
+
else:
|
|
1077
|
+
raise ValueError("Incorrect image_attention_mask inputs")
|
|
1078
|
+
|
|
1079
|
+
return Phi4MMImagePixelInputs(
|
|
1080
|
+
type="pixel_values",
|
|
1081
|
+
data=input_image_embeds,
|
|
1082
|
+
image_sizes=image_sizes,
|
|
1083
|
+
image_attention_mask=image_attention_mask,
|
|
1084
|
+
num_img_tokens=num_img_tokens,
|
|
1085
|
+
)
|
|
1086
|
+
|
|
1087
|
+
def _parse_and_validate_multimodal_inputs(self, **kwargs: object) -> dict:
|
|
1088
|
+
modalities = {}
|
|
1089
|
+
|
|
1090
|
+
# Preserve the order of modalities if there are multiple of them
|
|
1091
|
+
# from the order of kwargs.
|
|
1092
|
+
for input_key in kwargs:
|
|
1093
|
+
if input_key in ("input_image_embeds",
|
|
1094
|
+
"image_embeds") and "images" not in modalities:
|
|
1095
|
+
modalities["images"] = self._parse_and_validate_image_input(
|
|
1096
|
+
**kwargs)
|
|
1097
|
+
if input_key in ("input_audio_embeds",
|
|
1098
|
+
"audio_embeds") and "audios" not in modalities:
|
|
1099
|
+
modalities["audios"] = self._parse_and_validate_audio_input(
|
|
1100
|
+
**kwargs)
|
|
1101
|
+
|
|
1102
|
+
return modalities
|
|
1103
|
+
|
|
1104
|
+
def _process_image_input(
|
|
1105
|
+
self, image_input: Phi4MMImagePixelInputs) -> list[torch.Tensor]:
|
|
1106
|
+
|
|
1107
|
+
dtype = next(self.vision_encoder.parameters()).dtype
|
|
1108
|
+
pixel_values = image_input['data'].to(dtype)
|
|
1109
|
+
image_sizes = image_input['image_sizes']
|
|
1110
|
+
image_attention_mask = image_input['image_attention_mask']
|
|
1111
|
+
image_embeds = self.vision_encoder(pixel_values, image_sizes,
|
|
1112
|
+
image_attention_mask)
|
|
1113
|
+
return image_embeds
|
|
1114
|
+
|
|
1115
|
+
def get_multimodal_embeddings(
|
|
1116
|
+
self, **kwargs: object) -> Optional[MultiModalEmbeddings]:
|
|
1117
|
+
|
|
1118
|
+
modalities = self._parse_and_validate_multimodal_inputs(**kwargs)
|
|
1119
|
+
if not modalities:
|
|
1120
|
+
return None
|
|
1121
|
+
|
|
1122
|
+
# The result multimodal_embeddings is tuple of tensors, with each
|
|
1123
|
+
# tensor correspoending to a multimodal data item (image or video).
|
|
1124
|
+
multimodal_embeddings: tuple[torch.Tensor, ...] = ()
|
|
1125
|
+
|
|
1126
|
+
# NOTE: It is important to iterate over the keys in this dictionary
|
|
1127
|
+
# to preserve the order of the modalities.
|
|
1128
|
+
audio_projection_mode = 'speech'
|
|
1129
|
+
for modality in modalities:
|
|
1130
|
+
# make sure process images first
|
|
1131
|
+
if modality == "images":
|
|
1132
|
+
audio_projection_mode = "vision"
|
|
1133
|
+
image_input = modalities["images"]
|
|
1134
|
+
vision_embeddings = self._process_image_input(image_input)
|
|
1135
|
+
multimodal_embeddings += tuple(vision_embeddings)
|
|
1136
|
+
if modality == "audios":
|
|
1137
|
+
audio_input = modalities["audios"]
|
|
1138
|
+
audio_embeddings = self._process_audio_input(
|
|
1139
|
+
audio_input, audio_projection_mode=audio_projection_mode)
|
|
1140
|
+
multimodal_embeddings += tuple(audio_embeddings)
|
|
1141
|
+
|
|
1142
|
+
return multimodal_embeddings
|
|
1143
|
+
|
|
1144
|
+
def get_input_embeddings(
|
|
1145
|
+
self,
|
|
1146
|
+
input_ids: torch.Tensor,
|
|
1147
|
+
multimodal_embeddings: Optional[MultiModalEmbeddings] = None,
|
|
1148
|
+
) -> torch.Tensor:
|
|
1149
|
+
inputs_embeds = self.model.embed_tokens(input_ids)
|
|
1150
|
+
if multimodal_embeddings is not None:
|
|
1151
|
+
inputs_embeds = merge_multimodal_embeddings(
|
|
1152
|
+
input_ids, inputs_embeds, multimodal_embeddings,
|
|
1153
|
+
[_IMAGE_PLACEHOLDER_TOKEN_ID, _AUDIO_PLACEHOLDER_TOKEN_ID])
|
|
1154
|
+
return inputs_embeds
|
|
1155
|
+
|
|
1156
|
+
def get_input_embeddings_v0(
|
|
1157
|
+
self,
|
|
1158
|
+
input_ids: torch.Tensor,
|
|
1159
|
+
image_input: Optional[Phi4MMImagePixelInputs] = None,
|
|
1160
|
+
audio_input: Optional[Phi4MMAudioFeatureInputs] = None,
|
|
1161
|
+
) -> torch.Tensor:
|
|
1162
|
+
audio_projection_mode = 'speech'
|
|
1163
|
+
inputs_embeds = self.get_input_embeddings(input_ids)
|
|
1164
|
+
if image_input is not None:
|
|
1165
|
+
image_embeds = self._process_image_input(image_input)
|
|
1166
|
+
inputs_embeds = merge_multimodal_embeddings(
|
|
1167
|
+
input_ids,
|
|
1168
|
+
inputs_embeds,
|
|
1169
|
+
image_embeds,
|
|
1170
|
+
placeholder_token_id=_IMAGE_PLACEHOLDER_TOKEN_ID,
|
|
1171
|
+
)
|
|
1172
|
+
audio_projection_mode = 'vision'
|
|
1173
|
+
|
|
1174
|
+
if audio_input is not None:
|
|
1175
|
+
audio_embeds = self._process_audio_input(
|
|
1176
|
+
audio_input, audio_projection_mode=audio_projection_mode)
|
|
1177
|
+
inputs_embeds = merge_multimodal_embeddings(
|
|
1178
|
+
input_ids,
|
|
1179
|
+
inputs_embeds,
|
|
1180
|
+
audio_embeds,
|
|
1181
|
+
placeholder_token_id=_AUDIO_PLACEHOLDER_TOKEN_ID,
|
|
1182
|
+
)
|
|
1183
|
+
return inputs_embeds
|
|
1184
|
+
|
|
1185
|
+
def forward(
|
|
1186
|
+
self,
|
|
1187
|
+
input_ids: torch.Tensor,
|
|
1188
|
+
positions: torch.Tensor,
|
|
1189
|
+
intermediate_tensors: Optional[IntermediateTensors] = None,
|
|
1190
|
+
inputs_embeds: Optional[torch.Tensor] = None,
|
|
1191
|
+
**kwargs: object,
|
|
1192
|
+
) -> torch.Tensor:
|
|
1193
|
+
if intermediate_tensors is not None:
|
|
1194
|
+
inputs_embeds = None
|
|
1195
|
+
|
|
1196
|
+
# NOTE: In v1, inputs_embeds is always generated at model runner from
|
|
1197
|
+
# `get_multimodal_embeddings` and `get_input_embeddings`, this
|
|
1198
|
+
# condition is only for v0 compatibility.
|
|
1199
|
+
elif inputs_embeds is None:
|
|
1200
|
+
image_input = self._parse_and_validate_image_input(**kwargs)
|
|
1201
|
+
audio_input = self._parse_and_validate_audio_input(**kwargs)
|
|
1202
|
+
|
|
1203
|
+
if image_input is None and audio_input is None:
|
|
1204
|
+
inputs_embeds = None
|
|
1205
|
+
else:
|
|
1206
|
+
inputs_embeds = self.get_input_embeddings_v0(
|
|
1207
|
+
input_ids,
|
|
1208
|
+
image_input=image_input,
|
|
1209
|
+
audio_input=audio_input)
|
|
1210
|
+
input_ids = None
|
|
1211
|
+
|
|
1212
|
+
hidden_states = self.model(
|
|
1213
|
+
input_ids,
|
|
1214
|
+
positions,
|
|
1215
|
+
intermediate_tensors,
|
|
1216
|
+
inputs_embeds=inputs_embeds,
|
|
1217
|
+
)
|
|
1218
|
+
|
|
1219
|
+
return hidden_states
|
|
1220
|
+
|
|
1221
|
+
def compute_logits(
|
|
1222
|
+
self,
|
|
1223
|
+
hidden_states: torch.Tensor,
|
|
1224
|
+
sampling_metadata: SamplingMetadata,
|
|
1225
|
+
) -> Optional[torch.Tensor]:
|
|
1226
|
+
logits = self.logits_processor(self.lm_head, hidden_states,
|
|
1227
|
+
sampling_metadata)
|
|
1228
|
+
return logits
|
|
1229
|
+
|
|
1230
|
+
def load_weights(self, weights: Iterable[tuple[str,
|
|
1231
|
+
torch.Tensor]]) -> None:
|
|
1232
|
+
loader = AutoWeightsLoader(self, skip_substrs=["lora"])
|
|
1233
|
+
return loader.load_weights(weights, mapper=self.hf_to_vllm_mapper)
|
|
1234
|
+
|
|
1235
|
+
def get_mm_mapping(self) -> MultiModelKeys:
|
|
1236
|
+
"""
|
|
1237
|
+
Get the module prefix in multimodal models
|
|
1238
|
+
"""
|
|
1239
|
+
return MultiModelKeys.from_string_field(
|
|
1240
|
+
language_model="model.",
|
|
1241
|
+
connector=["audio_projection_for_vision", "audio_projection"],
|
|
1242
|
+
tower_model=["vision_encoder", "embed_tokens_extend"],
|
|
1243
|
+
)
|
|
1244
|
+
|
|
1245
|
+
def get_language_model(self) -> torch.nn.Module:
|
|
1246
|
+
return self.model
|