Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions vllm/compilation/vllm_inductor_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,42 @@
import functools
import operator
import time
import weakref
from dataclasses import dataclass
from typing import ClassVar

import regex as re
import torch
from torch._dynamo.utils import lazy_format_graph_code
from torch._inductor.pattern_matcher import PatternMatcherPass, PatternPrettyPrinter

from vllm.config import VllmConfig
from vllm.config import CompilationConfig, VllmConfig
from vllm.logger import init_logger

from .inductor_pass import InductorPass

logger = init_logger(__name__)


@dataclass
class SimplifiedCompilationConfig:
splitting_ops: list[str] | None = None
use_inductor_graph_partition: bool = False
compile_sizes: list[int | str] | None = None


def copy_necessary_config_for_pass(
config: CompilationConfig,
) -> SimplifiedCompilationConfig:
"""Get only the necessary CompilationConfig for the inductor pass, since
full `CompilationConfig` contains pointer to model which is unsafe.
"""
return SimplifiedCompilationConfig(
splitting_ops=config.splitting_ops,
use_inductor_graph_partition=config.use_inductor_graph_partition,
compile_sizes=config.compile_sizes,
)


class VllmInductorPass(InductorPass):
"""
An inductor pass with access to vLLM PassConfig.
Expand All @@ -29,7 +49,9 @@ class VllmInductorPass(InductorPass):
"""Keep track of pass index for debug dump ordering."""

def __init__(self, config: VllmConfig):
self.compilation_config = weakref.proxy(config.compilation_config)
self.compilation_config = copy_necessary_config_for_pass(
config.compilation_config
)
self.pass_config = config.compilation_config.pass_config
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

later pass_config can be also moved.

Copy link
Collaborator Author

@luccafong luccafong Oct 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can utilize it, but it will introduce duplicated attribute in config level, we can think of how to organize these config better in following PR. @zou3519

self.model_dtype = config.model_config.dtype if config.model_config else None
self.device = config.device_config.device if config.device_config else None
Expand Down
Loading