text
stringlengths
14
100k
source
stringclasses
1 value
repo
stringclasses
810 values
language
stringclasses
13 values
<|fim_suffix|>read_configs in itertools.product( all_group_blocks, all_m_blocks, all_thread_configs ): thread_k, thread_n, threads = thread_configs if threads == 256: # for small batch (m_blocks == 1), # we only nee...
fim
vllm-project/vllm
python
<|fim_suffix|>, // same for k dimension (reduction) const bool m_block_size_8, // whether m_block_size == 8 // only works when thread_m_blocks == 1 const int stages, // number of stages for the async global->shared // fetch pipeli...
fim
vllm-project/vllm
c
<|fim_prefix|> #include "marlin_dtypes.cuh" namespace MARLIN_NAMESPACE_NAME { // m16n8k16 tensor core mma instruction with fp16 inputs and fp32 // output/accumulation. template <vllm::ScalarTypeId type_id, bool use_fp16_accum, int k_size = 16> __device__ inline void mma( const typename MarlinScalarType<type_id>::...
fim
vllm-project/vllm
c
<|fim_suffix|>hared memory load is fully complete (as it may otherwise be // overwritten). cp_async_wait<stages - 2>(); __syncthreads(); }; // Load the next sub-tile from the current location in the shared memory pipe // into the current register buffer. auto fetch_to_registers = [&](int k, int pip...
fim
vllm-project/vllm
c
<|fim_suffix|>t32_t version_num = get_sm_version_num(); STD_TORCH_CHECK( false, "Int8 not supported on SM", version_num, ". Use FP8 quantization instead, or run on older arch (SM < 100)."); } } } else { STD_TORCH_CHECK(a_scales.dim() == 2, "a scale must be 2d tensor."); ...
fim
vllm-project/vllm
cpp
#pragma once #include <torch/csrc/stable/tensor.h> namespace vllm { void cutlass_scaled_mm_sm90_fp8( torch::stable::Tensor& out, torch::stable::Tensor const& a, torch::stable::Tensor const& b, torch::stable::Tensor const& a_scales, torch::stable::Tensor const& b_scales, std::optional<torch::stable::T...
fim
vllm-project/vllm
cpp
<|fim_suffix|> double max_8bit, bool scale_ue8m0 = false); // Public op: register-resident packed quant for the DeepGEMM Blackwell path. // Restricted to group_size == 128 and bf16/fp16 input; other configurations // raise STD_TORCH_CHECK. The legacy shared-memory fallback was removed because // ...
fim
vllm-project/vllm
c
<|fim_prefix|>#include "ops.h" #include "cuda_utils.h" #include "core/registration.h" #include <torch/csrc/stable/library.h> // Register ops with STABLE_TORCH_LIBRARY for libtorch stable ABI compatibility. // Note: We register under namespace "_C" so ops are accessible as // torch.ops._C.<op_name> for compatibility w...
fim
vllm-project/vllm
cpp
<|fim_prefix|>#pragma once #include <torch/csrc/inductor/aoti_torch/c/shim.h> #include <torch/csrc/stable/accelerator.h> #include <torch/csrc/stable/ops.h> #include <torch/csrc/stable/tensor.h> #include <torch/headeronly/util/shim_utils.h> #include <cuda_runtime.h> #include <cublas_v2.h> #include <deque> #include <m...
fim
vllm-project/vllm
c
<|fim_suffix|>or k output (elements); 0 = contiguous void** workspace{}; void* allreduce_in{}; void* rms_norm_out{}; void* rms_gamma{}; void* allreduce_in_k{}; void* rms_norm_out_k{}; void* rms_gamma_k{}; float rms_eps{}; cudaStream_t stream{}; }; void minimax_reduce_rms_op(MiniMaxReduceRMSParams con...
fim
vllm-project/vllm
c
<|fim_prefix|>#include <ATen/ATen.h> #include <ATen/Parallel.h> #include <torch/all.h> // _dyn_quant_matmul_4bit is only available on AArch64. #if defined(__aarch64__) #include <ATen/ops/_dyn_quant_matmul_4bit.h> #endif inline torch::Tensor mm(const torch::Tensor& a, const torch::Tensor& packed_w, ...
fim
vllm-project/vllm
cpp
<|fim_suffix|>rch::Tensor dynamic_4bit_int_moe_cpu( torch::Tensor x, torch::Tensor topk_ids, torch::Tensor topk_weights, torch::Tensor w13_packed, torch::Tensor w2_packed, int64_t H, int64_t I, int64_t I2, int64_t group_size, bool apply_router_weight_on_input, int64_t activation_kind); using fptr_t = i...
fim
vllm-project/vllm
c
<|fim_prefix|>#pragma once #include <cstdint> #include <hip/hip_runtime.h> #include <hip/hip_fp16.h> #include <hip/hip_bf16.h> #define __quickreduce_device_inline__ __device__ __forceinline__ #define __quickreduce_launch_bounds_two_shot__ __launch_bounds__(256, 4) #define __quickreduce_launch_bounds_one_shot__ __laun...
fim
vllm-project/vllm
c
#pragma once #include <vector> #include <hip/hip_runtime.h> #include "quick_reduce_impl.cuh" #define HIP_CHECK(err) \ do { \ hipError_t err_ = (err); ...
fim
vllm-project/vllm
c
<|fim_prefix|>#pragma once #include <torch/all.h> torch::Tensor LLMM1(at::Tensor& in_a, at::Tensor& in_b, const int64_t rows_per_block); torch::Tensor wvSplitK(const at::Tensor& in_a, const at::Tensor& in_b, const std::optional<at::Tensor>& in_bias, c...
fim
vllm-project/vllm
c
<|fim_suffix|>CH_LIBRARY_EXPAND(TORCH_EXTENSION_NAME, rocm_ops) { // vLLM custom ops for rocm // Custom gemm op for matrix-vector multiplication rocm_ops.def( "LLMM1(Tensor in_a, Tensor in_b, int rows_per_block) -> " "Tensor"); rocm_ops.impl("LLMM1", torch::kCUDA, &LLMM1); // Custom gemm op for ...
fim
vllm-project/vllm
cpp
<|fim_prefix|>#include <Python.h> extern "C" { #include <stdbool.h> #include <time.h> #if defined(__i386__) || defined(__x86_64__) #include <cpuid.h> #include <mwaitxintrin.h> #endif #if defined(CLOCK_MONOTONIC_RAW) #define TIMEOUT_CLOCK CLOCK_MONOTONIC_RAW #else #define TIMEOUT_CLOCK CLOCK_MONOTONIC #endif...
fim
vllm-project/vllm
cpp
<|fim_suffix|>weak_ref_tensor); #ifdef USE_ROCM // TODO: Remove this once we upgrade to torch 2.11. // ROCm still uses torch 2.10, // So we still need to use unstable torch ABI for now. ops.def("get_cuda_view_from_cpu_tensor(Tensor cpu_tensor) -> Tensor"); ops.impl("get_cuda_view_from_cpu_tensor", torch::kCP...
fim
vllm-project/vllm
cpp
#pragma once // Shared TORCH_UTILS_CHECK across both libtorch stable and unstable source // files. Keep this header free of CUTLASS/CUTE so attention/quant headers can // use it. // // If TORCH_TARGET_VERSION is defined, we are building _C_stable_libtorch.so so // use STD_TORCH_CHECK via header-only. // Otherwise, use...
fim
vllm-project/vllm
c
<|fim_suffix|>le_names = _index_file(filepath) for name, qualified in file_names.items(): if name not in index or module_depth < depth[name]: index[name] = qualified depth[name] = module_depth return index def on_startup(*, command: str, dirty: bool) -> None: ...
fim
vllm-project/vllm
python
<|fim_suffix|>fix = "#" * starting_heading_level self._argument_heading_prefix = "#" * (starting_heading_level + 1) self._markdown_output = [] def start_section(self, heading: str): if heading not in {"positional arguments", "options"}: heading_md = f"\n{self._section_heading_pr...
fim
vllm-project/vllm
python
# SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import itertools import logging from dataclasses import dataclass from functools import cached_property from pathlib import Path from typing import Literal import regex as re logger = logging.getLogger("mkdocs")...
fim
vllm-project/vllm
python
<|fim_suffix|> """Extract string value from an AST node.""" if isinstance(node, ast.Constant): return str(node.value) if node.value is not None else None return None def extract_metrics_from_file(filepath: Path) -> list[dict[str, str]]: """Parse a Python file and extract all me...
fim
vllm-project/vllm
python
<|fim_suffix|>main.html" # The file might be removed already if the build is triggered multiple # times (readthedocs build both HTML and PDF versions separately) if announcement_path.exists(): os.remove(announcement_path) <|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-Fil...
fim
vllm-project/vllm
python
<|fim_suffix|>g, files: Files ) -> str: """Pass the current page context to the preprocessor.""" _ext.page = page return markdown <|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """ MkDocs hook + markdown extension to enable the follow...
fim
vllm-project/vllm
python
<|fim_prefix|>/** * edit_and_feedback.js * * Enhances MkDocs Material docs pages by: * * 1. Adding a "Question? Give us feedback" link * below the "Edit"<|fim_suffix|>.com/vllm-project/vllm/issues/new?template=100-documentation.yml&title=${encodeURIComponent( `[Docs] Feedback for \`${page}\`` )}&body=${e...
fim
vllm-project/vllm
javascript
<|fim_suffix|>pesetClear() MathJax.texReset() MathJax.typesetPromise() }) <|fim_prefix|>// Enables MathJax rendering window.MathJax = { tex: { inlineMath: [["\\(", "\\)"]], displayMath: [["\\<|fim_middle|>[", "\\]"]], processEscapes: true, processEnvironments: true }, options: { ignoreHtml...
fim
vllm-project/vllm
javascript
<|fim_suffix|>ript" script.src = "https://widget.runllm.com"; script.setAttribute("version", "stable"); script.setAttribute("runllm-keyboard-shortcut", "Mod+j"); // cmd-j or ctrl-j to open the widget. script.setAttribute("runllm-name", "vLLM"); script.setAttribute("runllm-position", "BOTTOM_RI...
fim
vllm-project/vllm
javascript
/** * slack_and_forum.js * * Adds a custom Slack and Forum button to the MkDocs Material header. * */ window.addEventListener('DOMContentLoaded', () => { const headerInner = document.querySelector('.md-header__inner'); if (headerInner) { const slackButton = document.createElement('button'); slackButt...
fim
vllm-project/vllm
javascript
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """Example Python client for `vllm.entrypoints.api_server` Start the demo server: python -m vllm.entrypoints.api_server --model <model_name> NOTE: The API server is used only for demonstration a...
fim
vllm-project/vllm
python
<|fim_suffix|> parser = argparse.ArgumentParser( description="Chatbot Interface with Customizable Parameters" ) parser.add_argument( "--model-url", type=str, default="http://localhost:8000/v1", help="Model URL" ) parser.add_argument( "-m", "--model", type=str, required=True, ...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """Example for starting a Gradio Webserver Start vLLM API server: python -m vllm.entrypoints.api_server \ --model meta-llama/Llama-2-7b-chat-hf Start Webserver: python examples/appli...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """ vLLM Chat Assistant - A Streamlit Web Interface A streamlined chat interface that quickly integrates with vLLM API server. Features: - Multiple chat sessions management - Streaming response dis...
fim
vllm-project/vllm
python
<|fim_suffix|>eak output = qa_chain.invoke(question) print(output) else: # Default single question mode question = "How to install vLLM?" output = qa_chain.invoke(question) print("-" * 50) print(output) print("-" * 50) if __name__ == "__main...
fim
vllm-project/vllm
python
<|fim_suffix|> else: # Single query mode question = "How to install vLLM?" response = query_document(index, question, config["top_k"]) print("-" * 50) print("Response:\n") print(response) print("-" * 50) if __name__ == "__main__": main() <|fim_prefix|># SP...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from vllm import LLM, SamplingParams # Sample prompts. prompts = [ "Hello, my name is", "The president of the United States is", <|fim_suffix|> outputs = llm.generate(prompts, sampling...
fim
vllm-project/vllm
python
<|fim_suffix|>in(args: dict): # Pop arguments not used by LLM max_tokens = args.pop("max_tokens") temperature = args.pop("temperature") top_p = args.pop("top_p") top_k = args.pop("top_k") chat_template_path = args.pop("chat_template_path") # Create an LLM llm = LLM(**args) # Create...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from argparse import Namespace from vllm import LLM, EngineArgs from vllm.utils.argparse_utils import FlexibleArgumentParser def parse_args(): parser = FlexibleArgumentParser() parser = E...
fim
vllm-project/vllm
python
<|fim_suffix|>tal of France is", "The future of AI is", ] # Create an LLM. # You should pass runner="pooling" for embedding models llm = LLM(**vars(args)) # Generate embedding. The output is a list of EmbeddingRequestOutputs. outputs = llm.embed(prompts) # Print the outputs. p...
fim
vllm-project/vllm
python
<|fim_suffix|>ing_params.temperature = temperature if top_p is not None: sampling_params.top_p = top_p if top_k is not None: sampling_params.top_k = top_k # Generate texts from the prompts. The output is a list of RequestOutput # objects that contain the prompt, generated text, and othe...
fim
vllm-project/vllm
python
<|fim_suffix|>ngineArgs.add_cli_args(parser) # Set example specific arguments parser.set_defaults( model="BAAI/bge-reranker-v2-m3", runner="pooling", enforce_eager=True, ) return parser.parse_args() def main(args: Namespace): # Sample prompts. query = "What is the capit...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """Example Python client for OpenAI Chat Completion using vLLM API server NOTE: start a supported chat completion model server with `vllm serve`, e.g. vllm serve meta-llama/Llama-2-7b-chat-hf """...
fim
vllm-project/vllm
python
<|fim_suffix|> in completion: print(c) else: print(completion) print("-" * 50) if __name__ == "__main__": args = parse_args() main(args) <|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import argparse from o...
fim
vllm-project/vllm
python
<|fim_suffix|>eep(0.5) print("\n🎉 All streaming examples completed!") finally: # Always clean up the engine print("🔧 Shutting down engine...") engine.shutdown() if __name__ == "__main__": try: asyncio.run(main()) except KeyboardInterrupt: print("\n🛑 Int...
fim
vllm-project/vllm
python
<|fim_suffix|>s = create_test_prompts() process_requests(engine, test_prompts) if __name__ == "__main__": args = parse_args() main(args) <|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """ This file demonstrates using the `LLMEngine`...
fim
vllm-project/vllm
python
<|fim_prefix|>#!/usr/bin/env python3 # SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """ disagg_encoder_proxy.py Proxy that routes OpenAI-compatible “/v1/chat/completions” requests to two clusters: • encode (multimodal feature extraction) • decode (langu...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """ This file provides a disaggregated prefilling proxy demo to demonstrate an example usage of XpYd disaggregated prefi<|fim_suffix|> raise ValueError( f"Error communicating wi...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """ Disaggregated Prefill/Decode Proxy with Bidirectional KV Transfer This proxy sits between clients and a vLLM Prefill/Decode (P/D) deployment, routing multi-turn chat requests so that each turn r...
fim
vllm-project/vllm
python
<|fim_suffix|>s") except HTTPException: raise except Exception: exc_info = sys.exc_info() error_messages = [str(e) for e in exc_info if e] print("Error occurred in disagg push proxy server") print(error_messages) return StreamingRes...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright co<|fim_suffix|> render_data = render_resp.json() print(f"Response keys: {list(render_data.keys())}") print(f"Number of token_ids: {len(render_data['token_ids'])}") features = render_data.get("features") if feature...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import argparse import asyncio import copy import logging import os import socket import threading import uuid from urllib.parse import urlparse import aiohttp import msgpack import zmq from quart i...
fim
vllm-project/vllm
python
<|fim_suffix|>prompt!r}\nGenerated text: {generated_text!r}") print("-" * 30) if __name__ == "__main__": main() <|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from vllm import LLM, SamplingParams from vllm.config import KVTransferC...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from vllm import LLM, SamplingParams from vllm.config import KVTransferConfig def read_prompts(): context = "Hi " * 1000 context2 = "Hey " * 500 return [ context + "Hello, my n...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """ This example shows how to use FlexKV with vLLM for prefix caching. FlexKV is a distributed KV Store and multi-level cache management system for ultra-large-scale LLM inference. Requirements: ...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import argparse from vllm import LLM, SamplingParams from vllm.config import KVTransferConfig def read_prompts(): """Read prompts from prefill_output.txt""" prompts = [] try: w...
fim
vllm-project/vllm
python
<|fim_suffix|>None, set[str] | None]: if self._async_load: meta = self._get_connector_metadata() assert isinstance(meta, LoadRecoveryExampleConnectorMetadata) if meta.req_to_block_ids: return None, set(meta.req_to_block_ids) return None, None def...
fim
vllm-project/vllm
python
<|fim_suffix|>ate( prompts, sampling_params, ) new_prompts = [] print("-" * 30) for output in outputs: prompt = output.prompt generated_text = output.outputs[0].text new_prompts.append(prompt + generated_text) print(f"Prompt: {prompt!r}\nGenerated text: {...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """ This file demonstrates the example usage of cpu offloading with LMCache in vLLM v1 or v0. Usage: Specify vLLM version -v v0 : Use LMCacheConnector model = mistralai/Mistral...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """ This file demonstrates the example usage of disaggregated prefilling with LMCache. We will launch 2 vllm instances (GPU 0 for prefill and GPU 1 for decode), and launch an additional LMCache serve...
fim
vllm-project/vllm
python
<|fim_suffix|>eamingResponse(generate_stream(), media_type="text/event-stream") except Exception as e: import sys import traceback exc_info = sys.exc_info() print("Error occurred in disagg prefill proxy server - completions endpoint") print(e) print("".join(tracebac...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """ This file demonstrates the example usage of remote KV cache sharing with LMCache. We will launch 2 vllm instances, and launch an additional LMCache server. KV cache is transferred in the followin...
fim
vllm-project/vllm
python
<|fim_suffix|>uthorization": f"Bearer {os.environ.get('OPENAI_API_KEY')}", "X-Request-Id": request_id, } req_data["kv_transfer_params"] = { "do_remote_decode": False, "do_remote_prefill": True, "remote_bootstrap_addr": prefill_client_info["bootstrap_addr"], "remote_engin...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """ Demonstration script for Automatic Prefix Caching (APC) in vLLM. Automatic Prefix Caching (APC) allows the vLLM engine to reuse cached KV (key-value) pairs from previous prompts if a new query s...
fim
vllm-project/vllm
python
<|fim_suffix|>rated_same = all( [ regular_generated_texts[i] == cached_generated_texts[i] for i in range(len(prompts)) ] ) print(f"Generated answers are the same: {generated_same}") if __name__ == "__main__": main() <|fim_prefix|># SPDX-License-Identifier: Apache-2....
fim
vllm-project/vllm
python
<|fim_suffix|>0) # Try generating random numbers outside vLLM # The same number is output across runs, meaning that the random state # in the user code has been updated by vLLM print(random.randint(0, 100)) if __name__ == "__main__": main() <|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SP...
fim
vllm-project/vllm
python
<|fim_suffix|>at(llm) print_outputs(outputs, conversations) if __name__ == "__main__": main() <|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCo<|fim_middle|>pyrightText: Copyright contributors to the vLLM project """ This script demonstrates how to extend the context length of a Qwen model usi...
fim
vllm-project/vllm
python
<|fim_suffix|>isible by dp_num_nodes" dp_per_node = dp_size // dp_num_nodes from multiprocessing import Process if current_platform.is_rocm(): from multiprocessing import set_start_method set_start_method("spawn", force=True) procs = [] for local_dp_rank, global_dp_rank in enumer...
fim
vllm-project/vllm
python
<|fim_suffix|>tedLoggingStatLogger], ) stop_logging_event = threading.Event() logging_thread = threading.Thread( target=_do_background_logging, args=(engine_client, 5, stop_logging_event), daemon=True, ) logging_thread.start() sampling_params = SamplingParams( tem...
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 msgspec import zmq from msgspec.msgpack import Decoder from vllm.v1.core.kv_cache_utils import ExternalBlockHash # # Types copied from vllm.distributed.kv_events # c...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """This example demonstrates instantiating vLLM with a custom logits processor class object. For a basic example of implementing a custom logits processor, see the `DummyLogitsProcessor` implementa...
fim
vllm-project/vllm
python
# SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """This example demonstrates wrapping a request-level logits processor to be compatible with vLLM's batch-level logits processing For demo purposes, a dummy logits processor is employed which, if `target_token` ...
fim
vllm-project/vllm
python
<|fim_suffix|>e` request logits processor, or None """ if ( not self.is_cuda or ( target_token := params.extra_args and params.extra_args.get("target_token") ) is None ): return None return DummyP...
fim
vllm-project/vllm
python
# SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """ This example shows how to use LoRA with different quantization techniques for offline inference. Requires HuggingFace credentials for access. """ import gc import torch from huggingface_hub import snapshot_...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """ This example shows how to use the multi-LoRA functionality for offline inference. Requires HuggingFace credentials for access to Llama2. """ from huggingface_hub import snapshot_download from ...
fim
vllm-project/vllm
python
# SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """ Test pause/resume with Data Parallel (DP) via HTTP API. This example demonstrates coordinated pause/resume across multiple DP ranks. The pause synchronizes across all DP engines via all-reduce. Prerequisites...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """Test for pause/resume with keep mode. This test uses concurrent tasks to verify the engine truly stops generating during pause: 1. Generator task: continuously generates and logs time between tok...
fim
vllm-project/vllm
python
# SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from __future__ import annotations from vllm import LLM, EngineArgs from vllm.config import ProfilerConfig from vllm.utils.argparse_utils import FlexibleArgumentParser DEFAULT_MAX_TOKENS = 16 def create_parse...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import time from vllm import LLM, SamplingParams # Sample prompts. prompts = [ "Hello, my name is", "The president of the United States is", "The capital of France is", "The future...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """vLLM OpenAI-Compatible Client with Prompt Embeddings. This script demonstrates how to: 1. Generate prompt embeddings using Hugging Face Transformers. 2. Encode them in base64 format. 3. Send them...
fim
vllm-project/vllm
python
# SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """ Demonstrates how to generate prompt embeddings using Hugging Face Transformers and use them as input to vLLM for both single and batch inference. Model: meta-llama/Llama-3.2-1B-Instruct Note: This model is g...
fim
vllm-project/vllm
python
<|fim_suffix|>eset_running_requests=True) request_outputs: list[RequestOutput] = engine.step() for request_output in request_outputs: if request_output.finished: print("-" * 50) print(request_output) print("-" * 50) step_id += 1 def...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """ Validates the loading of a model saved with the sharded_state format. This script demonstrates how to load a model that was previously saved using save_sharded_state_offline.py and validates it b...
fim
vllm-project/vllm
python
<|fim_suffix|>must be a local directory") # Create LLM instance from arguments llm = LLM.from_engine_args(engine_args) # Prepare output directory Path(args.output).mkdir(exist_ok=True) # Dump worker states to output directory llm.llm_engine.engine_core.save_sharded_state( path=args.outp...
fim
vllm-project/vllm
python
<|fim_suffix|> max_tokens=10, extra_args={ "kv_transfer_params": { "hidden_states_path": os.path.join( tmpdirname, "custom_output.safetensors" ), "include_output_tokens": True, } ...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """ This file demonstrates the usage of text generation with an LLM model, comparing the performance with and without speculative decoding. Note that this example is out of date and not supported in...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from transformers import AutoTokenizer from vllm import LLM, SamplingParams from vllm.benchmarks.datasets import add_dataset_parser, get_samples from vllm.utils.argparse_utils import FlexibleArgume...
fim
vllm-project/vllm
python
<|fim_prefix|># ruff: noqa: E501 # SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import argparse import asyncio import enum import os from typing import Any, Literal import openai import pydantic from openai.types.chat import ChatCompletionChunk ConstraintsFo...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """ This file demonstrates the example usage of structured outputs in vLLM. It shows how to apply different constraints such as choice, regex, json schema, and grammar to produce structured and forma...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import json import logging import os import uuid from vllm import LLM, SamplingParams from vllm.engine.arg_utils import EngineArgs from vllm.lora.request import LoRARequest from vllm.model_executor...
fim
vllm-project/vllm
python
<|fim_suffix|>}\n" ) """ Further tips: 1. to communicate control messages across all ranks, use the cpu group, a PyTorch ProcessGroup with GLOO backend. ```python from vllm.distributed.parallel_state import get_world_group cpu_group = get_world_group().cpu_group torch_rank = dist.get_rank(group=cpu_group) if tor...
fim
vllm-project/vllm
python
<|fim_suffix|>icate control messages across all ranks, use the cpu group, a PyTorch ProcessGroup with GLOO backend. ```python from vllm.distributed.parallel_state import get_world_group cpu_group = get_world_group().cpu_group torch_rank = dist.get_rank(group=cpu_group) if torch_rank == 0: # do something for rank 0...
fim
vllm-project/vllm
python
<|fim_suffix|>ion": "Number of pages in the book", }, "short_summary": { "type": "string", "description": "A one-sentence summary of the book", }, "long_summary": { "type": "string", "description": ( ...
fim
vllm-project/vllm
python
<|fim_suffix|>mistral_common.audio import Audio from mistral_common.protocol.instruct.chunk import ( AudioChunk, RawAudio, TextChunk, ) from mistral_common.protocol.instruct.messages import ( UserMessage, ) from mistral_common.protocol.instruct.request import ChatComp...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """ This example shows how to use vLLM for running offline inference with the explicit/implicit prompt format on enc-dec LMMs for text generation. """ import os import time from collections.abc impo...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project # ruff: noqa import argparse from vllm import LLM from vllm.sampling_params import SamplingParams from vllm.assets.image import ImageAsset from vllm.multimodal.utils import encode_image_url # This...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """An example showing how to use vLLM to serve multimodal models and run online serving with OpenAI client. Launch the vLLM server with the following command: (single image inference with Llava) vl...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """ This example shows how to use vLLM for running offline inference with the correct prompt format on Qwen2.5-Omni (thinker only). """ from typing import NamedTuple from vllm import LLM, SamplingP...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """ This example shows how to use vLLM for running offline inference with the correct prompt format on Qwen3-Omni (thinker only). """ from typing import NamedTuple from vllm import LLM, SamplingPar...
fim
vllm-project/vllm
python
<|fim_suffix|>_template( messages, tokenize=False, add_generation_prompt=True ) image_data = [fetch_image(url) for url in image_urls] return ModelRequestData( engine_args=engine_args, prompt=prompt, image_data=image_data, ) def load_kimi_vl(question: str, image_urls: ...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """ This example shows how to use vLLM for running offline inference with the correct prompt format on vision language models for text generation. For most models, the prompt format should follow co...
fim
vllm-project/vllm
python