STRA-338: rustfmt of the merged size-gw files
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
7d10b60bcf
commit
c4e99d2ca6
@@ -25,8 +25,11 @@ pub async fn check(executable: &OsStr) -> Result<(), crate::BoxError> {
|
||||
let mut child = spawn_help(executable)?;
|
||||
match timeout(Duration::from_secs(10), child.wait()).await {
|
||||
Ok(Ok(status)) if status.success() => Ok(()),
|
||||
Ok(Ok(status)) => Err(format!("engine --help probe failed ({status}); check loader/shared-library dependencies \
|
||||
or use a profile with a working --help command").into()),
|
||||
Ok(Ok(status)) => Err(format!(
|
||||
"engine --help probe failed ({status}); check loader/shared-library dependencies \
|
||||
or use a profile with a working --help command"
|
||||
)
|
||||
.into()),
|
||||
failure => {
|
||||
let _ = child.kill().await;
|
||||
Err(match failure {
|
||||
|
||||
@@ -95,7 +95,11 @@ fn three_dialect_bodies() -> [(serde_json::Value, &'static str, &'static str); 3
|
||||
let responses = json!({"object": "response", "output": [
|
||||
{"type": "reasoning", "content": [{"type": "reasoning_text", "text": "x"}], "summary": [{"text": "y"}]},
|
||||
{"type": "message", "content": [{"type": "output_text", "text": "C"}]}], "usage": {"output_tokens": 3}});
|
||||
[(chat, "A", "r"), (messages, "B", "t"), (responses, "C", "xy")]
|
||||
[
|
||||
(chat, "A", "r"),
|
||||
(messages, "B", "t"),
|
||||
(responses, "C", "xy"),
|
||||
]
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -109,8 +109,10 @@ pub(super) fn select_active(states: &[(String, Value)]) -> Result<Option<(String
|
||||
if inactive(state) {
|
||||
continue;
|
||||
}
|
||||
let running = pid(state).map_err(|_| "catalog contains a failed, transitional or unknown service; reconcile \
|
||||
before selection")?;
|
||||
let running = pid(state).map_err(|_| {
|
||||
"catalog contains a failed, transitional or unknown service; reconcile \
|
||||
before selection"
|
||||
})?;
|
||||
if active.replace((id.clone(), running)).is_some() {
|
||||
return Err("multiple catalog services are active; selection is ambiguous".into());
|
||||
}
|
||||
|
||||
@@ -23,7 +23,17 @@ fn reconciliation_requires_explicit_exact_digest_arguments() {
|
||||
assert!(reconcile_arguments(&duplicate).is_err());
|
||||
}
|
||||
fn strict_catalog_arguments() -> [String; 8] {
|
||||
["--catalog", "/catalog", "--from", "a", "--to", "b", "--state-dir", "/state"].map(str::to_owned)
|
||||
[
|
||||
"--catalog",
|
||||
"/catalog",
|
||||
"--from",
|
||||
"a",
|
||||
"--to",
|
||||
"b",
|
||||
"--state-dir",
|
||||
"/state",
|
||||
]
|
||||
.map(str::to_owned)
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -152,6 +152,6 @@ mod admission;
|
||||
mod engine_io;
|
||||
mod generation;
|
||||
#[allow(unused_imports)]
|
||||
use generation::*;
|
||||
#[allow(unused_imports)]
|
||||
use admission::admit_request;
|
||||
#[allow(unused_imports)]
|
||||
use generation::*;
|
||||
|
||||
@@ -194,6 +194,6 @@ mod reasoning;
|
||||
mod restart;
|
||||
|
||||
use harness::{
|
||||
Rig, answer_within, assert_one_request_cancelled, assert_worker_is_ready, first_streamed_token, generate_command,
|
||||
join_within, marker_config, start_rig, wait_for_file,
|
||||
Rig, answer_within, assert_one_request_cancelled, assert_worker_is_ready, first_streamed_token,
|
||||
generate_command, join_within, marker_config, start_rig, wait_for_file,
|
||||
};
|
||||
|
||||
@@ -138,7 +138,8 @@ impl<'c> Experimental<'c> {
|
||||
) -> Result<()> {
|
||||
self.expect(Program::KvQ4)?;
|
||||
let grid = experimental::q4_gather_grid(max_ids, &p.shape)?;
|
||||
let gather = Q4Gather { p, k_q4, v_q4, table, ids, step, max_ids, k_scratch: &*k_scratch, v_scratch: &*v_scratch };
|
||||
let gather =
|
||||
Q4Gather { p, k_q4, v_q4, table, ids, step, max_ids, k_scratch: &*k_scratch, v_scratch: &*v_scratch };
|
||||
self.run(vec![gather.launch(self, grid)?])
|
||||
}
|
||||
|
||||
|
||||
@@ -27,8 +27,7 @@ pub(super) fn pattern(count: usize, salt: usize, modulus: usize, scale: f32, off
|
||||
impl<'a> Row<'a> {
|
||||
pub(super) fn new(context: &'a Context<'_>, salt: usize, poison: Poison) -> Result<Self> {
|
||||
let (host_alpha, host_weights, host_state, host_z) = Self::host_inputs(salt, poison);
|
||||
let [history, qkv, weights, alpha, beta_raw] =
|
||||
Self::upload_front(context, salt, [&host_weights, &host_alpha])?;
|
||||
let [history, qkv, weights, alpha, beta_raw] = Self::upload_front(context, salt, [&host_weights, &host_alpha])?;
|
||||
let [dt, a, gamma, z, state] = Self::upload_constants(context, [&host_z, &host_state])?;
|
||||
let [next_history, raw, h, qk, sigmoid] = Self::blank_products(context)?;
|
||||
let [gate, next_state, readout, normalized] = Self::blank_tail(context)?;
|
||||
|
||||
@@ -304,11 +304,7 @@ fn drive<'c>(
|
||||
}
|
||||
|
||||
/// The six stages of the program, in order, up to the candidate fetch.
|
||||
fn queue_program<'c>(
|
||||
prefix: &mut GdnFusedPrefix<'c, '_>,
|
||||
b: &'c RunBuffers<'c>,
|
||||
from_resident: bool,
|
||||
) -> Result<()> {
|
||||
fn queue_program<'c>(prefix: &mut GdnFusedPrefix<'c, '_>, b: &'c RunBuffers<'c>, from_resident: bool) -> Result<()> {
|
||||
prefix.scan_inputs(&b.qkv, &b.z)?;
|
||||
prefix.seed_state(if from_resident { Some(&b.resident) } else { None }, &b.next_state)?;
|
||||
prefix.conv_l2(&b.hist, &b.conv, &b.h, EPS)?;
|
||||
|
||||
@@ -16,8 +16,9 @@ use std::{
|
||||
|
||||
use futures_util::Stream;
|
||||
use leleka_backend_api::{
|
||||
Backend, ErrorCode, FinishReason, GenerationEvent, GenerationRequest, GenerationTerminal, InferenceMode,
|
||||
LoadedModel, ModelDescriptor, RuntimeConfig, SamplingOptions, StreamError, Usage,
|
||||
Backend, ErrorCode, FinishReason, GenerationEvent, GenerationRequest, GenerationTerminal,
|
||||
InferenceMode, LoadedModel, ModelDescriptor, RuntimeConfig, SamplingOptions, StreamError,
|
||||
Usage,
|
||||
};
|
||||
use leleka_runtime_client::{
|
||||
backend::GrpcBackend,
|
||||
|
||||
@@ -25,7 +25,11 @@ async fn reconfigure_reaches_the_runtime_and_returns_the_effective_settings_or_t
|
||||
let (_backend, refused) = blocking(backend, |b| b.reconfigure("{\"bad\":1}")).await;
|
||||
let error = refused.unwrap_err();
|
||||
assert_eq!(error.code, leleka_backend_api::ErrorCode::InvalidRequest);
|
||||
assert!(error.message.contains("context_tokens"), "{}", error.message);
|
||||
assert!(
|
||||
error.message.contains("context_tokens"),
|
||||
"{}",
|
||||
error.message
|
||||
);
|
||||
server.finish().await;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,25 +8,31 @@ async fn a_restarted_runtime_is_refused_before_dispatch_and_reattach_follows_the
|
||||
let server = Server::start(Some(loaded("h-1"))).await;
|
||||
let (backend, attached) = blocking(server.backend(), |b| b.load(descriptor(), config())).await;
|
||||
let attached = attached.unwrap();
|
||||
let (backend, empty) = blocking(backend, |b| b.capabilities().supported_models.is_empty()).await;
|
||||
let (backend, empty) =
|
||||
blocking(backend, |b| b.capabilities().supported_models.is_empty()).await;
|
||||
assert!(!empty, "a healthy attached runtime advertises its model");
|
||||
|
||||
// The runtime process restarts and loads the same model again: same handle, new epoch.
|
||||
server.fake.restart();
|
||||
server.fake.set_loaded(Some(loaded("h-1")));
|
||||
let (backend, result) = blocking(backend, move |b| b.start_generation(&attached, request(&id()))).await;
|
||||
let (backend, result) = blocking(backend, move |b| {
|
||||
b.start_generation(&attached, request(&id()))
|
||||
})
|
||||
.await;
|
||||
let error = result.err().expect("a stale epoch must not be dispatched");
|
||||
assert_eq!(error.code, ErrorCode::BackendUnavailable);
|
||||
assert!(error.retryable);
|
||||
assert!(server.fake.state.lock().unwrap().requests.is_empty());
|
||||
|
||||
// The health probe reports the model as gone until the caller attaches again.
|
||||
let (backend, empty) = blocking(backend, |b| b.capabilities().supported_models.is_empty()).await;
|
||||
let (backend, empty) =
|
||||
blocking(backend, |b| b.capabilities().supported_models.is_empty()).await;
|
||||
assert!(empty);
|
||||
let (backend, again) = blocking(backend, |b| b.load(descriptor(), config())).await;
|
||||
let again = again.unwrap();
|
||||
server.fake.push(vec![Ok(terminal(1, "stop", true))]);
|
||||
let (_backend, stream) = blocking(backend, move |b| b.start_generation(&again, request(&id()))).await;
|
||||
let (_backend, stream) =
|
||||
blocking(backend, move |b| b.start_generation(&again, request(&id()))).await;
|
||||
assert!(stream.is_ok());
|
||||
server.finish().await;
|
||||
}
|
||||
|
||||
@@ -13,9 +13,12 @@ impl Server {
|
||||
let task = tokio::spawn(async move {
|
||||
tonic::transport::Server::builder()
|
||||
.add_service(proto::runtime_server::RuntimeServer::new(service))
|
||||
.serve_with_incoming_shutdown(tokio_stream::wrappers::TcpListenerStream::new(listener), async {
|
||||
let _ = stopped.await;
|
||||
})
|
||||
.serve_with_incoming_shutdown(
|
||||
tokio_stream::wrappers::TcpListenerStream::new(listener),
|
||||
async {
|
||||
let _ = stopped.await;
|
||||
},
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
});
|
||||
@@ -28,7 +31,11 @@ impl Server {
|
||||
}
|
||||
|
||||
pub(super) fn backend(&self) -> GrpcBackend {
|
||||
GrpcBackend::new(tokio::runtime::Handle::current(), self.address, TOKEN.into())
|
||||
GrpcBackend::new(
|
||||
tokio::runtime::Handle::current(),
|
||||
self.address,
|
||||
TOKEN.into(),
|
||||
)
|
||||
}
|
||||
|
||||
pub(super) async fn finish(mut self) {
|
||||
@@ -104,7 +111,9 @@ pub(super) fn id() -> String {
|
||||
uuid::Uuid::new_v4().to_string()
|
||||
}
|
||||
|
||||
pub(super) fn drain(stream: &mut leleka_backend_api::GenerationStream) -> (Vec<GenerationEvent>, bool) {
|
||||
pub(super) fn drain(
|
||||
stream: &mut leleka_backend_api::GenerationStream,
|
||||
) -> (Vec<GenerationEvent>, bool) {
|
||||
let mut events = Vec::new();
|
||||
loop {
|
||||
match stream.recv() {
|
||||
|
||||
@@ -7,20 +7,31 @@ use super::*;
|
||||
async fn a_stream_that_ends_without_a_terminal_or_with_a_transport_error_has_no_terminal() {
|
||||
let server = Server::start(Some(loaded("h-1"))).await;
|
||||
server.fake.push(vec![Ok(text("half"))]);
|
||||
server.fake.push(vec![Ok(text("half")), Err(Status::internal("reset"))]);
|
||||
server
|
||||
.fake
|
||||
.push(vec![Ok(text("half")), Err(Status::internal("reset"))]);
|
||||
// A frame the contract cannot express (unknown finish reason) is not turned into a success.
|
||||
server.fake.push(vec![Ok(terminal(1, "weird", true))]);
|
||||
let (mut backend, attached) = blocking(server.backend(), |b| b.load(descriptor(), config())).await;
|
||||
let (mut backend, attached) =
|
||||
blocking(server.backend(), |b| b.load(descriptor(), config())).await;
|
||||
let attached = attached.unwrap();
|
||||
for case in 0..3 {
|
||||
let (b, stream) = {
|
||||
let attached = attached.clone();
|
||||
blocking(backend, move |b| b.start_generation(&attached, request(&id()))).await
|
||||
blocking(backend, move |b| {
|
||||
b.start_generation(&attached, request(&id()))
|
||||
})
|
||||
.await
|
||||
};
|
||||
backend = b;
|
||||
let mut stream = stream.unwrap();
|
||||
let (_, terminated) = tokio::task::spawn_blocking(move || drain(&mut stream)).await.unwrap();
|
||||
assert!(!terminated, "case {case}: no terminal event may be invented");
|
||||
let (_, terminated) = tokio::task::spawn_blocking(move || drain(&mut stream))
|
||||
.await
|
||||
.unwrap();
|
||||
assert!(
|
||||
!terminated,
|
||||
"case {case}: no terminal event may be invented"
|
||||
);
|
||||
}
|
||||
server.finish().await;
|
||||
}
|
||||
@@ -29,10 +40,15 @@ async fn a_stream_that_ends_without_a_terminal_or_with_a_transport_error_has_no_
|
||||
async fn dropping_the_stream_cancels_the_request_on_the_runtime() {
|
||||
let server = Server::start(Some(loaded("h-1"))).await;
|
||||
// The runtime stays silent after one delta; the consumer goes away while the pump waits.
|
||||
server.fake.push(vec![Ok(text("a")), Err(Status::aborted("hang"))]);
|
||||
server
|
||||
.fake
|
||||
.push(vec![Ok(text("a")), Err(Status::aborted("hang"))]);
|
||||
let (backend, attached) = blocking(server.backend(), |b| b.load(descriptor(), config())).await;
|
||||
let attached = attached.unwrap();
|
||||
let (_backend, stream) = blocking(backend, move |b| b.start_generation(&attached, request(&id()))).await;
|
||||
let (_backend, stream) = blocking(backend, move |b| {
|
||||
b.start_generation(&attached, request(&id()))
|
||||
})
|
||||
.await;
|
||||
let mut stream = stream.unwrap();
|
||||
let first = tokio::task::spawn_blocking(move || {
|
||||
let first = stream.recv();
|
||||
@@ -56,7 +72,9 @@ async fn dropping_the_stream_cancels_the_request_on_the_runtime() {
|
||||
async fn explicit_cancel_addresses_the_active_request_and_unknown_ids_are_refused() {
|
||||
let server = Server::start(Some(loaded("h-1"))).await;
|
||||
// The scripted stream never terminates; the request stays active until cancelled.
|
||||
server.fake.push(vec![Ok(text("a")), Err(Status::aborted("hang"))]);
|
||||
server
|
||||
.fake
|
||||
.push(vec![Ok(text("a")), Err(Status::aborted("hang"))]);
|
||||
let (backend, attached) = blocking(server.backend(), |b| b.load(descriptor(), config())).await;
|
||||
let attached = attached.unwrap();
|
||||
let request_id = id();
|
||||
|
||||
@@ -64,7 +64,7 @@ impl SshProfile {
|
||||
}
|
||||
// Static stdin only: no profile values interpolated into this remote shell program.
|
||||
const PROBE: &str = concat!(
|
||||
r#"export LC_ALL=C
|
||||
r#"export LC_ALL=C
|
||||
printf 'os\t'; uname -s
|
||||
if [ "$(uname -s)" != Linux ]; then exit 0; fi
|
||||
printf 'arch\t'; uname -m
|
||||
@@ -75,7 +75,7 @@ awk '/^MemTotal:/ {print "total_kib\t" $2} /^MemAvailable:/ {print "available_ki
|
||||
df -Pk . 2>/dev/null | awk 'NR==2 {print "disk_available_kib\t" $4}'
|
||||
if command -v nvidia-smi >/dev/null 2>&1; then
|
||||
nvidia-smi --query-gpu=name,memory.total,memory.free,driver_version "#,
|
||||
r#"--format=csv,noheader,nounits 2>/dev/null | sed 's/^/gpu\t/'
|
||||
r#"--format=csv,noheader,nounits 2>/dev/null | sed 's/^/gpu\t/'
|
||||
fi
|
||||
printf 'end\tok\n'
|
||||
"#
|
||||
|
||||
Reference in New Issue
Block a user