|
12 | 12 | from contextlib import contextmanager |
13 | 13 | from dataclasses import field, fields, is_dataclass, replace |
14 | 14 | from functools import cached_property, lru_cache |
| 15 | +from pathlib import Path |
15 | 16 | from typing import (TYPE_CHECKING, Any, Literal, Optional, Protocol, TypeVar, |
16 | 17 | Union, cast) |
17 | 18 |
|
@@ -541,6 +542,17 @@ def __post_init__(self): |
541 | 542 | # local attention. |
542 | 543 | self.scheduler_config.disable_hybrid_kv_cache_manager = True |
543 | 544 |
|
| 545 | + if self.compilation_config.debug_dump_path: |
| 546 | + self.compilation_config.debug_dump_path = \ |
| 547 | + self.compilation_config.debug_dump_path.absolute().expanduser() |
| 548 | + if envs.VLLM_DEBUG_DUMP_PATH is not None: |
| 549 | + env_path = Path(envs.VLLM_DEBUG_DUMP_PATH).absolute().expanduser() |
| 550 | + if self.compilation_config.debug_dump_path: |
| 551 | + logger.warning( |
| 552 | + "Config-specified debug dump path is overridden" |
| 553 | + " by VLLM_DEBUG_DUMP_PATH to %s", env_path) |
| 554 | + self.compilation_config.debug_dump_path = env_path |
| 555 | + |
544 | 556 | def update_sizes_for_sequence_parallelism(self, |
545 | 557 | possible_sizes: list) -> list: |
546 | 558 | # remove the sizes that not multiple of tp_size when |
@@ -672,6 +684,20 @@ def try_verify_and_update_config(self): |
672 | 684 | f"but got '{self.load_config.load_format}'. " |
673 | 685 | f"Model: {self.model_config.model}") |
674 | 686 |
|
| 687 | + def compile_debug_dump_path(self) -> Optional[Path]: |
| 688 | + """Returns a rank-aware path for dumping |
| 689 | + torch.compile debug information. |
| 690 | + """ |
| 691 | + if self.compilation_config.debug_dump_path is None: |
| 692 | + return None |
| 693 | + tp_rank = self.parallel_config.rank |
| 694 | + dp_rank = self.parallel_config.data_parallel_rank |
| 695 | + data_parallel_size = self.parallel_config.data_parallel_size |
| 696 | + append_path = f"rank_{tp_rank}" if data_parallel_size == 1 \ |
| 697 | + else f"rank_{tp_rank}_dp_{dp_rank}" |
| 698 | + path = self.compilation_config.debug_dump_path / append_path |
| 699 | + return path |
| 700 | + |
675 | 701 | def __str__(self): |
676 | 702 | return ( |
677 | 703 | f"model={self.model_config.model!r}, " |
|
0 commit comments