vllm.compilation.wrapper
¶
Classes:
-
TorchCompileWithNoGuardsWrapper–A wrapper class for torch.compile, it ensures that all guards are dropped
Functions:
-
remove_bytecode_hooks–Remove the global bytecode hooks of model's compiled modules, which
-
reset_compile_wrapper–Clean up compiled model and captured CUDA graphs for elastic EP.
TorchCompileWithNoGuardsWrapper
¶
A wrapper class for torch.compile, it ensures that all guards are dropped when CompilationMode is not CompilationMode.STOCK_TORCH_COMPILE. When guards are dropped, the first time call is invoked, a single compilation is triggered. Dynamo should never be traced again after that since we drop all guards.
Methods:
-
bytecode_hook–Hook to save the compiled bytecode for direct execution.
-
cleanup–Remove the bytecode hook registered by this instance.
-
original_code_object–Return the original code object of the forward method.
_dispatch_to_compiled_code()
¶
Context manager to dispatch to internally compiled code. Why does this work? Because Dynamo guarantees that the compiled bytecode has exactly the same arguments, cell variables, and free variables as the original code. Therefore we can directly switch the code object in the function and call it.
See https://dev-discuss.pytorch.org/t/what-is-the-relationship-requirement-among-original-bytecode-transformed-bytecode-and-bytecode-returned-by-hooks-in-dynamo/1693/7 for more details.
bytecode_hook(old_code, new_code)
¶
Hook to save the compiled bytecode for direct execution.
cleanup()
¶
Remove the bytecode hook registered by this instance.
original_code_object()
¶
Return the original code object of the forward method.
_bound_instance(frame)
¶
The instance a method frame is bound to. Also handles frames of wrappers
that take (*args, **kwargs), such as Transformers' deprecate_kwarg.
_compilation_context()
¶
Context manager for compilation settings.
This manager sets higher dynamo cache limits for compilation. (Needed for qwen2_5_vl see test_qwen2_5_vl_evs_functionality). Generally a recompilation can happen whenever we use a new backend instance in torch.compile.
remove_bytecode_hooks(model)
¶
Remove the global bytecode hooks of model's compiled modules, which otherwise keep them, and the weights they hold, alive.
reset_compile_wrapper(model)
¶
Clean up compiled model and captured CUDA graphs for elastic EP.