text
stringlengths
14
100k
source
stringclasses
1 value
repo
stringclasses
810 values
language
stringclasses
13 values
<|fim_suffix|>for empty args supports_typed_arguments: True if the parser supports typed function arguments """ # Parser identification parser_name: str # Test data - model outputs for each common test no_tool_calls_output: str single_tool_call_output: str parallel_tool_calls_outpu...
fim
vllm-project/vllm
python
# SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import pytest from transformers import AutoTokenizer from vllm.tokenizers import TokenizerLike @pytest.fixture(scope="module") def default_tokenizer() -> TokenizerLike: return AutoTokenizer.from_pretrained...
fim
vllm-project/vllm
python
<|fim_suffix|> = self._collect_tool_calls(results) assert len(tc) == 2 assert tc[0]["name"] == "get_weather" assert json.loads(tc[0]["arguments"]) == {"location": "London"} assert tc[1]["name"] == "get_time" assert json.loads(tc[1]["arguments"]) == {"location": "Paris"} def ...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import pytest from vllm.tokenizers import get_tokenizer from vllm.tool_parsers.deepseekv31_tool_parser import ( DeepSeekV31ToolParser, ) MODEL = "deepseek-ai/DeepSeek-V3.1" @pytest.fixture(s...
fim
vllm-project/vllm
python
# SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """Unit tests for DeepSeekV32ToolParser. These tests use a minimal mock tokenizer so no real model weights are required. """ import json from unittest.mock import MagicMock import pytest from openai.types.resp...
fim
vllm-project/vllm
python
<|fim_suffix|>nstreaming={ "test_malformed_input": ( "Parser sets tools_called=True even when tool_calls is " "empty (detects start token but fails to parse)" ), }, ) <|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-Fi...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """Unit tests for DeepSeekV4ToolParser.""" import json from unittest.mock import MagicMock import pytest from xgrammar import StructuralTag from vllm.entrypoints.openai.chat_completion.protocol i...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project # ruff: noqa: E501 import json from collections.abc import Generator import pytest from vllm.entrypoints.openai.chat_completion.protocol import ChatCompletionRequest from vllm.entrypoints.openai.e...
fim
vllm-project/vllm
python
<|fim_suffix|>buffer_delta_text("hello") assert result == "hello" assert parser.buffered_delta_text == "" def test_complete_tag_flushed(self, parser): parser.buffered_delta_text = "<start_function_" result = parser._buffer_delta_text("call>") assert "<start_function_call>" i...
fim
vllm-project/vllm
python
<|fim_suffix|>nts) assert args == {"is_active": True, "count": 42, "score": 3.14} def test_incomplete_tool_call(self, parser, mock_request): model_output = '<|tool_call>call:get_weather{location:<|"|>London' result = parser.extract_tool_calls(model_output, mock_request) # Incomplet...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import json import pytest from transformers import AutoTokenizer from tests.tool_parsers.utils import ( run_tool_extraction, run_tool_extraction_streaming, ) from vllm.entrypoints.openai.e...
fim
vllm-project/vllm
python
<|fim_suffix|>ll>", ] current_text = "" for chunk in chunks: current_text += chunk glm47_tool_parser.extract_tool_calls_streaming( previous_text="", current_text=current_text, delta_text=chunk, previous_token...
fim
vllm-project/vllm
python
<|fim_suffix|>"".join(tools_found[0]["args_fragments"])) assert args == {"city": "Beijing"} def test_stream_interval_extreme_single_chunk(glm4_moe_tokenizer): """Extreme MTP: entire output arrives in one chunk (interval=9999).""" tools = [ ChatCompletionToolsParam( function=FunctionDef...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import json import random from typing import Any import pytest from transformers import AutoTokenizer from vllm.entrypoints.openai.chat_completion.protocol import ChatCompletionRequest from vllm.en...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import pytest from tests.tool_parsers.common_tests import ( ToolParserTestConfig, ToolParserTests, ) class TestGranite20bFcToolParser(ToolParserTests): @pytest.fixture def test_co...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import pytest from tests.tool_parsers.common_tests import ( ToolParserTestConfig, ToolParserTests, ) from tests.tool_parsers.utils import run_tool_extraction class TestGraniteToolParser(...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import json import pytest from vllm.entrypoints.openai.chat_completion.protocol import ChatCompletionRequest from vllm.tokenizers import TokenizerLike from vllm.tool_parsers.abstract_tool_parser i...
fim
vllm-project/vllm
python
<|fim_suffix|>")( mock_tokenizer ) reconstructor = run_tool_extraction_streaming( tool_parser, model_deltas, assert_one_tool_per_delta=False ) # align the random id. for idx in range(len(reconstructor.tool_calls)): reconstructor.tool_calls[idx].id = expected_tool_calls[idx]....
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project # ruff: noqa: E501 """Tests for the HYV3 tool call parser.""" import json from unittest.moc<|fim_suffix|> assert r.tools_called assert r.tool_calls[0].function.name == "get_current_date" ...
fim
vllm-project/vllm
python
<|fim_suffix|> xfail_streaming={ "test_single_tool_call_simple_args": ( "InternLM2 streaming not fully implemented" ), "test_parallel_tool_calls": ( "InternLM2 streaming not fully implemented" ), ...
fim
vllm-project/vllm
python
<|fim_suffix|>_tool_calls( model_output, request=None ) # type: ignore[arg-type] assert not extracted_tool_calls.tools_called assert extracted_tool_calls.tool_calls == [] assert extracted_tool_calls.content == model_output @pytest.mark.parametrize( ids=[ "single_tool", "si...
fim
vllm-project/vllm
python
<|fim_suffix|>1" assert json.loads(rec.tool_calls[1].function.arguments) == {"city": "NYC"} def test_content_before_tools(self, parser): """Content before section is streamed; markers/args don't leak.""" deltas = _split_tool_output_to_deltas( "I'll check the weather. ", ...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from unittest.mock import MagicMock, patch import pytest from transformers import AutoTokenizer from tests.tool_parsers.utils <|fim_suffix|>nizerLike, ): tool_parser: ToolParser = ToolParserMa...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from unittest.mock import MagicMock, patch import pytest from transformers import AutoTokenizer from vllm.entrypoints.openai.engine.protocol import ExtractedToolCallInformation from vllm.tool_pars...
fim
vllm-project/vllm
python
<|fim_suffix|> = run_tool_extraction_streaming( tool_parser, model_output_deltas, assert_one_tool_per_delta=False ) assert reconstructor.other_content == "" assert len(reconstructor.tool_calls) == 3 assert reconstructor.tool_calls[0].function == SIMPLE_FUNCTION_CALL assert reconstructor.too...
fim
vllm-project/vllm
python
<|fim_suffix|>he result." ), escaped_strings_output="""<longcat_tool_call>{ "name": "test_function", "arguments": { "quoted": "He said \\"hello\\"", "path": "C:\\\\Users\\\\file.txt", "newline": "line1\\nline2", "unicode": "emoji: 🎉" } }</longcat_tool_call>""", ...
fim
vllm-project/vllm
python
<|fim_suffix|>ls_called assert out.content is not None assert "\u0120" not in out.content assert "\u010a" not in out.content assert "First, I need to check the weather." in out.content def test_properties_wrapped_arguments(parser: ToolParser) -> None: tools = [ _tool( "get_cust...
fim
vllm-project/vllm
python
<|fim_suffix|>t parser.prev_tool_call_arr[1]["arguments"] == {"q": "world"} # --------------------------------------------------------------------------- # DeltaMessage structure # --------------------------------------------------------------------------- class TestDeltaMessageFormat: """Verify the shape of em...
fim
vllm-project/vllm
python
<|fim_suffix|>er-by-character test passed") <|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project # ruff: noqa: E501 import json from typing import Any import pytest from vllm.entrypoints.openai.chat_completion.protocol import ( ChatCompletionToo...
fim
vllm-project/vllm
python
<|fim_suffix|>ken_id. fake_token_ids = list(range(99, 99 + fake_count)) if two_phase: # First delta: pure content, no bot token yet delta_message_before = parser.extract_tool_calls_streaming( previous_text="", current_text="Hello", delta_text="Hello", ...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from unittest.mock import MagicMock, patch import pytest from tests.tool_parsers.utils import ( run_tool_extraction, run_tool_extraction_streaming, ) from vllm.entrypoints.openai.engine.pr...
fim
vllm-project/vllm
python
# SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from unittest.mock import MagicMock import pytest from tests.tool_parsers.common_tests import ( ToolParserTestConfig, ToolParserTests, ) from vllm.tokenizers import TokenizerLike class TestPhi4MiniToo...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from unittest.mock import MagicMock, patch import pytest from tests.tool_parsers.utils i<|fim_suffix|>NCTION_OUTPUT}]", [SIMPLE_FUNCTION_CALL, MORE_TYPES_FUNCTION_CALL], id="parall...
fim
vllm-project/vllm
python
<|fim_suffix|>ool_calls, expected_tool_calls ): # Qwen3 parser doesn't generate IDs during extraction assert actual_tool_call.type == "function" assert actual_tool_call.function.name == expected_tool_call.function.name assert json.loads(actual_tool_call.function.arguments) == json.lo...
fim
vllm-project/vllm
python
<|fim_suffix|> if delta is not None: deltas.append(delta) names = [ tool_call.function.name for delta in deltas for tool_call in delta.tool_calls or [] if tool_call.function is not None and tool_call.function.name is not None ] assert names == [name for n...
fim
vllm-project/vllm
python
<|fim_suffix|> """optional. The user provided "Barcelona Spain" as the location, which fits the required format (city, """ """country). \n<seed:cot_budget_reflect>I have used 131 tokens, and there are 381 tokens remaining for use.""" """</seed:cot_budget_reflect>\n Since the unit isn\'t spec...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import pytest from tests.tool_parsers.common_tests import ( ToolParserTestConfig, ToolParserTests, ) from vllm.tokenizers import TokenizerLike, get_tokenizer class TestStep3ToolParser(To...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import json from collections.abc import Generator import pytest from vllm.entrypoints.openai.chat_completion.protocol import ( ChatCompletionRequest, ChatCompletionToolsParam, ) from vllm....
fim
vllm-project/vllm
python
<|fim_suffix|> "json_schema": { "type": "object", "properties": {"city": {"type": "string"}}, "required": ["city"], }, "style": "json", }, ...
fim
vllm-project/vllm
python
<|fim_suffix|> def test_integer_tried_before_string(self): assert coerce_to_schema_type("42", ["integer", "string"]) == 42 def test_falls_through_to_string(self): assert coerce_to_schema_type("hello", ["integer", "string"]) == "hello" class TestFallback: def test_unknown_ty...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import json from collections.abc import Generator import pytest from vllm.entrypoints.openai.chat_completion.protocol import ChatCompletionRequest from vllm.entrypoints.openai.engine.protocol impo...
fim
vllm-project/vllm
python
<|fim_suffix|>tructor.other_content or None, reconstructor.tool_calls else: extracted = run_tool_extraction_nonstreaming(tool_parser, model_output, request) assert extracted.tools_called == bool(extracted.tool_calls) return extracted.content, extracted.tool_calls def run_tool_extraction_no...
fim
vllm-project/vllm
python
# SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import pytest import pytest_asyncio from huggingface_hub import snapshot_download from tests.utils import RemoteOpenAIServer from vllm.platforms import current_platform from .utils import ARGS, CONFIGS, ServerC...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # <|fim_suffix|>e model and return the config @pytest.fixture(scope="package", params=CONFIGS.keys()) def server_config(request): config = CONFIGS[request.param] if current_platform.is_rocm() and not config.get("supports_rocm", True): pytest.skip( ...
fim
vllm-project/vllm
python
<|fim_suffix|> ) # Pre-v11 models lack grammar enforcement, so the model may still # emit tool calls even with tool_choice="none". pre_v11 = _is_pre_v11(server_config) result = await _collect_streamed_content(stream, no_tool_calls=not pre_v11) assert result.finish_reason_count == 1 if not ...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from tests.tool_use.utils import ServerConfig ARGS<|fim_suffix|> "--no-enable-prefix-caching", ], "system_prompt": "You are a helpful assistant with access to tools. If a too...
fim
vllm-project/vllm
python
<|fim_suffix|>sistant_msg.get("reasoning") is None assert "reasoning_content" not in assistant_msg SAMPLE_TOOL = { "type": "function", "function": { "name": "get_weather", "description": "Get the weather", "parameters": { "type": "object", "properties": {"lo...
fim
vllm-project/vllm
python
# SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import openai import pytest from .utils import ( MESSAGES_WITHOUT_TOOLS, SEED, WEATHER_TOOL, ServerConfig, ensure_system_prompt, ) # test: make sure chat completions without tools provided ...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """Regression tests for Responses API tool-calling request adjustment. Covers two bugs on the ``/v1/responses`` path that broke streaming tool calling for parsers relying on special-token delimiters...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import json import openai import pytest from .utils import ( MESSAGES_ASKING_FOR_PARALLEL_TOOLS, MESSAGES_WITH_PARALLEL_TOOL_RESPONSE, SEARCH_TOOL, SEED, WEATHER_TOOL, Serv...
fim
vllm-project/vllm
python
<|fim_suffix|>oice": "auto", } ) assert request.tool_choice == "auto" def test_responses_request_with_tools_tool_choice_required(): request = ResponsesRequest.model_validate( { "input": "Hello", "model": "test-model", "tools": [SAMPLE_TOOL], ...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import json import openai import pytest from .utils import ( MESSAGES_ASKING_FOR_TOOLS, MESSAGES_WITH_TOOL_RESPONSE, SEARCH_TOOL, SEED, WEATHER_TOOL, ServerConfig, ensu...
fim
vllm-project/vllm
python
<|fim_suffix|>=should_match ) @pytest.mark.parametrize("output", VALID_TOOLS) @pytest.mark.parametrize("empty_params", [False, True]) @pytest.mark.parametrize("delta_len", [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) def test_streaming_output_valid(output, empty_params, delta_len): output = deepcopy(output) if empty_...
fim
vllm-project/vllm
python
<|fim_suffix|> "model": "meta-llama/Llama-4-Scout-17B-16E-Instruct", "arguments": [ "--enforce-eager", "--no-enable-prefix-caching", "--tool-call-parser", "llama4_pythonic", "--chat-template", str(VLLM_PATH / "examples/tool_chat_templ...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import ast import pytest from tools.pre_commit.validate_config import validate_ast _TestConfig1 = ''' @config class _TestConfig1: a: int """docstring""" ''' _TestConfig2 = """ @config cl...
fim
vllm-project/vllm
python
<|fim_suffix|>IMAGE_TAG", "VLLM_BUILD_COMMIT=${VLLM_BUILD_COMMIT:-unknown}", "VLLM_BUILD_PIPELINE=${VLLM_BUILD_PIPELINE:-local}", "VLLM_BUILD_URL=${VLLM_BUILD_URL:-}", "VLLM_IMAGE_TAG=${VLLM_IMAGE_TAG:-local/vllm-openai:dev}", 'ai.vllm.build.commit="${VLLM_BUILD_COMMIT}"', ...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import threading from collections.abc import Callable, Generator, Iterable from concurrent import futures from typing import Any, Literal import grpc import pytest from opentelemetry.proto.collector...
fim
vllm-project/vllm
python
# SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import asyncio import pytest from opentelemetry.sdk.environment_variables import OTEL_EXPORTER_OTLP_TRACES_INSECURE from tests.tracing.conftest import FAKE_TRACE_SERVER_ADDRESS, FakeTraceService from vllm.tracin...
fim
vllm-project/vllm
python
<|fim_suffix|> project <|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-Fil<|fim_middle|>eCopyrightText: Copyright contributors to the vLLM<|endoftext|>
fim
vllm-project/vllm
python
<|fim_suffix|>s(42) <|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import pytest import transformers.image_utils from PIL import Image from vllm.transformers_utils.processors.pixtral import MistralCommonImageProcessor @pytest.fixture(scope="mo...
fim
vllm-project/vllm
python
<|fim_suffix|>" sentinel = np.array([0.5, -0.5], dtype=np.float32) received: dict[str, object] = {} def fake_load_audio(path, sampling_rate=None): received["path"] = path received["sampling_rate"] = sampling_rate return sentinel import transformers.audio_utils monkeypatch....
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """ This test file includes some cases where it is inappropriate to only get the `eos_token_id` from the tokenizer as defined by `BaseRenderer.get_eos_token_id`. """ from vllm.tokenizers import get_...
fim
vllm-project/vllm
python
<|fim_suffix|>g_parser(): with pytest.raises(ValueError): @register_config_parser("invalid_config_parser") class InvalidConfigParser: pass <|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from pathlib import Path ...
fim
vllm-project/vllm
python
# SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """Test that hf_overrides model_type returns the correct config class.""" import json import tempfile from transformers import PretrainedConfig from vllm.transformers_utils.config import _CONFIG_REGISTRY, get_c...
fim
vllm-project/vllm
python
<|fim_suffix|>odule_name) assert hasattr(mod, "_FakeProcessorKwargs") proc = _ProcWithoutUnpack() keys = get_processor_kwargs_keys(get_processor_kwargs_type(proc)) _assert_has_all_expected(keys) <|fim_prefix|># S<|fim_middle|>PDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contri...
fim
vllm-project/vllm
python
<|fim_suffix|>=tmp_dir, revision="revision", repo_type="model", token="token", ) @pytest.mark.parametrize( ("files", "expected_bool"), [ (["consolidated.safetensors", "incorrect.txt"], True), (["consolidated-1.safetensors", "incorrect.txt"], True), ...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from vllm.transformers_utils.utils import ( is_azure, is_cloud_storage, is_gcs, is_s3, ) def test_is_gcs(): assert is_gcs("<|fim_suffix|> test_is_azure(): assert is_azure("a...
fim
vllm-project/vllm
python
<|fim_suffix|>gpu memory used/total (GiB): ", end="") for k, v in output.items(): print(f"{k}={v}; ", end="") print("") if threshold_bytes is not None and threshold_ratio is not None: threshold_gib = threshold_bytes / 2**30 threshold = f"max({threshold_gib:.2...
fim
vllm-project/vllm
python
<|fim_suffix|>g `tests/utils.py`. """ <|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """ This module is named `utils_` instead of `u<|fim_middle|>tils` to avoid obscurin<|endoftext|>
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project # ruff: noqa import json import os import pytest import yaml from transformers import AutoTokenizer from pydantic import ValidationError from vllm.tokenizers.detokenizer_utils import convert_ids_l...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import asyncio from collections.abc import AsyncIterator import pytest from vllm.utils.async_utils import merge_async_iterators async def _mock_async_iterator(idx: int): try: while Tr...
fim
vllm-project/vllm
python
<|fim_suffix|>ter == 3 cache[6] = 6 assert len(cache) == 3 assert set(cache.cache) == {2, 4, 6} assert 2 in cache assert 4 in cache assert 6 in cache <|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from vllm.utils.cache im...
fim
vllm-project/vllm
python
# SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import pytest from vllm.utils.collection_utils import common_prefix, swap_dict_values @pytest.mark.parametrize( ("inputs", "expected_output"), [ ([""], ""), (["a"], "a"), (["a", ...
fim
vllm-project/vllm
python
<|fim_suffix|> requires_kw_only=requires_kw_only, allow_var_kwargs=allow_var_kwargs, ) == is_supported ) <|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project # ruff: noqa import pytest from vllm.utils.func_utils ...
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 from vllm.utils.gc_utils import ( GCDebugConfig, _compute_detailed_type, _compute_top_gc_collected_objects, ) @dataclass class ...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import has<|fim_suffix|>ot None assert isinstance(digest, bytes) assert digest != b"" input_bytes = pickle.dumps(input, protocol=pickle.HIGHEST_PROTOCOL) assert digest == hashlib.sha...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from unittest.mock import MagicMock, patch import pytest from vllm.utils.import_utils import PlaceholderModule, _has_module def _raises_module_not_found(): return pytest.raises(ModuleNotFound...
fim
vllm-project/vllm
python
# SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from vllm.utils.jsontree import json_count_leaves def test_json_count_leaves(): """Test json_count_leaves function from jsontree utility.""" # Single leaf values assert json_count_leaves(42) == 1 ...
fim
vllm-project/vllm
python
<|fim_suffix|>_psutil.virtual_memory.assert_not_called() <|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from unittest.mock import MagicMock, patch import torch from vllm_test_utils.monitor import monitor from vllm.utils.mem_utils import MemoryS...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import socket import pytest import zmq from vllm.utils.network_utils import ( get_open_port, get_open_ports_list, get_tcp_uri, join_host_port, make_zmq_path, make_zmq_socket...
fim
vllm-project/vllm
python
<|fim_suffix|> 1]) assert ( numa_utils._get_numactl_worker_args(vllm_config.parallel_config, local_rank=1) == "--physcpubind=0,1,16,17,64,65,80,81 --membind=1" ) def test_get_numactl_args_engine_core_baseline_single_node_shard(): """Baseline (no PCT): single-NUMA shard -> single-node bind....
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project from unittest.mock import MagicMock, patch import pytest from vllm.v1.executor.ray_utils import get_bundles_sorted_by_node NODE_A = "node_a" NODE_B = "node_b" NODE_C = "node_c" IP_A = "10.0.0.1"...
fim
vllm-project/vllm
python
<|fim_suffix|>.01) else: # for fp8 torch.testing.assert_close(tensor, new_tensor, atol=0.1, rtol=0.1) check_embeddings_close( embeddings_0_lst=tensor.view(1, -1), embeddings_1_lst=new_tensor.view(1, -1), name_0="gt", name_1="new", ...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """Tests for spawn_new_process_for_each_test decorator.""" import pytest from tests.utils import spawn_new_process_for_each_test @spawn_new_process_for_each_test def test_spawn_decorator_passing(...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import os impor<|fim_suffix|> path_fn = lambda i: Path(temp_dir) / f"file_{i}.txt" paths = set() for i in range(10): path = unique_filepath(path_fn) path.write_text("test"...
fim
vllm-project/vllm
python
<|fim_suffix|>sionVideoPixelInputs(pixel_values_videos=([x, y, x], [y], [x, y])) def test_tensor_schema_inconsistent_shapes_in_list(): with pytest.raises(ValueError, match="contains inconsistent shapes"): Phi3VImagePixelInputs( pixel_values=[ torch.randn(64, 3, 32, 32), ...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import pytest import torch from vllm.utils.torch_utils import ( common_broadcastable_dtype, current_stream, is_lossless_cast, ) @pytest.mark.parametrize( ("src_dtype", "tgt_dtype",...
fim
vllm-project/vllm
python
<|fim_suffix|>k_mod( b: torch.Tensor, h: torch.Tensor, q_idx: torch.Tensor, kv_idx: torch.Tensor, *, context_len: int, sliding_window: int, ): return torch.abs(q_idx + context_len - kv_idx) < sliding_window batch_spec = BATCH_SPECS[batch_spec_name...
fim
vllm-project/vllm
python
<|fim_suffix|>, MambaAttentionBackendEnum.LINEAR, ), (ShortConv, ShortConvAttentionBackend, MambaAttentionBackendEnum.SHORT_CONV), ], ) def test_mamba_layers_have_unified_interface( layer_class, expected_backend, expected_mamba_type ): """Test that all Mamba layers have the unifi...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project import pytest import torch from tests.v1.attention.test_attention_backends import BATCH_SPECS from tests.v1.attention.utils import BatchSpec, create_common_attn_metadata from vllm.v1.attention.back...
fim
vllm-project/vllm
python
<|fim_suffix|>nput_batch = MockInputBatch(req_ids, num_computed_tokens, num_prompt_tokens) scheduler_output = MockSchedulerOutput(num_scheduled_tokens) modified = reorder_batch_to_split_decodes_and_prefills( input_batch, scheduler_output, decode_threshold=test_case.decode_threshold ) expected_...
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 pytest import torch from tests.v1.attention.utils import BatchSpec, create_common_attn_metadata from vllm.platforms import current_platfo...
fim
vllm-project/vllm
python
# SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """Tests for GDNAttentionMetadataBuilder.build() — specifically the reclassification of non-spec decodes as prefills when spec decodes exist. Covers the fix for https://github.com/vllm-project/vllm/issues/34845. "...
fim
vllm-project/vllm
python
<|fim_suffix|>ock_table_tensor=block_table_tensor, slot_mapping=slot_mapping, causal=True, ) md = builder.build(common_prefix_len=0, common_attn_metadata=common) # The compressed slot_mapping retains the original uncompressed size (40). # Only every compress_ratio-th position gets a va...
fim
vllm-project/vllm
python
# SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """Unit tests for canonicalize_singleton_dim_strides. Background ---------- When num_kv_heads_per_rank == 1 (e.g. Qwen3.5-397B with TP=8 → 1 KV head per rank), PyTorch's is_contiguous() returns True for *any* str...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """ Regression test for https://github.com/vllm-project/vllm/issues/34865 When multiple KV cache groups share the same MambaSpec (as in Nemotron hybrid models), the metadata caching optimization reu...
fim
vllm-project/vllm
python
# SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """Tests for v1 MLA backends without GPUModelRunner dependency. Known Issues: - FLASH_ATTN_MLA backend occasionally produces NaN values in test_backend_correctness[mixed_small] when run after test_backend_cor...
fim
vllm-project/vllm
python
<|fim_suffix|>t_mla_prefill_registry.CustomMLAPrefillBackend" ) backend_cls = MLAPrefillBackendEnum.CUSTOM.get_class() assert backend_cls.get_name() == "CUSTOM" def test_register_custom_backend_as_decorator(): @register_mla_prefill_backend(MLAPrefillBackendEnum.CUSTOM) class DecoratedPrefillBacke...
fim
vllm-project/vllm
python
<|fim_prefix|># SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project """Tests for MLA prefill backend selector.""" from unittest.mock import MagicMock, patch import pytest import torch from vllm.config import AttentionConfig, ModelConfig, VllmConfig from vllm.platf...
fim
vllm-project/vllm
python
<|fim_suffix|>tor_config = AttentionSelectorConfig( head_size=128, dtype=torch.float16, kv_cache_dtype="auto", block_size=16, use_mla=False, has_sink=False, use_sparse=True, ) RocmPlatform.get_attn_backend_cls( ...
fim
vllm-project/vllm
python