Skip to main content

HyperConnectionPlan

Struct HyperConnectionPlan 

Source
pub struct HyperConnectionPlan<T: Element> { /* private fields */ }
Expand description

Hyper-Connection forward plan (static-H, bf16 weights, Tier 1).

Formula (with M = Sinkhorn-Knopp(softmax_or_exp(H_res)), s_pre = sigmoid(H_pre), s_post = 2 * sigmoid(H_post), y_agg[b, c] = Σ_i s_pre[i] * x_expanded[b, i, c], y_norm = RMSNorm(y_agg)):

out[b, i, c] = Σ_j M[i, j] * x_expanded[b, j, c] + s_post[i] * y_norm[b, c]

When to use: replace the bare x + sublayer(x) residual in a transformer block when training a fresh model — mHC reports improved training stability + downstream task scores in DeepSeek-AI’s experiments.

Dtypes: f32 only in Tier 1. The rmsnorm_weight is always bf16 regardless of T.

State: this plan owns a native MHCLayer* handle with ~B*n*C*sizeof(float) bytes of GPU scratch. Reuse across many run() calls; construction is heavy.

Implementations§

Source§

impl<T: Element> HyperConnectionPlan<T>

Source

pub fn select( _stream: &Stream, desc: &HyperConnectionDescriptor, _pref: PlanPreference, ) -> Result<Self>

Construct a plan for the given descriptor. Allocates the internal MHCLayer scratch on the current CUDA context. Returns Err(Error::Unsupported) if the mhc feature is off or the descriptor is outside the Tier-1 SKU matrix.

Source

pub fn can_implement(&self, args: &HyperConnectionArgs<'_, T>) -> Result<()>

Validate args against the descriptor.

Source

pub fn workspace_size(&self) -> usize

Workspace size in bytes. Always zero — internal scratch lives in the native handle (allocated at select time).

Source

pub fn sku(&self) -> KernelSku

Identity of the kernel SKU this plan dispatches to.

Source

pub fn precision_guarantee(&self) -> PrecisionGuarantee

Numerical guarantees — deterministic, bit-stable on the same hardware (no atomicAdd on the FW path).

Source

pub fn run( &self, stream: &Stream, _workspace: Workspace<'_>, args: HyperConnectionArgs<'_, T>, ) -> Result<()>

Launch the kernel against args.

Trait Implementations§

Source§

impl<T: Element> Drop for HyperConnectionPlan<T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl<T: Element> Send for HyperConnectionPlan<T>

Source§

impl<T: Element> Sync for HyperConnectionPlan<T>

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.

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.