pub struct CudaPipeline<'a> { /* private fields */ }Implementations§
Source§impl<'a> CudaPipeline<'a>
impl<'a> CudaPipeline<'a>
Sourcepub fn compile_cuda_c(
context: &'a CudaComputeContext,
kernel: &KernelSpec,
schedule: Schedule,
) -> Result<Self, ForgeError>
pub fn compile_cuda_c( context: &'a CudaComputeContext, kernel: &KernelSpec, schedule: Schedule, ) -> Result<Self, ForgeError>
Emit CUDA-C for the kernel and compile it to PTX via NVRTC (mirrors the HLSL -> DXC path), then load the resulting module.
Sourcepub fn compile_cuda_c_source(
context: &'a CudaComputeContext,
source: &str,
entry_point: &str,
storage_buffer_bindings: &[u32],
) -> Result<Self, ForgeError>
pub fn compile_cuda_c_source( context: &'a CudaComputeContext, source: &str, entry_point: &str, storage_buffer_bindings: &[u32], ) -> Result<Self, ForgeError>
Compile a raw CUDA-C source string (entry point + storage-buffer bindings
supplied directly) to PTX via NVRTC and load it. This is for kernels that
have no portable-IR analogue — notably the nvcuda::wmma tensor-core GEMM,
whose f16/f32 fragment API and fixed 16x16x16 shape cannot be expressed in
WGSL/IR. storage_buffer_bindings lists the kernel’s pointer parameters in
binding order (all treated as storage pointers; no by-value uniform).
Sourcepub fn from_ptx(
context: &'a CudaComputeContext,
ptx: &Ptx,
entry_point: &str,
spec: KernelSpec,
) -> Result<Self, ForgeError>
pub fn from_ptx( context: &'a CudaComputeContext, ptx: &Ptx, entry_point: &str, spec: KernelSpec, ) -> Result<Self, ForgeError>
Load a pipeline from already-compiled PTX (no NVRTC). Used by the process-wide
WMMA cache path so hot GEMM calls only pay load_module.
Sourcepub fn compile_cuda_c_source_cached(
context: &'a CudaComputeContext,
source: &str,
entry_point: &str,
storage_buffer_bindings: &[u32],
) -> Result<Self, ForgeError>
pub fn compile_cuda_c_source_cached( context: &'a CudaComputeContext, source: &str, entry_point: &str, storage_buffer_bindings: &[u32], ) -> Result<Self, ForgeError>
Compile (or reuse cached PTX for) raw CUDA-C and load — same as
[compile_cuda_c_source] but shares the process NVRTC cache when source
matches a previously compiled kernel body.
Sourcepub fn compile_ptx(
context: &'a CudaComputeContext,
ptx_source: &str,
entry_point: &str,
storage_buffer_bindings: &[u32],
) -> Result<Self, ForgeError>
pub fn compile_ptx( context: &'a CudaComputeContext, ptx_source: &str, entry_point: &str, storage_buffer_bindings: &[u32], ) -> Result<Self, ForgeError>
Load a hand-emitted PTX module (from emit/ptx.rs) directly into the CUDA
driver — no NVRTC compilation step. This is the PTX execution bridge:
the emitter produces complete PTX text with .version, .target,
.address_size, entry point, and full kernel body; the driver JITs it
to the actual GPU ISA.
Shared-memory size is passed via LaunchConfig.shared_mem_bytes at
dispatch time, not at compile time.
Source§impl<'a> CudaPipeline<'a>
impl<'a> CudaPipeline<'a>
Sourcepub fn dispatch_async(
&self,
buffers: &[BufferView],
schedule: &Schedule,
element_count: usize,
) -> Result<(), ForgeError>
pub fn dispatch_async( &self, buffers: &[BufferView], schedule: &Schedule, element_count: usize, ) -> Result<(), ForgeError>
Launch without a host fence. Same-stream kernels stay ordered; the next
read_buffer_* / synchronize is the completion barrier. Used by the
P4 decode attention chain to avoid one PCIe-class fence per micro-kernel.
Sourcepub fn dispatch_ptx(
&self,
buffers: &[BufferView],
grid: (u32, u32, u32),
block: (u32, u32, u32),
shared_mem_bytes: u32,
) -> Result<(), ForgeError>
pub fn dispatch_ptx( &self, buffers: &[BufferView], grid: (u32, u32, u32), block: (u32, u32, u32), shared_mem_bytes: u32, ) -> Result<(), ForgeError>
Launch a PTX kernel with shared-memory size and a 3D grid/block config.
Used by hand-emitted PTX kernels (RMSNorm, Q4K GEMV, WMMA GEMV, SDPA)
that need shared_mem_bytes and multi-dimensional dispatch.
Sourcepub fn dispatch_async_sorted(
&self,
buffers: &[BufferView],
schedule: &Schedule,
element_count: usize,
) -> Result<(), ForgeError>
pub fn dispatch_async_sorted( &self, buffers: &[BufferView], schedule: &Schedule, element_count: usize, ) -> Result<(), ForgeError>
Fast-path async dispatch for pre-sorted buffer views.
Assumes buffers are already in ascending binding order (as the mega-pass
always provides). Skips spec.buffers.clone() + sort + linear search —
eliminating 2 Vec allocations and O(n²) search per dispatch.
Sourcepub fn dispatch_gpu_timed_ms_sorted(
&self,
buffers: &[BufferView],
schedule: &Schedule,
element_count: usize,
) -> Result<f32, ForgeError>
pub fn dispatch_gpu_timed_ms_sorted( &self, buffers: &[BufferView], schedule: &Schedule, element_count: usize, ) -> Result<f32, ForgeError>
Measure one pre-sorted kernel launch with CUDA events.
This is a lab/profiling operation, not a decode hot-path primitive: creating and synchronizing timing events intentionally fences the stream. It remains useful when hardware performance counters are unavailable because the elapsed value is device time rather than host submission/synchronization wall time.
Trait Implementations§
Source§impl<'a> QualiaCompute for CudaPipeline<'a>
Available on crate feature cuda only.
impl<'a> QualiaCompute for CudaPipeline<'a>
cuda only.Source§fn dispatch(
&self,
buffers: &[BufferView],
schedule: &Schedule,
element_count: usize,
) -> Result<u64, ForgeError>
fn dispatch( &self, buffers: &[BufferView], schedule: &Schedule, element_count: usize, ) -> Result<u64, ForgeError>
Schedule and buffer views. Read moreAuto Trait Implementations§
impl<'a> Freeze for CudaPipeline<'a>
impl<'a> RefUnwindSafe for CudaPipeline<'a>
impl<'a> Send for CudaPipeline<'a>
impl<'a> Sync for CudaPipeline<'a>
impl<'a> Unpin for CudaPipeline<'a>
impl<'a> UnsafeUnpin for CudaPipeline<'a>
impl<'a> UnwindSafe for CudaPipeline<'a>
Blanket Implementations§
§impl<S, A> Aggregate<Result<S, Error>> for Awhere
A: Aggregate<S>,
impl<S, A> Aggregate<Result<S, Error>> for Awhere
A: Aggregate<S>,
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<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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