text
stringlengths
14
100k
source
stringclasses
1 value
repo
stringclasses
810 values
language
stringclasses
13 values
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from collections.abc import Callable from typing import Any import torch from vllm._aiter_ops import rocm_aiter_ops from vllm.config import ParallelConfig, get_current_vllm_config from vllm.distri...
fim
vllm-project/vllm
python
<|fim_suffix|> 1. - shared_experts: SharedExperts | None. The shared experts if any. - shared_experts_input (Optional[torch.Tensor]): Optional separate input for shared experts. For latent MoE, this is the original hidden_states before latent projection. Returns: ...
fim
vllm-project/vllm
python
<|fim_suffix|> - num_tokens_post_pad (torch.Tensor): Torch tensor of size 1 indicating the number of valid blocks with actual data to process. This is represented in terms of num tokens. Example: Let num_batches=5, max_tokens_per_batch=8, block_size=4, and expert_num_tokens=[2, 3, 0, 6, 8]....
fim
vllm-project/vllm
python
<|fim_suffix|> expert for each token. Shape: (num_tokens, top_k). outputs: Optional pre-allocated output tensor. Shape: (num_tokens, hidden_size). topk_ids: Optional indices of the top-k experts. Used when `expert_map` is provided. Shape: (num_tokens, top_k). ...
fim
vllm-project/vllm
python
<|fim_suffix|>moe_unpermute. - expert_first_token_offset (Optional[torch.Tensor]): offset of the first token of each expert for grouped gemm. Returns: - hidden_states (torch.Tensor): The reduced and unpermuted activation tensor. """ topk = topk_weights.size(1) n_hidden = permuted_hid...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX<|fim_suffix|>leCopyrightText: Copyright contributors to the vLLM project <|fim_middle|>-Fi<|endoftext|>
fim
vllm-project/vllm
python
# SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from enum import Enum import torch import vllm.model_executor.layers.fused_moe.modular_kernel as mk from vllm import envs from vllm._aiter_ops import rocm_aiter_ops from vllm.config.kernel import MoEBackend from...
fim
vllm-project/vllm
python
<|fim_suffix|>d. for backend in AVAILABLE_BACKENDS: for k_cls in backend_to_kernel_cls(backend): supported, reason = k_cls.is_supported_config( k_cls, config, weight_key, activation_key, activation_format, ...
fim
vllm-project/vllm
python
<|fim_suffix|>eros, size_k=w2_qzeros.shape[1], size_n=w2_qzeros.shape[2] * pack_factor, num_bits=weight_bits, is_a_8bit=is_a_8bit, ) if w13_bias is not None: w13_bias_out = marlin_permute_bias(w13_bias) if w2_bias is not None: w2_bias_out = marlin_permute_bia...
fim
vllm-project/vllm
python
# SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from enum import Enum from typing import TYPE_CHECKING, Literal, Union import torch import vllm.model_executor.layers.fused_moe.modular_kernel as mk from vllm.config import get_current_vllm_config from vllm.conf...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import vllm.model_executor.layers.fused_moe.modu<|fim_suffix|>ackend, experts_cls raise ValueError("No MXFP8 MoE backends available.") <|fim_middle|>lar_kernel as mk from vllm.logger import ini...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from enum import Enum import torch import vllm.envs as envs import vllm.model_executor.layers.fused_moe.modular_kernel as mk from vllm.config.kernel import MoEBackend from vllm.logger import init_l...
fim
vllm-project/vllm
python
<|fim_suffix|>et("VLLM_ROCM_USE_AITER_MOE"): if not envs.VLLM_ROCM_USE_AITER or not envs.VLLM_ROCM_USE_AITER_MOE: if UnquantizedMoeBackend.AITER in AVAILABLE_BACKENDS: AVAILABLE_BACKENDS.remove(UnquantizedMoeBackend.AITER) else: backend = UnquantizedMoeBackend.AIT...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from enum import Enum from typing import TYPE_CHECKING import torch import vllm.model_executor.layers.fused_moe.modular_kernel as mk from vllm.logger import init_logger from vllm.model_executor.lay...
fim
vllm-project/vllm
python
<|fim_suffix|>ht[e], # [2I, H] w13_weight_scale[e], # [2I, H/g or 1] w13_bias[e] if w13_bias is not None else None, # [2I] H, I2, group_size, ) ) w2_packed_list.append( pack_int4_weights_for_kleidi...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from vllm.model_executor.layers.fused_moe.prepare_finalize.batched import ( BatchedPrepareAndFinalize, ) from <|fim_suffix|> MoEPrepareAndFinalizeNaiveDPEPMonolithic, make_moe_prepare_and_fi...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import torch import vllm.model_executor.layers.fused_moe.modular_kernel as mk from vllm.model_executor.layers.fused_moe.config import FusedMoEQuantConfig from vllm.model_executor.layers.fused_moe.t...
fim
vllm-project/vllm
python
<|fim_suffix|>expert_x, expert_x_scale = moe_kernel_quantize_input( expert_x, a1_scale, quant_dtype=quant_config.quant_dtype, per_act_token_quant=False, block_shape=quant_config.block_shape, is_scale_...
fim
vllm-project/vllm
python
# SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from collections.abc import Callable import deep_ep import torch import vllm.model_executor.layers.fused_moe.modular_kernel as mk from vllm import envs from vllm.logger import init_logger from vllm.model_executo...
fim
vllm-project/vllm
python
<|fim_suffix|> output, fused_expert_output, topk_weights, topk_ids, apply_router_weight_on_input, weight_and_reduce_impl, False, ) <|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to t...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import torch import vllm.model_executor.layers.fused_moe.modular_kernel as mk from vllm.distributed import get_ep_group from vllm.distributed.device_communicators.base_device_communicator import ( ...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import torch import vllm.model_executor.layers.fused_moe.modular_kernel as mk from vllm.distributed import get_ep_group from vllm.distributed.device_communicators.base_device_communicator import ( ...
fim
vllm-project/vllm
python
<|fim_suffix|>h and not defer_input_quant: from aiter import QuantType, get_hip_quant if quant_config.is_block_quantized: quant_func = get_hip_quant(QuantType.per_1x128) a1, scale = quant_func(a1, quant_dtype=current_platform.fp8_dtype()) elif quant_c...
fim
vllm-project/vllm
python
<|fim_suffix|>ch AR/RS or AR for dispatch/combine operations, applied to the router logits (the MoE kernel runs the router internally). """ def __init__( self, is_sequence_parallel: bool = False, num_dispatchers: int = 1, ) -> None: super().__init__() self.is_seq...
fim
vllm-project/vllm
python
<|fim_suffix|> hook() return receiver() def _finalize( self, output: torch.Tensor, fused_expert_output: torch.Tensor, topk_weights: torch.Tensor, topk_ids: torch.Tensor, apply_router_weight_on_input: bool, weight_and_reduce_impl: mk.TopKWeight...
fim
vllm-project/vllm
python
<|fim_suffix|> weight_and_reduce_impl = TopKWeightAndReduceContiguous() weight_and_reduce_impl.apply( output=output, fused_expert_output=fused_expert_output, topk_weights=topk_weights, topk_ids=topk_ids, apply_router_weight_on_input=apply_router_weigh...
fim
vllm-project/vllm
python
<|fim_suffix|>utedExperts instance. Args: x: Input tensor after any transforms topk_weights: Routing weights from router (for modular kernels) topk_ids: Selected expert IDs from router (for modular kernels) shared_experts: The shared experts (if any) ...
fim
vllm-project/vllm
python
<|fim_suffix|>fferent MoE model families expose this under different keys: - ``num_experts``: Mixtral, Qwen2-MoE, Qwen3-MoE - ``n_routed_experts``: DeepSeek-V2/V3 - ``num_local_experts``: Mixtral (older exports) """ for key in ("num_experts", "n_routed_experts", "num_local_experts"): v...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-File<|fim_suffix|>yright contributors to the vLLM project <|fim_middle|>CopyrightText: Cop<|endoftext|>
fim
vllm-project/vllm
python
<|fim_suffix|> M, topk, dtype=torch.int32, device=hidden_states.device ) if rocm_aiter_ops.fuse_sigmoid_in_kernel(aiter_topK_meta_data): total_topk_weights, total_topk_ids = aiter_topK_meta_data # type: ignore[misc] total_topk_weights_slice = total_topk_weights[:M] ...
fim
vllm-project/vllm
python
<|fim_suffix|> topk_indices_dtype: torch.dtype | None = None, *, input_ids: torch.Tensor | None = None, ) -> tuple[torch.Tensor, torch.Tensor]: """ Route the input hidden states to the top-k experts based on the router logits. This method implements the templat...
fim
vllm-project/vllm
python
<|fim_suffix|>tates: torch.Tensor, router_logits: torch.Tensor, indices_type: torch.dtype | None, *, input_ids: torch.Tensor | None = None, ) -> tuple[torch.Tensor, torch.Tensor]: """Compute routing using the custom routing function.""" topk_weights, topk_ids = self.c...
fim
vllm-project/vllm
python
<|fim_suffix|> **Compatibility**: When EPLB is not enabled, the returned ids are equivalent to global logical ids, so should be compatible with plain MoE implementations without redundant experts. """ topk_weights, topk_ids = self._select_experts( hidden_sta...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import functools import torch import torch.nn.functional as F import vllm._custom_ops as ops import vllm.envs as envs from vllm._aiter_ops import rocm_aiter_ops from vllm.distributed.eplb.eplb_stat...
fim
vllm-project/vllm
python
<|fim_suffix|>lm_topk_softmax def dispatch_topk_sigmoid_func( use_rocm_aiter: bool = False, ) -> Callable[..., tuple[torch.Tensor, ...]]: if use_rocm_aiter: return rocm_aiter_ops.topk_sigmoid return vllm_topk_sigmoid def fused_topk( hidden_states: torch.Tensor, gating_output: torch.Tenso...
fim
vllm-project/vllm
python
<|fim_suffix|>ration does not support runtime dispatching on num_tokens. """ if x.shape[0] <= _FP32_ROUTER_GEMM_MAX_TOKENS: return ops.fp32_router_gemm(x, weight) else: return torch.nn.functional.linear(x.float(), weight) def fp32_router_gemm_dispatch_fake( x: torch.Tensor, weight:...
fim
vllm-project/vllm
python
<|fim_suffix|>ing_func = scoring_func self.routed_scaling_factor = routed_scaling_factor self.num_fused_shared_experts = num_fused_shared_experts def forward_native( self, hidden_states: torch.Tensor, gating_output: torch.Tensor, e_score_correction_bias: torch.Tensor...
fim
vllm-project/vllm
python
# SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from collections.abc import Callable import torch import vllm.envs as envs from vllm._aiter_ops import rocm_aiter_ops from vllm.distributed.eplb.eplb_state import EplbLayerState from vllm.model_executor.layers.f...
fim
vllm-project/vllm
python
<|fim_suffix|>ion_params.setdefault("std", 1.0) def route_tokens( self, hidden_states: torch.Tensor, router_logits: torch.Tensor, top_k: int, indices_type: torch.dtype | None = None, ) -> tuple[torch.Tensor, torch.Tensor]: """ Randomly select experts for ...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import torch from vllm.distributed.eplb.eplb_state import EplbLayerState from vllm.model_executor.layers.fused_moe.config import ( RoutingMethodType, get_routing_method_type, ) from vllm.mo...
fim
vllm-project/vllm
python
<|fim_suffix|>ributors to the vLLM project <|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyright<|fim_middle|>Text: Copyright cont<|endoftext|>
fim
vllm-project/vllm
python
# SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from collections.abc import Callable, Iterable from contextlib import nullcontext from typing import TYPE_CHECKING import torch import torch.nn.functional as F from vllm.config import VllmConfig, get_current_vll...
fim
vllm-project/vllm
python
<|fim_suffix|>_placement_strategy(self) -> ExpertPlacementStrategy: raise NotImplementedError @property @abstractmethod def expert_global_to_physical(self) -> torch.Tensor | None: raise NotImplementedError @property @abstractmethod def expert_physical_to_global(self) -> torch.T...
fim
vllm-project/vllm
python
<|fim_suffix|>record_stream(current_stream()) # because we synch the streams before using shared_output. shared_experts_input.record_stream(self._stream) # Mark sync start point for the aux stream since we will # run in parallel with router/gate. self._stream...
fim
vllm-project/vllm
python
<|fim_suffix|>ed(mk.TopKWeightAndReduce): """ TopKWeightAndReduce implementation for a fused_experts output of shape (num_experts, batch_size, K) """ def __init__(self, rank: int): self.rank = rank def __eq__(self, other): return isinstance(other, TopKWeightAndReduceNaiveBatche...
fim
vllm-project/vllm
python
<|fim_suffix|> layer: "RoutedExperts", x: torch.Tensor, topk_weights: torch.Tensor, topk_ids: torch.Tensor, shared_experts: SharedExperts | None, shared_experts_input: torch.Tensor | None, ) -> torch.Tensor: return self.forward_native( layer, ...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from math import prod import torch import torch.nn.functional as F from vllm import _custom_ops as ops from vllm.model_executor.layers.quantization.utils.fp8_utils import ( per_token_group_quan...
fim
vllm-project/vllm
python
# SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """Fused QK-RMSNorm + (partial) RoPE + gate copy Triton kernel. Currently used by the Qwen3.5 attention path (``attn_output_gate`` with NeoX-style partial RoPE). The unfused reference sequence is ``split -> Gemma...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """ A QuantizedActivation is a pre-quantized activation produced by a fused kernel and consumed directly by a linear layer, letting the layer skip its own input quantization. A linear advertises the ...
fim
vllm-project/vllm
python
<|fim_suffix|>on equivalent to forward().""" return self.forward_static( x, z, self.weight, self.eps, x.dtype, group_size=self.group_size, norm_before_gate=self.norm_before_gate, activation=self.activation, )...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import torch from einops import rearrange from vllm.platforms import current_platform from vllm.triton_utils import tl, triton from vllm.v1.attention.backends.utils import PAD_SLOT_ID @triton.jit...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import itertools from abc import abstractmethod import torch from torch.nn.parameter import Parameter import vllm.envs as envs from vllm.distributed import ( divide, get_tensor_model_paral...
fim
vllm-project/vllm
python
<|fim_suffix|>its = hidden_states else: # Get the logits for the next tokens. logits = self._get_logits(hidden_states, lm_head, embedding_bias) if logits is not None: if self.soft_cap is not None: logits = logits / self.soft_cap logits ...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from abc import abstractmethod from collections.abc import Iterable import torch from vllm.config import VllmConfig from vllm.model_executor.layers.attention_layer_base import AttentionLayerBase fr...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import torch from transformers import PretrainedConfig from vllm.config import ( VllmConfig, ) from vllm.distributed import ( get_tensor_model_parallel_rank, get_tensor_model_parallel_wo...
fim
vllm-project/vllm
python
<|fim_suffix|>_dim), (q, k, v) ) if attn_metadata_narrowed.num_prefills > 0: assert non_spec_state_indices_tensor is not None assert has_initial_state is not None zero_idx = non_spec_state_indices_tensor[~has_initial_state] recurrent_state[zero_idx] = 0 ...
fim
vllm-project/vllm
python
# SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import torch from einops import rearrange from torch import nn from vllm.config import ( VllmConfig, get_current_vllm_config, ) from vllm.distributed import ( divide, ) from vllm.forward_context impor...
fim
vllm-project/vllm
python
# SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """Inference-only Qwen3-Next/Qwen3.5 model.""" import functools from typing import Literal import torch from einops import rearrange from torch import nn from vllm import envs from vllm._aiter_ops import rocm_a...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import copy import torch import torch.nn.functional as F from transformers.configuration_utils import PretrainedConfig from vllm.config import ( VllmConfig, get_current_vllm_config, ) from ...
fim
vllm-project/vllm
python
<|fim_suffix|> ) self.hidden_inner_size = self.head_dim * self.num_heads self.tp_size = get_tensor_model_parallel_world_size() self.tp_rank = get_tensor_model_parallel_rank() assert self.num_heads % self.tp_size == 0 @property def mamba_type(self) -> MambaAttentionBackendE...
fim
vllm-project/vllm
python
# SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import math from collections.abc import Callable import torch import torch.nn.functional as F from einops import rearrange from vllm.config import get_current_vllm_config from vllm.forward_context import Forwar...
fim
vllm-project/vllm
python
<|fim_suffix|>n MambaAttentionBackendEnum.MAMBA1 def _time_proj_bias(self) -> torch.Tensor | None: if hasattr(self.dt_proj, "bias") and self.dt_proj.bias is not None: return self.dt_proj.bias.float() return None class PrefillDecodeSplit(NamedTuple): hidden_states_BC_p: torch.Tenso...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import torch from torch import nn from vllm.config import CacheConfig, ModelConfig, get_current_vllm_config from vllm.distributed import ( divide, get_tensor_model_parallel_rank, get_t...
fim
vllm-project/vllm
python
<|fim_suffix|>p_size - ngroups @classmethod def gated_delta_net_state_shape( cls, tp_world_size: int, num_k_heads: int, num_v_heads: int, head_k_dim: int, head_v_dim: int, conv_kernel_size: int, num_spec: int = 0, ): conv_dim = head_k_...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project # Copyright (c) 2024, Tri Dao. # Adapted from https://github.com/Dao-AILab/causal-conv1d/blob/main/causal_conv1d/causal_conv1d_interface.py import numpy as np import torch from vllm.triton_utils ...
fim
vllm-project/vllm
python
# SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from __future__ import annotations import torch import torch.nn.functional as F # for prefill def causal_conv1d_torch( x: torch.Tensor, weight: torch.Tensor, bias: torch.Tensor | None, conv_sta...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from __future__ import annotations import torch import vllm._custom_ops as ops from vllm.forward_context import ForwardContext, get_forward_context from vllm.model_executor.layers.mamba.mamba_util...
fim
vllm-project/vllm
python
<|fim_suffix|> ``[N, Hv, V, K]``. cu_seqlens: Cumulative sequence lengths with shape ``[N + 1]``. chunk_indices: Chunk index metadata with shape ``[NT, 2]``. chunk_offsets: Cumulative chunk offsets with shape ``[N + 1]``. core_attn_out: Optional output buffer with shape ``[T, Hv, V]``. ...
fim
vllm-project/vllm
python
# SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from functools import cache import cutlass import torch from cuda.bindings.driver import CUstream from cutlass import BFloat16, Float32, Int32, Int64, Uint32, cute from cutlass.cute.nvgpu import cpasync, warp fro...
fim
vllm-project/vllm
python
<|fim_suffix|> cute.arch.sync_warp() cute.copy(ldsm_atom, sAi_ldsm[3, None, 3], Ai_bf16) for i in cutlass.range_constexpr(4): Ai[i] ^= Uint32(0x80008000) cute.copy(ldsm_trans_atom, sAi_ldsm[3, None, 0], mma_B_bf16) ...
fim
vllm-project/vllm
python
<|fim_suffix|>hape((2, 1)) # apply gamma and causal mask Gamma = cute.math.exp(g_cu_rows - g_cu_cols, fastmath=True) tmp = qk[None, None, i] * Gamma tmp = cute.where(row_indices >= col_indices + i * 8, tmp, 0.0) # Cute...
fim
vllm-project/vllm
python
<|fim_suffix|>_size = N assert N % group_size == 0 ngroups = N // group_size assert x.stride(-1) == 1 if z is not None: assert z.stride(-1) == 1 assert z.shape == (M, N) assert weight.shape == (N,) assert weight.stride(-1) == 1 if bias is not None: assert bias.stride(...
fim
vllm-project/vllm
python
# SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project # Copyright (c) 2024, Tri Dao, Albert Gu. # Adapted from https://github.com/state-spaces/mamba/blob/v2.2.4/mamba_ssm/ops/triton/selective_state_update.py import functools import json import os from contextlib im...
fim
vllm-project/vllm
python
<|fim_suffix|>b.stride(1), stride_bk=b.stride(2), stride_out_chunk=out.stride(0), stride_out_head=out.stride(1), stride_outm=out.stride(-2), stride_outn=out.stride(-1), IS_CAUSAL=causal, dot_dtype=dot_dtype, ) return out <|f...
fim
vllm-project/vllm
python
<|fim_suffix|>tes, cu_chunk_seqlens_ptr=cu_chunk_seqlens, chunk_size=chunk_size, hdim=headdim, dstate=dstate, nheads_ngroups_ratio=nheads // ngroups, stride_cb_chunk=cb.stride(0), stride_cb_head=cb.stride(1), stride_cb_csize_m=cb.stride(2), stride_...
fim
vllm-project/vllm
python
<|fim_suffix|>e=x.device, dtype=states_dtype ) grid = lambda META: ( triton.cdiv(headdim, META["BLOCK_SIZE_M"]) * triton.cdiv(dstate, META["BLOCK_SIZE_N"]), nchunks, nheads, ) with torch.accelerator.device_index(x.device.index): _chunk_state_fwd_kernel[grid](...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project # Copyright (c) 2024, Tri Dao, Albert Gu. # Adapted from https://github.com/state-spaces/mamba/blob/v2.2.4/mamba_ssm/ops/triton/ssd_combined.py # ruff: noqa: E501 import torch from einops import r...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project # Copyright (c) 2024, Tri Dao, Albert Gu. # Adapted from https://github.com/state-spaces/mamba/blob/v2.2.4/mamba_ssm/ops/triton/ssd_state_passing.py # ruff: noqa: E501 import torch from vllm.mode...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """ Dispatch module for Mamba selective state update (SSU) backends. Provides a unified `selective_state_update` function that dispatches to either the Triton or FlashInfer backend based on the conf...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from vllm.triton_utils import tl, triton @<|fim_suffix|>x) = exp2(x * log2(e)), where log2(e) = 1/ln(2) = 1.4426950408889634 LOG2E = tl.constexpr(1.4426950408889634) return tl.math.exp2(LO...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import torch from vllm.config import CacheConfig, ModelConfig, get_current_vllm_config from vllm.distributed import get_tensor_model_parallel_world_size from vllm.forward_context import ForwardCon...
fim
vllm-project/vllm
python
<|fim_suffix|> fn, hc_scale, hc_base, rms_eps, hc_pre_eps, hc_sinkhorn_eps, hc_post_mult_value, sinkhorn_repeat, n_splits, tile_n, norm_weight, norm_eps, ) def forward_hip( ...
fim
vllm-project/vllm
python
<|fim_suffix|>layers.minimax_rms_norm.rms_norm_tp import ( MiniMaxText01RMSNormTP, ) __all__ = [ "MiniMaxText01RMSNormTP", ] <|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from vllm.model_e<|fim_middle|>xecutor.<|endoftext|>
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import array import contextlib import struct import sys import threading import torch try: from cuda.bindings import runtime as cudart except ImportError: from cuda import cudart _ALIGN ...
fim
vllm-project/vllm
python
<|fim_suffix|>.cat([q_var, k_var], dim=-1) qk_var = _all_reduce_variance(qk_var) / q_norm.tp_world q_var, k_var = qk_var.chunk(2, dim=-1) q = q * torch.rsqrt(q_var + q_norm.variance_epsilon) * q_norm.weight k = k * torch.rsqrt(k_var + k_norm.variance_epsilon) * k_norm.weight ...
fim
vllm-project/vllm
python
<|fim_suffix|>tates: torch.Tensor, llama_4_scaling: torch.Tensor | None = None, ) -> torch.Tensor: q_c = None kv_lora = None if self.q_lora_rank is not None: assert self.fused_qkv_a_proj is not None, ( "fused_qkv_a_proj is required when q_lora_rank is not...
fim
vllm-project/vllm
python
<|fim_suffix|>stract import * from .common import * from .special import * <|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: C<|fim_middle|>opyright contributors to the vLLM project from .ab<|endoftext|>
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from abc import ABC, abstractmethod from collections.abc import Set import torch import torch.nn as nn from vllm.tasks import PoolingTask from vllm.v1.outputs import PoolerOutput from vllm.v1.pool....
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from abc import ABC, abstractmethod from collections.abc import Callable from typing import TypeVar import torch import torch.nn as nn import torch.nn.functional as F from transformers import Pretra...
fim
vllm-project/vllm
python
<|fim_suffix|>ires_token_ids __all__ = ["ActivationFn", "ClassifierFn", "ProjectorFn", "PoolingParamsUpdate"] <|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: C<|fim_middle|>opyright contributors to the vLLM project from collections.abc import Callable from dataclasses import dataclass fr...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """Poolers that produce an output aggregating all tokens in the sequence.""" from .heads import ( ClassifierPoolerHead, EmbeddingPoolerHead, SequencePoolerHead, SequencePoolerHeadOut...
fim
vllm-project/vllm
python
<|fim_suffix|> f"pooling_params length ({len(pooling_params)})" ) if isinstance(pooled_data, list): pooled_data = torch.stack(pooled_data) # pooled_data shape: [batchsize, hidden_size] if self.head_dtype is not None: pooled_data = pooled_data...
fim
vllm-project/vllm
python
# SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from abc import ABC, abstractmethod from collections.abc import Set from typing import TypeAlias import torch import torch.nn as nn from vllm.config.pooler import SequencePoolingType from vllm.model_executor.lay...
fim
vllm-project/vllm
python
<|fim_suffix|>(self, task: PoolingTask) -> PoolingParamsUpdate: updates = PoolingParamsUpdate() if isinstance(self.pooling, SequencePoolingMethod): updates |= self.pooling.get_pooling_updates(task) return updates def forward( self, hidden_states: torch.Tensor, ...
fim
vllm-project/vllm
python
<|fim_suffix|>sks(self) -> Set[PoolingTask]: return {"embed&token_classify"} def get_pooling_updates(self, task: PoolingTask) -> PoolingParamsUpdate: return self.embed_pooler.get_pooling_updates( "embed" ) | self.token_classify_pooler.get_pooling_updates("token_classify") d...
fim
vllm-project/vllm
python
<|fim_suffix|>"AllPool", "StepPool", "get_tok_pooling_method", "TokenPooler", "TokenPoolerOutput", "TokenPoolingFn", "TokenPoolingHeadFn", "pooler_for_token_classify", "pooler_for_token_embed", ] <|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright cont...
fim
vllm-project/vllm
python
<|fim_suffix|>enPoolingMethodOutputItem, pooling_param: PoolingParams, ) -> TokenPoolerHeadOutputItem: # for unfinished chunked prefill if pooled_data is None: return None if self.head_dtype is not None: pooled_data = pooled_data.to(self.head_dtype) #...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from abc import ABC, abstractmethod from collections.abc import Set from typing import TypeAlias import torch import torch.nn as nn from vllm.config import get_current_vllm_config from vllm.config....
fim
vllm-project/vllm
python
# SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from collections.abc import Callable, Set from typing import TypeAlias import torch from vllm.config import PoolerConfig, get_current_vllm_config from vllm.model_executor.layers.pooler import ( ClassifierFn,...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from ty<|fim_suffix|>if quantization not in QUANTIZATION_METHODS: raise ValueError(f"Invalid quantization method: {quantization}") # lazy import to avoid triggering `torch.compile` too ...
fim
vllm-project/vllm
python