mirror of
https://git.datalinker.icu/vllm-project/vllm.git
synced 2026-05-19 23:07:03 +08:00
- **Add SPDX license headers to python source files**
- **Check for SPDX headers using pre-commit**
commit 9d7ef44c3cfb72ca4c32e1c677d99259d10d4745
Author: Russell Bryant <rbryant@redhat.com>
Date: Fri Jan 31 14:18:24 2025 -0500
Add SPDX license headers to python source files
This commit adds SPDX license headers to python source files as
recommended to
the project by the Linux Foundation. These headers provide a concise way
that is
both human and machine readable for communicating license information
for each
source file. It helps avoid any ambiguity about the license of the code
and can
also be easily used by tools to help manage license compliance.
The Linux Foundation runs license scans against the codebase to help
ensure
we are in compliance with the licenses of the code we use, including
dependencies. Having these headers in place helps that tool do its job.
More information can be found on the SPDX site:
- https://spdx.dev/learn/handling-license-info/
Signed-off-by: Russell Bryant <rbryant@redhat.com>
commit 5a1cf1cb3b80759131c73f6a9dddebccac039dea
Author: Russell Bryant <rbryant@redhat.com>
Date: Fri Jan 31 14:36:32 2025 -0500
Check for SPDX headers using pre-commit
Signed-off-by: Russell Bryant <rbryant@redhat.com>
---------
Signed-off-by: Russell Bryant <rbryant@redhat.com>
52 lines
1.8 KiB
Python
52 lines
1.8 KiB
Python
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
import time
|
|
|
|
import torch
|
|
|
|
from vllm.config import CompilationConfig
|
|
# yapf: disable
|
|
from vllm.distributed import get_tensor_model_parallel_rank as get_tp_rank
|
|
from vllm.distributed import (
|
|
get_tensor_model_parallel_world_size as get_tp_world_size)
|
|
from vllm.distributed import model_parallel_is_initialized as p_is_init
|
|
# yapf: enable
|
|
from vllm.logger import init_logger
|
|
|
|
from .inductor_pass import InductorPass
|
|
|
|
logger = init_logger(__name__)
|
|
|
|
|
|
class VllmInductorPass(InductorPass):
|
|
"""
|
|
An inductor pass with access to vLLM PassConfig.
|
|
It provides timing, logging, and dumping utilities.
|
|
"""
|
|
|
|
def __init__(self, config: CompilationConfig.PassConfig):
|
|
self.config = config
|
|
self.pass_name = self.__class__.__name__
|
|
|
|
def dump_graph(self, graph: torch.fx.Graph, stage: str):
|
|
if stage in self.config.dump_graph_stages:
|
|
# Make sure filename includes rank in the distributed setting
|
|
parallel = p_is_init() and get_tp_world_size() > 1
|
|
rank = f"-{get_tp_rank()}" if parallel else ""
|
|
filepath = self.config.dump_graph_dir / f"{stage}{rank}.py"
|
|
|
|
logger.info("%s printing graph to %s", self.pass_name, filepath)
|
|
with open(filepath, "w") as f:
|
|
src = graph.python_code(root_module="self", verbose=True).src
|
|
# Add imports so it's not full of errors
|
|
print("import torch; from torch import device", file=f)
|
|
print(src, file=f)
|
|
|
|
def begin(self):
|
|
self._start_time = time.perf_counter_ns()
|
|
|
|
def end_and_log(self):
|
|
self._end_time = time.perf_counter_ns()
|
|
duration_ms = float(self._end_time - self._start_time) / 1.0e6
|
|
logger.debug("%s completed in %.1f ms", self.pass_name, duration_ms)
|