ml: keep Whisper cross-attention K/V on device, row-mode long softmax
- Commit
8eb8ee18e343763ad1c6a8aa746d1add3d7cb0ea- Author
- vayun-mathur <[email protected]>
- When
- 2026-10-25 19:56 UTC (1 month ago)
- Parents
c3d29a4
Diff
library/ml/src/main/rust/examples/profile_net.rs
diff --git a/library/ml/src/main/rust/examples/profile_net.rs b/library/ml/src/main/rust/examples/profile_net.rsindex 0070645392..566e3f09d1 100644--- a/library/ml/src/main/rust/examples/profile_net.rs+++ b/library/ml/src/main/rust/examples/profile_net.rs@@ -10,7 +10,7 @@ use std::collections::BTreeMap; use std::time::Instant; -use modelrunner::nets::nllb;+use modelrunner::nets::{nllb, whisper}; use modelrunner::vulkan::context; use modelrunner::vulkan::reshape::Reshaped; use modelrunner::vulkan::run::{Net, StepParams};@@ -27,7 +27,8 @@ fn main() { let model = args.first().map(String::as_str).unwrap_or("nllb"); let result = match model { "nllb" => nllb_profile(args.get(1).map(String::as_str)),- other => Err(format!("unknown model {other:?}; known: nllb")),+ "whisper" => whisper_profile(args.get(1).map(String::as_str)),+ other => Err(format!("unknown model {other:?}; known: nllb, whisper")), }; if let Err(why) = result { println!("failed: {why}");@@ -96,6 +97,84 @@ fn nllb_profile(path: Option<&str>) -> Result<(), String> { Ok(()) } +/// Whisper over a synthetic window: the real prompt, then a fixed number of greedy steps.+///+/// Prints the ids and a logits checksum so two builds can be compared for identical output, which+/// is the regression check here - there is no recorded reference transcript to match.+fn whisper_profile(path: Option<&str>) -> Result<(), String> {+ const STEPS: u32 = 32;+ // `<|startoftranscript|> <|en|> <|transcribe|> <|notimestamps|>`.+ const PROMPT: [u32; 4] = [50_258, 50_259, 50_359, 50_363];+ let path = path+ .map(str::to_owned)+ .or_else(|| std::env::var("MODELRUNNER_WHISPER").ok())+ .ok_or("pass the whisper_base.maml path or set MODELRUNNER_WHISPER")?;+ let bytes = std::fs::read(&path).map_err(|e| format!("cannot read {path}: {e}"))?;+ let weights = Weights::parse(&bytes, graph::WHISPER)?;+ let context = context::shared()?;++ let started = Instant::now();+ let mut net = Reshaped::new(context, &weights, whisper::Mode::Encode, |offsets, mode| {+ whisper::build(offsets, mode)+ })?;+ println!("load {:>8.1} ms (upload + first record)", ms(started));++ // A deterministic log-mel-like window: smooth in time, varied across bins.+ let mel: Vec<f32> = (0..whisper::MELS * whisper::MEL_FRAMES)+ .map(|i| {+ let (bin, frame) = (i / whisper::MEL_FRAMES, i % whisper::MEL_FRAMES);+ ((frame as f32 * 0.013 + bin as f32 * 0.37).sin() * 0.6 - 0.2).clamp(-1.0, 1.0)+ })+ .collect();++ let mut encode_ms = Vec::new();+ let mut step_ms = Vec::new();+ let mut ids = Vec::new();+ let mut checksum = 0.0f64;+ for round in 0..2 {+ let t = Instant::now();+ let encoder = net.at(whisper::Mode::Encode)?;+ let encoded = encoder.infer_raw_many(&[&mel])?;+ encode_ms.push(ms(t));+ // HEAD's encoder hands its twelve cross caches back; the decode step there takes them in.+ let cross: Vec<Vec<f32>> = encoded.into_iter().skip(1).collect();++ let mut token = PROMPT[0];+ for step in 0..PROMPT.len() as u32 + STEPS {+ let row = whisper::embed_positions(weights.reader(), &[token], step)?;+ let at = net.at(whisper::Mode::DecodeStep)?;+ at.set_params(StepParams { prefix: step, window_start: 0 })?;+ let mut inputs: Vec<&[f32]> = vec![&row];+ inputs.extend(cross.iter().map(Vec::as_slice));+ let t = Instant::now();+ let out = at.infer_raw_many(&inputs)?;+ step_ms.push(ms(t));+ let logits = out.first().ok_or("no logits")?;+ token = if let Some(&next) = PROMPT.get(step as usize + 1) {+ next+ } else {+ let next = greedy(&out).unwrap_or(50_257);+ if round == 0 {+ ids.push(next);+ checksum += logits.iter().map(|&v| f64::from(v)).sum::<f64>();+ }+ next+ };+ }+ }+ println!("encode {}", stats(&encode_ms));+ println!("step {}", stats(&step_ms));+ println!("ids {ids:?}");+ println!("checksum {checksum:.3}");++ let decode = net.at(whisper::Mode::DecodeStep)?;+ print_kinds("decode step", decode);+ let encode = net.at(whisper::Mode::Encode)?;+ encode.infer_raw_many(&[&mel])?;+ print_kinds("encode", encode);+ Ok(())+}+ /// The token from a greedy plan's `[lo, hi]` output, or the argmax of a logits plan's splits. fn greedy(out: &[Vec<f32>]) -> Option<u32> { if let [pair] = out {
library/ml/src/main/rust/src/bridge_part5.rs
diff --git a/library/ml/src/main/rust/src/bridge_part5.rs b/library/ml/src/main/rust/src/bridge_part5.rsindex f90aeae8e9..e28da693f8 100644--- a/library/ml/src/main/rust/src/bridge_part5.rs+++ b/library/ml/src/main/rust/src/bridge_part5.rs@@ -39,15 +39,15 @@ pub unsafe extern "system" fn Java_com_vayunmathur_library_ml_MlNative_destroyMu /// /// # One net, two plans, and two kinds of cache ///-/// [`Reshaped`] keyed by [`whisper::Mode`]. The encoder runs once per utterance; a decode step is-/// re-recorded every token because its self-attention cache grows by one position, which is a-/// `device_wait_idle` and a re-record per token — the same known cost the translation handle-/// documents.+/// [`Reshaped`] keyed by [`whisper::Mode`]. The encoder runs once per utterance and the decode step+/// is recorded once - its key carries no step number, which reaches the plan through+/// [`StepParams`] - so a transcription pays one re-record on each switch between the two. ///-/// The **cross-attention** caches are the difference. Whisper's decoder cross-attends over 1500-/// encoder positions through each layer's own key and value projections, so recomputing them per-/// step would be 4.7 GMAC against the logits head's 26.5 MMAC. [`whisper::Mode::Encode`] computes-/// them once, they are held here, and each step passes them back in. See `nets::whisper`.+/// The **cross-attention** caches are the difference from a plain decoder. Whisper's decoder+/// cross-attends over 1500 encoder positions through each layer's own key and value projections,+/// so recomputing them per step would be 4.7 GMAC against the logits head's 26.5 MMAC.+/// [`whisper::Mode::Encode`] computes them once into tensors that stay on the device, at offsets+/// both plans agree on. See `nets::whisper`. /// /// # The weights file stays open ///@@ -64,24 +64,21 @@ fn whisper_plan(offsets: &Offsets, mode: whisper::Mode) -> Result<Plan, String> whisper::build(offsets, mode) } -/// Cross-attention caches per decoder layer, K then V. See [`WhisperHandle`].-const WHISPER_CROSS: usize = whisper::DECODER_LAYERS * 2;--/// The two GPU passes, as [`whisper_post::Nets`] wants them, plus the cross-attention caches.+/// The two GPU passes, as [`whisper_post::Nets`] wants them. ///-/// Built per transcription and dropped with it. The **self-attention** caches are not here at all-/// any more: the decode plan holds them in the arena and writes to them in place.+/// Built per transcription and dropped with it. Neither kind of cache is here: the encoder pass+/// leaves the cross-attention K and V in the arena and the decode plan writes its self-attention+/// rows there too. struct WhisperNets<'a> { net: &'a mut Reshaped<whisper::Mode>, weights: &'a Streamed,- /// Each layer's cross-attention K then V, `[512 * 1500]` each, channel-major and constant for- /// the whole transcript.- cross: Vec<Vec<f32>>,+ /// Whether this transcription's encoder has run, so a step cannot read last utterance's caches.+ encoded: bool, } impl WhisperNets<'_> { fn new<'a>(handle: &'a mut WhisperHandle) -> WhisperNets<'a> {- WhisperNets { net: &mut handle.net, weights: &handle.weights, cross: Vec::new() }+ WhisperNets { net: &mut handle.net, weights: &handle.weights, encoded: false } } } @@ -92,18 +89,15 @@ impl whisper_post::Nets for WhisperNets<'_> { return Err(format!("{} mel values, not {expected}", mel.len())); } let net = self.net.at(whisper::Mode::Encode)?;- let mut out = net.infer_raw_many(&[mel])?;- // Output 0 is the hidden states, which only the parity script reads; the twelve cross- // caches follow, in layer order.- if out.len() != 1 + WHISPER_CROSS {- return Err(format!("the encoder returned {} tensors, not {}", out.len(), 1 + WHISPER_CROSS));- }- self.cross = out.split_off(1);+ // The one output is the hidden states, which only the parity script reads. The twelve+ // cross caches it also computed stay on the device.+ net.infer_raw_many(&[mel])?;+ self.encoded = true; Ok(()) } fn decode_step(&mut self, token: u32, step: usize) -> Result<Vec<f32>, String> {- if self.cross.len() != WHISPER_CROSS {+ if !self.encoded { return Err("a decode step before the encoder ran".into()); } let cache_len = u32::try_from(step).map_err(|_| "a step past u32")?;@@ -119,13 +113,7 @@ impl whisper_post::Nets for WhisperNets<'_> { // One key for every step, so this re-records once - leaving `Encode` - and never again. let net = self.net.at(whisper::Mode::DecodeStep)?; net.set_params(StepParams { prefix: cache_len, window_start: 0 })?;- // Declaration order: the token, then the twelve cross caches.- let mut inputs: Vec<&[f32]> = Vec::with_capacity(1 + WHISPER_CROSS);- inputs.push(&embedded);- for held in &self.cross {- inputs.push(held);- }- let out = net.infer_raw_many(&inputs)?;+ let out = net.infer_raw_many(&[&embedded])?; // The logits, and nothing else: the self-attention rows went into the device-side cache. if out.len() != 1 {
library/ml/src/main/rust/src/nets/mod_part3.rs
diff --git a/library/ml/src/main/rust/src/nets/mod_part3.rs b/library/ml/src/main/rust/src/nets/mod_part3.rsindex 3353d14d52..7feb44fa2b 100644--- a/library/ml/src/main/rust/src/nets/mod_part3.rs+++ b/library/ml/src/main/rust/src/nets/mod_part3.rs@@ -58,6 +58,23 @@ fn row_reduce(rows: u32, len: u32) -> (u32, u32) { } } +/// Rows at least this long reduce one workgroup per row however many there are - for a softmax.+///+/// A softmax row is contiguous, so lanes splitting it read consecutive elements and the row mode+/// costs nothing in access pattern; a norm's row is strided by the sequence length, which is why+/// [`row_reduce`] keeps many-position norms on the per-position shader. Whisper's encoder has+/// 12,000 score rows of 1,500 keys: one thread each made its six softmaxes 420 ms on a Pixel 8.+const ROW_REDUCE_LONG_ROW: u32 = 512;++/// [`row_reduce`] for a softmax, whose rows are contiguous. See [`ROW_REDUCE_LONG_ROW`].+fn row_reduce_contiguous(rows: u32, len: u32) -> (u32, u32) {+ if len >= ROW_REDUCE_LONG_ROW {+ (1, rows * ROW_REDUCE_LANES)+ } else {+ row_reduce(rows, len)+ }+}+ #[cfg(test)] fn gemv_rows_of(shader: &str) -> u32 { let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("shaders").join(shader);
library/ml/src/main/rust/src/nets/mod_part9b.rs
diff --git a/library/ml/src/main/rust/src/nets/mod_part9b.rs b/library/ml/src/main/rust/src/nets/mod_part9b.rsindex a9340a1b1b..5daa1b4010 100644--- a/library/ml/src/main/rust/src/nets/mod_part9b.rs+++ b/library/ml/src/main/rust/src/nets/mod_part9b.rs@@ -343,7 +343,7 @@ impl<'a> Builder<'a> { let rows = so.c * so.h; let (kw, invocations) = match mode { SoftmaxMode::Causal => (0, rows),- SoftmaxMode::Full | SoftmaxMode::Prefix => row_reduce(rows, so.w),+ SoftmaxMode::Full | SoftmaxMode::Prefix => row_reduce_contiguous(rows, so.w), }; ops.push(Op::Dispatch { kind: match mode {
library/ml/src/main/rust/src/nets/reference_part9.rs
diff --git a/library/ml/src/main/rust/src/nets/reference_part9.rs b/library/ml/src/main/rust/src/nets/reference_part9.rsindex 5982408ec0..b8c238ba85 100644--- a/library/ml/src/main/rust/src/nets/reference_part9.rs+++ b/library/ml/src/main/rust/src/nets/reference_part9.rs@@ -132,8 +132,7 @@ .expect("the whisper asset parses"); let plan = whisper::build(&weights, whisper::Mode::Encode).expect("the encoder builds"); let outputs = run_multi(&plan, weights.data(), &[&input]).expect("the encoder runs");- // Output 0 is the hidden states; the twelve cross-attention caches follow and are not- // what the export's own output is.+ // The one output is the hidden states; the cross-attention caches stay on the device. let hidden = outputs.first().expect("the hidden states"); write(&dir.join("reference.f32"), hidden); println!("whisper encoder: wrote {} values", hidden.len());
library/ml/src/main/rust/src/nets/whisper.rs
diff --git a/library/ml/src/main/rust/src/nets/whisper.rs b/library/ml/src/main/rust/src/nets/whisper.rsindex 656d14d6ed..c229f04dd0 100644--- a/library/ml/src/main/rust/src/nets/whisper.rs+++ b/library/ml/src/main/rust/src/nets/whisper.rs@@ -51,12 +51,15 @@ //! step*, against the 26.5 MMAC of the logits head. That is 177 times the head, and at 224 tokens it //! is a thousand GMAC. //!-//! So [`Mode::Encode`] runs them once and hands back **twelve** `[512, 1, 1500]` tensors, and-//! [`Mode::DecodeStep`] takes them as inputs. The host then re-uploads 18.4 MB per step, which at a-//! few GB/s is an order of magnitude cheaper than recomputing them — measured against arithmetic, not-//! on a device, and flagged for the device. Nothing is transposed: a single-query cross-attention-//! reads a channel-major sequence through the ordinary [`Builder::attn_scores`] pair, exactly as-//! `nets::nllb`'s does.+//! So [`Mode::Encode`] runs them once and copies them into **twelve** persistent `[512, 1, 1500]`+//! tensors that [`Mode::DecodeStep`] reads in place. Nothing comes back to the host and nothing is+//! re-uploaded: an earlier version handed them to the host and back in, 18.4 MB per token.+//!+//! Both passes declare those tensors first, through [`declare_cross_caches`], because+//! [`Builder::finish`] gives pinned tensors their arena offsets in declaration order, and that is+//! what puts them in the same place in both plans. Nothing is transposed: a single-query+//! cross-attention reads a channel-major sequence through the ordinary [`Builder::attn_scores`]+//! pair, exactly as `nets::nllb`'s does. //! //! # The two position tables go opposite ways //!@@ -187,12 +190,9 @@ pub const INT8_CONVS: usize = 2 + ENCODER_LAYERS * 6 + DECODER_LAYERS * 10 + 1; pub enum Mode { /// The audio encoder, and every decoder layer's cross-attention K and V. ///- /// `[80, 1, 3000]` in — the log-mel window. **Thirteen** outputs: the `[512, 1, 1500]` hidden- /// states, then layer 0's cross K and V, layer 1's, and so on, all the same shape.- ///- /// The hidden states are not needed by [`Mode::DecodeStep`] — the caches are what it reads — but- /// they are what `scripts/ml/onnx_parity.py` compares against the reference export, and the- /// readback is 1.5 MB once per utterance.+ /// `[80, 1, 3000]` in — the log-mel window. One output, the `[512, 1, 1500]` hidden states,+ /// which only `scripts/ml/onnx_parity.py` reads. The cross K and V stay on the device for+ /// [`Mode::DecodeStep`]; see [`declare_cross_caches`]. Encode, /// One decoder step against the self-attention cache. ///@@ -268,12 +268,27 @@ pub fn build(weights: &dyn WeightSource, mode: Mode) -> Result<Plan, String> { } } +/// Every decoder layer's cross-attention K and V, `[512, 1, 1500]` each, held on the device.+///+/// Must be the first pinned tensors either pass declares, so both plans give them the same arena+/// offsets. See the module docs.+fn declare_cross_caches(b: &mut Builder) -> Vec<(Id, Id)> {+ (0..DECODER_LAYERS)+ .map(|_| {+ let k = b.persistent(Shape::new(D_MODEL, 1, SOURCE_POSITIONS));+ let v = b.persistent(Shape::new(D_MODEL, 1, SOURCE_POSITIONS));+ (k, v)+ })+ .collect()+}+ /// The audio encoder over one 30-second window, plus the twelve cross-attention caches. fn encode(weights: &dyn WeightSource) -> Result<Plan, String> { let mut builder = Builder::new(weights); let b = &mut builder; name_host_tensors(b, &device_tensors(Mode::Encode)); + let caches = declare_cross_caches(b); let mel = b.input(Shape::new(MELS, 1, MEL_FRAMES)); // `1 x 3` same-padded, GELU, stride 1 then stride 2. The second stride is what turns 3000 mel // frames into the 1500 positions the decoder cross-attends over.@@ -321,31 +336,30 @@ fn encode(weights: &dyn WeightSource) -> Result<Plan, String> { } let encoded = b.layer_norm(x, ENC_NORM, EPSILON); - // Each decoder layer's cross-attention key and value, computed once for the whole transcript.- let mut outputs = Vec::with_capacity(1 + DECODER_LAYERS * 2);- outputs.push(encoded);- for layer in 0..DECODER_LAYERS {+ // Each decoder layer's cross-attention key and value, computed once for the whole transcript+ // and left on the device.+ for (layer, &(cache_k, cache_v)) in caches.iter().enumerate() { let cross = &mut Layers { next: cross_kv(layer) };- outputs.push(point(b, cross, encoded, D_MODEL, Act::None));- outputs.push(point(b, cross, encoded, D_MODEL, Act::None));+ let k = point(b, cross, encoded, D_MODEL, Act::None);+ let v = point(b, cross, encoded, D_MODEL, Act::None); if cross.next != cross_kv(layer) + 6 { return Err(format!("layer {layer}'s cross cache ends at {}", cross.next)); }+ b.copy_into(k, cache_k);+ b.copy_into(v, cache_v); }- builder.finish(&outputs)+ builder.finish(&[encoded]) } /// One decoder step. ///-/// # Inputs, in declaration order+/// # Inputs ///-/// | | shape | |-/// | :--- | :--- | :--- |-/// | 0 | `[512, 1, 1]` | the current token, after [`embed_positions`] at `past = prefix` |-/// | 1..13 | `[512, 1, 1500]` | each layer's cross-attention K then V, from [`Mode::Encode`] |+/// One: the current token, `[512, 1, 1]`, after [`embed_positions`] at `past = prefix`. ///-/// The self-attention caches are **not** inputs: they live in the arena across steps and this-/// plan writes into them at the row the step names. See [`Builder::persistent`].+/// The cross-attention K and V are not inputs: [`Mode::Encode`] left them in persistent tensors at+/// the offsets this plan declares them at. The self-attention caches live in the arena too, and+/// this plan writes into them at the row the step names. See [`Builder::persistent`]. /// /// # Outputs, in declaration order ///@@ -357,15 +371,9 @@ fn decode_step(weights: &dyn WeightSource) -> Result<Plan, String> { let b = &mut builder; name_host_tensors(b, &device_tensors(Mode::DecodeStep)); + // First, so the offsets match the encode pass's.+ let cross = declare_cross_caches(b); let mut x = b.input(Shape::new(D_MODEL, 1, 1));- // Declared up front, in layer order, so the host uploads them as one block.- let cross: Vec<(Id, Id)> = (0..DECODER_LAYERS)- .map(|_| {- let k = b.input(Shape::new(D_MODEL, 1, SOURCE_POSITIONS));- let v = b.input(Shape::new(D_MODEL, 1, SOURCE_POSITIONS));- (k, v)- })- .collect(); // Sized for the longest transcript of one window rather than for this step, so the plan does // not mention the step number and is recorded once. let past: Vec<(Id, Id)> = (0..DECODER_LAYERS)@@ -400,7 +408,8 @@ fn decode_step(weights: &dyn WeightSource) -> Result<Plan, String> { // uses the ordinary pair rather than the cached one, and needs no transpose. let normed = b.layer_norm(x, l.take(), EPSILON); let q = point(b, l, normed, D_MODEL, Act::None);- // The key and value projections were run by `Mode::Encode`; their results are the inputs.+ // The key and value projections were run by `Mode::Encode`; their results are on the+ // device. l.skip3(2); let scores = b.attn_scores(q, cross_k, HEADS); let probs = b.softmax(scores);
library/ml/src/main/rust/src/nets/whisper_part2.rs
diff --git a/library/ml/src/main/rust/src/nets/whisper_part2.rs b/library/ml/src/main/rust/src/nets/whisper_part2.rsindex 86dee71647..613e37544d 100644--- a/library/ml/src/main/rust/src/nets/whisper_part2.rs+++ b/library/ml/src/main/rust/src/nets/whisper_part2.rs@@ -155,14 +155,40 @@ mod tests { assert_eq!(counts.len(), 7, "{counts:?}"); assert_eq!(plan.input().unwrap().shape, Shape::new(MELS, 1, MEL_FRAMES));- // The hidden states, then twelve caches in layer order — all the same shape.- assert_eq!(plan.outputs.len(), 1 + DECODER_LAYERS * 2);- for binding in &plan.outputs {- assert_eq!(binding.shape, Shape::new(D_MODEL, 1, SOURCE_POSITIONS));- }+ // The hidden states only: the twelve caches stay on the device.+ assert_eq!(plan.outputs.len(), 1);+ assert_eq!(plan.outputs[0].shape, Shape::new(D_MODEL, 1, SOURCE_POSITIONS)); assert_no_aliasing(&plan); } + #[test]+ fn the_encode_pass_leaves_the_cross_caches_where_the_decode_step_reads_them() {+ // Two plans agreeing on where twelve persistent tensors live. If they disagree the decoder+ // attends over the other plan's activations and still transcribes something plausible.+ let encode = plan(Mode::Encode);+ let step = plan(Mode::DecodeStep);+ let caches = DECODER_LAYERS * 2;+ assert_eq!(encode.pinned[..caches], step.pinned[..caches]);+ let starts: Vec<u32> = encode.pinned[..caches].iter().map(|b| b.at).collect();+ // The encode pass fills every one of them, whole.+ for &at in &starts {+ let filled = encode.ops.iter().any(|op| {+ matches!(*op, Op::Copy { dst, elems, .. }+ if dst == at && elems == D_MODEL * SOURCE_POSITIONS)+ });+ assert!(filled, "the encode pass never fills the cache at {at}");+ }+ // And every cross-attention read in the decode step is one of them.+ let mut reads = 0;+ for op in &step.ops {+ if let Op::Dispatch { kind: Kind::AttnScores | Kind::AttnApply, push, .. } = op {+ assert!(starts.contains(&push.in1), "a cross-attention read from {}", push.in1);+ reads += 1;+ }+ }+ assert_eq!(reads, caches);+ }+ #[test] fn the_encoder_score_maps_are_square_at_fifteen_hundred() { // Self-attention over one window, so queries and keys are the same positions. This is also@@ -229,16 +255,12 @@ mod tests { } #[test]- fn a_decode_step_takes_the_token_and_the_cross_caches_only() {+ fn a_decode_step_takes_only_the_token() { let plan = plan(Mode::DecodeStep);- // The token and twelve cross caches. The self-attention caches are on the device now, so- // they are neither uploaded nor read back - which was 18.4 MB per step.- assert_eq!(plan.inputs.len(), 1 + DECODER_LAYERS * 2);+ // The token alone. Both kinds of cache are on the device: the cross caches used to be+ // uploaded here every step, 18.4 MB a token.+ assert_eq!(plan.inputs.len(), 1); assert_eq!(plan.inputs[0].shape, Shape::new(D_MODEL, 1, 1));- for binding in &plan.inputs[1..] {- // Channel-major, because a single-query cross-attention reads a sequence directly.- assert_eq!(binding.shape, Shape::new(D_MODEL, 1, SOURCE_POSITIONS));- } // The logits, and nothing else. assert_eq!(plan.outputs.len(), 1); assert_eq!(plan.outputs[0].shape, Shape::new(VOCAB, 1, 1));