pub struct LayerDetail {
pub layer: usize,
pub ln1_out: Vec<f32>,
pub q: Vec<f32>,
pub k: Vec<f32>,
pub v: Vec<f32>,
pub scores: Vec<f32>,
pub attn_head_out: Vec<f32>,
pub attn_proj_out: Vec<f32>,
pub resid_attn: Vec<f32>,
pub ln2_out: Vec<f32>,
pub mlp_hidden: Vec<f32>,
pub block_out: Vec<f32>,
}Expand description
One block’s Q/K/V, MLP and output tensors for one step, read back from the
device. Captured only for the first detail_layers blocks — the expensive
kinds — while AttnStep is captured for every block.
q/k/v are the tensors for the new positions only ([n_head, q_len, head_dim]), which is what the step computed: the older keys and values
live in the cache and were never recomputed.
Fields§
§layer: usize§ln1_out: Vec<f32>[q_len, n_embd], the block’s first LayerNorm.
q: Vec<f32>[n_head, q_len, head_dim]
k: Vec<f32>§v: Vec<f32>§scores: Vec<f32>[n_head, q_len, kv_len] — q · kᵢ / √head_dim before the causal
mask and the softmax. The masked triangle only means something next to
the full rectangle it was cut from.
attn_head_out: Vec<f32>[q_len, n_embd] — the heads concatenated, before the output
projection. Kept separate from attn_proj_out because this is the one
place n_head × head_dim becomes n_embd.
attn_proj_out: Vec<f32>[q_len, n_embd], after the attention output projection.
resid_attn: Vec<f32>[q_len, n_embd], after the first residual add.
ln2_out: Vec<f32>[q_len, n_embd], the block’s second LayerNorm.
[q_len, 4 * n_embd], post-GELU.
block_out: Vec<f32>[q_len, n_embd], after the second residual add.
Trait Implementations§
Source§impl Clone for LayerDetail
impl Clone for LayerDetail
Source§fn clone(&self) -> LayerDetail
fn clone(&self) -> LayerDetail
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for LayerDetail
impl RefUnwindSafe for LayerDetail
impl Send for LayerDetail
impl Sync for LayerDetail
impl Unpin for LayerDetail
impl UnsafeUnpin for LayerDetail
impl UnwindSafe for LayerDetail
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more