pub struct GenericMdlm { /* private fields */ }Expand description
MDLM masked-diffusion backend.
Loads kuleshov-group/mdlm-owt-format weights (prefix backbone.) and runs
the bidirectional DiT forward pass with full hook support, exactly
matching the fp32 reference.
Implementations§
Source§impl GenericMdlm
impl GenericMdlm
Sourcepub fn load(
config: MdlmConfig,
device: &Device,
dtype: DType,
vb: VarBuilder<'_>,
) -> Result<Self>
pub fn load( config: MdlmConfig, device: &Device, dtype: DType, vb: VarBuilder<'_>, ) -> Result<Self>
Load an MDLM model from a VarBuilder.
The caller constructs the VarBuilder (buffered or mmap) and provides
the parsed MdlmConfig. The constant conditioning vector and the
RoPE cache are pre-computed here.
§Shapes
- returns: a model whose
forwardmaps[batch, seq]token ids to[batch, seq, vocab_size]logits.
§Memory
Loads the single mdlm-owt safetensors (~648 MB) through the caller’s
VarBuilder: near-zero extra copy with the mmap feature, or ~648 MB
CPU when buffered. The conditioning vector and RoPE cache are negligible.
§Errors
Returns MIError::Config if the checkpoint sets
time_conditioning = true (unsupported), or
MIError::Model if weight loading fails or a
dimension is inconsistent with the checkpoint.
Sourcepub const fn config(&self) -> &MdlmConfig
pub const fn config(&self) -> &MdlmConfig
Access the model configuration.
Trait Implementations§
Source§impl MIBackend for GenericMdlm
impl MIBackend for GenericMdlm
Source§fn num_layers(&self) -> usize
fn num_layers(&self) -> usize
d_model).Source§fn vocab_size(&self) -> usize
fn vocab_size(&self) -> usize
Source§fn forward(&self, input_ids: &Tensor, hooks: &HookSpec) -> Result<HookCache>
fn forward(&self, input_ids: &Tensor, hooks: &HookSpec) -> Result<HookCache>
Source§fn project_to_vocab(&self, hidden: &Tensor) -> Result<Tensor>
fn project_to_vocab(&self, hidden: &Tensor) -> Result<Tensor>
Auto Trait Implementations§
impl !RefUnwindSafe for GenericMdlm
impl !UnwindSafe for GenericMdlm
impl Freeze for GenericMdlm
impl Send for GenericMdlm
impl Sync for GenericMdlm
impl Unpin for GenericMdlm
impl UnsafeUnpin for GenericMdlm
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
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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