|
| 1 | +from ucm.integration.vllm.patch.utils import patch_or_inject, when_imported |
| 2 | +from ucm.logger import init_logger |
| 3 | + |
| 4 | +logger = init_logger(__name__) |
| 5 | + |
| 6 | + |
| 7 | +@when_imported("vllm.config.vllm") |
| 8 | +def patch_vllm_config(mod): |
| 9 | + logger.debug(f"Patched {mod} called") |
| 10 | + |
| 11 | + from ucm.integration.vllm.patch.v0180.vllm.pc.config import vllm |
| 12 | + |
| 13 | + vllm.patch_vllm_config_cls(mod.VllmConfig) |
| 14 | + |
| 15 | + |
| 16 | +@when_imported("vllm.model_executor.models.config") |
| 17 | +def patch_model_config(mod): |
| 18 | + logger.debug(f"Patched {mod} called") |
| 19 | + |
| 20 | + from ucm.integration.vllm.patch.v0180.vllm.pc.model_executor.models import ( |
| 21 | + config, |
| 22 | + ) |
| 23 | + |
| 24 | + config.patch_mamba_model_config_cls(mod.MambaModelConfig) |
| 25 | + |
| 26 | + |
| 27 | +@when_imported("vllm.v1.core.sched.scheduler") |
| 28 | +def patch_core_sched_scheduler(mod): |
| 29 | + logger.debug(f"Patched {mod} called") |
| 30 | + |
| 31 | + from ucm.integration.vllm.patch.v0180.vllm.pc.v1.core.sched import scheduler |
| 32 | + |
| 33 | + patch_or_inject( |
| 34 | + mod.Scheduler, |
| 35 | + "_mamba_block_aligned_split", |
| 36 | + scheduler.Scheduler._mamba_block_aligned_split, |
| 37 | + ) |
| 38 | + |
| 39 | + |
| 40 | +@when_imported("vllm.v1.worker.gpu_model_runner") |
| 41 | +def patch_worker_gpu_model_runner(mod): |
| 42 | + logger.debug(f"Patched {mod} called") |
| 43 | + |
| 44 | + from ucm.integration.vllm.patch.v0180.vllm.pc.v1.worker import gpu_model_runner |
| 45 | + |
| 46 | + patch_or_inject( |
| 47 | + mod.GPUModelRunner, |
| 48 | + "may_reinitialize_input_batch", |
| 49 | + gpu_model_runner.GPUModelRunner.may_reinitialize_input_batch, |
| 50 | + ) |
| 51 | + |
| 52 | + |
| 53 | +@when_imported("vllm.v1.worker.mamba_utils") |
| 54 | +def patch_worker_mamba_utils(mod): |
| 55 | + logger.debug(f"Patched {mod} called") |
| 56 | + |
| 57 | + from ucm.integration.vllm.patch.v0180.vllm.pc.v1.worker import mamba_utils |
| 58 | + |
| 59 | + mamba_utils.patch_preprocess_mamba(mod) |
0 commit comments