Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aien-sovereign-core-mv/blob/main/crates/aien-platform/src/queue.rs # 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 Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aien-sovereign-core-mv / crates / aien-platform / src / queue.rs` 69 lines ยท 2138 bytes Raw Blame History 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright 2026 Drake Stapleton (AIEN / aien-dev) 3 // 4 // Licensed under the Apache License, Version 2.0 (the "License"); 5 // you may not use this file except in compliance with the License. 6 // You may obtain a copy of the License at 7 // 8 // http://www.apache.org/licenses/LICENSE-2.0 9 // 10 // Unless required by applicable law or agreed to in writing, software 11 // distributed under the License is distributed on an "AS IS" BASIS, 12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 // See the License for the specific language governing permissions and 14 // limitations under the License. 15 16 pub type SequenceId = u64; 17 pub type Ticks = u64; 18 19 #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] 20 pub enum Priority { 21 Background = 0, 22 Normal = 1, 23 Interactive = 2, 24 Realtime = 3, 25 } 26 27 #[derive(Debug, Clone, Copy, PartialEq, Eq)] 28 pub struct ModelHandle(pub u32); 29 30 #[derive(Debug, Clone, Copy, PartialEq, Eq)] 31 pub struct KvHandle(pub u64); 32 33 /// The fundamental scheduling unit of SparkOS: tokens are the workload, not processes. 34 #[derive(Debug, Clone, PartialEq, Eq)] 35 pub struct InferenceWork { 36 pub sequence: SequenceId, 37 pub model: ModelHandle, 38 pub kv: KvHandle, 39 pub priority: Priority, 40 pub deadline: Option, 41 pub branch_parent: Option, 42 pub next_token_budget: u32, 43 } 44 45 #[derive(Debug, Clone, PartialEq, Eq)] 46 pub enum QueueError { 47 Full, 48 Empty, 49 InvalidSequence(SequenceId), 50 } 51 52 impl core::fmt::Display for QueueError { 53 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 54 match self { 55 Self::Full => write!(f, "WorkQueue error: queue capacity exceeded"), 56 Self::Empty => write!(f, "WorkQueue error: queue empty"), 57 Self::InvalidSequence(id) => write!(f, "WorkQueue error: invalid sequence id {}", id), 58 } 59 } 60 } 61 62 pub trait WorkQueue { 63 fn push(&self, work: InferenceWork) -> Result<(), QueueError>; 64 fn pop(&self) -> Option; 65 fn len(&self) -> usize; 66 fn is_empty(&self) -> bool { 67 self.len() == 0 68 } 69 }