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
aien-sovereign-core-mv / crates / aien-inference-runtime / tests / runtime_tests.rs
| 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 | use aien_inference_runtime::EmbeddedInferenceService; |
| 17 | use aien_inference_service::{InferenceEvent, InferenceRequest, InferenceService}; |
| 18 | |
| 19 | #[tokio::test] |
| 20 | async fn test_embedded_inference_service_reference_weights() { |
| 21 | let svc = EmbeddedInferenceService::with_reference_weights().expect("load reference weights"); |
| 22 | assert_eq!(svc.model_id(), "TinyLlama/TinyLlama-1.1B-Chat-v1.0"); |
| 23 | assert_eq!(svc.endpoint(), "embedded://sovereign-core"); |
| 24 | |
| 25 | let req = InferenceRequest::new("Testing protocol").with_max_tokens(8); |
| 26 | let output = svc.generate(&req).await.expect("generate"); |
| 27 | assert!(!output.is_empty()); |
| 28 | |
| 29 | let mut rx = svc.stream_events(&req).await.expect("stream events"); |
| 30 | let mut received_tokens = Vec::new(); |
| 31 | let mut completed = false; |
| 32 | |
| 33 | while let Some(evt) = rx.recv().await { |
| 34 | match evt { |
| 35 | InferenceEvent::Token(tok) => received_tokens.push(tok), |
| 36 | InferenceEvent::Completed { total_tokens, .. } => { |
| 37 | completed = true; |
| 38 | assert_eq!(total_tokens, received_tokens.len()); |
| 39 | } |
| 40 | InferenceEvent::Error(err) => panic!("Unexpected error: {err}"), |
| 41 | _ => {} |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | assert!(completed); |
| 46 | assert!(!received_tokens.is_empty()); |
| 47 | } |