[KV Offload] Pass ScheduleEndContext to on_schedule_end hook (#46450)

Signed-off-by: Ronen Schaffer <ronen.schaffer@ibm.com>
Co-authored-by: Or Ozeri <oro@il.ibm.com>
This commit is contained in:
Ronen Schaffer
2026-06-30 17:07:12 +03:00
committed by GitHub
co-authored by Or Ozeri
parent 62c7d8009f
commit 0fc2512094
11 changed files with 42 additions and 14 deletions
+11 -2
View File
@@ -8,7 +8,7 @@ from abc import ABC, abstractmethod
from collections.abc import Collection, Iterable, Sequence
from dataclasses import dataclass
from enum import Enum, auto
from typing import TYPE_CHECKING, Any, NewType
from typing import TYPE_CHECKING, Any, NamedTuple, NewType
import numpy as np
import torch
@@ -76,6 +76,15 @@ class RequestOffloadingContext:
policy: OffloadPolicy = OffloadPolicy.BLOCK_LEVEL
class ScheduleEndContext(NamedTuple):
"""Per-step scheduling info passed to on_schedule_end()."""
# Request IDs scheduled for the first time this step.
new_req_ids: Collection[str]
# Request IDs preempted this step.
preempted_req_ids: Collection[str]
class LoadStoreSpec(ABC):
"""
Abstract metadata that encapsulates information allowing a worker
@@ -309,7 +318,7 @@ class OffloadingManager(ABC):
"""
return ()
def on_schedule_end(self) -> None:
def on_schedule_end(self, context: ScheduleEndContext) -> None:
"""Called once at the end of each scheduler step.
Managers may override this to flush deferred work accumulated