interplane.Get Omega
Read in your language

aien-sovereign-core-mv

AienOS host runtime: inference scheduling, paged KV state, the aien CLI and Spark verification tooling. Its inference engine is in alpha testing (DGX Spark GB10); Omega is the implementation destination.

Brought by drakestapleton

branch main Branches Tags History

aien-sovereign-core-mv / crates / aien-expert-store / src / error.rs

122 lines · 4122 bytes Raw Blame History
1//! Structured errors. [`StoreError`] covers the store, the formats and the
2//! indexer; [`ReadError`] covers the read adapter and is a plain value.
3
4use crate::format::ExpertKey;
5use std::io::ErrorKind;
6
7/// Why a store, index, artifact or checkpoint operation was refused.
8#[derive(Debug, Clone, PartialEq, Eq)]
9pub enum StoreError {
10 /// An I/O call failed (the kind only, no path, so nothing private leaks).
11 Io(ErrorKind),
12 BadMagic,
13 UnsupportedVersion,
14 /// An artifact header field is out of range or disagrees with the others.
15 BadHeader(&'static str),
16 /// The index file is malformed (size, ordering, reserved bytes, enums).
17 BadIndex(&'static str),
18 /// The index trailer digest does not match its contents.
19 IndexChecksum,
20 /// A key is already bound to different content.
21 DuplicateKey(ExpertKey),
22 /// Weight or scale bytes do not have the length the geometry requires.
23 PayloadLength {
24 expected: u64,
25 found: u64,
26 },
27 /// More entries than `StoreLimits::max_entries`.
28 TooManyEntries,
29 /// An artifact larger than `StoreLimits::max_object_bytes`.
30 ObjectTooLarge {
31 len: u64,
32 max: u64,
33 },
34 /// An existing object file does not hash to its name.
35 ObjectCorrupt,
36 /// A size computation overflowed.
37 Overflow,
38 /// The store root would be inside the source checkpoint directory.
39 StoreInsideCheckpoint,
40 /// The checkpoint index or a shard header is malformed.
41 Checkpoint(String),
42 /// A tensor the index or the expert layout requires is missing.
43 MissingTensor(String),
44 /// A tensor has the wrong dtype.
45 DtypeMismatch {
46 name: String,
47 found: String,
48 },
49 /// A tensor has the wrong shape.
50 ShapeMismatch {
51 name: String,
52 },
53}
54
55impl From<std::io::Error> for StoreError {
56 fn from(e: std::io::Error) -> Self {
57 Self::Io(e.kind())
58 }
59}
60
61impl core::fmt::Display for StoreError {
62 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
63 write!(f, "expert store: {self:?}")
64 }
65}
66
67impl std::error::Error for StoreError {}
68
69/// Why a read was refused at submit or failed before it became ready.
70#[derive(Debug, Clone, Copy, PartialEq, Eq)]
71pub enum ReadError {
72 /// `max_in_flight` jobs are already queued or running.
73 QueueFull,
74 /// Admitting this read would exceed `max_inflight_bytes`.
75 InflightBytesExceeded,
76 /// The object is larger than `max_object_bytes`.
77 ObjectTooLarge,
78 /// The staging buffer is smaller than the object.
79 InsufficientCapacity { need: u64, have: u64 },
80 /// The index entry cannot describe a valid artifact (length not aligned or
81 /// smaller than the header region).
82 InvalidEntry,
83 /// The deadline passed before submit, or before the read finished.
84 DeadlineExceeded,
85 /// The adapter is shutting down.
86 ShutDown,
87 /// No object with that digest exists in the source.
88 NotFound,
89 /// An I/O call failed.
90 Io(ErrorKind),
91 /// The object has a different length than the index records (truncated or
92 /// extended file).
93 LengthMismatch { expected: u64, found: u64 },
94 /// The source returned end of file before the object was complete.
95 UnexpectedEof { read: u64, expected: u64 },
96 /// SHA-256 of the bytes read differs from the index digest.
97 DigestMismatch,
98 /// The bytes hash correctly but their header does not describe the
99 /// requested key and length.
100 HeaderMismatch,
101 /// Adapter limits that are zero, or a chunk size that is not a 4096 multiple.
102 InvalidLimits,
103 /// Direct I/O is not available on this platform or file system.
104 DirectIoUnsupported,
105}
106
107impl From<std::io::Error> for ReadError {
108 fn from(e: std::io::Error) -> Self {
109 match e.kind() {
110 ErrorKind::NotFound => Self::NotFound,
111 k => Self::Io(k),
112 }
113 }
114}
115
116impl core::fmt::Display for ReadError {
117 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
118 write!(f, "expert read: {self:?}")
119 }
120}
121
122impl std::error::Error for ReadError {}