From c4e99d2ca6dd1cb048254b2443f1e7b7fda4b87a Mon Sep 17 00:00:00 2001 From: Pavlo Ratushnyi Date: Sat, 7 Nov 2026 09:41:44 +0100 Subject: [PATCH] STRA-338: rustfmt of the merged size-gw files Co-Authored-By: Claude Sonnet 5.5 --- control-plane/src/engine_probe.rs | 7 ++-- control-plane/src/request_monitor/tests.rs | 6 +++- .../src/service_switch/provision_budget.rs | 6 ++-- control-plane/src/service_switch/tests.rs | 12 ++++++- control-plane/src/worker.rs | 4 +-- control-plane/src/worker/tests.rs | 4 +-- .../impl_experimental/impl_experimental_2.rs | 3 +- .../src/gdn_closed_queue_gpu/bytes_fn.rs | 3 +- crates/cuda-driver/src/gdn_fused_t1_gpu.rs | 6 +--- crates/runtime-client/tests/grpc_backend.rs | 5 +-- .../grpc_backend/attach_and_reconfigure.rs | 6 +++- .../grpc_backend/runtime_restart_and_loss.rs | 14 +++++--- .../tests/grpc_backend/server_and_frames.rs | 19 ++++++++--- .../tests/grpc_backend/stream_lifecycle.rs | 34 ++++++++++++++----- desktop-core/src/remote.rs | 4 +-- 15 files changed, 93 insertions(+), 40 deletions(-) diff --git a/control-plane/src/engine_probe.rs b/control-plane/src/engine_probe.rs index 022d3a4e..64978632 100644 --- a/control-plane/src/engine_probe.rs +++ b/control-plane/src/engine_probe.rs @@ -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 { diff --git a/control-plane/src/request_monitor/tests.rs b/control-plane/src/request_monitor/tests.rs index 5d7f5021..6fc6dcb8 100644 --- a/control-plane/src/request_monitor/tests.rs +++ b/control-plane/src/request_monitor/tests.rs @@ -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] diff --git a/control-plane/src/service_switch/provision_budget.rs b/control-plane/src/service_switch/provision_budget.rs index f3f8db58..a5ebe567 100644 --- a/control-plane/src/service_switch/provision_budget.rs +++ b/control-plane/src/service_switch/provision_budget.rs @@ -109,8 +109,10 @@ pub(super) fn select_active(states: &[(String, Value)]) -> Result [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] diff --git a/control-plane/src/worker.rs b/control-plane/src/worker.rs index 040c419e..653a8306 100644 --- a/control-plane/src/worker.rs +++ b/control-plane/src/worker.rs @@ -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::*; diff --git a/control-plane/src/worker/tests.rs b/control-plane/src/worker/tests.rs index 1e760d30..7b4b76e4 100644 --- a/control-plane/src/worker/tests.rs +++ b/control-plane/src/worker/tests.rs @@ -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, }; diff --git a/crates/cuda-driver/src/experimental_gpu/impl_experimental/impl_experimental_2.rs b/crates/cuda-driver/src/experimental_gpu/impl_experimental/impl_experimental_2.rs index 0282dc84..34f820e5 100644 --- a/crates/cuda-driver/src/experimental_gpu/impl_experimental/impl_experimental_2.rs +++ b/crates/cuda-driver/src/experimental_gpu/impl_experimental/impl_experimental_2.rs @@ -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)?]) } diff --git a/crates/cuda-driver/src/gdn_closed_queue_gpu/bytes_fn.rs b/crates/cuda-driver/src/gdn_closed_queue_gpu/bytes_fn.rs index 52bec529..84beebcc 100644 --- a/crates/cuda-driver/src/gdn_closed_queue_gpu/bytes_fn.rs +++ b/crates/cuda-driver/src/gdn_closed_queue_gpu/bytes_fn.rs @@ -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 { 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)?; diff --git a/crates/cuda-driver/src/gdn_fused_t1_gpu.rs b/crates/cuda-driver/src/gdn_fused_t1_gpu.rs index 69decb3e..5333a7f6 100644 --- a/crates/cuda-driver/src/gdn_fused_t1_gpu.rs +++ b/crates/cuda-driver/src/gdn_fused_t1_gpu.rs @@ -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)?; diff --git a/crates/runtime-client/tests/grpc_backend.rs b/crates/runtime-client/tests/grpc_backend.rs index 2af9bae8..1f7960b5 100644 --- a/crates/runtime-client/tests/grpc_backend.rs +++ b/crates/runtime-client/tests/grpc_backend.rs @@ -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, diff --git a/crates/runtime-client/tests/grpc_backend/attach_and_reconfigure.rs b/crates/runtime-client/tests/grpc_backend/attach_and_reconfigure.rs index 38371c80..5185a6d9 100644 --- a/crates/runtime-client/tests/grpc_backend/attach_and_reconfigure.rs +++ b/crates/runtime-client/tests/grpc_backend/attach_and_reconfigure.rs @@ -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; } diff --git a/crates/runtime-client/tests/grpc_backend/runtime_restart_and_loss.rs b/crates/runtime-client/tests/grpc_backend/runtime_restart_and_loss.rs index 6160da37..690cb974 100644 --- a/crates/runtime-client/tests/grpc_backend/runtime_restart_and_loss.rs +++ b/crates/runtime-client/tests/grpc_backend/runtime_restart_and_loss.rs @@ -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; } diff --git a/crates/runtime-client/tests/grpc_backend/server_and_frames.rs b/crates/runtime-client/tests/grpc_backend/server_and_frames.rs index 27660cdd..518973ab 100644 --- a/crates/runtime-client/tests/grpc_backend/server_and_frames.rs +++ b/crates/runtime-client/tests/grpc_backend/server_and_frames.rs @@ -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, bool) { +pub(super) fn drain( + stream: &mut leleka_backend_api::GenerationStream, +) -> (Vec, bool) { let mut events = Vec::new(); loop { match stream.recv() { diff --git a/crates/runtime-client/tests/grpc_backend/stream_lifecycle.rs b/crates/runtime-client/tests/grpc_backend/stream_lifecycle.rs index cbe109e6..9bc2bf14 100644 --- a/crates/runtime-client/tests/grpc_backend/stream_lifecycle.rs +++ b/crates/runtime-client/tests/grpc_backend/stream_lifecycle.rs @@ -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(); diff --git a/desktop-core/src/remote.rs b/desktop-core/src/remote.rs index c6660838..63c65092 100644 --- a/desktop-core/src/remote.rs +++ b/desktop-core/src/remote.rs @@ -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' "#