Coverage for / home / jenkins / .local / lib / python3.10 / site-packages / hyper_parallel / auto_parallel / hyper_offload / ir / trace.py: 100%
24 statements
« prev ^ index » next coverage.py v7.13.1, created at 2026-07-06 05:41 +0800
« prev ^ index » next coverage.py v7.13.1, created at 2026-07-06 05:41 +0800
1# Copyright 2026 Huawei Technologies Co., Ltd
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14# ============================================================================
15"""Scheduler input model for activation residency planning."""
17from __future__ import annotations
19from dataclasses import dataclass, field
20from enum import Enum, auto
23class AccessKind(Enum):
24 """How an op accesses a storage."""
26 READ = auto()
27 WRITE = auto()
30@dataclass
31class StorageAccess:
32 """A storage access made by an op."""
34 op_id: int
35 storage_id: int
36 kind: AccessKind
39@dataclass
40class TraceOp:
41 """A scheduler-visible execution op."""
43 name: str
44 duration_ms: float = 0.0
45 accesses: list[StorageAccess] = field(default_factory=list)
48@dataclass
49class ActivationTrace:
50 """Scheduler input: ordered ops plus storage metadata."""
52 ops: list[TraceOp] = field(default_factory=list)
53 storage_sizes: dict[int, int] = field(default_factory=dict)
54 retained_sids: set[int] = field(default_factory=set)
55 memory_limit_bytes: int | None = None
56 d2h_bandwidth_gbps: float = 16.0
57 h2d_bandwidth_gbps: float = 16.0