text
stringlengths
14
100k
source
stringclasses
1 value
repo
stringclasses
810 values
language
stringclasses
13 values
<|fim_suffix|>rue", help="enable prefix caching" ) args = parser.parse_args() main(args) <|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import cProfile import pstats from vllm import LLM, SamplingParams from vllm.utils.argparse_util...
fim
vllm-project/vllm
python
#!/usr/bin/env python3 # SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project # # A command line tool for running pytorch's hipify preprocessor on CUDA # source files. # # See https://github.com/ROCm/hipify_torch # and <torch install dir>/utils/hipify/hipify_python.p...
fim
vllm-project/vllm
python
#pragma once #include "attention_generic.cuh" #include "dtype_float16.cuh" #include "dtype_float32.cuh" #include "dtype_bfloat16.cuh" #include "dtype_fp8.cuh" <|endoftext|>
fim
vllm-project/vllm
c
<|fim_suffix|> torch::Tensor& key_cache, torch::Tensor& value_cache, torch::Tensor& slot_mapping, const std::string& kv_cache_dtype, torch::Tensor& k_scale, torch::Tensor& v_sc...
fim
vllm-project/vllm
c
<|fim_prefix|>#pragma once #in<|fim_suffix|>// if env VLLM_BATCH_INVARIANT=1 inline bool vllm_is_batch_invariant() { static bool cached = []() { std::string env_key = "VLLM_BATCH_INVARIANT"; const char* val = std::getenv(env_key.c_str()); return (val && std::atoi(val) != 0) ? 1 : 0; }(); return cached...
fim
vllm-project/vllm
cpp
<|fim_suffix|>p, q) (!(p) || (q)) <|fim_prefix|>#pragma once #define VLLM_IMPLIES<|fim_middle|>(<|endoftext|>
fim
vllm-project/vllm
cpp
<|fim_suffix|>T round_to_next_multiple_of(T a, T b) { return a % b == 0 ? a : ((a / b) + 1) * b; } <|fim_prefix|>#pragma once #include <climits> #include <iostream> inline constexpr uint32_t next_pow_2(uint32_t const num) { if (num <= 1) return num; return 1 << (CHAR_BIT * sizeof(num) - __builtin_clz(num - 1));...
fim
vllm-project/vllm
cpp
<|fim_suffix|>AME // could be a macro instead of a literal token. #define TORCH_LIBRARY_IMPL_EXPAND(NAME, DEVICE, MODULE) \ TORCH_LIBRARY_IMPL(NAME, DEVICE, MODULE) // REGISTER_EXTENSION allows the shared library to be loaded and initialized // via python's import statement. #define REGISTER_EXTENSION(NAME) ...
fim
vllm-project/vllm
c
<|fim_prefix|>#pragma once #include <cstdint> #include <string> #include <tuple> #include <utility> #include <variant> // For STD_TORCH_CHECK #include <torch/headeronly/util/Exception.h> namespace vllm { // // ScalarType can represent a wide range of floating point and integer types, // in particular it can be us...
fim
vllm-project/vllm
cpp
<|fim_prefix|>#include "cpu_types.hpp" namespace { template <typename scalar_t, vec_op::FP32Vec8 (*func)(const vec_op::FP32Vec8&), bool is_gated> void activation_kernel(int num_tokens, int d, scalar_t* __restrict__ input, scalar_t* __restrict__ output) { using scalar_vec_t = vec_op::...
fim
vllm-project/vllm
cpp
<|fim_prefix|>#include "cpu_types.hpp" #include <array> #include <cstdint> #include <mutex> #include <string> #include <ATen/ops/empty.h> #include <ATen/ops/gelu.h> #include <c10/util/BFloat16.h> constexpr uint32_t ActivationLutSize = 1u << 16; at::Tensor gelu_reference(const at::Tensor& x) { return at::gelu(x, "no...
fim
vllm-project/vllm
cpp
<|fim_prefix|>#ifndef CPU_ARCH_MACROS_H #define CPU_ARCH_MACROS_H // x86_64 #ifdef __x86_64__ #define FAST_SPINNING _mm_pause(); #ifdef __AVX512F__ #define DEFINE_FAST_EXP \ const __m512 vec_factorial_1 = _mm512_set1_ps(0.999999701f); \ ...
fim
vllm-project/vllm
c
<|fim_prefix|>#include "cpu_attn_dispatch_generated.h" // Maps kv_cache_dtype string to Fp8KVCacheDataType enum. // "auto" -> kAuto(0); "fp8"/"fp8_e4m3" -> kFp8E4M3; "fp8_e5m2" -> kFp8E5M2. static inline cpu_attention::Fp8KVCacheDataType parse_fp8_kv_dtype( const std::string& kv_cache_dtype) { if (kv_cache_dtype...
fim
vllm-project/vllm
cpp
<|fim_prefix|>#ifndef CPU_ATTN_AMX_HPP #define CPU_ATTN_AMX_HPP #include "cpu_attn_fp8.hpp" #include "cpu_attn_impl.hpp" namespace cpu_attention { namespace { // AMX specific constexpr static int64_t AMX_TILE_ROW_BYTES = 64; constexpr static int64_t AMX_TILE_ROW_NUM = 16; constexpr static int64_t AMX_TILE_BYTES = AMX...
fim
vllm-project/vllm
cpp
<|fim_suffix|>8_vec_impl( const scalar_t* key_ptr, const scalar_t* value_ptr, uint8_t* key_cache_ptr, uint8_t* value_cache_ptr, const int64_t* slot_ptr, int64_t token_num, int64_t head_num, int64_t head_dim, int64_t block_size, int64_t k_stride0, int64_t k_stride1, int64_t v_stride0, int64_t v_stride1, ...
fim
vllm-project/vllm
cpp
#ifndef CPU_ATTN_HPP #define CPU_ATTN_HPP #include <type_traits> #include <cstddef> #if defined(__APPLE__) #include <sys/sysctl.h> #endif #include "cpu/cpu_arch_macros.h" #include "cpu/utils.hpp" namespace cpu_attention { enum class ISA { AMX, VEC, VEC16, NEON, VXE, RVV, VSX }; // Mirrors csrc/attention/dtype_fp...
fim
vllm-project/vllm
cpp
<|fim_suffix|>m_stride + head_idx * value_head_num_stride; scalar_t* value_cache_start_ptr = value_cache + block_idx * num_blocks_stride + head_idx * cache_head_num_stride + block_offset * head_dim; std::memcpy(value_cache_start...
fim
vllm-project/vllm
cpp
<|fim_prefix|>// SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: Copyright contributors to the vLLM project #ifndef CPU_ATTN_NEON_BFMMLA_HPP #define CPU_ATTN_NEON_BFMMLA_HPP #include "cpu_attn_impl.hpp" #include <arm_neon.h> #include <cstdint> #include <vector> namespace cpu_attention { namespace { ...
fim
vllm-project/vllm
cpp
<|fim_suffix|> = 0; for (; i < head_dim;) { size_t vl; if constexpr (std::is_same_v<scalar_t, float>) { vl = __riscv_vsetvl_e32m2(head_dim - i); vfloat32m2_t v = __riscv_vle32_v_f32m2( reinterpret_cast<const float*>(key_start_pt...
fim
vllm-project/vllm
cpp
<|fim_prefix|>#ifndef CPU_ATTN_VEC_HPP #define CPU_ATTN_VEC_HPP #include "cpu_attn_fp8.hpp" #include "cpu_attn_impl.hpp" namespace cpu_attention { namespace { // Load 32 kv_cache_t elements starting at ptr and return them as two FP32Vec16s // covering the lower 16 and upper 16 positions. // For FP8: both halves com...
fim
vllm-project/vllm
cpp
<|fim_suffix|>ze, dynamic_k_size, accum_c); break; case 7: case 8: gemm_micro<8>(a_tile, b_tile, c_tile, lda, ldb, ldc, block_size, dynamic_k_size, accum_c); break; case 9: case 10: case 11: case 12: gemm_mic...
fim
vllm-project/vllm
cpp
// SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: Copyright contributors to the vLLM project #ifndef CPU_ATTN_VSX_HPP #define CPU_ATTN_VSX_HPP #include "cpu_attn_impl.hpp" #include <altivec.h> #include <type_traits> namespace cpu_attention { namespace { // ppc64le Vector = 16 bytes (128 bits) #defin...
fim
vllm-project/vllm
cpp
#ifndef CPU_ATTN_VXE_HPP #define CPU_ATTN_VXE_HPP #include "cpu_attn_impl.hpp" #include <vecintrin.h> #include <type_traits> namespace cpu_attention { namespace { // s390x Vector = 16 bytes (128 bits) #define BLOCK_SIZE_ALIGNMENT 32 #define HEAD_SIZE_ALIGNMENT 32 #define MAX_Q_HEAD_NUM_PER_ITER 16 template <typena...
fim
vllm-project/vllm
cpp
<|fim_suffix|>r_t* __restrict__ output, const int32_t m_size, const int32_t n_size, const int32_t input_stride, const int32_t output_stride) { using scalar_vec_t = typename cpu_utils::VecTypeTrait<scalar_t>::vec_t; const int32_t dim = n_size / 2; ...
fim
vllm-project/vllm
cpp
<|fim_suffix|>es_scalar.hpp" #endif #ifdef _OPENMP #include <omp.h> #endif #endif<|fim_prefix|>#ifndef CPU_TYPES_HPP #define CPU_TYPES_HPP #if defined(__x86_64__) // x86 implementation #include "cpu_types_x86.hpp" #elif defined(__POWER9_VECTOR__) // ppc implementation #include "cpu_types_vsx.hpp" #elif def...
fim
vllm-project/vllm
cpp
<|fim_prefix|>#include <cmath> #include <type_traits> #include <arm_neon.h> #include <torch/all.h> #include <ATen/cpu/vec/functional.h> #include <ATen/cpu/vec/vec.h> #if defined(__APPLE__) #include "omp.h" #endif using namespace at::vec; namespace vec_op { struct fp8_e4m3_tag {}; struct fp8_e5m2_tag {}; #defin...
fim
vllm-project/vllm
cpp
<|fim_prefix|>#ifndef CPU_TYPES_RISCV_HPP #define CPU_TYPES_RISCV_HPP // RISC-V Vector (RVV) CPU type definitions for vLLM. // // Supports multiple VLENs via compile-time dispatch. The compiler defines // __riscv_v_min_vlen from the zvl<N>b extension in -march. The defs header // maps VLEN to the correct LMUL suffixes...
fim
vllm-project/vllm
cpp
<|fim_suffix|>pedef vbool16_t rvv_mask_f32x8_t; typedef vbool8_t rvv_mask_f32x16_t; #elif __riscv_v_min_vlen == 256 typedef vbool32_t rvv_mask_f32x8_t; typedef vbool16_t rvv_mask_f32x16_t; #endif #endif // CPU_TYPES_RISCV_DEFS_HPP <|fim_prefix|>#ifndef CPU_TYPES_RISCV_DEFS_HPP #define CPU_TYPES_RISCV_DEFS_HPP // VLE...
fim
vllm-project/vllm
cpp
<|fim_prefix|>#ifndef CPU_TYPES_RISCV_IMPL_HPP #define CPU_TYPES_RISCV_IMPL_HPP // Shared implementation of RVV vector-type wrapper classes. // This file is VLEN-independent: it uses the semantic type names and // RVVI() intrinsic macros from cpu_types_riscv_defs.hpp. // // DO NOT include this file directly; include c...
fim
vllm-project/vllm
cpp
<|fim_suffix|>, 0, 3); } }; // namespace vec_op <|fim_prefix|>#include <cmath> #include <cstdint> #include <cstring> #include <torch/all.h> #include "float_convert.hpp" namespace vec_op { struct fp8_e4m3_tag {}; struct fp8_e5m2_tag {}; #define VLLM_DISPATCH_CASE_FLOATING_TYPES(...) \ AT_DISPATCH_CASE(...
fim
vllm-project/vllm
cpp
<|fim_prefix|> #ifndef CPU_TYPES_VSX_HPP #define CPU_TYPES_VSX_HPP #include <altivec.h> #include <cmath> #include <algorithm> #include <torch/all.h> namespace vec_op { // FP8 tag types for tag dispatch (see cpu_attn_vec.hpp) struct fp8_e4m3_tag {}; struct fp8_e5m2_tag {}; // FIXME: FP16 is not fully supported in To...
fim
vllm-project/vllm
cpp
<|fim_prefix|> #ifndef CPU_TYPES_VXE_HPP #define CPU_TYPES_VXE_HPP #include <vecintrin.h> #include <bit> #include <cmath> #include <cstdint> #include <limits> #include <torch/all.h> namespace vec_op { struct fp8_e4m3_tag {}; struct fp8_e5m2_tag {}; #define vec_neg(a) (-(a)) #define vec_add(a, b) ((a) + (b)) #define ...
fim
vllm-project/vllm
cpp
<|fim_prefix|> #ifndef CPU_TYPES_X86_HPP #define CPU_TYPES_X86_HPP #include <immintrin.h> #include <torch/all.h> #ifndef __AVX2__ static_assert(false, "AVX2 must be supported for the current implementation."); #endif namespace vec_op { // Tags for FP8 BF16Vec32 constructors (avoid overload collision with // BF16Vec...
fim
vllm-project/vllm
cpp
#include "cpu/cpu_types.hpp" #include "cpu/utils.hpp" #ifdef CPU_CAPABILITY_AMXBF16 #include "cpu/micro_gemm/cpu_micro_gemm_amx.hpp" #endif #include "cpu/micro_gemm/cpu_micro_gemm_vec.hpp" #define VLLM_DISPATCH_CASE_16B_TYPES(...) \ AT_DISPATCH_CASE(at::ScalarType::BFloat16, __VA_ARGS__) \ AT_DI...
fim
vllm-project/vllm
cpp
#include <list> #include <optional> #include "common/memory_desc.hpp" #include "common/memory.hpp" #include "cpu/utils.hpp" #include "cpu/dnnl_helper.h" static dnnl::engine& default_engine() { static dnnl::engine engine(dnnl::engine::kind::cpu, 0); return engine; } static dnnl::stream& default_stream() { stat...
fim
vllm-project/vllm
cpp
<|fim_suffix|> void execute(ExecArgs& args); private: dnnl::matmul::primitive_desc create_primitive_desc(const MSizeCacheKey& key, bool first_time); void init_runtime_memory_cache(const Args& args); dnnl::matmul get_matmul_cache(const MSizeCacheKey& key)...
fim
vllm-project/vllm
c
<|fim_prefix|>#include "cpu_types.hpp" #include "dnnl_helper.h" namespace { template <typename scalar_t> struct KernelVecType { using load_vec_type = void; using cvt_vec_type = void; }; template <> struct KernelVecType<float> { using load_vec_type = vec_op::FP32Vec16; using cvt_vec_type = vec_op::FP32Vec16; }...
fim
vllm-project/vllm
cpp
<|fim_prefix|>#pragma once #include <bit> #include <cstdint> inline float bf16_to_float(uint16_t bf16) { uint32_t bits = static_cast<uint32_t>(bf16) << 16; return std::bit_cast<float>(bits); } inline uint16_t float_to_bf16(float fp32) { uint32_t bits = std::bit_cast<uint32_t>(fp32); return static_cast<uint16...
fim
vllm-project/vllm
cpp
<|fim_prefix|>#!/usr/bin/env python3 # SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """ Generate CPU attention dispatch switch cases and kernel instantiations. """ import os # Head dimensions divisible by 32 (support all ISAs) HEAD_DIMS_32 = [32, 64, 96, 128...
fim
vllm-project/vllm
python
#include "cpu_types.hpp" namespace { template <typename scalar_t> void rms_norm_impl(scalar_t* __restrict__ out, const scalar_t* __restrict__ input, const scalar_t* __restrict__ weight, const float epsilon, const int num_tokens, const int hidden_size) { using ...
fim
vllm-project/vllm
cpp
<|fim_suffix|> weight += 16 * input_size; packed_weight += 16 * input_size; } } private: alignas(64) __tilecfg amx_tile_config_; int32_t curr_m_; }; } // namespace cpu_micro_gemm #endif <|fim_prefix|>#ifndef CPU_MICRO_GEMM_AMX_HPP #define CPU_MICRO_GEMM_AMX_HPP #include "cpu/micro_gemm/cpu_micro...
fim
vllm-project/vllm
cpp
<|fim_prefix|>#ifndef CPU_MICRO_GEMM_IMPL_HPP #define CPU_MICRO_GEMM_IMPL_HPP #include "cpu/utils.hpp" #include "cpu/cpu_types.hpp" namespace cpu_micro_gemm { #define DEFINE_CPU_MICRO_GEMM_PARAMS \ scalar_t *__restrict__ a_ptr, scalar_t *__restrict__ b_ptr, \ ...
fim
vllm-project/vllm
cpp
<|fim_suffix|> } // Note: pack contiguous weight [output_size, input_size] as contiguous // packed weight [output_size / 16, input_size, 16] static void pack_weight(const scalar_t* __restrict__ weight, scalar_t* __restrict__ packed_weight, const int32_t output_...
fim
vllm-project/vllm
cpp
#include "cpu_types.hpp" #include <float.h> namespace { template <typename scalar_t> struct KernelVecType { using qk_load_vec_type = void; using qk_vec_type = void; using v_load_vec_type = void; }; template <> struct KernelVecType<float> { using qk_load_vec_type = vec_op::FP32Vec16; using qk_vec_type = vec_...
fim
vllm-project/vllm
cpp
<|fim_prefix|> #include "cpu_types.hpp" namespace { template <typename scalar_t> void rotary_embedding_impl( const int64_t* __restrict__ positions, // [batch_size, seq_len] or // [num_tokens] scalar_t* __restrict__ query, /// [batch_size, seq_len, num_head...
fim
vllm-project/vllm
cpp
<|fim_prefix|>// SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: Copyright contributors to the vLLM project #include <ATen/native/CPUBlas.h> // Unlike brgemm, PyTorch does not publicly expose at::native::cpublas::gemm // If OpenBLS is available in the PyTorch wheel, we rely on it for fast // bf16:bf16-...
fim
vllm-project/vllm
c
<|fim_suffix|> \ } \ case at::ScalarType::Float8_e4m3fn: { \ using packed_t = at::Float8_e4m3fn; \ return __VA_ARGS__(); \ } ...
fim
vllm-project/vllm
c
<|fim_suffix|>d."); const int64_t batch = is_var_seqlen ? query_start_loc.value().size(0) - 1 : x.size(0); const int64_t dim = x.size(-2); const int64_t seqlen = x.size(-1); const int64_t width = weight.size(-1); const auto scalar_type = x.scalar_type(); CHECK_EQ(weight.scalar_type(), scalar_type); CHEC...
fim
vllm-project/vllm
cpp
<|fim_prefix|>// Adapted from // https://github.com/sgl-project/sglang/tree/main/sgl-kernel/csrc/cpu // clang-format off #include "common.h" #include "gemm.h" #include "vec.h" #include "vec_pack.h" namespace { // For this cpu kernel, we have some innovations aside from the existing gpu kernels: // 1) Use less parall...
fim
vllm-project/vllm
cpp
// Adapted from // https://github.com/sgl-project/sglang/tree/main/sgl-kernel/csrc/cpu // clang-format off #include "gemm.h" #include "common.h" #include "vec.h" namespace { // packed layout: // quants {N, K} int8_t // comp {N} int32_t template <int BLOCK_N> inline void s8s8_compensation(int8_t* __res...
fim
vllm-project/vllm
cpp
<|fim_suffix|>t float* __restrict__ w2s, int group_size, const float* __restrict__ topk_weights, const int32_t* __restrict__ sorted_ids, const int32_t* __restrict__ expert_ids, const int32_t* __restrict__ offsets, int64_t M, int64_t N, int64_t K, int64_t E, int64_t topk, int6...
fim
vllm-project/vllm
c
// Adapted from // https://github.com/sgl-project/sglang/tree/main/sgl-kernel/csrc/cpu // clang-format off #include "common.h" #include "gemm.h" #include "vec.h" namespace { template <typename scalar_t> inline void copy_stub(scalar_t* __restrict__ out, const float* __restrict__ input, int64_t size) { using bVec =...
fim
vllm-project/vllm
cpp
<|fim_suffix|>unpacked = (at::bitwise_right_shift(qzeros_unsq, bitshifts) & 0xF).contiguous(); auto qzeros_final = qzeros_unpacked.flatten(-2).to(at::kByte).clone(); return std::make_tuple(qweight_final, qzeros_final); } else if (quant_method_4bit == CPUQuantAlgo::GPTQ) { // autogptq unpacking auto ou...
fim
vllm-project/vllm
cpp
<|fim_suffix|>, Bcomp, bias, As[m], Bs); } return; } // pattern: 1-4-16 constexpr int64_t BLOCK_M = 4; constexpr int64_t BLOCK_N = 64; const int64_t MB = div_up(M, BLOCK_M); const int64_t NB = div_up(N, BLOCK_N); for (int64_t mb = 0; mb < MB; ++mb) { int64_t mb_start = mb * BLOCK_M; int64...
fim
vllm-project/vllm
cpp
<|fim_suffix|>ache1 + M * N)); if (use_int8_w8a8) { uint8_t* __restrict__ Aq_tmp = (uint8_t*)((void*)(C_tmp + num_threads * 2 * BLOCK_M * BLOCK_N)); float* __restrict__ As_tmp = (float*)((void*)(Aq_tmp + std::max(M * K, M * N))); auto w1s = w1_scale.value(); auto w2s = w2_scale.value(); ...
fim
vllm-project/vllm
cpp
<|fim_suffix|>, const float alpha, const float limit) { using bVec = at::vec::Vectorized<scalar_t>; using fVec = at::vec::Vectorized<float>; const fVec one = fVec(1.f); const fVec zero = fVec(0.f); const fVec limit_v = fVec(limit); const fVec nlimit_v = fVec(-limit); const fVec alpha_v = fVec(alph...
fim
vllm-project/vllm
c
<|fim_prefix|>// Adapted from // https://github.com/sgl-project/sglang/tree/main/sgl-kernel/csrc/cpu // clang-format off #include "common.h" #include "gemm.h" #include "moe.h" template <typename scalar_t, typename packed_t, typename param_t, bool is_mxfp4> void fused_experts_fp_kernel_impl( scalar_t* __restrict_...
fim
vllm-project/vllm
cpp
<|fim_suffix|>e, _block_k, IC, BLOCK_N, BLOCK_N, false, use_brgemm); } // 2.b copy from C to ic2 in original order // and also mul topk_weights in float32 for (int64_t m = 0; m < m_size; ++m) { int32_t index = A_i...
fim
vllm-project/vllm
cpp
// Adapted from // https://github.com/sgl-project/sglang/tree/main/sgl-kernel/csrc/cpu // clang-format off #include "common.h" #include "gemm.h" #include "moe.h" namespace { template <typename scalar_t, int BLOCK_N> inline void silu_and_mul( scalar_t* __restrict__ C, const int32_t* __restrict__ C0, // x: x...
fim
vllm-project/vllm
cpp
<|fim_suffix|>mbined, _mm512_set1_epi16(0x3c00)); const __mmask32 is_nonzero = _mm512_cmpneq_epi16_mask(x, _mm512_setzero_si512()); return (__m512bh)_mm512_maskz_mov_epi16(is_nonzero, combined); } inline __m512bh cvt_e4m3_bf16_intrinsic_without_denorm(__m256i fp8_vec) { // The following conversion is without de...
fim
vllm-project/vllm
c
<|fim_prefix|>// Adapted from // https://github.com/sgl-project/sglang/tree/main/sgl-kernel/csrc/cpu // clang-format off // To use the transpose functions #include <ATen/native/cpu/utils.h> #include "vec.h" namespace { using namespace at::vec; template <typename index_t> inline index_t get_index(index_t* ind, int...
fim
vllm-project/vllm
c
<|fim_suffix|>or_list_with_metadata.end()); return tensor_list; } } // namespace void shm_gather(int64_t handle, torch::Tensor& data, const std::optional<std::vector<torch::Tensor>>& outputs, int64_t dst) { TORCH_CHECK(data.is_contiguous()) VLLM_DISPATCH_FLOATING_TYPES(data.scal...
fim
vllm-project/vllm
cpp
<|fim_suffix|>_t block_id = bt_ptr[req_idx * bt_stride + block_number]; int64_t slot_id = block_id * block_size + (clamped_position % block_size); out_slot_ptr[req_idx] = exceeds_max ? PAD_ID : slot_id; int32_t seq_len = seq_lens_ptr[req_idx]; int32_t new_seq_len = exceeds_max ? 1 : (seq_len + 1); ...
fim
vllm-project/vllm
cpp
<|fim_suffix|>> ()", &cpu_utils::rejection_greedy_sample_kernel_impl); ops.def( "rejection_random_sample_kernel_impl(" "Tensor(a0!) output_token_ids, Tensor cu_num_draft_tokens, " "Tensor draft_token_ids, Tensor? draft_probs, " "Tensor target_probs, Tensor bonus_token_ids, " "Tenso...
fim
vllm-project/vllm
cpp
<|fim_prefix|>#ifndef VLLM_NUMA_DISABLED #include <numa.h> #include <unistd.h> #include <string> #include <sched.h> #endif #if __GLIBC__ == 2 && __GLIBC_MINOR__ < 30 #include <unistd.h> #include <sys/syscall.h> #define gettid() syscall(SYS_gettid) #endif #include "cpu/utils.hpp" #ifdef VLLM_NUMA_DISABLE...
fim
vllm-project/vllm
cpp
<|fim_prefix|>#ifndef UTILS_HPP #define UTILS_HPP #include <atomic> #include <unistd.h> #include <ATen/cpu/Utils.h> #include "cpu/cpu_types.hpp" namespace cpu_utils { enum class ISA { AMX, VEC }; inline ISA get_isa(const std::string& isa) { if (isa == "amx") { return ISA::AMX; } else if (isa == "vec") { ...
fim
vllm-project/vllm
cpp
<|fim_prefix|>#pragma once #ifndef USE_ROCM #include <cub/cub.cuh> #if CUB_VERSION ><|fim_suffix|>ubAddOp = hipcub::Sum; using CubMaxOp = hipcub::Max; #endif // USE_ROCM <|fim_middle|>= 200800 #include <cuda/std/functional> using CubAddOp = cuda::std::plus<>; using CubMaxOp = cuda::maximum<>; #else // if ...
fim
vllm-project/vllm
c
<|fim_prefix|>#pragma once #ifdef USE_ROCM #include <hip/hip_runtime.h> #endif #ifdef USE_ROCM struct Utils { static __host__ int get_warp_size() { static bool is_cached = false; static int result; if (!is_cached) { int device_id; cudaDeviceProp deviceProp; cudaGetDevice(&device_id)...
fim
vllm-project/vllm
c
<|fim_prefix|>#pragma once #include <stdio.h> #if defined(__HIPCC__) #define HOST_DEVICE_INLINE __host__ __device__ #define DEVICE_INLINE __device__ #define HOST_INLINE __host__ #elif defined(__CUDACC__) || defined(_NVHPC_CUDA) #define HOST_DEVICE_INLINE __host__ __device__ __forceinline__ #define DEVICE_IN...
fim
vllm-project/vllm
c
<|fim_prefix|>// A CUDAPluggableAllocator based on cumem* APIs. // Important: allocation size, CUdeviceptr and CUmemGenericAllocationHandle* // need to be unsigned long long #include <iostream> #include "cumem_allocator_compat.h" #ifndef USE_ROCM static const char* PYARGS_PARSE = "KKKK"; #else #include <cstdlib> ...
fim
vllm-project/vllm
cpp
#pragma once #ifdef USE_ROCM //////////////////////////////////////// // For compatibility with CUDA and ROCm //////////////////////////////////////// #include <hip/hip_runtime_api.h> extern "C" { #ifndef CUDA_SUCCESS #define CUDA_SUCCESS hipSuccess #endif // CUDA_SUCCESS // https://rocm.docs.amd.com/proj...
fim
vllm-project/vllm
c
/*************************************************************************************************** * Copyright (c) 2023 - 2024 NVIDIA CORPORATION & AFFILIATES. All rights *reserved. SPDX-License-Identifier: BSD-3-Clause * * Redistribution and use in source and binary forms, with or without * modification, are pe...
fim
vllm-project/vllm
cpp
<|fim_prefix|>/*************************************************************************************************** * Copyright (c) 2023 - 2024 NVIDIA CORPORATION & AFFILIATES. All rights *reserved. SPDX-License-Identifier: BSD-3-Clause * * Redistribution and use in source and binary forms, with or without * modifi...
fim
vllm-project/vllm
cpp
<|fim_suffix|>s(TensorType const& a_scales, TensorType const& b_scales, TensorType const& bias) { auto a_args = SUPER::template args_from_tensor<ScaleA, float>(a_scales); auto b_args = SUPER::template args_from_tensor<ScaleB, float>(b_scales)...
fim
vllm-project/vllm
cpp
<|fim_prefix|>#pragma once #include "torch_utils.h" // This header is shared between _C (unstable ABI, used by machete) and // _C_stable_libtorch (stable ABI, used by W4A8/sparse). TORCH_TARGET_VERSION // is defined only for the stable target, so we switch includes and types // accordingly. TorchTensor (not Tensor) a...
fim
vllm-project/vllm
cpp
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import enum from cutlass_library import * # # Extend cutlass library with custom types, and missing values # class VLLMDataType(enum.Enum): u4b8 = enum_auto() u8b128 = enum_auto() cl...
fim
vllm-project/vllm
python
<|fim_suffix|> \ break; \ } \ case 4: { \ constexpr int vec_size = 4; \ __VA_ARGS__(); \ break; \ }...
fim
vllm-project/vllm
c
<|fim_prefix|>/*************************************************************************************************** * Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: BSD-3-Clause * * Redistribution and use in source and binary forms, with or without * modification...
fim
vllm-project/vllm
cpp
<|fim_prefix|>/*************************************************************************************************** * Copyright (c) 2024 - 2025 NVIDIA CORPORATION & AFFILIATES. All rights *reserved. SPDX-License-Identifier: BSD-3-Clause * * Redistribution and use in source and binary forms, with or without * modifi...
fim
vllm-project/vllm
cpp
<|fim_suffix|>; } } ++pipeline_load_qk_producer_state; } // prefetch next K load to keep busy while we transpose-load from cache const int kPrefetchDistance = 1; for (int i = 0; i < IterationsQKLatent; i++) { if (cute::elect_one_sync()) { if constexpr...
fim
vllm-project/vllm
cpp
<|fim_suffix|>e above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * 3. Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived from *...
fim
vllm-project/vllm
cpp
#include "common.hpp" int32_t get_sm_version_num() { int32_t major_capability, minor_capability; cudaDeviceGetAttribute(&major_capability, cudaDevAttrComputeCapabilityMajor, 0); cudaDeviceGetAttribute(&minor_capability, cudaDevAttrComputeCapabilityMinor, 0); in...
fim
vllm-project/vllm
cpp
#pragma once #include "cutlass/cutlass.h" #include <climits> #include "cuda_runtime.h" #include <cstdio> #include <cstdlib> #include <torch/headeronly/util/shim_utils.h> /** * Helper function for checking CUTLASS errors */ #define CUTLASS_CHECK(status) \ { ...
fim
vllm-project/vllm
cpp
<|fim_prefix|>/*************************************************************************************************** * Copyright (c) 2023 - 2024 NVIDIA CORPORATION & AFFILIATES. All rights *reserved. SPDX-License-Identifier: BSD-3-Clause * * Redistribution and use in source and binary forms, with or without * modifi...
fim
vllm-project/vllm
cpp
<|fim_suffix|>:template ColOrScalarLoad<float>; using ScaleB = typename SUPER::template RowOrScalarLoad<float>; using Bias = typename SUPER::template RowOrZeroLoad<ElementD>; // Per-token azp term, shape (m,1) using Azp = typename SUPER::template ColLoad<int32_t>; // This is the AZP adjustment term, J @ B, ...
fim
vllm-project/vllm
cpp
<|fim_prefix|>/* * Stable ABI compatible dispatch utilities for vLLM. * Adapted from dispatch_utils.h <|fim_suffix|> VLLM_STABLE_DISPATCH_CASE_INTEGRAL_AND_UNSIGNED_TYPES(__VA_ARGS__)) // FP8 type dispatch - ROCm uses FNUZ format, CUDA uses OCP format #ifdef USE_ROCM #define VLLM_STABLE_DISPATCH_CASE_FP8_TYPES(......
fim
vllm-project/vllm
c
<|fim_prefix|>#pragma once #include <cuda_runtime_api.h> #include <algorithm> // maximum blocks per SM cap #ifndef VLLM_LAUNCH_BLOCKS_CAP #define VLLM_LAUNCH_BLOCKS_CAP 4 #endif // Compile-time estimate of max threads per SM for launch bounds. // Families: 1024, 1536, 2048 threads/SM. #ifndef VLLM_MAX_THREADS_PER_...
fim
vllm-project/vllm
c
<|fim_suffix|>nst float (&out_vals)[Ktraits::kNItems], typename Ktraits::BlockStoreT::TempStorage &smem_store, int seqlen) { typename Ktraits::input_t write_vals[Ktraits::kNItems]; #pragma unroll for (int i = 0; i < Ktraits::kNItems; ++...
fim
vllm-project/vllm
c
<|fim_suffix|>OND, CONST_NAME, ...) \ [&] { \ if (COND) { \ constexpr bool CONST_NAME = true; \ return __VA_ARGS__(); \ } else { \ constexpr bool CONST_NAME = false; \ return...
fim
vllm-project/vllm
c
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import glob import itertools import os import subprocess import sys import jinja2 ARCHS = [] SUPPORT_FP8 = False SUPPORT_SM75 = False SUPPORT_SM80 = False for arch in sys.argv[1].split(","): ar...
fim
vllm-project/vllm
python
#ifndef MARLIN_NAMESPACE_NAME #define MARLIN_NAMESPACE_NAME marlin_moe_wna16 #endif #include "libtorch_stable/quantization/marlin/marlin.cuh" #include "libtorch_stable/quantization/marlin/marlin_dtypes.cuh" #include "core/scalar_type.hpp" #define MARLIN_KERNEL_PARAMS \ co...
fim
vllm-project/vllm
c
<|fim_prefix|>/* * Modified by Neural Magic * Copyright (C) Marlin.2024 Elias Frantar * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENS...
fim
vllm-project/vllm
c
<|fim_prefix|>#pragma once #include <torch/csrc/stable/tensor.h> #include <optional> #include <tuple> void topk_softmax(torch::stable::Tensor& topk_weights, torch::stable::Tensor& topk_indices, torch::stable::Tensor& token_expert_indices, torch::stable::Tensor& g...
fim
vllm-project/vllm
c
<|fim_prefix|> #include <cuda_fp16.h> #include <cuda_bf16.h> template <typename scalar_t> class ScalarType {}; template <> class ScalarType<half> { public: using scalar_t = half; using scalar_t2 = half2; static __device__ float inline num2float(const half x) { return __half2float(x); } static __devic...
fim
vllm-project/vllm
c
<|fim_prefix|>#pragma once #include <cuda_fp8.h> #include <torch/headeronly/core/ScalarType.h> #include <torch/headeronly/util/Exception.h> #define MOE_SWITCH(TYPE, ...) \ const auto _st = (TYPE); \ switch (_st) { ...
fim
vllm-project/vllm
c
<|fim_suffix|>* expert_map_ptr, int num_experts, cudaStream_t stream); #include "moe_permute_unpermute_kernel.inl" <|fim_prefix|>#pragma once // reference from tensorrt_llm moe kernel implementation archive in // https://github.com/BBuf/tensorrt-llm-moe/tree/master #include <torch/csrc/s...
fim
vllm-project/vllm
c
<|fim_prefix|>#include "core/registration.h" #include "moe_ops.h" #include <torch/csrc/stable/library.h> STABLE_TORCH_LIBRARY_FRAGMENT(_moe_C, m) { // Apply topk softmax to the gating outputs. m.def( "topk_softmax(Tensor! topk_weights, Tensor! topk_indices, Tensor! " "token_expert_indices, Tensor gati...
fim
vllm-project/vllm
cpp
<|fim_suffix|>nsor>& alibi_slopes, const std::string& kv_cache_dtype, torch::stable::Tensor& k_scale, torch::stable::Tensor& v_scale, const int64_t tp_rank, const int64_t blocksparse_local_blocks, const int64_t blocksparse_vert_stride, const int64_t blocksparse_block_size, const int64_t blocksparse_...
fim
vllm-project/vllm
c
<|fim_suffix|>edules(default_heuristic)), itertools.repeat(default_heuristic), ) ] AWQ_kernel_type_configs = list( TypeConfig( a=a, b=b, b_group_scale=a, b_group_zeropoint=a, b_channel_scale=DataType.void, a_tok...
fim
vllm-project/vllm
python
<|fim_suffix|>2_intermediates_casted = reinterpret_cast<uint32_t*>(fp32_intermediates); static constexpr uint32_t fp32_base = 0x4B000000; fp32_intermediates_casted[0] = __byte_perm(q, fp32_base, 0x7650); fp32_intermediates_casted[1] = __byte_perm(q, fp32_base, 0x7652); fp32_intermediates_casted[2] = __by...
fim
vllm-project/vllm
c