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 """ FileSystemTierManager: Pure-Python file system secondary tier for KV cache offloading. Store path: Data is written to a temp file (<dest_path.tmp>) via os.write, then os.replace'd to the...
fim
vllm-project/vllm
python
<|fim_suffix|> self._load_q.append((fn, state)) self._condition.notify(n_tasks) def enqueue_store( self, job_id: JobId, n_tasks: int, tasks: Iterable[Callable], ) -> None: """Enqueue store tasks for a job (high-priority for store-priority thread...
fim
vllm-project/vllm
python
<|fim_suffix|>ons. For request-level tiers, blocks already present in the primary tier are immediately cascaded via submit_store(). Args: keys: Blocks to prepare for storing. req_context: Per-request context. Returns: PrepareStoreOutput describing w...
fim
vllm-project/vllm
python
<|fim_suffix|>r secret_key: str scheme: str = "http" ca_bundle: str = "" def to_nixl_params(self) -> dict[str, str]: """Build the NIXL backend params dict.""" params: dict[str, str] = { "bucket": self.bucket, "endpoint_override": self.endpoint_override, ...
fim
vllm-project/vllm
python
<|fim_suffix|>f._agent.create_backend("OBJ", params) self._transfers: dict[int, TransferEntry] = {} self._failed_jobs: list[JobResult] = [] self._primary_reg = None self._block_size_bytes: int = 0 root_dir = f"{prefix}/" if prefix else "" # Opt in; FileMapper enables it o...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """ TieringOffloadingSpec: Spec for multi-tier KV cache offloading. This spec creates a TieringOffloadingManager with a CPU primary tier and configurable secondary tiers (e.g., Storage, Network). C...
fim
vllm-project/vllm
python
<|fim_suffix|> job_id, e, exc_info=True, ) return False if not success: logger.warning("Failed to submit %r transfer %d", transfer_type, job_id) else: logger.debug("Submitted %r transfer %d: %r", transfer_type, job_...
fim
vllm-project/vllm
python
<|fim_suffix|>, 0.005, 0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1, 2, 5, 10, 20, 30, 60, ...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """ Analytic flops/memory estimation module for transformer components, to help derive MFU (Model Flops Utilization) stats for a running model. """ import json import time from abc import ABC, abst...
fim
vllm-project/vllm
python
<|fim_suffix|>et the appropriate prometheus registry based on multiprocessing configuration. Returns: Registry: A prometheus registry """ if os.getenv("PROMETHEUS_MULTIPROC_DIR") is not None: logger.debug("Using multiprocess registry for prometheus metrics") registry = Collector...
fim
vllm-project/vllm
python
<|fim_suffix|> pass <|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import copy import time from vllm.distributed.kv_transfer.kv_connector.v1.metrics import KVConnectorProm from vllm.v1.metrics.loggers import PrometheusStatLogger from vllm....
fim
vllm-project/vllm
python
<|fim_suffix|>t]]: # # In the case of DP, we have an indigestable # per-bucket-per-engine count as a list of labelled # samples, along with total and sum samples # # bucket_samples (in): # labels = {bucket: 100, idx: 0}, value = 2 # labels = {bucket: 200, idx: 0}, value = 4 # l...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0<|fim_suffix|> # Reset the metrics before aggregating the current stats. if stats.reset: self.reset() # DO NOT appending empty stats to avoid helpful info get kicked out # due to sliding window. if stats.requests == 0:...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from typing import TypeAlias from prometheus_client import Counter, Gauge, Histogram PromMetric: TypeAlias = Gauge | Counter | Histogram def <|fim_suffix|>> dict[int, PromMetric]: """Create ...
fim
vllm-project/vllm
python
<|fim_suffix|> sampled_token_ids: list[list[int]] = [[0] for _ in req_ids] # Pooler outputs are not available yet ⇒ use None placeholders pooler_output: list[torch.Tensor | None] = [None for _ in req_ids] return ModelRunnerOutput( req_ids=req_ids, req_id_to_index=req_id_to_index, ...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import zlib from collections.abc import Sequence import torch from vllm.pooling_params import LateInteractionParams, PoolingParams LATE_INTERACTION_MODE_CACHE_QUERY = "cache_query" LATE_INTERACTI...
fim
vllm-project/vllm
python
<|fim_suffix|> f"the number of sequences: {query_start_loc_gpu.shape[0]} " f"!= {n_seq + 1}." ) if query_start_loc_gpu.device != device: raise ValueError( "query_start_loc_gpu must be on the same device as the " ...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import enum import time from collections import deque from collections.abc import Callable, Mapping from dataclasses import dataclass from typing import TYPE_CHECKING, Any import torch from vllm.m...
fim
vllm-project/vllm
python
<|fim_suffix|>lm_config, device, is_pin_memory)`. Subclass constructor may find it useful to utilize the `vllm_config`, `device` and `is_pin_memory` argument. However regardless of whether these arguments are used, the vLLM logits processor interface requires all three arguments to be p...
fim
vllm-project/vllm
python
<|fim_suffix|>op_tok_ids)) for req_idx, (min_tok, out_tok_ids, stop_tok_ids) in self.min_toks.items() if stop_tok_ids ] if not entries: return logits all_rows: list[np.ndarray] = [] # row indices to mask all_toks: list[np.ndarray] = [] # stop-token...
fim
vllm-project/vllm
python
<|fim_suffix|> batch_update: "BatchUpdate | None", ) -> None: """Called when there are new output tokens, prior to each forward pass. Args: batch_update: Non-None iff there have been changes to the batch makeup. """ raise NotImplementedError <...
fim
vllm-project/vllm
python
<|fim_suffix|>iant) <|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from collections.abc import Iterable, Iterator from itertools import chain from typing import TYPE_CHECKING from vllm.v1.sample.logits_processor.interface import ( AddedReque...
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 from dataclasses import dataclass import torch from vllm.v1.sample.logits_processor import LogitsProcessors from vllm.v1.sample.thinking_budget_state import Thi...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import torch _SMALLEST_LOGIT = float("-inf") def<|fim_suffix|>> len(past_tokens_ids) + 1: continue prefix_length = len(bad_word_ids) - 1 last_token_id = bad_word_ids[...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """Some utilities for logprobs, including logits.""" import torch from vllm.platforms import current_platform @torch.compile(backend=current_platform.simple_compile_backend) def batched_count_gre...
fim
vllm-project/vllm
python
# SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import torch from vllm.model_executor.layers.utils import apply_penalties from vllm.utils.platform_utils import is_pin_memory_available from vllm.utils.torch_utils import make_tensor_with_pad def apply_all_pen...
fim
vllm-project/vllm
python
<|fim_suffix|>en_ids = self.aiter_ops.top_p_sampling_from_probs( probs, None, *_to_tensor_scalar_tuple(p), deterministic=True ) return next_token_ids.view(-1) # Top-k only path elif use_top_k: probs = logits.softmax(dim=-1, dtype=torch.float32).contigu...
fim
vllm-project/vllm
python
<|fim_suffix|> # tile-level merge logic. for i in range(0, NUM_TILES): offs_n = i * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE) mask_n = offs_n < VOCAB_SIZE probs_blk = tl.load( BUFFER_...
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 from collections.abc import Sequence from dataclasses import replace from typing import TYPE_CHECKING import torch import torch.nn as nn from vllm.logger import...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """A layer that samples the next tokens from the model's outputs.""" import torch import torch.nn as nn from vllm.config.model import LogprobsMode from vllm.utils.platform_utils import is_pin_memor...
fim
vllm-project/vllm
python
# SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """Per-batch thinking token budget state; applied after penalties at sample time.""" from typing import TYPE_CHECKING, Any import torch from vllm.platforms import current_platform from vllm.utils.torch_utils im...
fim
vllm-project/vllm
python
<|fim_suffix|> serializer = core_schema.plain_serializer_function_ser_schema( cls._serialize_msgspec, info_arg=False, ) # Accept either an already-constructed msgspec.Struct instance or a # JSON/dict-like payload. return core_schema.union_schema( ...
fim
vllm-project/vllm
python
<|fim_suffix|>c_blocks, dst_blocks, params, is_store, event_idx, events_list = item copy_blocks(src_blocks, dst_blocks, params) stream = store_stream if is_store else load_stream event = torch.Event() event.record(stream) events_list.append((event_idx, event))...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """Low-level CUDA/HIP memory helpers: pinning and batch DMA transfers.""" import ctypes from typing import Any, NamedTuple import numpy as np import torch from vllm.logger import init_logger from ...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """Scheduler-side manager for SimpleCPUOffloadConnector.""" import contextlib from collections.abc import Iterable from dataclasses import dataclass, field from typing import TYPE_CHECKING, Any fro...
fim
vllm-project/vllm
python
<|fim_suffix|>ctory=dict) # Store event per step. INVALID_JOB_ID means no blocks to store this step. store_event: int = INVALID_JOB_ID store_gpu_blocks: list[int] = field(default_factory=list) store_cpu_blocks: list[int] = field(default_factory=list) # Whether any requests were preempted this step...
fim
vllm-project/vllm
python
<|fim_suffix|>ts.clear() for event_idx, event in self._store_events: event.synchronize() self._store_hwm = event_idx self._store_events.clear() def _poll_stream_events(self, is_store: bool) -> int: """Non-blocking poll for completed events and return the high-water ...
fim
vllm-project/vllm
python
<|fim_suffix|> callable." ) logger.info( "Loaded custom proposer class '%s' with num_speculative_tokens=%d", backend, spec_config.num_speculative_tokens, ) return instance <|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors t...
fim
vllm-project/vllm
python
<|fim_suffix|>lens - num_rejected_tokens_gpu # Skip num_rejected_tokens (GPU-only); overestimating is fine here. new_seq_lens_cpu_upper_bound = ( cad.seq_lens_cpu_upper_bound + num_query_per_req if cad.seq_lens_cpu_upper_bound is not None else None ) ...
fim
vllm-project/vllm
python
<|fim_suffix|>config(self) -> VllmConfig: base = super()._create_draft_vllm_config() spec = self.speculative_config return replace( base, quant_config=None, parallel_config=replace( spec.draft_parallel_config, rank=self.vllm_co...
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 VllmConfig from vllm.v1.spec_decode.llm_base_proposer import<|fim_suffix|>r(SpecDecodeBaseProposer): def __init__( self, vllm_config: VllmCo...
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 from typing import TYPE_CHECKING import torch import torch.nn as nn from vllm.config import CUDAGraphMode, VllmConfig, get_layers_from_vllm_config from vllm.for...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """Gemma4 MTP (Multi-Token Prediction) proposer for speculative decoding. The Gemma4 assistant model runs all decoder layers per draft step (producing one token), and all its attention layers share ...
fim
vllm-project/vllm
python
<|fim_suffix|>self.set_inputs_first_pass( target_token_ids=target_token_ids, next_token_ids=next_token_ids, target_positions=target_positions, target_hidden_states=target_hidden_states, token_indices_to_sample=token_indices_to_sample, ...
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 as nn from vllm.config import VllmConfig from vllm.forward_context import set_forward_context from vllm.logger import init_logger from vllm.model_executor.model_loader ...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from dataclasses import dataclass import numpy as np import torch @dataclass class SpecDecodeMetadata: # [num_tokens] draft_token_ids: torch.Tensor # [batch_size] num_draft_tokens:...
fim
vllm-project/vllm
python
<|fim_suffix|>e per-position acceptance vector does # not apply, so it is omitted. self.is_diffusion = is_diffusion self.spec_decoding_enabled = speculative_config is not None or is_diffusion if not self.spec_decoding_enabled: return if is_diffusion: coun...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import os import numpy as np import torch from numba import get_num_threads, jit, njit, prange, set_num_threads from vllm.config import VllmConfig class NgramProposer: def __init__(self, vllm...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """ GPU-accelerated N-gram proposer using fully async PyTorch tensor operations. This version uses a fully vectorized approach with unfold and argmax for finding the first match across all sequences...
fim
vllm-project/vllm
python
<|fim_suffix|>ositions_dependent_metadata( positions, common_attn_metadata, batch_size, input_batch_size, block_size, ) if not self.constant_draft_positions or token_index == 0: ...
fim
vllm-project/vllm
python
# SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import torch from vllm.config import VllmConfig from vllm.v1.worker.gpu_input_batch import InputBatch class SuffixDecodingProposer: """ Speculative decoding proposer for Suffix Decoding (https://arxiv.o...
fim
vllm-project/vllm
python
<|fim_suffix|>ot_mapping for context and query positions into separate buffers via block_table lookup. 5. Writes token_indices_to_sample for the mask (speculative) tokens. """ req_idx = tl.program_id(axis=0) block_idx = tl.program_id(axis=1) # Load context token range for this request ...
fim
vllm-project/vllm
python
<|fim_suffix|> return False # To determine whether we can advance the FSM. # Supports thinking usage where we skip the reasoning components. if TYPE_CHECKING: assert request.structured_output_request is not None assert request.structured_output_request.grammar is n...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import copy import json import os from dataclasses import dataclass from typing import TYPE_CHECKING, Any import torch from vllm.logger import init_logger from vllm.sampling_params import Sampling...
fim
vllm-project/vllm
python
<|fim_suffix|>mfe_vllm.TokenEnforcerTokenizerData": return lmfe_vllm.build_vllm_token_enforcer_tokenizer_data( tokenizer, use_bitmask=True, vocab_size=vocab_size ) @dataclass class LMFormatEnforcerGrammar(StructuredOutputGrammar): token_enforcer: lmformatenforcer.TokenEnforcer current_tokens_p...
fim
vllm-project/vllm
python
<|fim_suffix|>sal start state" "This means that the Regex uses anchors (^) or look-arounds " "in a way which requires context before any token is matched." "structured outputs needs regexes that can match without needing " "that context. Try rewriting the pattern without ...
fim
vllm-project/vllm
python
<|fim_suffix|>l: """ Checks whether the structured output process has terminated. Returns: bool: True if the process is terminated, False otherwise. """ @abstractmethod def reset(self): """ Resets the state of the structured output grammar. "...
fim
vllm-project/vllm
python
<|fim_suffix|>_tokens = 0 self.matcher.reset() # cf https://github.com/mlc-ai/xgrammar/blob/a32ac892676d2eedc0327416105b9b06edfb94b2/cpp/json_schema_converter.cc STRING_SUPPORTED_FORMATS = { "email", "date", "time", "date-time", "duration", "ipv4", "ipv6", "hostname", "uuid...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import dataclasses import functools import json from concurrent.futures import Future from concurrent.futures._base import TimeoutError from typing import TYPE_CHECKING, Any, cast from vllm.sampling...
fim
vllm-project/vllm
python
<|fim_suffix|> except ValueError as e: raise ValueError(f"Error on line {line_num}: {str(e)}") from e # Add final rule if exists if current_rule: output_lines.append(f"{current_rule} ::= {' | '.join(current_definition)}") # Validate all rules are defined undefined_rules = ...
fim
vllm-project/vllm
python
<|fim_suffix|>d timeout=%ss", len(procs), timeout, ) for proc in procs: if proc.is_alive(): proc.terminate() deadline = time.monotonic() + timeout for proc in procs: remaining = deadline - time.monotonic() if remaining <= 0: break ...
fim
vllm-project/vllm
python
<|fim_suffix|> kernel_block_size: The block_size of underlying attention kernel. Will be the same as `block_size` if `block_size` is supported by the attention kernel. """ self.max_num_reqs = max_num_reqs self.max_num_batched_tokens = max_num_batched_tokens ...
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, cast from vllm.config import VllmConfig, get_layers_from_vllm_config from vllm.distributed import get_dcp_group, get_pcp_group if TYPE_CHECKING: from vllm...
fim
vllm-project/vllm
python
<|fim_suffix|>aise RuntimeError("UVA is not available") self.cpu = torch.zeros(size, dtype=dtype, device="cpu") self.np = self.cpu.numpy() self.uva = self.cpu <|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from collections...
fim
vllm-project/vllm
python
<|fim_suffix|>Runner logger = init_logger(__name__) class CPUModelRunner(GPUModelRunner): # TBD: Whether need to move this to Worker? def warming_up_model(self) -> None: logger.info("Warming up model for the compilation...") # Only generate graph for the generic shape self.profile_run...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project # isort: skip_file # ruff: noqa: E402 # mypy: disable-error-code="misc, assignment" from typing import Any # Patch torch APIs import torch def noop(*args: Any, **kwargs: Any) -> None: pass ...
fim
vllm-project/vllm
python
<|fim_suffix|>y: if inductor_config.get("max_autotune", False): torch_inductor_config.freezing = True yield finally: torch_inductor_config.freezing = freezing_value def _set_torch_accelerator_to_noop() -> None: def noop(*args: Any, **kwargs: Any) -> None: pass ...
fim
vllm-project/vllm
python
<|fim_suffix|>platform.startswith("linux"): check_preloaded_libs("libtcmalloc") if current_platform.get_cpu_architecture() == CpuArchEnum.X86: iomp_loaded = check_preloaded_libs("libiomp") if not iomp_loaded and self.vllm_config.speculative_config is not None: ...
fim
vllm-project/vllm
python
<|fim_suffix|>ith the same number of tokens. 3. Synchronizes cudagraph_mode across ranks by taking the minimum. Returns: tuple[ should_ubatch: Are all DP ranks going to microbatch num_tokens_after_padding: A tensor containing the total number of tokens per-microbatch for each DP rank i...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """ Define EC connector functionality mixin for model runners. """ from collections.abc import Generator from contextlib import AbstractContextManager, contextmanager, nullcontext from typing import...
fim
vllm-project/vllm
python
<|fim_suffix|>_stats() total_requests = self.graph_hits + self.graph_misses if total_requests > 0 and total_requests % self.log_stats_interval == 0: logger.debug( "Encoder CUDA graph cumulative stats: " "hits=%d, misses=%d, hit_rate=%.1f%%", st...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """Data transfer objects for encoder CUDA graph management.""" from collections.abc import Callable from dataclasses import dataclass, field import torch EncoderCudaGraphPaddingLogic = Callable[[t...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import contextlib import numpy as np import torch from vllm.v1.output<|fim_suffix|> self.is_valid = is_valid self.copy_event = torch.cuda.Event() with stream(copy_stream, main_stre...
fim
vllm-project/vllm
python
<|fim_suffix|>_metadata: ModelSpecificAttnMetadata | None = None, for_cudagraph_capture: bool = False, causal: bool = True, ) -> dict[str, Any]: seq_lens = seq_lens[:num_reqs] if dcp_local_seq_lens is not None: dcp_local_seq_lens = dcp_local_seq_lens[:num_reqs] if seq_lens_cpu_upper_bound is...
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 import torch from vllm.triton_utils import tl, triton from vllm.v1.attention.backends.utils import PAD_SLOT_ID from vllm.v1.worker.gpu.buffer_utils import Stage...
fim
vllm-project/vllm
python
<|fim_suffix|>_uva = self.write_indices.copy_to_uva(self._staged_write_indices) starts_uva = self.write_starts.copy_to_uva(self._staged_write_starts) cu_lens_uva = self.write_cu_lens.copy_to_uva(self._staged_write_cu_lens) # Special handling for write_contents write_contents = async_ten...
fim
vllm-project/vllm
python
<|fim_suffix|>, seq_lens, dcp_size, dcp_rank, cp_interleave, num_reqs, max_num_reqs, BLOCK_SIZE, ) @triton.jit def _dcp_local_seq_lens_kernel( out_ptr, seq_lens_ptr, dcp_size, dcp_rank, cp_interleave, num_reqs, max_num_reqs, B...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from collections import defaultdict from collections.abc import Callable from dataclasses import dataclass from typing import Any, NamedTuple, Protocol import torch import torch.nn as nn from tqdm i...
fim
vllm-project/vllm
python
<|fim_suffix|>dp = tensor[2] if torch.all(num_tokens_across_dp == 0).item(): synced_desc = BatchExecutionDescriptor( cg_mode=CUDAGraphMode.NONE, num_tokens=0, num_reqs=0 ) return synced_desc, None synced_cg_mode = CUDAGraphMode(int(cg_mode_across_dp.min().item())) # If...
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 functools import wraps from typing import Any import torch import torch.nn as nn from vllm.distributed.eplb.eplb_state import EplbState from vllm.logger i...
fim
vllm-project/vllm
python
<|fim_suffix|>shape[0] for actual request count num_reqs = idx_mapping.shape[0] num_speculative_steps = draft_tokens.shape[-1] logits_indices = torch.empty( num_logits, dtype=torch.int64, device=input_ids.device, ) _combine_sampled_and_draft_tokens_kernel[(num_reqs,)]( ...
fim
vllm-project/vllm
python
<|fim_suffix|>lock_ids_with_load_errors() output.kv_connector_stats = self.kv_connector.get_kv_connector_stats() output.kv_cache_events = self.kv_connector.get_kv_connector_kv_cache_events() output.kv_connector_worker_meta = ( self.kv_connector.build_connector_worker_meta() )...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import numpy as np from vllm.lora.request import LoRARequest NO_LORA_ID = 0 <|fim_suffix|>ra_request is not None: self.lora_requests[req_id] = lora_request self.lora_ids[re...
fim
vllm-project/vllm
python
<|fim_suffix|>rch.Tensor: num_reqs, vocab_size = logits.shape BLOCK_SIZE = 8192 num_nans = torch.empty(num_reqs, dtype=torch.int32, device=logits.device) _num_nans_kernel[(num_reqs,)]( logits, logits.stride(0), num_nans, vocab_size, BLOCK_SIZE=BLOCK_SIZE, ) ...
fim
vllm-project/vllm
python
<|fim_suffix|>str, mm_features: list[MultiModalFeatureSpec] ) -> None: self.mm_features[req_id] = mm_features def remove_request(self, req_id: str) -> None: self.mm_features.pop(req_id, None) def reset_mm_cache(self) -> None: """ Clear the multi-modal cache that was used du...
fim
vllm-project/vllm
python
<|fim_suffix|>olist() query_end = (computed_prefill_lens + num_scheduled_tokens).tolist() mm_embeds: list[torch.Tensor] = [] is_mm_embed = torch.zeros( total_num_scheduled_tokens, dtype=torch.bool, device="cpu" ) for i, req_id in enumerate(req_ids): if no...
fim
vllm-project/vllm
python
<|fim_suffix|>s(num_tokens) for num_tokens in encoder_token_counts ], dtype=np.int32, ), ) lora_manager.set_active_adapters( lora_requests, LoRAMapping( index_mapping=tuple(connector_token_mapping.tolist()), prompt_mapping=t...
fim
vllm-project/vllm
python
<|fim_suffix|>e, uva_instead_of_gpu=True, ) self.positions = torch.zeros( (num_dims, max_num_tokens + 1), dtype=torch.int64, device=device ) # Delta is non-zero for M-RoPE, always 0 for XD-RoPE. self.prefill_delta = UvaBackedTensor(max_num_reqs, dtype=tor...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """ NOTE: Coding style guide for this file: This model runner is shared by all models: text and multimodal, generative and embedding, public and private. As a result, this file must only contain code...
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 as nn from vllm.config import VllmConfig from vllm.v1.worker.gpu.mm.encoder_cache import EncoderCache def init_model_state( vllm_config: VllmConfig, model: nn....
fim
vllm-project/vllm
python
# SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from typing import Any import torch import torch.nn as nn from vllm.config import VllmConfig from vllm.config.compilation import CUDAGraphMode from vllm.tasks import GenerationTask from vllm.v1.core.sched.output...
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 typing import Any import torch import torch.nn as nn from vllm.config import VllmConfig from vllm.config.compilation import CUDAGraphMode from vllm.tasks im...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from dataclasses import dataclass from typing import Any import numpy as np import torch import torch.nn as nn from vllm.config import VllmConfig from vllm.config.compilation import CUDAGraphMode f...
fim
vllm-project/vllm
python
<|fim_suffix|> if has_cross_attn: seq_lens_by_group[kv_cache_group_idx] = ( encoder_seq_lens_gpu, encoder_seq_lens_np, ) return seq_lens_by_group <|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright co...
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 import torch from vllm.pooling_params import PoolingParams from vllm.v1.outputs import PoolerOutput from vllm.v1.pool.late_interaction import ( LATE_INTERAC...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from typing import cast import torch import torch.nn as nn import torch.nn.functional as F from vllm.model_executor.models import VllmModelForPooling, is_pooling_model from vllm.tasks import Poolin...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """Pipeline Parallelism utils for V2 Model Runner.""" from collections import deque from dataclasses import data<|fim_suffix|>ndices. idx_mapping_np = np.where(exclude_mask, -1, slot.idx...
fim
vllm-project/vllm
python
<|fim_suffix|>ise ValueError( f"Too many bad words: {num_bad_words}. " f"The max number is {MAX_NUM_BAD_WORDS}." ) # Flatten bad words and compute offsets flattened_tokens: list[int] = [] offsets: list[int] = [0] for bad_word in bad_words_toke...
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 HAS_TRITON, tl, triton # Smallest positive normal fp32 value. Used to clamp the uniform draw so that # `log(u)` cannot produce -inf (and thus `-log(-log(u...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import numpy as np import torch from vllm.sampling_params import SamplingParams from vllm.triton_utils import tl, triton from vllm.v1.worker.gpu.buffer_utils import StagedWriteTensor, UvaBackedTenso...
fim
vllm-project/vllm
python