vllm.compilation.passes.vllm_inductor_pass ¶
Classes:
-
VllmFusionPatternMatcherPass–A VllmPatternMatcherPass for passes that use VllmPatternReplacement objects.
-
VllmInductorPass–An inductor pass with access to vLLM PassConfig.
-
VllmPatternMatcherPass–A VllmInductorPass that uses the Inductor pattern matcher.
-
VllmPatternReplacement–A pattern/replacement pair for FX graph fusion.
Functions:
-
fold_consecutive_reshapes–Fold consecutive reshape ops into a single reshape.
-
get_match_table–Return a snapshot of the match table.
VllmFusionPatternMatcherPass ¶
Bases: VllmPatternMatcherPass
A VllmPatternMatcherPass for passes that use VllmPatternReplacement objects. Subclasses register patterns via self.register() in their own init.
Source code in vllm/compilation/passes/vllm_inductor_pass.py
VllmInductorPass ¶
Bases: InductorPass
An inductor pass with access to vLLM PassConfig. It provides timing, logging, and dumping utilities.
Attributes:
-
dump_prefix(int | None) –Keep track of pass index for debug dump ordering.
Source code in vllm/compilation/passes/vllm_inductor_pass.py
dump_prefix = None class-attribute ¶
Keep track of pass index for debug dump ordering.
VllmPatternMatcherPass ¶
Bases: VllmInductorPass
A VllmInductorPass that uses the Inductor pattern matcher. Provides pattern registration with match counting, debug dumping, and logging.
Methods:
-
dump_patterns–If debug dumping is enabled, dump the Inductor pattern-matcher patterns
Attributes:
-
match_table(defaultdict[str, int]) –Global table mapping pass name to its total match count.
-
matched_count(int) –The number of matched patterns in the pass.
Source code in vllm/compilation/passes/vllm_inductor_pass.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | |
match_table = defaultdict(int) class-attribute ¶
Global table mapping pass name to its total match count.
matched_count = 0 class-attribute instance-attribute ¶
The number of matched patterns in the pass.
_replace_op_overloads(string) ¶
Replace
Source code in vllm/compilation/passes/vllm_inductor_pass.py
dump_patterns(config, pm_pass) ¶
If debug dumping is enabled, dump the Inductor pattern-matcher patterns into the debug_dump_path folder next to the dumped fx graphs.
This method does its best to print something that looks like Python code for easier debugging and potentially navigation. If any errors appear in the output, please add to this method.
TODO(luka): use pattern object to manually produce pattern graph
Source code in vllm/compilation/passes/vllm_inductor_pass.py
VllmPatternReplacement ¶
A pattern/replacement pair for FX graph fusion.
Implement the three abstract members below, then pass instances to VllmFusionPatternMatcherPass.register(). The pass will find every occurrence of pattern in the graph and substitute it with replacement.
Methods:
-
get_inputs–Example tensors used to trace pattern and replacement.
Attributes:
-
pattern(Callable[P, R]) –Returns a closure defining the FX subgraph to search for.
-
replacement(Callable[P, R]) –Returns a closure defining the FX subgraph to
Source code in vllm/compilation/passes/vllm_inductor_pass.py
fold_consecutive_reshapes(gm) ¶
Fold consecutive reshape ops into a single reshape.
make_fx faithfully records every view/reshape the Python code performs, so patterns like x.reshape(a, b).reshape(c, d) produce two reshape nodes. Inductor's own optimisation would fold these, but pm.register_replacement's trace_fn runs before Inductor, so we must fold them ourselves for the pattern to match the compiled graph.
When reshape(A, shape1) feeds only into reshape(result, shape2), the first reshape is redundant -- replace with reshape(A, shape2).