Skip to main content

Gpu

Struct Gpu 

Source
pub struct Gpu {
    pub ctx: Arc<CudaContext>,
    pub blas: CudaBlasLT,
    /* private fields */
}
Expand description

GPU runtime handle: a context + stream + cuBLASLt.

Fields§

§ctx: Arc<CudaContext>§blas: CudaBlasLT

Implementations§

Source§

impl Gpu

Source

pub fn stream(&self) -> Arc<CudaStream>

The stream every engine op launches on: the thread’s override if one is pushed (pp2 stage scopes), else the main compute stream. By-value Arc so callers hold a stable handle across the call regardless of later pushes/pops.

Source

pub fn main_stream(&self) -> &Arc<CudaStream>

The main compute stream, override-blind (graph capture pins itself here; the pp2 runtime uses it to fence stage streams against load-time state).

Source§

impl Gpu

Source

pub fn new(ordinal: usize) -> Result<Self, Box<dyn Error>>

Source

pub fn linear_f32( &self, x: &CudaSlice<f32>, w: &CudaSlice<f32>, m_tokens: usize, in_f: usize, out_f: usize, ) -> Result<Vec<f32>, Box<dyn Error>>

GPU linear y = x @ W^T using cuBLASLt (f32), matching cpu_linear exactly.

Layout reasoning (cuBLASLt is column-major): We want y[m,out] row-major = y^T[out,m] column-major. Treat:

  • x[m,in] row-major == x^T[in,m] col-major (an in×m col-major matrix)
  • w[out,in] row-major == w^T[in,out] col-major (an in×out col-major matrix) Compute C[out,m] col-major = W_colmajor(out×in) * X_colmajor(in×m) => set A = w (interpreted col-major as in×out, so transa to get out×in), B = x (col-major in×m), C = y (col-major out×m == y[m,out] row-major). cfg: m_=out, n_=m_tokens, k=in. A is in×out (lda=in, transa=true -> out×in), B is in×m (ldb=in), C is out×m (ldc=out).

Auto Trait Implementations§

§

impl Freeze for Gpu

§

impl RefUnwindSafe for Gpu

§

impl Send for Gpu

§

impl Sync for Gpu

§

impl Unpin for Gpu

§

impl UnsafeUnpin for Gpu

§

impl UnwindSafe for Gpu

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.

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.