metrale_scheduler/
types.rs1use std::time::Duration;
9
10#[derive(Debug, Clone, Copy, PartialEq, Eq)]
12pub struct Ticket(pub u32);
13
14#[derive(Debug, Clone, Copy, PartialEq, Eq)]
16pub enum WaitPolicy {
17 NoWait,
19 Bounded(Duration),
21 Block,
23}
24
25#[derive(Debug, Clone, Copy, PartialEq, Eq)]
27pub struct DeviceFacts {
28 pub free_blocks: usize,
29 pub total_blocks: usize,
30 pub ssm_occupancy: Option<(u32, u32)>,
31}
32
33#[derive(Debug)]
36pub enum DeviceError {
37 Forward(anyhow::Error),
38 Readback(anyhow::Error),
39 Effect(anyhow::Error),
40}
41
42impl DeviceError {
43 pub fn into_inner(self) -> anyhow::Error {
44 match self {
45 Self::Forward(e) | Self::Readback(e) | Self::Effect(e) => e,
46 }
47 }
48
49 pub fn is_kv_exhausted(&self) -> bool {
52 matches!(self, Self::Forward(e) if format!("{e:#}").contains("KV cache exhausted"))
53 }
54}
55
56impl std::fmt::Display for DeviceError {
57 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
58 match self {
59 Self::Forward(e) | Self::Readback(e) | Self::Effect(e) => write!(f, "{e:#}"),
60 }
61 }
62}