Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,22 @@ unsafe_op_in_unsafe_fn = "warn"
[workspace.lints.clippy]
# Widely-satisfied hygiene lints only.
uninlined_format_args = "warn"
# rustc/clippy 1.98.0 (2026-08-18) added `chunks_exact_to_as_chunks`, a warn-by-default
# lint that fires at 201 call sites across 12 crates here and so turns every
# `-D warnings` gate red the moment a runner picks up the new stable. This repo pins no
# toolchain, so that is not opt-in.
#
# It is also not uniformly auto-fixable: where the chunk size is an associated const of
# a type parameter (`onnx-runtime-ir::read_vec_le` uses `T::BYTE_SIZE`), the suggested
# `as_chunks::<T::BYTE_SIZE>()` fails to compile — "generic parameters may not be used
# in const operations". Verified directly against rustc 1.98.0.
#
# Allowed centrally so a toolchain bump cannot gate unrelated work. Migrating the sites
# that do benefit (`as_chunks` yields `&[T; N]`, dropping fallible `try_into` and helping
# codegen) is worth doing per-crate by each owner, not as one 201-site emergency rewrite:
# tracked in #1606, which also owns deleting this line. #1605 covers pinning the toolchain
# so the next new stable lint is not an outage.
chunks_exact_to_as_chunks = "allow"

[workspace.dependencies]
# Internal crates
Expand Down
4 changes: 1 addition & 3 deletions crates/onnx-genai-engine/src/decode/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,7 @@ impl DecodeRunner {
/// and a pure-dense native runner — answers `None`, so the commit machinery
/// stays inert outside hybrid recurrent targets.
#[cfg(feature = "native-backend")]
fn native_recurrent_mut(
&mut self,
) -> Option<&mut crate::native_decode::NativeDecodeSession> {
fn native_recurrent_mut(&mut self) -> Option<&mut crate::native_decode::NativeDecodeSession> {
match self {
DecodeRunner::Native(runner) if runner.has_recurrent_state() => Some(runner),
_ => None,
Expand Down
4 changes: 3 additions & 1 deletion crates/onnx-genai-engine/src/decode/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,9 @@ impl DecodeState {
pub(crate) fn native_recurrent_runner_mut(
&mut self,
) -> Option<&mut crate::native_decode::NativeDecodeSession> {
self.runner.as_mut().and_then(DecodeRunner::native_recurrent_mut)
self.runner
.as_mut()
.and_then(DecodeRunner::native_recurrent_mut)
}

pub(crate) fn rewind_runner(&mut self, target_len: usize) -> anyhow::Result<()> {
Expand Down
20 changes: 8 additions & 12 deletions crates/onnx-genai-engine/src/native_decode/cuda.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4836,9 +4836,7 @@ impl DecodeCudaState {
}
}
self.set_logical_len(seq_len)?;
for row_len in &mut self.row_lens {
*row_len = seq_len;
}
self.row_lens.fill(seq_len);
let expose = self.decode_mask_expose_len(seq_len);
self.extend_mask(0, seq_len, expose)?;
Ok(())
Expand All @@ -4861,9 +4859,7 @@ impl DecodeCudaState {
self.bindings[0].set_logical_shape(vec![self.batch, target_len])?;
// Ragged per-row lengths collapse back to the uniform rewind target
// (stage 3a, #750): after a rewind every row shares `target_len`.
for row_len in &mut self.row_lens {
*row_len = target_len;
}
self.row_lens.fill(target_len);
if target_len == 0 {
// Fixed-size recurrent/conv states are unmasked rolling caches: a
// reused session would otherwise inherit the previous generation's
Expand Down Expand Up @@ -4905,9 +4901,9 @@ impl DecodeCudaState {
binding.physical_shape()
)
})?;
let host = binding.read_bytes_range(0, bytes).with_context(|| {
format!("read device recurrent/conv state for binding {index}")
})?;
let host = binding
.read_bytes_range(0, bytes)
.with_context(|| format!("read device recurrent/conv state for binding {index}"))?;
snapshot.push((index, host));
}
Ok(snapshot)
Expand Down Expand Up @@ -4937,9 +4933,9 @@ impl DecodeCudaState {
host.len()
);
}
binding
.write_bytes(0, host)
.with_context(|| format!("restore device recurrent/conv state for binding {index}"))?;
binding.write_bytes(0, host).with_context(|| {
format!("restore device recurrent/conv state for binding {index}")
})?;
}
Ok(())
}
Expand Down
9 changes: 7 additions & 2 deletions crates/onnx-genai-engine/src/native_decode/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -514,9 +514,14 @@ impl NativeDecodeSession {
let mut host = HashMap::with_capacity(recurrent.len());
for name in &recurrent {
let tensor = self.past.get(name).with_context(|| {
format!("recurrent state '{name}' is not materialized yet; snapshot it after a step")
format!(
"recurrent state '{name}' is not materialized yet; snapshot it after a step"
)
})?;
host.insert(name.clone(), tensor.try_clone().map_err(anyhow::Error::from)?);
host.insert(
name.clone(),
tensor.try_clone().map_err(anyhow::Error::from)?,
);
}
Ok(RecurrentStateSnapshot {
len,
Expand Down
5 changes: 4 additions & 1 deletion crates/onnx-genai-engine/src/native_decode/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,10 @@ fn mutating_hybrid_decoder() -> InferenceSession {
"ReduceSum",
vec![cast],
token_sum,
&[("axes", Attribute::Ints(vec![1])), ("keepdims", Attribute::Int(1))],
&[
("axes", Attribute::Ints(vec![1])),
("keepdims", Attribute::Int(1)),
],
);
let current_kv = graph.create_value(
DataType::Float32,
Expand Down
13 changes: 5 additions & 8 deletions crates/onnx-runtime-ep-cpu/src/kernels/moe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1014,18 +1014,16 @@ pub(super) fn run_expert_grouped(
let mut fc1_out = linear_grouped(input, rows, fc1_weights, fc1_bias, fc1_size, hidden)?;
let activated = match attributes.activation {
Activation::Swiglu => {
let linear_part;
let gate_part;
if attributes.swiglu_fusion == 0 {
gate_part = fc1_out;
linear_part = linear_grouped(
let (gate_part, linear_part) = if attributes.swiglu_fusion == 0 {
let linear = linear_grouped(
input,
rows,
fc3_weights.expect("validated unfused swiglu FC3"),
fc3_bias,
inter,
hidden,
)?;
(fc1_out, linear)
} else {
let mut gate = Vec::with_capacity(rows * inter);
let mut linear = Vec::with_capacity(rows * inter);
Expand All @@ -1040,9 +1038,8 @@ pub(super) fn run_expert_grouped(
linear.extend_from_slice(&row[inter..]);
}
}
gate_part = gate;
linear_part = linear;
}
(gate, linear)
};
gate_part
.into_iter()
.zip(linear_part)
Expand Down
Loading