mirror of
https://git.datalinker.icu/vllm-project/vllm.git
synced 2025-12-10 07:45:29 +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>
40 lines
1.4 KiB
Python
40 lines
1.4 KiB
Python
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
from copy import deepcopy
|
|
from typing import Callable, Union
|
|
|
|
from torch import fx
|
|
|
|
from vllm.compilation.inductor_pass import InductorPass
|
|
|
|
|
|
class TestBackend:
|
|
"""
|
|
This class provides a simple Inductor backend that can be used for testing.
|
|
It takes a list of custom passes and runs them after Inductor's passes.
|
|
It also saves the graph before and after the custom passes for inspection.
|
|
"""
|
|
|
|
def __init__(self, *passes: Union[InductorPass, Callable[[fx.Graph],
|
|
None]]):
|
|
self.custom_passes = list(passes)
|
|
from torch._inductor import config
|
|
self.current_config = config.shallow_copy_dict()
|
|
self.current_config['force_disable_caches'] = True
|
|
self.current_config['post_grad_custom_post_pass'] = self.post_pass
|
|
|
|
def __call__(self, graph: fx.GraphModule, example_inputs):
|
|
from torch._inductor.compile_fx import compile_fx
|
|
return compile_fx(graph,
|
|
example_inputs,
|
|
config_patches=self.current_config)
|
|
|
|
def post_pass(self, graph: fx.Graph):
|
|
self.graph_pre_pass = deepcopy(graph)
|
|
for pass_ in self.custom_passes:
|
|
pass_(graph)
|
|
|
|
self.graph_post_pass = deepcopy(graph)
|
|
# assign by reference, will reflect the final state of the graph
|
|
self.final_graph = graph
|