TiledAttention

Struct TiledAttention 

Source
pub struct TiledAttention {
    pub m_state: DeviceBuffer,
    pub l_state: DeviceBuffer,
    pub o_state: DeviceBuffer,
    /* private fields */
}

Fields§

§m_state: DeviceBuffer§l_state: DeviceBuffer§o_state: DeviceBuffer

Implementations§

Source§

impl TiledAttention

Source

pub fn new(dims: TiledAttentionDims) -> Result<Self>

Source

pub fn begin_step(&self, ctx: &CudaCtx, num_seqs: usize) -> Result<()>

Reset (m, l, o) for num_seqs sequences. Call once at the start of each decode step before the first step_tile.

Source

pub fn begin_step_on_stream(&self, stream: u64, num_seqs: usize) -> Result<()>

Source

pub fn paged_strides(&self) -> (i64, i64, i64)

Stride triple for the kernel-native paged K/V layout: [num_blocks, block_size, num_kv_heads, head_dim]. All in BF16 elements.

Source

pub fn scratch_pool_strides(&self) -> (i64, i64, i64)

Stride triple for the scratch-pool slot layout [slot, K|V, kv_head, block_size, head_dim]. Reads of contiguous- per-(kv_head) groups stay efficient on disk; the kernel pays a single extra multiply per address calculation.

Source

pub fn step_tile( &self, ctx: &CudaCtx, q: u64, k_pool: u64, v_pool: u64, tile_blocks: u64, tile_block_counts: u64, num_seqs: usize, blk_stride: i64, tok_stride: i64, kvh_stride: i64, last_block_valid_slots: i32, ) -> Result<()>

One tile of blocks across num_seqs sequences. Stride triple (blk_stride, tok_stride, kvh_stride) selects the K/V layout — see paged_strides and scratch_pool_strides.

Source

pub fn step_tile_on_stream( &self, stream: u64, q: u64, k_pool: u64, v_pool: u64, tile_blocks: u64, tile_block_counts: u64, num_seqs: usize, blk_stride: i64, tok_stride: i64, kvh_stride: i64, last_block_valid_slots: i32, ) -> Result<()>

Source

pub fn finalize( &self, ctx: &CudaCtx, output: u64, num_seqs: usize, ) -> Result<()>

Divide o_state by l_state and store as BF16 in output.

Source

pub fn finalize_on_stream( &self, stream: u64, output: u64, num_seqs: usize, ) -> Result<()>

Source

pub fn dims(&self) -> TiledAttentionDims

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more