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,1103 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
|
3
|
+
|
|
4
|
+
import math
|
|
5
|
+
from collections import OrderedDict
|
|
6
|
+
from collections.abc import Iterable, Mapping, Sequence
|
|
7
|
+
from typing import Literal, Optional, TypedDict, Union
|
|
8
|
+
|
|
9
|
+
import torch
|
|
10
|
+
import torch.nn as nn
|
|
11
|
+
import torch.nn.functional as F
|
|
12
|
+
from einops import rearrange
|
|
13
|
+
from transformers import BartTokenizer, BatchFeature, PretrainedConfig
|
|
14
|
+
|
|
15
|
+
from vllm.config import VllmConfig
|
|
16
|
+
from vllm.model_executor.layers.logits_processor import LogitsProcessor
|
|
17
|
+
from vllm.model_executor.model_loader.weight_utils import default_weight_loader
|
|
18
|
+
from vllm.model_executor.models.bart import (BartDecoder, BartEncoder,
|
|
19
|
+
BartParallelLMHead,
|
|
20
|
+
BartScaledWordEmbedding)
|
|
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)
|
|
25
|
+
from vllm.multimodal.parse import MultiModalDataItems
|
|
26
|
+
from vllm.multimodal.processing import (BaseProcessingInfo,
|
|
27
|
+
EncDecMultiModalProcessor,
|
|
28
|
+
PromptIndexTargets, PromptInsertion,
|
|
29
|
+
PromptUpdate)
|
|
30
|
+
from vllm.multimodal.profiling import BaseDummyInputsBuilder
|
|
31
|
+
from vllm.sequence import IntermediateTensors
|
|
32
|
+
|
|
33
|
+
from .interfaces import (MultiModalEmbeddings, SupportsMultiModal,
|
|
34
|
+
SupportsV0Only)
|
|
35
|
+
from .utils import AutoWeightsLoader, flatten_bn, merge_multimodal_embeddings
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class Florence2ImagePixelInputs(TypedDict):
|
|
39
|
+
type: Literal["pixel_values"]
|
|
40
|
+
data: torch.Tensor
|
|
41
|
+
"""Shape: (batch_size, num_channel, height, width)"""
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
# ViT implementation are all copied from
|
|
45
|
+
# https://huggingface.co/microsoft/Florence-2-base/blob/main/modeling_florence2.py
|
|
46
|
+
class LearnedAbsolutePositionEmbedding2D(nn.Module):
|
|
47
|
+
"""
|
|
48
|
+
This module learns positional embeddings up to a fixed maximum size.
|
|
49
|
+
"""
|
|
50
|
+
|
|
51
|
+
def __init__(self, embedding_dim=256, num_pos=50):
|
|
52
|
+
super().__init__()
|
|
53
|
+
self.row_embeddings = nn.Embedding(num_pos, embedding_dim // 2)
|
|
54
|
+
self.column_embeddings = nn.Embedding(
|
|
55
|
+
num_pos, embedding_dim - (embedding_dim // 2))
|
|
56
|
+
|
|
57
|
+
def forward(self, pixel_values):
|
|
58
|
+
"""
|
|
59
|
+
pixel_values: (batch_size, height, width, num_channels)
|
|
60
|
+
returns: (batch_size, height, width, embedding_dim * 2)
|
|
61
|
+
"""
|
|
62
|
+
if len(pixel_values.shape) != 4:
|
|
63
|
+
raise ValueError('pixel_values must be a 4D tensor')
|
|
64
|
+
height, width = pixel_values.shape[1:3]
|
|
65
|
+
width_values = torch.arange(width, device=pixel_values.device)
|
|
66
|
+
height_values = torch.arange(height, device=pixel_values.device)
|
|
67
|
+
x_emb = self.column_embeddings(width_values)
|
|
68
|
+
y_emb = self.row_embeddings(height_values)
|
|
69
|
+
# (height, width, embedding_dim * 2)
|
|
70
|
+
pos = torch.cat([
|
|
71
|
+
x_emb.unsqueeze(0).repeat(height, 1, 1),
|
|
72
|
+
y_emb.unsqueeze(1).repeat(1, width, 1)
|
|
73
|
+
],
|
|
74
|
+
dim=-1)
|
|
75
|
+
# (embedding_dim * 2, height, width)
|
|
76
|
+
pos = pos.permute(2, 0, 1)
|
|
77
|
+
pos = pos.unsqueeze(0)
|
|
78
|
+
# (batch_size, embedding_dim * 2, height, width)
|
|
79
|
+
pos = pos.repeat(pixel_values.shape[0], 1, 1, 1)
|
|
80
|
+
# (batch_size, height, width, embedding_dim * 2)
|
|
81
|
+
pos = pos.permute(0, 2, 3, 1)
|
|
82
|
+
return pos
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
class PositionalEmbeddingCosine1D(nn.Module):
|
|
86
|
+
"""
|
|
87
|
+
This class implements a very simple positional encoding. It follows closely
|
|
88
|
+
the encoder from the link below:
|
|
89
|
+
https://pytorch.org/tutorials/beginner/translation_transformer.html
|
|
90
|
+
Args:
|
|
91
|
+
embed_dim: The dimension of the embeddings.
|
|
92
|
+
dropout_prob: The dropout probability.
|
|
93
|
+
max_seq_len: The maximum length to precompute the positional encodings.
|
|
94
|
+
"""
|
|
95
|
+
|
|
96
|
+
def __init__(self, embed_dim: int = 512, max_seq_len: int = 1024) -> None:
|
|
97
|
+
super().__init__()
|
|
98
|
+
self.embed_dim = embed_dim
|
|
99
|
+
self.max_seq_len = max_seq_len
|
|
100
|
+
# Generate the sinusoidal arrays.
|
|
101
|
+
factor = math.log(10000)
|
|
102
|
+
denominator = torch.exp(-factor * torch.arange(0, self.embed_dim, 2) /
|
|
103
|
+
self.embed_dim)
|
|
104
|
+
# Matrix where rows correspond to a positional embedding as a function
|
|
105
|
+
# of the position index (i.e., the row index).
|
|
106
|
+
frequencies = \
|
|
107
|
+
torch.arange(0, self.max_seq_len) \
|
|
108
|
+
.reshape(self.max_seq_len, 1) * denominator
|
|
109
|
+
pos_idx_to_embed = torch.zeros((self.max_seq_len, self.embed_dim))
|
|
110
|
+
# Populate uneven entries.
|
|
111
|
+
pos_idx_to_embed[:, 0::2] = torch.sin(frequencies)
|
|
112
|
+
pos_idx_to_embed[:, 1::2] = torch.cos(frequencies)
|
|
113
|
+
# Save the positional embeddings in a constant buffer.
|
|
114
|
+
# self.register_buffer("pos_idx_to_embed", pos_idx_to_embed)
|
|
115
|
+
self.pos_idx_to_embed = nn.Parameter(pos_idx_to_embed,
|
|
116
|
+
requires_grad=False)
|
|
117
|
+
|
|
118
|
+
def forward(self, seq_embeds: torch.Tensor) -> torch.Tensor:
|
|
119
|
+
"""
|
|
120
|
+
Args:
|
|
121
|
+
seq_embeds: The sequence embeddings in order. Allowed size:
|
|
122
|
+
1. [T, D], where T is the length of the sequence, and D is the
|
|
123
|
+
frame embedding dimension.
|
|
124
|
+
2. [B, T, D], where B is the batch size and T and D are the
|
|
125
|
+
same as above.
|
|
126
|
+
Returns a tensor of with the same dimensions as the input: i.e.,
|
|
127
|
+
[1, T, D] or [T, D].
|
|
128
|
+
"""
|
|
129
|
+
shape_len = len(seq_embeds.shape)
|
|
130
|
+
assert 2 <= shape_len <= 3
|
|
131
|
+
len_seq = seq_embeds.size(-2)
|
|
132
|
+
assert len_seq <= self.max_seq_len
|
|
133
|
+
pos_embeds = self.pos_idx_to_embed[0:seq_embeds.size(-2), :]
|
|
134
|
+
# Adapt pre-computed positional embeddings to the input.
|
|
135
|
+
if shape_len == 3:
|
|
136
|
+
pos_embeds = pos_embeds.view(
|
|
137
|
+
(1, pos_embeds.size(0), pos_embeds.size(1)))
|
|
138
|
+
return pos_embeds
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
class MySequential(nn.Sequential):
|
|
142
|
+
|
|
143
|
+
def forward(self, *inputs):
|
|
144
|
+
for module in self._modules.values():
|
|
145
|
+
if isinstance(inputs, tuple):
|
|
146
|
+
inputs = module(*inputs)
|
|
147
|
+
else:
|
|
148
|
+
inputs = module(inputs)
|
|
149
|
+
return inputs
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
class PreNorm(nn.Module):
|
|
153
|
+
|
|
154
|
+
def __init__(self, norm, fn):
|
|
155
|
+
super().__init__()
|
|
156
|
+
self.norm = norm
|
|
157
|
+
self.fn = fn
|
|
158
|
+
|
|
159
|
+
def forward(self, x, *args, **kwargs):
|
|
160
|
+
shortcut = x
|
|
161
|
+
if self.norm is not None:
|
|
162
|
+
x, size = self.fn(self.norm(x), *args, **kwargs)
|
|
163
|
+
else:
|
|
164
|
+
x, size = self.fn(x, *args, **kwargs)
|
|
165
|
+
|
|
166
|
+
x = shortcut + x
|
|
167
|
+
|
|
168
|
+
return x, size
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
class Mlp(nn.Module):
|
|
172
|
+
|
|
173
|
+
def __init__(
|
|
174
|
+
self,
|
|
175
|
+
in_features,
|
|
176
|
+
hidden_features=None,
|
|
177
|
+
out_features=None,
|
|
178
|
+
act_layer=nn.GELU,
|
|
179
|
+
):
|
|
180
|
+
super().__init__()
|
|
181
|
+
out_features = out_features or in_features
|
|
182
|
+
hidden_features = hidden_features or in_features
|
|
183
|
+
self.net = nn.Sequential(
|
|
184
|
+
OrderedDict([("fc1", nn.Linear(in_features, hidden_features)),
|
|
185
|
+
("act", act_layer()),
|
|
186
|
+
("fc2", nn.Linear(hidden_features, out_features))]))
|
|
187
|
+
|
|
188
|
+
def forward(self, x, size):
|
|
189
|
+
return self.net(x), size
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
class DepthWiseConv2d(nn.Module):
|
|
193
|
+
|
|
194
|
+
def __init__(
|
|
195
|
+
self,
|
|
196
|
+
dim_in,
|
|
197
|
+
kernel_size,
|
|
198
|
+
padding,
|
|
199
|
+
stride,
|
|
200
|
+
bias=True,
|
|
201
|
+
):
|
|
202
|
+
super().__init__()
|
|
203
|
+
self.dw = nn.Conv2d(dim_in,
|
|
204
|
+
dim_in,
|
|
205
|
+
kernel_size=kernel_size,
|
|
206
|
+
padding=padding,
|
|
207
|
+
groups=dim_in,
|
|
208
|
+
stride=stride,
|
|
209
|
+
bias=bias)
|
|
210
|
+
|
|
211
|
+
def forward(self, x, size):
|
|
212
|
+
B, N, C = x.shape
|
|
213
|
+
H, W = size
|
|
214
|
+
assert N == H * W
|
|
215
|
+
|
|
216
|
+
x = self.dw(x.transpose(1, 2).view(B, C, H, W))
|
|
217
|
+
size = (x.size(-2), x.size(-1))
|
|
218
|
+
x = x.flatten(2).transpose(1, 2)
|
|
219
|
+
return x, size
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
class ConvEmbed(nn.Module):
|
|
223
|
+
""" Image to Patch Embedding
|
|
224
|
+
"""
|
|
225
|
+
|
|
226
|
+
def __init__(self,
|
|
227
|
+
patch_size=7,
|
|
228
|
+
in_chans=3,
|
|
229
|
+
embed_dim=64,
|
|
230
|
+
stride=4,
|
|
231
|
+
padding=2,
|
|
232
|
+
norm_layer=None,
|
|
233
|
+
pre_norm=True):
|
|
234
|
+
super().__init__()
|
|
235
|
+
self.patch_size = patch_size
|
|
236
|
+
|
|
237
|
+
self.proj = nn.Conv2d(in_chans,
|
|
238
|
+
embed_dim,
|
|
239
|
+
kernel_size=patch_size,
|
|
240
|
+
stride=stride,
|
|
241
|
+
padding=padding)
|
|
242
|
+
|
|
243
|
+
dim_norm = in_chans if pre_norm else embed_dim
|
|
244
|
+
self.norm = norm_layer(dim_norm) if norm_layer else None
|
|
245
|
+
|
|
246
|
+
self.pre_norm = pre_norm
|
|
247
|
+
|
|
248
|
+
def forward(self, x, size):
|
|
249
|
+
H, W = size
|
|
250
|
+
if len(x.size()) == 3:
|
|
251
|
+
if self.norm and self.pre_norm:
|
|
252
|
+
x = self.norm(x)
|
|
253
|
+
x = rearrange(x, 'b (h w) c -> b c h w', h=H, w=W)
|
|
254
|
+
|
|
255
|
+
x = self.proj(x)
|
|
256
|
+
|
|
257
|
+
_, _, H, W = x.shape
|
|
258
|
+
x = rearrange(x, 'b c h w -> b (h w) c')
|
|
259
|
+
if self.norm and not self.pre_norm:
|
|
260
|
+
x = self.norm(x)
|
|
261
|
+
|
|
262
|
+
return x, (H, W)
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
class ChannelAttention(nn.Module):
|
|
266
|
+
|
|
267
|
+
def __init__(self, dim, groups=8, qkv_bias=True):
|
|
268
|
+
super().__init__()
|
|
269
|
+
|
|
270
|
+
self.groups = groups
|
|
271
|
+
self.qkv = nn.Linear(dim, dim * 3, bias=qkv_bias)
|
|
272
|
+
self.proj = nn.Linear(dim, dim)
|
|
273
|
+
|
|
274
|
+
def forward(self, x, size):
|
|
275
|
+
B, N, C = x.shape
|
|
276
|
+
|
|
277
|
+
qkv = self.qkv(x).reshape(B, N, 3, self.groups,
|
|
278
|
+
C // self.groups).permute(2, 0, 3, 1, 4)
|
|
279
|
+
q, k, v = qkv[0], qkv[1], qkv[2]
|
|
280
|
+
|
|
281
|
+
q = q * (float(N)**-0.5)
|
|
282
|
+
attention = q.transpose(-1, -2) @ k
|
|
283
|
+
attention = attention.softmax(dim=-1)
|
|
284
|
+
x = (attention @ v.transpose(-1, -2)).transpose(-1, -2)
|
|
285
|
+
x = x.transpose(1, 2).reshape(B, N, C)
|
|
286
|
+
x = self.proj(x)
|
|
287
|
+
return x, size
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
class ChannelBlock(nn.Module):
|
|
291
|
+
|
|
292
|
+
def __init__(self,
|
|
293
|
+
dim,
|
|
294
|
+
groups,
|
|
295
|
+
mlp_ratio=4.,
|
|
296
|
+
qkv_bias=True,
|
|
297
|
+
drop_path_rate=0.,
|
|
298
|
+
act_layer=nn.GELU,
|
|
299
|
+
norm_layer=nn.LayerNorm,
|
|
300
|
+
conv_at_attn=True,
|
|
301
|
+
conv_at_ffn=True):
|
|
302
|
+
super().__init__()
|
|
303
|
+
|
|
304
|
+
self.conv1 = PreNorm(None, DepthWiseConv2d(
|
|
305
|
+
dim, 3, 1, 1)) if conv_at_attn else None
|
|
306
|
+
self.channel_attn = PreNorm(
|
|
307
|
+
norm_layer(dim),
|
|
308
|
+
ChannelAttention(dim, groups=groups, qkv_bias=qkv_bias),
|
|
309
|
+
)
|
|
310
|
+
self.conv2 = PreNorm(None, DepthWiseConv2d(dim, 3, 1,
|
|
311
|
+
1)) if conv_at_ffn else None
|
|
312
|
+
self.ffn = PreNorm(
|
|
313
|
+
norm_layer(dim),
|
|
314
|
+
Mlp(in_features=dim,
|
|
315
|
+
hidden_features=int(dim * mlp_ratio),
|
|
316
|
+
act_layer=act_layer),
|
|
317
|
+
)
|
|
318
|
+
|
|
319
|
+
def forward(self, x, size):
|
|
320
|
+
if self.conv1:
|
|
321
|
+
x, size = self.conv1(x, size)
|
|
322
|
+
x, size = self.channel_attn(x, size)
|
|
323
|
+
|
|
324
|
+
if self.conv2:
|
|
325
|
+
x, size = self.conv2(x, size)
|
|
326
|
+
x, size = self.ffn(x, size)
|
|
327
|
+
|
|
328
|
+
return x, size
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
def window_partition(x, window_size: int):
|
|
332
|
+
B, H, W, C = x.shape
|
|
333
|
+
x = x.view(B, H // window_size, window_size, W // window_size, window_size,
|
|
334
|
+
C)
|
|
335
|
+
windows = x.permute(0, 1, 3, 2, 4,
|
|
336
|
+
5).contiguous().view(-1, window_size, window_size, C)
|
|
337
|
+
return windows
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
def window_reverse(windows, batch_size: int, window_size: int, H: int, W: int):
|
|
341
|
+
B = batch_size
|
|
342
|
+
|
|
343
|
+
x = windows.view(B, H // window_size, W // window_size, window_size,
|
|
344
|
+
window_size, -1)
|
|
345
|
+
x = x.permute(0, 1, 3, 2, 4, 5).contiguous().view(B, H, W, -1)
|
|
346
|
+
return x
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
class WindowAttention(nn.Module):
|
|
350
|
+
|
|
351
|
+
def __init__(self, dim, num_heads, window_size, qkv_bias=True):
|
|
352
|
+
|
|
353
|
+
super().__init__()
|
|
354
|
+
self.dim = dim
|
|
355
|
+
self.window_size = window_size
|
|
356
|
+
self.num_heads = num_heads
|
|
357
|
+
head_dim = dim // num_heads
|
|
358
|
+
self.scale = float(head_dim)**-0.5
|
|
359
|
+
|
|
360
|
+
self.qkv = nn.Linear(dim, dim * 3, bias=qkv_bias)
|
|
361
|
+
self.proj = nn.Linear(dim, dim)
|
|
362
|
+
|
|
363
|
+
self.softmax = nn.Softmax(dim=-1)
|
|
364
|
+
|
|
365
|
+
def forward(self, x, size):
|
|
366
|
+
|
|
367
|
+
H, W = size
|
|
368
|
+
B, L, C = x.shape
|
|
369
|
+
assert L == H * W, "input feature has wrong size"
|
|
370
|
+
|
|
371
|
+
x = x.view(B, H, W, C)
|
|
372
|
+
|
|
373
|
+
pad_l = pad_t = 0
|
|
374
|
+
pad_r = (self.window_size - W % self.window_size) % self.window_size
|
|
375
|
+
pad_b = (self.window_size - H % self.window_size) % self.window_size
|
|
376
|
+
x = F.pad(x, (0, 0, pad_l, pad_r, pad_t, pad_b))
|
|
377
|
+
_, Hp, Wp, _ = x.shape
|
|
378
|
+
|
|
379
|
+
x = window_partition(x, self.window_size)
|
|
380
|
+
x = x.view(-1, self.window_size * self.window_size, C)
|
|
381
|
+
|
|
382
|
+
# W-MSA/SW-MSA
|
|
383
|
+
# attn_windows = self.attn(x_windows)
|
|
384
|
+
|
|
385
|
+
B_, N, C = x.shape
|
|
386
|
+
qkv = self.qkv(x).reshape(B_, N, 3, self.num_heads,
|
|
387
|
+
C // self.num_heads).permute(2, 0, 3, 1, 4)
|
|
388
|
+
q, k, v = qkv[0], qkv[1], qkv[2]
|
|
389
|
+
|
|
390
|
+
q = q * self.scale
|
|
391
|
+
attn = (q @ k.transpose(-2, -1))
|
|
392
|
+
attn = self.softmax(attn)
|
|
393
|
+
|
|
394
|
+
x = (attn @ v).transpose(1, 2).reshape(B_, N, C)
|
|
395
|
+
x = self.proj(x)
|
|
396
|
+
|
|
397
|
+
# merge windows
|
|
398
|
+
x = x.view(-1, self.window_size, self.window_size, C)
|
|
399
|
+
x = window_reverse(x, B, self.window_size, Hp, Wp)
|
|
400
|
+
|
|
401
|
+
if pad_r > 0 or pad_b > 0:
|
|
402
|
+
x = x[:, :H, :W, :].contiguous()
|
|
403
|
+
|
|
404
|
+
x = x.view(B, H * W, C)
|
|
405
|
+
|
|
406
|
+
return x, size
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+
class SpatialBlock(nn.Module):
|
|
410
|
+
|
|
411
|
+
def __init__(self,
|
|
412
|
+
dim,
|
|
413
|
+
num_heads,
|
|
414
|
+
window_size,
|
|
415
|
+
mlp_ratio=4.,
|
|
416
|
+
qkv_bias=True,
|
|
417
|
+
drop_path_rate=0.,
|
|
418
|
+
act_layer=nn.GELU,
|
|
419
|
+
norm_layer=nn.LayerNorm,
|
|
420
|
+
conv_at_attn=True,
|
|
421
|
+
conv_at_ffn=True):
|
|
422
|
+
super().__init__()
|
|
423
|
+
|
|
424
|
+
self.conv1 = PreNorm(None, DepthWiseConv2d(
|
|
425
|
+
dim, 3, 1, 1)) if conv_at_attn else None
|
|
426
|
+
self.window_attn = PreNorm(
|
|
427
|
+
norm_layer(dim),
|
|
428
|
+
WindowAttention(dim, num_heads, window_size, qkv_bias=qkv_bias),
|
|
429
|
+
)
|
|
430
|
+
self.conv2 = PreNorm(None, DepthWiseConv2d(dim, 3, 1,
|
|
431
|
+
1)) if conv_at_ffn else None
|
|
432
|
+
self.ffn = PreNorm(
|
|
433
|
+
norm_layer(dim),
|
|
434
|
+
Mlp(in_features=dim,
|
|
435
|
+
hidden_features=int(dim * mlp_ratio),
|
|
436
|
+
act_layer=act_layer),
|
|
437
|
+
)
|
|
438
|
+
|
|
439
|
+
def forward(self, x, size):
|
|
440
|
+
if self.conv1:
|
|
441
|
+
x, size = self.conv1(x, size)
|
|
442
|
+
x, size = self.window_attn(x, size)
|
|
443
|
+
|
|
444
|
+
if self.conv2:
|
|
445
|
+
x, size = self.conv2(x, size)
|
|
446
|
+
x, size = self.ffn(x, size)
|
|
447
|
+
return x, size
|
|
448
|
+
|
|
449
|
+
|
|
450
|
+
class DaViT(nn.Module):
|
|
451
|
+
|
|
452
|
+
def __init__(
|
|
453
|
+
self,
|
|
454
|
+
in_chans=3,
|
|
455
|
+
num_classes=1000,
|
|
456
|
+
depths=(1, 1, 3, 1),
|
|
457
|
+
patch_size=(7, 2, 2, 2),
|
|
458
|
+
patch_stride=(4, 2, 2, 2),
|
|
459
|
+
patch_padding=(3, 0, 0, 0),
|
|
460
|
+
patch_prenorm=(False, False, False, False),
|
|
461
|
+
embed_dims=(64, 128, 192, 256),
|
|
462
|
+
num_heads=(3, 6, 12, 24),
|
|
463
|
+
num_groups=(3, 6, 12, 24),
|
|
464
|
+
window_size=7,
|
|
465
|
+
mlp_ratio=4.,
|
|
466
|
+
qkv_bias=True,
|
|
467
|
+
drop_path_rate=0.1,
|
|
468
|
+
norm_layer=nn.LayerNorm,
|
|
469
|
+
enable_checkpoint=False,
|
|
470
|
+
conv_at_attn=True,
|
|
471
|
+
conv_at_ffn=True,
|
|
472
|
+
):
|
|
473
|
+
super().__init__()
|
|
474
|
+
|
|
475
|
+
self.num_classes = num_classes
|
|
476
|
+
self.embed_dims = embed_dims
|
|
477
|
+
self.num_heads = num_heads
|
|
478
|
+
self.num_groups = num_groups
|
|
479
|
+
self.num_stages = len(self.embed_dims)
|
|
480
|
+
self.enable_checkpoint = enable_checkpoint
|
|
481
|
+
assert self.num_stages == len(self.num_heads) == len(self.num_groups)
|
|
482
|
+
|
|
483
|
+
num_stages = len(embed_dims)
|
|
484
|
+
dpr = [
|
|
485
|
+
x.item() for x in torch.linspace(0, drop_path_rate,
|
|
486
|
+
sum(depths) * 2)
|
|
487
|
+
]
|
|
488
|
+
|
|
489
|
+
depth_offset = 0
|
|
490
|
+
convs = []
|
|
491
|
+
blocks = []
|
|
492
|
+
for i in range(num_stages):
|
|
493
|
+
conv_embed = ConvEmbed(
|
|
494
|
+
patch_size=patch_size[i],
|
|
495
|
+
stride=patch_stride[i],
|
|
496
|
+
padding=patch_padding[i],
|
|
497
|
+
in_chans=in_chans if i == 0 else self.embed_dims[i - 1],
|
|
498
|
+
embed_dim=self.embed_dims[i],
|
|
499
|
+
norm_layer=norm_layer,
|
|
500
|
+
pre_norm=patch_prenorm[i])
|
|
501
|
+
convs.append(conv_embed)
|
|
502
|
+
|
|
503
|
+
block = MySequential(*[
|
|
504
|
+
MySequential(
|
|
505
|
+
OrderedDict([('spatial_block',
|
|
506
|
+
SpatialBlock(
|
|
507
|
+
embed_dims[i],
|
|
508
|
+
num_heads[i],
|
|
509
|
+
window_size,
|
|
510
|
+
drop_path_rate=dpr[depth_offset + j * 2],
|
|
511
|
+
qkv_bias=qkv_bias,
|
|
512
|
+
mlp_ratio=mlp_ratio,
|
|
513
|
+
conv_at_attn=conv_at_attn,
|
|
514
|
+
conv_at_ffn=conv_at_ffn,
|
|
515
|
+
)),
|
|
516
|
+
('channel_block',
|
|
517
|
+
ChannelBlock(
|
|
518
|
+
embed_dims[i],
|
|
519
|
+
num_groups[i],
|
|
520
|
+
drop_path_rate=dpr[depth_offset + j * 2 +
|
|
521
|
+
1],
|
|
522
|
+
qkv_bias=qkv_bias,
|
|
523
|
+
mlp_ratio=mlp_ratio,
|
|
524
|
+
conv_at_attn=conv_at_attn,
|
|
525
|
+
conv_at_ffn=conv_at_ffn,
|
|
526
|
+
))])) for j in range(depths[i])
|
|
527
|
+
])
|
|
528
|
+
blocks.append(block)
|
|
529
|
+
depth_offset += depths[i] * 2
|
|
530
|
+
|
|
531
|
+
self.convs = nn.ModuleList(convs)
|
|
532
|
+
self.blocks = nn.ModuleList(blocks)
|
|
533
|
+
|
|
534
|
+
self.avgpool = nn.AdaptiveAvgPool1d(1)
|
|
535
|
+
|
|
536
|
+
@property
|
|
537
|
+
def dim_out(self):
|
|
538
|
+
return self.embed_dims[-1]
|
|
539
|
+
|
|
540
|
+
def forward_features_unpool(self, x):
|
|
541
|
+
"""
|
|
542
|
+
forward until avg pooling
|
|
543
|
+
Args:
|
|
544
|
+
x (_type_): input image tensor
|
|
545
|
+
"""
|
|
546
|
+
input_size = (x.size(2), x.size(3))
|
|
547
|
+
for conv, block in zip(self.convs, self.blocks):
|
|
548
|
+
x, input_size = conv(x, input_size)
|
|
549
|
+
x, input_size = block(x, input_size)
|
|
550
|
+
return x
|
|
551
|
+
|
|
552
|
+
def forward_features(self, x):
|
|
553
|
+
x = self.forward_features_unpool(x)
|
|
554
|
+
|
|
555
|
+
# (batch_size, num_tokens, token_dim)
|
|
556
|
+
x = self.avgpool(x.transpose(1, 2))
|
|
557
|
+
# (batch_size, 1, num_tokens)
|
|
558
|
+
x = torch.flatten(x, 1)
|
|
559
|
+
x = self.norms(x)
|
|
560
|
+
|
|
561
|
+
return x
|
|
562
|
+
|
|
563
|
+
def forward(self, x):
|
|
564
|
+
x = self.forward_features(x)
|
|
565
|
+
x = self.head(x)
|
|
566
|
+
return x
|
|
567
|
+
|
|
568
|
+
@classmethod
|
|
569
|
+
def from_config(cls, config):
|
|
570
|
+
return cls(
|
|
571
|
+
depths=config.depths,
|
|
572
|
+
embed_dims=config.dim_embed,
|
|
573
|
+
num_heads=config.num_heads,
|
|
574
|
+
num_groups=config.num_groups,
|
|
575
|
+
patch_size=config.patch_size,
|
|
576
|
+
patch_stride=config.patch_stride,
|
|
577
|
+
patch_padding=config.patch_padding,
|
|
578
|
+
patch_prenorm=config.patch_prenorm,
|
|
579
|
+
drop_path_rate=config.drop_path_rate,
|
|
580
|
+
window_size=config.window_size,
|
|
581
|
+
)
|
|
582
|
+
|
|
583
|
+
|
|
584
|
+
# Language backbone and processor implementation
|
|
585
|
+
class Florence2LanguageModel(nn.Module):
|
|
586
|
+
|
|
587
|
+
def __init__(self, *, vllm_config: VllmConfig, prefix: str = ""):
|
|
588
|
+
super().__init__()
|
|
589
|
+
|
|
590
|
+
config = vllm_config.model_config.hf_config
|
|
591
|
+
cache_config = vllm_config.cache_config
|
|
592
|
+
quant_config = vllm_config.quant_config
|
|
593
|
+
|
|
594
|
+
self.config = config
|
|
595
|
+
|
|
596
|
+
self.vocab_size = config.vocab_size
|
|
597
|
+
|
|
598
|
+
self.shared = BartScaledWordEmbedding(self.vocab_size, config.d_model)
|
|
599
|
+
self.encoder = BartEncoder(config,
|
|
600
|
+
cache_config=cache_config,
|
|
601
|
+
quant_config=quant_config,
|
|
602
|
+
prefix=f"{prefix}.encoder")
|
|
603
|
+
self.decoder = BartDecoder(config,
|
|
604
|
+
cache_config=cache_config,
|
|
605
|
+
quant_config=quant_config,
|
|
606
|
+
prefix=f"{prefix}.decoder")
|
|
607
|
+
|
|
608
|
+
if self.config.tie_word_embeddings:
|
|
609
|
+
self.encoder.embed_tokens.weight = self.shared.weight
|
|
610
|
+
self.decoder.embed_tokens.weight = self.shared.weight
|
|
611
|
+
|
|
612
|
+
def forward(
|
|
613
|
+
self,
|
|
614
|
+
input_ids: torch.Tensor,
|
|
615
|
+
positions: torch.Tensor,
|
|
616
|
+
encoder_input_ids: torch.Tensor,
|
|
617
|
+
encoder_positions: torch.Tensor,
|
|
618
|
+
inputs_embeds: Optional[torch.Tensor] = None,
|
|
619
|
+
) -> torch.Tensor:
|
|
620
|
+
r"""
|
|
621
|
+
Args:
|
|
622
|
+
input_ids
|
|
623
|
+
Indices of *decoder* input sequence tokens in the vocabulary.
|
|
624
|
+
Padding will be ignored by default should you
|
|
625
|
+
provide it.
|
|
626
|
+
positions
|
|
627
|
+
Positions of *decoder* input sequence tokens.
|
|
628
|
+
encoder_input_ids
|
|
629
|
+
Indices of *encoder* input sequence tokens in the vocabulary.
|
|
630
|
+
encoder_positions:
|
|
631
|
+
Positions of *encoder* input sequence tokens.
|
|
632
|
+
Returns:
|
|
633
|
+
Model output torch.Tensor
|
|
634
|
+
"""
|
|
635
|
+
|
|
636
|
+
encoder_hidden_states = None
|
|
637
|
+
|
|
638
|
+
if inputs_embeds is not None or encoder_input_ids.numel() > 0:
|
|
639
|
+
# Run encoder attention if a non-zero number of encoder tokens
|
|
640
|
+
# are provided as input
|
|
641
|
+
encoder_hidden_states = self.encoder(input_ids=encoder_input_ids,
|
|
642
|
+
positions=encoder_positions,
|
|
643
|
+
inputs_embeds=inputs_embeds)
|
|
644
|
+
|
|
645
|
+
# decoder outputs consists of
|
|
646
|
+
# (dec_features, past_key_value, dec_hidden, dec_attn)
|
|
647
|
+
decoder_outputs = self.decoder(
|
|
648
|
+
decoder_input_ids=input_ids,
|
|
649
|
+
decoder_positions=positions,
|
|
650
|
+
encoder_hidden_states=encoder_hidden_states)
|
|
651
|
+
|
|
652
|
+
return decoder_outputs
|
|
653
|
+
|
|
654
|
+
|
|
655
|
+
class Florence2LanguageForConditionalGeneration(nn.Module, SupportsV0Only):
|
|
656
|
+
|
|
657
|
+
def __init__(self, *, vllm_config: VllmConfig, prefix: str = ""):
|
|
658
|
+
super().__init__()
|
|
659
|
+
|
|
660
|
+
config = vllm_config.model_config.hf_config
|
|
661
|
+
|
|
662
|
+
self.config = config
|
|
663
|
+
self.model = Florence2LanguageModel(vllm_config=vllm_config,
|
|
664
|
+
prefix=f"{prefix}.model")
|
|
665
|
+
embed_scale = math.sqrt(
|
|
666
|
+
config.d_model) if config.scale_embedding else 1.0
|
|
667
|
+
|
|
668
|
+
self.vocab_size = config.vocab_size
|
|
669
|
+
self.lm_head = BartParallelLMHead(self.vocab_size,
|
|
670
|
+
config.d_model,
|
|
671
|
+
embed_scale=embed_scale)
|
|
672
|
+
|
|
673
|
+
self.logits_processor = LogitsProcessor(self.vocab_size,
|
|
674
|
+
config.vocab_size)
|
|
675
|
+
|
|
676
|
+
def forward(
|
|
677
|
+
self,
|
|
678
|
+
input_ids: torch.Tensor,
|
|
679
|
+
positions: torch.Tensor,
|
|
680
|
+
encoder_input_ids: torch.Tensor,
|
|
681
|
+
encoder_positions: torch.Tensor,
|
|
682
|
+
inputs_embeds: Optional[torch.Tensor] = None,
|
|
683
|
+
**kwargs,
|
|
684
|
+
) -> torch.Tensor:
|
|
685
|
+
r"""
|
|
686
|
+
Args:
|
|
687
|
+
input_ids
|
|
688
|
+
torch.Tensor of *decoder* input token ids.
|
|
689
|
+
positions
|
|
690
|
+
torch.Tensor of *decoder* position indices.
|
|
691
|
+
encoder_input_ids
|
|
692
|
+
torch.Tensor of *encoder* input token ids.
|
|
693
|
+
encoder_positions
|
|
694
|
+
torch.Tensor of *encoder* position indices
|
|
695
|
+
Returns:
|
|
696
|
+
Output torch.Tensor
|
|
697
|
+
"""
|
|
698
|
+
|
|
699
|
+
return self.model(input_ids,
|
|
700
|
+
positions,
|
|
701
|
+
encoder_input_ids,
|
|
702
|
+
encoder_positions,
|
|
703
|
+
inputs_embeds=inputs_embeds)
|
|
704
|
+
|
|
705
|
+
def get_input_embeddings(self, input_ids: torch.Tensor) -> torch.Tensor:
|
|
706
|
+
return self.model.encoder.embed_tokens(input_ids)
|
|
707
|
+
|
|
708
|
+
def compute_logits(
|
|
709
|
+
self,
|
|
710
|
+
hidden_states: torch.Tensor,
|
|
711
|
+
sampling_metadata: SamplingMetadata,
|
|
712
|
+
) -> Optional[torch.Tensor]:
|
|
713
|
+
logits = self.logits_processor(self.lm_head, hidden_states,
|
|
714
|
+
sampling_metadata)
|
|
715
|
+
return logits
|
|
716
|
+
|
|
717
|
+
def load_weights(self, weights: Iterable[tuple[str,
|
|
718
|
+
torch.Tensor]]) -> set[str]:
|
|
719
|
+
stacked_params_mapping = [
|
|
720
|
+
# (param_name, shard_name, shard_id)
|
|
721
|
+
("qkv_proj", "q_proj", "q"),
|
|
722
|
+
("qkv_proj", "k_proj", "k"),
|
|
723
|
+
("qkv_proj", "v_proj", "v"),
|
|
724
|
+
]
|
|
725
|
+
|
|
726
|
+
params_dict = dict(self.named_parameters())
|
|
727
|
+
loaded_params: set[str] = set()
|
|
728
|
+
for name, loaded_weight in weights:
|
|
729
|
+
for (param_name, weight_name, shard_id) in stacked_params_mapping:
|
|
730
|
+
if weight_name not in name:
|
|
731
|
+
continue
|
|
732
|
+
name = name.replace(weight_name, param_name)
|
|
733
|
+
param = params_dict[name]
|
|
734
|
+
weight_loader = param.weight_loader
|
|
735
|
+
weight_loader(param, loaded_weight, shard_id)
|
|
736
|
+
break
|
|
737
|
+
else:
|
|
738
|
+
if "final_logits_bias" in name:
|
|
739
|
+
continue
|
|
740
|
+
if self.config.tie_word_embeddings and "embed_tokens" in name:
|
|
741
|
+
continue
|
|
742
|
+
param = params_dict[name]
|
|
743
|
+
weight_loader = getattr(param, "weight_loader",
|
|
744
|
+
default_weight_loader)
|
|
745
|
+
weight_loader(param, loaded_weight)
|
|
746
|
+
loaded_params.add(name)
|
|
747
|
+
return loaded_params
|
|
748
|
+
|
|
749
|
+
|
|
750
|
+
class Florence2ProcessingInfo(BaseProcessingInfo):
|
|
751
|
+
|
|
752
|
+
def get_hf_config(self):
|
|
753
|
+
return self.ctx.get_hf_config()
|
|
754
|
+
|
|
755
|
+
def get_hf_processor(self):
|
|
756
|
+
return self.ctx.get_hf_processor()
|
|
757
|
+
|
|
758
|
+
def get_supported_mm_limits(self) -> Mapping[str, Optional[int]]:
|
|
759
|
+
return {"image": 1}
|
|
760
|
+
|
|
761
|
+
def get_num_image_tokens(self) -> int:
|
|
762
|
+
processor_config = self.ctx.get_hf_image_processor_config()
|
|
763
|
+
return processor_config["image_seq_length"]
|
|
764
|
+
|
|
765
|
+
|
|
766
|
+
class Florence2DummyInputsBuilder(
|
|
767
|
+
BaseDummyInputsBuilder[Florence2ProcessingInfo]):
|
|
768
|
+
|
|
769
|
+
def get_dummy_text(self, mm_counts: Mapping[str, int]) -> str:
|
|
770
|
+
return ""
|
|
771
|
+
|
|
772
|
+
def get_dummy_mm_data(
|
|
773
|
+
self,
|
|
774
|
+
seq_len: int,
|
|
775
|
+
mm_counts: Mapping[str, int],
|
|
776
|
+
) -> MultiModalDataDict:
|
|
777
|
+
num_images = mm_counts.get("image", 0)
|
|
778
|
+
|
|
779
|
+
target_width = target_height = self.info.get_hf_config().projection_dim
|
|
780
|
+
|
|
781
|
+
return {
|
|
782
|
+
"image":
|
|
783
|
+
self._get_dummy_images(width=target_width,
|
|
784
|
+
height=target_height,
|
|
785
|
+
num_images=num_images)
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
|
|
789
|
+
class Florence2MultiModalProcessor(
|
|
790
|
+
EncDecMultiModalProcessor[Florence2ProcessingInfo]):
|
|
791
|
+
|
|
792
|
+
def _hf_processor_applies_updates(
|
|
793
|
+
self,
|
|
794
|
+
prompt_text: str,
|
|
795
|
+
mm_items: MultiModalDataItems,
|
|
796
|
+
hf_processor_mm_kwargs: Mapping[str, object],
|
|
797
|
+
) -> bool:
|
|
798
|
+
return False
|
|
799
|
+
|
|
800
|
+
def create_encoder_prompt(
|
|
801
|
+
self,
|
|
802
|
+
prompt: Union[str, list[int]],
|
|
803
|
+
mm_data: MultiModalDataDict,
|
|
804
|
+
) -> Union[str, list[int]]:
|
|
805
|
+
return prompt
|
|
806
|
+
|
|
807
|
+
def create_decoder_prompt(
|
|
808
|
+
self,
|
|
809
|
+
prompt: Union[str, list[int]],
|
|
810
|
+
mm_data: MultiModalDataDict,
|
|
811
|
+
) -> Union[str, list[int]]:
|
|
812
|
+
return [self.info.get_hf_config().eos_token_id]
|
|
813
|
+
|
|
814
|
+
def _apply_hf_processor_tokens_only(
|
|
815
|
+
self,
|
|
816
|
+
prompt_tokens: list[int],
|
|
817
|
+
) -> list[int]:
|
|
818
|
+
hf_processor = self.info.get_hf_processor()
|
|
819
|
+
tokenizer: BartTokenizer = hf_processor.tokenizer
|
|
820
|
+
prompt_text = tokenizer.decode(prompt_tokens)
|
|
821
|
+
# convert task tokens to prompt
|
|
822
|
+
prompt_text = hf_processor._construct_prompts([prompt_text])[0]
|
|
823
|
+
prompt_tokens = tokenizer.encode(prompt_text, add_special_tokens=False)
|
|
824
|
+
return prompt_tokens
|
|
825
|
+
|
|
826
|
+
def _call_hf_processor(
|
|
827
|
+
self,
|
|
828
|
+
prompt: str,
|
|
829
|
+
mm_data: Mapping[str, object],
|
|
830
|
+
mm_kwargs: Mapping[str, object],
|
|
831
|
+
) -> BatchFeature:
|
|
832
|
+
if mm_data:
|
|
833
|
+
processed_outputs = super()._call_hf_processor(
|
|
834
|
+
prompt, mm_data, mm_kwargs)
|
|
835
|
+
else:
|
|
836
|
+
hf_processor = self.info.get_hf_processor()
|
|
837
|
+
tokenizer = hf_processor.tokenizer
|
|
838
|
+
prompt = hf_processor._construct_prompts([prompt])[0]
|
|
839
|
+
processed_outputs = tokenizer(prompt,
|
|
840
|
+
add_special_tokens=True,
|
|
841
|
+
return_tensors="pt")
|
|
842
|
+
return processed_outputs
|
|
843
|
+
|
|
844
|
+
def _get_mm_fields_config(
|
|
845
|
+
self,
|
|
846
|
+
hf_inputs: BatchFeature,
|
|
847
|
+
hf_processor_mm_kwargs: Mapping[str, object],
|
|
848
|
+
) -> Mapping[str, MultiModalFieldConfig]:
|
|
849
|
+
return dict(pixel_values=MultiModalFieldConfig.batched("image"))
|
|
850
|
+
|
|
851
|
+
def _get_prompt_updates(
|
|
852
|
+
self,
|
|
853
|
+
mm_items: MultiModalDataItems,
|
|
854
|
+
hf_processor_mm_kwargs: Mapping[str, object],
|
|
855
|
+
out_mm_kwargs: MultiModalKwargs,
|
|
856
|
+
) -> Sequence[PromptUpdate]:
|
|
857
|
+
hf_config = self.info.get_hf_config()
|
|
858
|
+
pad_token_id = hf_config.pad_token_id
|
|
859
|
+
num_image_tokens = self.info.get_num_image_tokens()
|
|
860
|
+
image_tokens = [pad_token_id] * num_image_tokens
|
|
861
|
+
|
|
862
|
+
return [
|
|
863
|
+
PromptInsertion(
|
|
864
|
+
modality="image",
|
|
865
|
+
target=PromptIndexTargets.start(),
|
|
866
|
+
insertion=image_tokens,
|
|
867
|
+
)
|
|
868
|
+
]
|
|
869
|
+
|
|
870
|
+
|
|
871
|
+
@MULTIMODAL_REGISTRY.register_processor(
|
|
872
|
+
Florence2MultiModalProcessor,
|
|
873
|
+
info=Florence2ProcessingInfo,
|
|
874
|
+
dummy_inputs=Florence2DummyInputsBuilder)
|
|
875
|
+
class Florence2ForConditionalGeneration(nn.Module, SupportsMultiModal,
|
|
876
|
+
SupportsV0Only):
|
|
877
|
+
|
|
878
|
+
def __init__(self, *, vllm_config: VllmConfig, prefix: str = ""):
|
|
879
|
+
super().__init__()
|
|
880
|
+
config = vllm_config.model_config.hf_config
|
|
881
|
+
processor_config = vllm_config.model_config.hf_image_processor_config
|
|
882
|
+
|
|
883
|
+
self.config = config
|
|
884
|
+
self.vision_config = config.vision_config
|
|
885
|
+
self.processor_config = processor_config
|
|
886
|
+
assert config.vision_config.model_type == 'davit', (
|
|
887
|
+
'only DaViT is supported for now')
|
|
888
|
+
self.vision_tower = DaViT.from_config(config=config.vision_config)
|
|
889
|
+
self._build_image_projection_layers(config)
|
|
890
|
+
self.language_model = Florence2LanguageForConditionalGeneration(
|
|
891
|
+
vllm_config=vllm_config.with_hf_config(config.text_config),
|
|
892
|
+
prefix=f"{prefix}.language_model",
|
|
893
|
+
)
|
|
894
|
+
self.pad_token_id = config.pad_token_id
|
|
895
|
+
|
|
896
|
+
def _build_image_projection_layers(self, config: PretrainedConfig):
|
|
897
|
+
image_dim_out = config.vision_config.dim_embed[-1]
|
|
898
|
+
dim_projection = config.vision_config.projection_dim
|
|
899
|
+
self.image_projection = nn.Parameter(
|
|
900
|
+
torch.empty(image_dim_out, dim_projection))
|
|
901
|
+
self.image_proj_norm = nn.LayerNorm(dim_projection)
|
|
902
|
+
image_pos_embed_config = config.vision_config.image_pos_embed
|
|
903
|
+
if image_pos_embed_config['type'] == 'learned_abs_2d':
|
|
904
|
+
self.image_pos_embed = LearnedAbsolutePositionEmbedding2D(
|
|
905
|
+
embedding_dim=image_dim_out,
|
|
906
|
+
num_pos=image_pos_embed_config['max_pos_embeddings'])
|
|
907
|
+
else:
|
|
908
|
+
raise NotImplementedError("Florence2 only supports learned_abs_2d "
|
|
909
|
+
"as image position embedding.")
|
|
910
|
+
|
|
911
|
+
self.image_feature_source = config.vision_config.image_feature_source
|
|
912
|
+
|
|
913
|
+
# temporal embedding
|
|
914
|
+
visual_temporal_embedding_config = (
|
|
915
|
+
self.vision_config.visual_temporal_embedding)
|
|
916
|
+
if visual_temporal_embedding_config['type'] == 'COSINE':
|
|
917
|
+
self.visual_temporal_embed = PositionalEmbeddingCosine1D(
|
|
918
|
+
embed_dim=image_dim_out,
|
|
919
|
+
max_seq_len=visual_temporal_embedding_config[
|
|
920
|
+
'max_temporal_embeddings'])
|
|
921
|
+
else:
|
|
922
|
+
raise NotImplementedError(
|
|
923
|
+
'Florence2 only supports COSINE as temporal embedding.')
|
|
924
|
+
|
|
925
|
+
def _validate_pixel_values(
|
|
926
|
+
self, data: Union[torch.Tensor, list[torch.Tensor]]
|
|
927
|
+
) -> Union[torch.Tensor, list[torch.Tensor]]:
|
|
928
|
+
|
|
929
|
+
size = self.processor_config["size"]
|
|
930
|
+
h, w = size["height"], size["width"]
|
|
931
|
+
expected_dims = (3, h, w)
|
|
932
|
+
|
|
933
|
+
def _validate_shape(d: torch.Tensor):
|
|
934
|
+
actual_dims = tuple(d.shape)
|
|
935
|
+
|
|
936
|
+
if actual_dims != expected_dims:
|
|
937
|
+
expected_expr = tuple(*map(str, expected_dims))
|
|
938
|
+
raise ValueError(
|
|
939
|
+
"The expected shape of pixel values per batch "
|
|
940
|
+
f"is {expected_expr}. You supplied {tuple(d.shape)}.")
|
|
941
|
+
|
|
942
|
+
for d in data:
|
|
943
|
+
_validate_shape(d)
|
|
944
|
+
|
|
945
|
+
return data
|
|
946
|
+
|
|
947
|
+
def _parse_and_validate_image_input(self, **kwargs: object):
|
|
948
|
+
pixel_values: Optional[Union[list[list[torch.Tensor]],
|
|
949
|
+
list[torch.Tensor],
|
|
950
|
+
torch.Tensor]] = kwargs.pop(
|
|
951
|
+
"pixel_values", None)
|
|
952
|
+
image_embeds: Optional[Union[list[list[torch.Tensor]],
|
|
953
|
+
list[torch.Tensor],
|
|
954
|
+
torch.Tensor]] = kwargs.pop(
|
|
955
|
+
"image_embeds", None)
|
|
956
|
+
|
|
957
|
+
if pixel_values is None and image_embeds is None:
|
|
958
|
+
return None
|
|
959
|
+
|
|
960
|
+
if pixel_values is not None and image_embeds is not None:
|
|
961
|
+
raise ValueError(
|
|
962
|
+
"Both pixel values and image embeds are provided.")
|
|
963
|
+
|
|
964
|
+
if pixel_values is not None:
|
|
965
|
+
return Florence2ImagePixelInputs(
|
|
966
|
+
type="pixel_values",
|
|
967
|
+
data=self._validate_pixel_values(
|
|
968
|
+
flatten_bn(pixel_values, concat=True)),
|
|
969
|
+
)
|
|
970
|
+
|
|
971
|
+
if image_embeds is not None:
|
|
972
|
+
raise NotImplementedError
|
|
973
|
+
|
|
974
|
+
raise AssertionError("This line should be unreachable.")
|
|
975
|
+
|
|
976
|
+
def _encode_image(self, pixel_values: torch.Tensor) -> torch.Tensor:
|
|
977
|
+
dtype = next(self.vision_tower.parameters()).dtype
|
|
978
|
+
pixel_values = pixel_values.to(dtype)
|
|
979
|
+
|
|
980
|
+
batch_size, T = pixel_values.size(0), 1
|
|
981
|
+
x = self.vision_tower.forward_features_unpool(pixel_values)
|
|
982
|
+
if self.image_pos_embed is not None:
|
|
983
|
+
x = x.view(batch_size * T, -1, x.shape[-1])
|
|
984
|
+
num_tokens = x.shape[-2]
|
|
985
|
+
h, w = int(num_tokens**0.5), int(num_tokens**0.5)
|
|
986
|
+
assert h * w == num_tokens, (
|
|
987
|
+
'only support square feature maps for now')
|
|
988
|
+
x = x.view(batch_size * T, h, w, x.shape[-1])
|
|
989
|
+
pos_embed = self.image_pos_embed(x)
|
|
990
|
+
x = x + pos_embed
|
|
991
|
+
x = x.view(batch_size, T * h * w, x.shape[-1])
|
|
992
|
+
|
|
993
|
+
if self.visual_temporal_embed is not None:
|
|
994
|
+
visual_temporal_embed = self.visual_temporal_embed(
|
|
995
|
+
x.view(batch_size, T, -1, x.shape[-1])[:, :, 0])
|
|
996
|
+
x = x.view(batch_size, T, -1,
|
|
997
|
+
x.shape[-1]) + visual_temporal_embed.view(
|
|
998
|
+
1, T, 1, x.shape[-1])
|
|
999
|
+
|
|
1000
|
+
x_feat_dict = {}
|
|
1001
|
+
|
|
1002
|
+
spatial_avg_pool_x = x.view(batch_size, T, -1, x.shape[-1]).mean(dim=2)
|
|
1003
|
+
x_feat_dict['spatial_avg_pool'] = spatial_avg_pool_x
|
|
1004
|
+
|
|
1005
|
+
temporal_avg_pool_x = x.view(batch_size, T, -1,
|
|
1006
|
+
x.shape[-1]).mean(dim=1)
|
|
1007
|
+
x_feat_dict['temporal_avg_pool'] = temporal_avg_pool_x
|
|
1008
|
+
|
|
1009
|
+
x = x.view(batch_size, T, -1, x.shape[-1])[:, -1]
|
|
1010
|
+
x_feat_dict['last_frame'] = x
|
|
1011
|
+
|
|
1012
|
+
new_x = []
|
|
1013
|
+
for _image_feature_source in self.image_feature_source:
|
|
1014
|
+
if _image_feature_source not in x_feat_dict:
|
|
1015
|
+
raise ValueError('invalid image feature source: {}'.format(
|
|
1016
|
+
_image_feature_source))
|
|
1017
|
+
new_x.append(x_feat_dict[_image_feature_source])
|
|
1018
|
+
|
|
1019
|
+
x = torch.cat(new_x, dim=1)
|
|
1020
|
+
|
|
1021
|
+
x = x @ self.image_projection
|
|
1022
|
+
x = self.image_proj_norm(x)
|
|
1023
|
+
|
|
1024
|
+
return x
|
|
1025
|
+
|
|
1026
|
+
def _process_image_input(
|
|
1027
|
+
self, image_input: Florence2ImagePixelInputs) -> torch.Tensor:
|
|
1028
|
+
assert image_input["type"] == "pixel_values"
|
|
1029
|
+
pixel_values = image_input["data"]
|
|
1030
|
+
return self._encode_image(pixel_values)
|
|
1031
|
+
|
|
1032
|
+
def get_language_model(self) -> torch.nn.Module:
|
|
1033
|
+
return self.language_model
|
|
1034
|
+
|
|
1035
|
+
def get_multimodal_embeddings(
|
|
1036
|
+
self, **kwargs: object) -> Optional[MultiModalEmbeddings]:
|
|
1037
|
+
image_input = self._parse_and_validate_image_input(**kwargs)
|
|
1038
|
+
if image_input is None:
|
|
1039
|
+
return None
|
|
1040
|
+
vision_embeddings = self._process_image_input(image_input)
|
|
1041
|
+
return vision_embeddings
|
|
1042
|
+
|
|
1043
|
+
def get_input_embeddings(
|
|
1044
|
+
self,
|
|
1045
|
+
input_ids: torch.Tensor,
|
|
1046
|
+
multimodal_embeddings: Optional[MultiModalEmbeddings] = None,
|
|
1047
|
+
) -> torch.Tensor:
|
|
1048
|
+
inputs_embeds = self.language_model.get_input_embeddings(input_ids)
|
|
1049
|
+
if multimodal_embeddings is not None:
|
|
1050
|
+
inputs_embeds = merge_multimodal_embeddings(
|
|
1051
|
+
input_ids, inputs_embeds, multimodal_embeddings,
|
|
1052
|
+
self.pad_token_id)
|
|
1053
|
+
return inputs_embeds
|
|
1054
|
+
|
|
1055
|
+
def forward(
|
|
1056
|
+
self,
|
|
1057
|
+
input_ids: torch.Tensor,
|
|
1058
|
+
positions: torch.Tensor,
|
|
1059
|
+
intermediate_tensors: Optional[IntermediateTensors] = None,
|
|
1060
|
+
*,
|
|
1061
|
+
encoder_input_ids: torch.Tensor,
|
|
1062
|
+
encoder_positions: torch.Tensor,
|
|
1063
|
+
**kwargs,
|
|
1064
|
+
) -> torch.Tensor:
|
|
1065
|
+
r"""
|
|
1066
|
+
Args:
|
|
1067
|
+
input_ids
|
|
1068
|
+
torch.Tensor of *decoder* input token ids.
|
|
1069
|
+
positions
|
|
1070
|
+
torch.Tensor of *decoder* position indices.
|
|
1071
|
+
encoder_input_ids
|
|
1072
|
+
torch.Tensor of *encoder* input token ids.
|
|
1073
|
+
encoder_positions
|
|
1074
|
+
torch.Tensor of *encoder* position indices
|
|
1075
|
+
Returns:
|
|
1076
|
+
Output torch.Tensor
|
|
1077
|
+
"""
|
|
1078
|
+
vision_embeddings = self.get_multimodal_embeddings(**kwargs)
|
|
1079
|
+
if encoder_input_ids.numel() > 0 or vision_embeddings is not None:
|
|
1080
|
+
inputs_embeds = self.get_input_embeddings(encoder_input_ids,
|
|
1081
|
+
vision_embeddings)
|
|
1082
|
+
else:
|
|
1083
|
+
inputs_embeds = None
|
|
1084
|
+
|
|
1085
|
+
hidden_states = self.language_model(input_ids,
|
|
1086
|
+
positions,
|
|
1087
|
+
encoder_input_ids,
|
|
1088
|
+
encoder_positions,
|
|
1089
|
+
inputs_embeds=inputs_embeds)
|
|
1090
|
+
return hidden_states
|
|
1091
|
+
|
|
1092
|
+
def compute_logits(
|
|
1093
|
+
self,
|
|
1094
|
+
hidden_states: torch.Tensor,
|
|
1095
|
+
sampling_metadata: SamplingMetadata,
|
|
1096
|
+
) -> Optional[torch.Tensor]:
|
|
1097
|
+
return self.language_model.compute_logits(hidden_states,
|
|
1098
|
+
sampling_metadata)
|
|
1099
|
+
|
|
1100
|
+
def load_weights(self, weights: Iterable[tuple[str,
|
|
1101
|
+
torch.Tensor]]) -> set[str]:
|
|
1102
|
+
loader = AutoWeightsLoader(self)
|
|
1103
|
+
return loader.load_weights(weights)
|