| 1 | # SPDX-License-Identifier: Apache-2.0 |
| 2 | # SPDX-FileCopyrightText: Copyright contributors to the vLLM project |
| 3 | |
| 4 | from dataclasses import dataclass |
| 5 | |
| 6 | |
| 7 | @dataclass(frozen=True) |
| 8 | class SparseKVPageTransfer: |
| 9 | """Copy one logical KV page between cache-manager and worker-owned tiers.""" |
| 10 | |
| 11 | transfer_id: int |
| 12 | host_block_id: int |
| 13 | resident_block_ids: tuple[int, ...] |
| 14 | after_forward: bool |
| 15 | restore: bool = False |
| 16 | |
| 17 | |
| 18 | @dataclass(frozen=True) |
| 19 | class SparseKVRowMirror: |
| 20 | """Mirror one contiguous resident-row span into the host cache.""" |
| 21 | |
| 22 | source_starts: tuple[int, ...] |
| 23 | destination_start: int |
| 24 | num_rows: int |
| 25 | |
| 26 | |
| 27 | @dataclass |
| 28 | class SparseKVOffloadCommand: |
| 29 | """Opaque scheduler-to-worker command for one model step.""" |
| 30 | |
| 31 | page_transfers: list[SparseKVPageTransfer] |