Documentation
¶
Overview ¶
Package dflash implements the DFlash block-diffusion draft model: qwen3-shaped layers drafting a whole block per forward, conditioned on tapped target hidden states as key/value context.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Attention ¶
type Attention struct {
QProj nn.LinearLayer
KVProj nn.LinearLayer
GProj nn.LinearLayer
OProj nn.LinearLayer
QNorm *nn.RMSNorm
KNorm *nn.RMSNorm
// contains filtered or unexported fields
}
Attention holds a q projection and a fused k|v projection: split checkpoints are stacked at load, fused ones sliced. Context rows produce no queries, so the context path uses only KVProj.
type Config ¶
type Config struct {
HiddenSize int32
NumHiddenLayers int32
NumAttentionHeads int32
NumKeyValueHeads int32
HeadDim int32
RMSNormEps float32
RopeTheta float32
Scale float32
SlidingWindow int32
LayerTypes []string
BlockSize int
MaskTokenID int32
VocabSize int32
TargetLayerIDs []int
// RopeInterleaved selects the draft's rotary pairing convention:
// true pairs adjacent dims (torch view_as_complex over pairs, the glimmer
// publisher convention); false pairs split halves (HF rotate_half, the
// laguna convention). Defaults to false for backwards compatibility with
// laguna drafts.
RopeInterleaved bool
// Causal, when set, overrides every layer's attention direction;
// otherwise only sliding layers run causal.
Causal *bool
}
type Layer ¶
type MLP ¶
type MLP struct {
// GateUpProj is gate|up stacked at load; SwiGLU splits the halves.
GateUpProj nn.LinearLayer
DownProj nn.LinearLayer
}
type Model ¶
type Model struct {
FC nn.LinearLayer
HiddenNorm *nn.RMSNorm
Norm *nn.RMSNorm
Layers []*Layer
// AuxNorms, when shipped, normalize each target slice before fusion.
AuxNorms []*nn.RMSNorm
*Config
QuantGroupSize int
QuantBits int
QuantMode string
TensorQuant map[string]*model.TensorQuantInfo
// contains filtered or unexported fields
}
func (*Model) BlockParams ¶
func (*Model) Forward ¶
func (m *Model) Forward(b *batch.Batch, _, draftCaches []cache.Cache) (hidden, auxHidden *mlx.Array)
Forward writes b.Hidden's rows into each layer's context cache starting at SeqOffsets[0] and runs b.InputIDs as a block positioned after them; queries come from the block only. Either input may be absent: with no block the call just extends the context, with no context the block drafts from whatever is already cached.