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 copy import deepcopy from typing import Any import torch from safetensors.torch import _TYPES as _SAFETENSORS_TO_TORCH_DTYPE from transformers import PretrainedConfig import vllm.model_execut...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from typing import TYPE_CHECKING, Any, Union import torch from safetensors.torch import _TYPES as _SAFETENSORS_TO_TORCH_DTYPE from transformers import PretrainedConfig from vllm import _custom_ops...
fim
vllm-project/vllm
python
<|fim_suffix|>ition // self.quant_config.pack_factor, dtype=torch.int32, ), input_dim=0, output_dim=1, packed_dim=1, packed_factor=self.quant_config.pack_factor, weight_loader=weight_loader, ) num_groups = input_siz...
fim
vllm-project/vllm
python
<|fim_suffix|>[0] // qzeros.shape[0] assert N > 0 and K > 0 and M > 0 assert qweight.shape[0] == K and qweight.shape[1] == N // 8 assert qzeros.shape[0] == K // group_size and qzeros.shape[1] == N // 8 assert scales.shape[0] == K // group_size and scales.shape[1] == N assert split_k_iters & (split_...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributor<|fim_suffix|>stractmethod def get_quant_method( self, layer: torch.nn.Module, prefix: str ) -> QuantizeMethodBase | None: """Get the quantize method to use for the quantized layer. Args: ...
fim
vllm-project/vllm
python
# SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from functools import cached_property from typing import Any, Union import torch from packaging import version from vllm.model_executor.layers.fused_moe import ( FusedMoEConfig, FusedMoEMethodBase, ...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX<|fim_suffix|>tributors to the vLLM project <|fim_middle|>-FileCopyrightText: Copyright con<|endoftext|>
fim
vllm-project/vllm
python
# SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from functools import partial from typing import TYPE_CHECKING, Any, Literal, cast import torch from compressed_tensors.config import CompressionFormat, SparsityCompressionConfig from compressed_tensors.quantiza...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """Quantized embedding method for compressed-tensors. Adds dequant-on-lookup support for a pack-quantized ``VocabParallelEmbedding`` (2-8 bit INT, channel- or group-quantized). Only the gathered tok...
fim
vllm-project/vllm
python
# SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from vllm.model_executor.layers.quantization.compressed_tensors.compressed_tensors_moe.compressed_tensors_moe import ( # noqa: E501 CompressedTensorsMoEMethod, ) __all__ = [ "CompressedTensorsMoEMethod"...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import torch from compressed_tensors import CompressionFormat from compressed_tensors.quantization import ( ActivationOrdering, Quantiza<|fim_suffix|>NA16_SUPPORTED_BITS and...
fim
vllm-project/vllm
python
# 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.logger import init_logger from vllm.model_executor.layers.fused_moe import ( FusedMoeWeightScaleSupported, RoutedE...
fim
vllm-project/vllm
python
<|fim_suffix|>etattr(layer, "swiglu_limit", None), ) def apply_monolithic( self, layer: RoutedExperts, x: torch.Tensor, router_logits: torch.Tensor, input_ids: torch.Tensor | None = None, ) -> torch.Tensor: assert self.is_monolithic assert self.mo...
fim
vllm-project/vllm
python
<|fim_suffix|> dtype=layer.orig_dtype, ), requires_grad=False, ) layer.register_parameter("w2_weight_scale", w2_weight_scale) # Add PER-GROUP quantization for RoutedExperts.weight_loader. extra_weight_attrs.update( {"quant_method": FusedMoeWeigh...
fim
vllm-project/vllm
python
<|fim_suffix|> ) if self.has_bias: replace_parameter( layer, "w2_bias", torch.nn.Parameter(w2_bias, requires_grad=False), ) quant_config = self.get_fused_moe_quant_config(layer) assert quant_config is not None ...
fim
vllm-project/vllm
python
<|fim_suffix|> w2_scale=w2_scale, w13_input_scale=w13_input_scale, w2_input_scale=w2_input_scale, ) # Replace parameters with updated versions. Note that this helper # function ensures the replacement is compatible with RL weight reloads. replace_para...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import torch from compressed_tensors.quantization import ( QuantizationArgs, QuantizationStrategy, ) import vllm.model_executor.layers.fused_moe.modular_kernel as mk from vllm.logger impor...
fim
vllm-project/vllm
python
<|fim_suffix|>rch.Tensor, shared_experts: SharedExperts | None, shared_experts_input: torch.Tensor | None, ) -> torch.Tensor: assert not self.is_monolithic assert self.moe_kernel is not None return self.moe_kernel.apply( x, layer.w13_weight, ...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import torch from compressed_tensors.quantization import ( QuantizationArgs, ) import vllm.model_executor.layers.fused_moe.modular_kernel as mk from vllm.logger import init_logger from vllm.mo...
fim
vllm-project/vllm
python
<|fim_suffix|>ale", w13_scales) replace_parameter(layer, "w2_weight_scale", w2_scales) if w13_qzeros is not None: replace_parameter(layer, "w13_weight_zero_point", w13_qzeros) if w2_qzeros is not None: replace_parameter(layer, "w2_weight_zero_point", w2_qzeros) ...
fim
vllm-project/vllm
python
<|fim_suffix|>te, dtype=act_dtype, device=device ) layer.rdna3_out_buf = torch.zeros( max_decode_tokens, hidden_size, dtype=act_dtype, device=device ) layer.rdna3_empty_tw = torch.empty(0, device=device) def apply( self, layer: RoutedExperts, x: t...
fim
vllm-project/vllm
python
<|fim_suffix|>tensors_moe_wna16_rdna3 import ( CompressedTensorsWNA16RDNA3MoEMethod, ) logger.info_once( "Using CompressedTensorsWNA16RDNA3MoEMethod (native RDNA3 HIP kernel)" ) return CompressedTensorsWNA16RDNA3MoEMethod( weight_quant, input_quant, m...
fim
vllm-project/vllm
python
<|fim_suffix|>dTensorsWNA8O8Int", "CompressedTensorsW8A16Fp8", "CompressedTensorsW8A8Int8", "CompressedTensorsW8A8Fp8", "WNA16_SUPPORTED_BITS", "CompressedTensorsW4A4Mxfp4", "CompressedTensorsW4A4Fp4", "CompressedTensorsW4A8Int", "CompressedTensorsW4A8Fp8", "CompressedTensorsW8A8Mxfp...
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 import torch __all__ = ["CompressedTensorsScheme"] class C<|fim_suffix|>ias: torch.Tensor | None ): """ Run the forward pass for the parti...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from collections.abc import Callable import torch from torch.nn.parameter import Parameter from vllm.model_executor.kernels.linear import init_mxfp4_linear_kernel from vllm.model_executor.layers.qu...
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 from torch.nn.parameter import Parameter from vllm.logger import init_logger from vllm.model_executor.kernels.linear import init_nvfp4_linear_kernel from vllm.mo...
fim
vllm-project/vllm
python
<|fim_suffix|>les: weight_scale = ChannelQuantScaleParameter(output_dim=0, **weight_scale_args) else: weight_scale = GroupQuantScaleParameter( output_dim=0, input_dim=1, **weight_scale_args ) # A 2D array defining the original shape of the weights ...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from collections.abc import Callable import torch from vllm.logger import init_logger from vllm.model_executor.kernels.linear import ( MPLinearLayerConfig, choose_mp_linear_kernel, ) from ...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from collections.abc import Callable import torch from compressed_tensors.quantization import QuantizationArgs, QuantizationStrategy from vllm.config import get_current_vllm_config from vllm.model...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from collections.abc impo<|fim_suffix|> QuantizedActivation, expose_input_quant_key, ) from vllm.model_executor.layers.quantization.compressed_tensors.schemes import ( CompressedTensorsS...
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 from compressed_tensors.quantization import QuantizationStrategy from vllm.logger import init_logger from vllm.model_executor.kernels.linear import ( init_i...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from collections.abc import Callable import torch from vllm.model_executor.kernels.linear import init_mxfp8_linear_kernel from vllm.model_executor.layers.quantization.compressed_tensors.schemes imp...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from collections.abc import Callable import torch from compressed_tensors.quantization import ActivationOrdering from vllm.logger import init_logger from vllm.model_executor.kernels.linear import ...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """Weight N-bit INT scheme with static INT8 input/output activation quant. Handles compressed-tensors INT weight checkpoints that carry static per-tensor INT8 ``input_activations`` and/or ``output_a...
fim
vllm-project/vllm
python
# SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from collections.abc import Callable, Generator from itertools import accumulate import torch from compressed_tensors.transform import ( TransformArgs, TransformConfig, TransformLocation, Transfor...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import math from collections.abc import Callable, Hashable import torch from compressed_tensors.transform import ( TransformArgs, TransformLocation, TransformScheme, ) from torch import ...
fim
vllm-project/vllm
python
<|fim_suffix|>t def apply( self, layer: torch.nn.Module, x: torch.Tensor, bias: torch.Tensor | None = None, ) -> torch.Tensor: raise NotImplementedError() <|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM pro...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0<|fim_suffix|>ghtText: Copyright contributors to the vLLM project from typing import NamedTuple from compressed_tensors.transform import TransformArgs, TransformScheme __all__ = ["TransformTuple"] class TransformTuple(NamedTuple): scheme_name: str scheme: T...
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.triton_utils import tl, triton def is_weak_contiguous(x: torch.Tensor): strides = x.stride() sizes = x.shape is_not_transpose = strides[0] == 1 and (strides[1]...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from collections.abc import Iterable, Mapping from types import MappingProxyType import regex as re from compressed_tensors import CompressionFormat from compressed_tensors.quantization import Quan...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from typing import Any import torch from vllm.model_executor.layers.fused_moe import ( RoutedExperts, ) from vllm.model_executor.layers.linear import LinearBase, Unq<|fim_suffix|>rn Int8Online...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from typing import Any import torch from torch.nn import Module from torch.nn.parameter import Parameter from vllm.config import get_current_vllm_config from vllm.logger import init_logger from vl...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from typing import TYPE_CHECKING, Any import torch from torch.utils._python_dispatch import TorchDispatchMode import vllm.envs as envs import vllm.model_executor.layers.fused_moe.modular_kernel as...
fim
vllm-project/vllm
python
<|fim_suffix|>is not aligned with the quantized " "weight shape. This can be caused by too large " "tensor parallel size. Or other skill issues." ) assert self.quant_config.forward_dtype in ["mxfp4", "nvfp4"], ( "Only mxfp4 and nvfp4 are supported for now...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import json import math from collections.abc import Callable from typing import TYPE_CHECKING, Any import regex as re import torch import vllm.utils.humming as _hm from vllm import envs from vllm.m...
fim
vllm-project/vllm
python
<|fim_suffix|> self, layer: torch.nn.Module, x: torch.Tensor, bias: torch.Tensor | None = None, ) -> torch.Tensor: return layer.ark_linear.forward(x) <|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from fra...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import torch import torch.nn.functional as F from vllm import _custom_ops as ops from vllm._aiter_ops import rocm_aiter_ops from vllm.model_executor.custom_op import CustomOp from vllm.model_execut...
fim
vllm-project/vllm
python
# SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import torch from vllm.logger import init_logger from vllm.model_executor.layers.quantization.base_config import ( QuantizationConfig, QuantizeMethodBase, ) from vllm.platforms import current_platform fr...
fim
vllm-project/vllm
python
<|fim_suffix|>ayer_excluded(prefix): if isinstance(layer, (LinearBase, ParallelLMHead)): return UnquantizedLinearMethod() return None quant_algo = self._resolve_quant_algo(prefix) if isinstance(layer, (LinearBase, ParallelLMHead)): if quant_algo == "...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from typing import Any import torch from vllm.distributed import get_tensor_model_parallel_rank, get_tp_group from vllm.model_executor.layers.fused_moe import ( FusedMoEConfig, FusedMoEMet...
fim
vllm-project/vllm
python
<|fim_suffix|>ert ( w2_scale.dim() == 3 and w2_scale.shape[1] == hidden_size and w2_scale.shape[2] == intermediate_size // sf_block_size ) if w13_bias is not None: assert ( w13_bias.dim() == 2 and w13_bias.shape[0] == num_ex...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyr<|fim_suffix|>e vLLM project <|fim_middle|>ight contributors to th<|endoftext|>
fim
vllm-project/vllm
python
<|fim_suffix|> if should_ignore_layer( prefix, ignore=self.ignored_layers, fused_mapping=self.packed_modules_mapping, ): return UnquantizedLinearMethod() method = self._dispatch(self.args.linear, _ONLINE_LINEAR_METHODS, layer) ...
fim
vllm-project/vllm
python
<|fim_suffix|>d_process_weights_after_loading", False): return fp8_dtype = current_platform.fp8_dtype() w13 = torch.empty_like(layer.w13_weight, dtype=fp8_dtype) w2 = torch.empty_like(layer.w2_weight, dtype=fp8_dtype) block_size = self.weight_block_size assert block...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from typing import TYPE_CHECKING import torch from torch.nn import Module if TYPE_CHECKING: from vllm.model_executor.layers.fused_moe.config import ( FusedMoEQuantConfig, ) from v...
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 import torch import vllm.model_executor.layers.fused_moe.modular_kernel as mk from vllm.model_executor.layers.fused_moe import ( FusedMoEMethodBase, RoutedEx...
fim
vllm-project/vllm
python
<|fim_suffix|> ( convert_to_fp8_moe_kernel_format, make_fp8_moe_kernel, ) # Shuffle weights to runtime format. w13, w2, w13_scale, w2_scale = convert_to_fp8_moe_kernel_format( fp8_backend=self.fp8_backend, layer=layer, w13=w13, ...
fim
vllm-project/vllm
python
<|fim_suffix|>rsScheme associated with each layer to create the necessary parameters for the layer. See LinearMethodBase for param details """ weight_loader = extra_weight_attrs.get("weight_loader") layer.scheme.create_weights( layer=layer, input_size=inpu...
fim
vllm-project/vllm
python
<|fim_suffix|>input_scale_2", w2_input_scale_2) set_weight_attrs(w2_input_scale_2, extra_weight_attrs) def process_weights_after_loading(self, layer: RoutedExperts) -> None: """ Convert NVFP4 MoE weights into kernel format and setup the kernel. """ if not torch.allclose( ...
fim
vllm-project/vllm
python
# SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from .quark_nvfp4 import QuarkNVFP4 from .quark_ocp_mx import QuarkOCP_MX from .quark_scheme import QuarkScheme from .quark_w4a8_mxfp4_fp8 import QuarkW4A8_MXFP4_FP8 from .quark_w8a8_fp8 import QuarkW8A8Fp8 from ...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from collections.abc import Callable import torch from torch.nn.parameter import Parameter from vllm.logger import init_logger from vllm.model_executor.kernels.linear import init_nvfp4_linear_kern...
fim
vllm-project/vllm
python
# SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from collections.abc import Callable from fractions import Fraction from functools import partial from typing import Any import torch import torch.nn.functional as F from vllm._aiter_ops import rocm_aiter_ops f...
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 import torch __all__ = ["QuarkScheme"] class QuarkScheme(ABC): """ Abstract class used to describe the weight creation and forward pass of differe...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from collections.abc import Callable from fractions import Fraction from typing import Any import torch import torch.nn.functional as F from vllm._aiter_ops import is_aiter_found_and_supported, ro...
fim
vllm-project/vllm
python
<|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, cast import torch from torch.nn import Parameter from vllm.config import get_current_vllm_config from vllm.logger import init_logger fr...
fim
vllm-project/vllm
python
<|fim_suffix|>e=torch.float32), weight_loader=weight_loader, ) PerTensorZPParameter = PerTensorScaleParameter weight_zero_point = PerTensorZPParameter( data=torch.empty(len(output_partition_sizes), dtype=torch.int8), weight_loader=weigh...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from collections.abc import Iterable, Mapping from types import MappingProxyType from typing import Any import regex as re import torch def deep_compare(dict1: Any, dict2: Any) -> bool: if ty...
fim
vllm-project/vllm
python
<|fim_suffix|>triton" ) -> torch.Tensor: """ Rearrange a large matrix by breaking it into blocks and applying the rearrangement pattern. See: https://docs.nvidia.com/cuda/cublas/index.html#d-block-scaling-factors-layout Args: input_matrix: Input tensor of shape (H, W) backe...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import importlib import json import types from importlib.util import find_spec from typing import Any import regex as re import torch import torch.nn.functional as F from packaging import version fr...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """TurboQuant: KV-cache quantization for vLLM. Hadamard rotation + per-coordinate Lloyd-Max scalar quantization for keys, uniform quantization for values. The core algorithmic pattern implemented f...
fim
vllm-project/vllm
python
<|fim_suffix|>e centroids[i]) if max(abs(new_centroids[i] - centroids[i]) for i in range(n_levels)) < tol: break centroids = new_centroids boundaries = [(centroids[i] + centroids[i + 1]) / 2.0 for i in range(n_levels - 1)] return ( torch.tensor(centroids, dtype=torch.float3...
fim
vllm-project/vllm
python
<|fim_suffix|>nd it hurts attention quality by amplifying variance through softmax. Named presets (use via --kv-cache-dtype): turboquant_k8v4: FP8 keys + 4-bit values, 2.6x, +1.17% PPL turboquant_4bit_nc: 4-bit MSE keys + 4-bit values + NC, 3.8x, +2.71% turboquant_k3v4_nc: 3-bit MSE k...
fim
vllm-project/vllm
python
<|fim_suffix|>place_parameter"] <|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from .layer_utils import replace_parameter, update_tensor_inplace __al<|fim_middle|>l__ = ["update_tensor_inplace", "re<|endoftext|>
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.platforms import current_platform from vllm.scalar_type import ScalarType, scalar_types ALLSPARK_AMPERE_M_CUBLAS_THRESHOLD = 1024 ALLSPARK_SUPPORTED_QUANT_TYPES = [scalar_ty...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """Utility helpers for NVFP4 + FlashInfer fused-MoE path""" from typing import TYPE_CHECKING import torch from vllm.logger import init_logger from vllm.model_executor.layers.quantization.utils.fla...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """Utility helpers for MxInt4 + FlashInfer fused-MoE path""" import functools import torch import vllm.envs as envs from vllm.logger import init_logger from vllm.platforms import current_platform ...
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 from vllm.logger import init_logger from vllm.model_executor.layers.fused_moe.activation import MoEActivation from vllm.utils.mat...
fim
vllm-project/vllm
python
<|fim_suffix|>s the tensor values into float8 values. """ groups_per_row = y_num_columns // group_size # Map the program id to the row of X and Y it should compute. g_id = tl.program_id(0) row = g_id // groups_per_row row_g_id = g_id % groups_per_row # Ensure offset calculations use int64 ...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from collections.abc import Mapping from copy import deepcopy from types import MappingProxyType from typing import TYPE_CHECKING import regex as re import torch from vllm.model_executor.layers.lin...
fim
vllm-project/vllm
python
<|fim_suffix|> None = None, gemm1_clamp_limit: float | None = None, ): input_schema = layer.input_schemas["w13"] weight_schema = layer.weight_schemas["w13"] a_dtype = input_schema.a_dtype if a_dtype is None or a_dtype.num_bits == 16: a_quant_desc = FusedMoEQuantDesc(dtype=None) else: ...
fim
vllm-project/vllm
python
<|fim_suffix|> "Using configuration from %s for W8A8 Block INT8 kernel.", config_file_path, ) # If a configuration has been found, return it return {int(key): val for key, val in json.load(f).items()} # If no optimized configuration is available, we ...
fim
vllm-project/vllm
python
<|fim_suffix|> parameter, convert to Parameter if necessary # this not only ensures we don't register a tensor as a parameter, but # also ensures that all parameter subclasses get re-registered as # parameters for `torch.compile` compatibility if not isinstance(new, torch.nn.Parameter): ...
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.scalar_type import ScalarType, scalar_types MACHETE_PREPACKED_BLOCK_SHAPE = [64, 128] def query_machete_supported_quant_types(zero_points: bool) -> list[ScalarType]: <|f...
fim
vllm-project/vllm
python
<|fim_suffix|> scale_perm_single: list[int] = [] for i in range(4): scale_perm_single.extend([2 * i + j for j in [0, 1, 8, 9, 16, 17, 24, 25]]) return scale_perm, scale_perm_single def marlin_permute_scales( s: torch.Tensor, size_k: int, size_n: int, group_size: int, is_a_8bit: bool = False ) -...
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._custom_ops as ops from vllm.logger import init_logger from vllm.model_executor.layers.fused_moe.routed_experts import RoutedExperts from vllm.model_executor.layers.quanti...
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._custom_ops as ops from vllm.logger import init_logger from vllm.model_executor.layers.quantization.utils.marlin_utils import ( USE_FP32_REDUCE_DEFAULT, get_marlin...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """Utility functions used for tests and benchmarks""" import numpy as np import torch from vllm import _custom_ops as ops from vllm.scalar_type import ScalarType, scalar_types from .marlin_utils i...
fim
vllm-project/vllm
python
<|fim_suffix|> value_layout_opts: dict[str, Any] = {} scale_layout_opts: dict[str, Any] = {} if ( current_platform.is_cuda() and current_platform.is_device_capability(90) and not is_torch_equal_or_newer("2.8.1") ): logger.warning_once( "Mxfp4 on hopper is runn...
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.model_executor.layers.quantization.utils.ocp_mx_utils import OCP_MX_BLOCK_SIZE from vllm.utils.torch_utils import direct_register_custom_op def _quant_dequant_mxfp6( x: ...
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.utils.torch_utils import direct_register_custom_op # MXFP8 constants MXFP8_VALUE_DTYPE = torch.float8_e4m3fn MXFP8_SCALE_DTYPE = torch.uint8 MXFP8_BLOCK_SIZE = 32 def swiz...
fim
vllm-project/vllm
python
<|fim_suffix|>x + (x == 0) * 1e8) elif isinstance(x, (float, int)): return 0.0 if x == 0 else 1.0 / x else: raise TypeError("Input must be a float, int, or a torch.Tensor.") def cast_to_fp4(x): sign = torch.sign(x) x = torch.abs(x) x[(x >= 0.0) & (x <= 0.25)] = 0.0 x[(x > 0.25)...
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._custom_ops import ( cutlass_scaled_mm_supports_fp4, ) from vllm<|fim_suffix|> to remove padding in N dimension if weight was padded. """ if out.shape[-1] != outp...
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 vllm.logger import init_logger logger = init_logger(__name__) OCP_MX_BLOCK_SIZE = 32 OCP_MX_DTYPES = { "mxfp4", "mxfp6_e3m2", "mxfp6_e2m3", "mxfp8_e4m3"...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """This file is used for /tests and /benchmarks""" from collections.abc import Callable, Mapping from dataclasses import dataclass from types import MappingProxyType from typing import TYPE_CHECKING...
fim
vllm-project/vllm
python
<|fim_suffix|>cale. if unfused_module_in_checkpoint: start = 0 for idx, logical_width in enumerate(logical_widths): # Skip any component with zero width. if logical_width == 0: continue end = start + logical_width weight_dq = per_tensor...
fim
vllm-project/vllm
python
<|fim_suffix|>s) self.ln_q = norm_layer(embed_dim) self.ln_kv = norm_layer(embed_dim) self.do_post_projection = do_post_projection if self.do_post_projection: self.ln_post = norm_layer(embed_dim) data = (embed_dim**-0.5) * torch.empty(embed_dim, embed_dim) ...
fim
vllm-project/vllm
python
<|fim_suffix|>wargs, ) else: raise ValueError(f"Unknown RoPE scaling type {scaling_type}") _ROPE_DICT[key] = rotary_emb return rotary_emb <|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """Rotary Positional Embeddings."...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """Rotary Positional Embeddings Base Class.""" import torch from vllm._aiter_ops import rocm_aiter_ops from vllm.model_executor.custom_op import CustomOp from .common import ApplyRotaryEmb # --8...
fim
vllm-project/vllm
python
<|fim_suffix|>D_DIM or batch > _HIP_MAX_GRID_DIM: output = self.forward_static( x, cos, sin, self.is_neox_style, self.enable_fp32_compute ) return self._post_process(output, origin_shape, origin_dtype) """ Arguments of apply_ro...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import math import torch from vllm.platforms import current_platform from vllm.utils.flashinfer import has_flashinfer from .base import RotaryEmbeddingBase from .common import ( rotate_gptj, ...
fim
vllm-project/vllm
python