mirror of
https://git.datalinker.icu/vllm-project/vllm.git
synced 2026-01-19 21:14:47 +08:00
Signed-off-by: Luka Govedič <lgovedic@redhat.com> Signed-off-by: luka <lgovedic@redhat.com> Signed-off-by: Luka Govedič <ProExpertProg@users.noreply.github.com> Signed-off-by: yewentao256 <zhyanwentao@126.com>
21 lines
757 B
Python
21 lines
757 B
Python
# SPDX-License-Identifier: Apache-2.0
|
|
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
|
from torch import fx
|
|
|
|
from vllm.compilation.vllm_inductor_pass import VllmInductorPass
|
|
|
|
|
|
class PostCleanupPass(VllmInductorPass):
|
|
"""
|
|
This pass performs cleanup after custom passes.
|
|
It topologically sorts the graph and removes unused nodes.
|
|
This is needed because the pattern matcher does not guarantee producing
|
|
a topologically sorted graph, and there may be unused nodes left around.
|
|
"""
|
|
|
|
@VllmInductorPass.time_and_log
|
|
def __call__(self, graph: fx.Graph) -> None:
|
|
from torch._inductor.pattern_matcher import stable_topological_sort
|
|
stable_topological_sort(graph)
|
|
graph.eliminate_dead_code()
|