__init__.py 1.66 KB
Newer Older
chenzk's avatar
chenzk committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
"""
Benchmark helpers for kv-prune / compactor kernels.

Upstream snapshot (``compactor-vllm/src/compactor_vllm/benchmark``) contained **only**
an empty ``__init__.py`` — no additional ``.py`` scripts. Those files are merged here
as-is; there is nothing else to list under that directory in upstream.

Use :data:`BENCHMARK_REGISTRY` to register microbenchmarks or CLI entrypoints you
add under ``vllm.kvprune.benchmark``.
"""

from __future__ import annotations

from typing import Any, Callable

# Files copied from upstream ``compactor_vllm/benchmark/`` (relative to that dir).
UPSTREAM_BENCHMARK_FILES: tuple[str, ...] = ("__init__.py",)

# Optional: name -> benchmark callable or import path string (e.g. "mymod:main").
# Populated when you add real benchmarks beside this package.
BENCHMARK_REGISTRY: dict[str, Callable[..., Any] | str] = {}


def list_upstream_benchmark_files() -> tuple[str, ...]:
    """Return the list of filenames that existed in upstream ``benchmark/``."""
    return UPSTREAM_BENCHMARK_FILES


def register_benchmark(name: str, target: Callable[..., Any] | str) -> None:
    """Register a benchmark by name (callable or ``"module:attr"`` import path)."""
    BENCHMARK_REGISTRY[name] = target


def iter_registered_benchmarks() -> list[tuple[str, Callable[..., Any] | str]]:
    """Return ``(name, target)`` pairs from :data:`BENCHMARK_REGISTRY`."""
    return list(BENCHMARK_REGISTRY.items())


__all__ = [
    "BENCHMARK_REGISTRY",
    "UPSTREAM_BENCHMARK_FILES",
    "iter_registered_benchmarks",
    "list_upstream_benchmark_files",
    "register_benchmark",
]