Skip to content

Get up and running with Kimi, GLM, MiniMax, DeepSeek, gpt-oss, Qwen, Gemma and other models.

mlxrunner: return the draft-conditioning state from a model forward

Jesse Gross2f84872ce0a6
diff --git a/x/mlxrunner/batch/batch.go b/x/mlxrunner/batch/batch.go
index 011b31103..eac191534 100644
--- a/x/mlxrunner/batch/batch.go
+++ b/x/mlxrunner/batch/batch.go
@@ -17,8 +17,8 @@ type Batch struct {
// Length equals the batch dimension of InputIDs.
SeqQueryLens []int32
- // Hidden is the target hidden state a draft model fuses with its input
- // embedding for this step. It is nil for ordinary forward passes.
+ // Hidden is the draft-conditioning state for a draft model's forward.
+ // It is nil for ordinary forward passes.
Hidden *mlx.Array
// Memo is per-forward memoization used to cache results, such as masks,
diff --git a/x/mlxrunner/model/base/base.go b/x/mlxrunner/model/base/base.go
index 2d27aaa43..b7c6696b0 100644
--- a/x/mlxrunner/model/base/base.go
+++ b/x/mlxrunner/model/base/base.go
@@ -15,7 +15,9 @@ import (
// Model is the interface that model implementations must satisfy.
type Model interface {
- Forward(b *batch.Batch, cache []cache.Cache) *mlx.Array
+ // Forward returns the hidden state to unembed and the state a draft
+ // model conditions on; plain models return the final hidden for both.
+ Forward(b *batch.Batch, cache []cache.Cache) (hidden, auxHidden *mlx.Array)
Unembed(x *mlx.Array) *mlx.Array
NumLayers() int
Tokenizer() *tokenizer.Tokenizer
@@ -31,8 +33,8 @@ type Model interface {
// tokens.
type DraftModel interface {
// Draft fuses b.Hidden (the target hidden state) into its own forward and
- // returns the head's hidden plus the projected hidden seeding the next step.
- Draft(b *batch.Batch, caches []cache.Cache) (hidden, projected *mlx.Array)
+ // returns the head's hidden plus the aux hidden seeding the next step.
+ Draft(b *batch.Batch, caches []cache.Cache) (hidden, auxHidden *mlx.Array)
// Unembed projects a hidden state to vocabulary logits.
Unembed(x *mlx.Array) *mlx.Array
diff --git a/x/mlxrunner/mtp.go b/x/mlxrunner/mtp.go
index bf40e5696..833d11354 100644
--- a/x/mlxrunner/mtp.go
+++ b/x/mlxrunner/mtp.go
@@ -63,11 +63,11 @@ type mtpDraftSession struct {
pendingHiddens []*mlx.Array
pendingCount int
- // heldHidden is the frontier row's pre-unembed hidden and heldProjected
+ // heldHidden is the frontier row's pre-unembed hidden and heldAuxHidden
// its fusion hidden, carried from the last flush so the first proposal
// reuses them without a head call.
heldHidden *mlx.Array
- heldProjected *mlx.Array
+ heldAuxHidden *mlx.Array
}
func (d *mtpDraftSession) committed(tokens, hiddens *mlx.Array, position int) {
@@ -135,7 +135,7 @@ func (d *mtpDraftSession) queueCacheWrites(tokens, hiddens *mlx.Array) {
// flush writes the pending pairs to the draft caches in one head forward,
// dropping speculative entries past the committed range first and holding
-// the last row's logits and projected hidden for the next proposal chain.
+// the last row's logits and aux hidden for the next proposal chain.
func (d *mtpDraftSession) flush() {
if len(d.pendingTokens) == 0 {
return
@@ -151,13 +151,13 @@ func (d *mtpDraftSession) flush() {
ids := mlx.Concatenate(d.pendingTokens, 1)
hiddens := mlx.Concatenate(d.pendingHiddens, 1)
- hidden, projected := spec.draft.Draft(&batch.Batch{
+ hidden, auxHidden := spec.draft.Draft(&batch.Batch{
InputIDs: ids,
SeqOffsets: []int32{int32(d.committedDraftOffset)},
SeqQueryLens: []int32{int32(ids.Dim(1))},
Hidden: hiddens,
}, spec.caches)
- d.setHeld(lastHiddenRow(hidden), lastHiddenRow(projected))
+ d.setHeld(lastHiddenRow(hidden), lastHiddenRow(auxHidden))
d.committedDraftOffset += ids.Dim(1)
// Force the draft writes: a session that never drafts would otherwise
@@ -181,10 +181,10 @@ func (d *mtpDraftSession) setFrontierHidden(h *mlx.Array) {
}
// setHeld replaces the held flush outputs, pinned until the next flush or close.
-func (d *mtpDraftSession) setHeld(hidden, projected *mlx.Array) {
- mlx.Pin(hidden, projected)
- mlx.Unpin(d.heldHidden, d.heldProjected)
- d.heldHidden, d.heldProjected = hidden, projected
+func (d *mtpDraftSession) setHeld(hidden, auxHidden *mlx.Array) {
+ mlx.Pin(hidden, auxHidden)
+ mlx.Unpin(d.heldHidden, d.heldAuxHidden)
+ d.heldHidden, d.heldAuxHidden = hidden, auxHidden
}
// propose drafts a token chain after the not-yet-validated current token.
@@ -211,11 +211,11 @@ func (d *mtpDraftSession) propose(current *mlx.Array, maxTokens int) *draftCandi
var prefix *mlx.Array
for i := range maxTokens {
- var hidden, projected *mlx.Array
+ var hidden, auxHidden *mlx.Array
if i == 0 && len(spec.draftKV) > 0 {
// The settle flush already produced the frontier row; reuse it
// instead of re-running the head.
- hidden, projected = d.heldHidden, d.heldProjected
+ hidden, auxHidden = d.heldHidden, d.heldAuxHidden
} else {
// A head with draft caches writes each draft token to the next
// draft-cache slot, advancing one per step from the last committed
@@ -226,7 +226,7 @@ func (d *mtpDraftSession) propose(current *mlx.Array, maxTokens int) *draftCandi
if len(spec.draftKV) > 0 {
pos = d.frontier - 1 + i
}
- hidden, projected = spec.draft.Draft(&batch.Batch{
+ hidden, auxHidden = spec.draft.Draft(&batch.Batch{
InputIDs: lastToken,
SeqOffsets: []int32{int32(pos)},
SeqQueryLens: []int32{1},
@@ -235,7 +235,7 @@ func (d *mtpDraftSession) propose(current *mlx.Array, maxTokens int) *draftCandi
}
// Unembed only the row being sampled, never the batch.
stepLogits := spec.draft.Unembed(hidden).Squeeze(1)
- lastHidden = projected
+ lastHidden = auxHidden
// The chain's earlier drafts ride along as the row's history, so
// penalties shape proposals the same way they shape validation.
dist := r.Sampler.Distribution(pipelineSlot, stepLogits, prefix)
diff --git a/x/mlxrunner/mtp_test.go b/x/mlxrunner/mtp_test.go
index 1dcd186c2..8d4fec078 100644
--- a/x/mlxrunner/mtp_test.go
+++ b/x/mlxrunner/mtp_test.go
@@ -57,7 +57,7 @@ type forwardCall struct {
n int32
}
-func (m *fakeMTPModel) Forward(b *batch.Batch, caches []cache.Cache) *mlx.Array {
+func (m *fakeMTPModel) Forward(b *batch.Batch, caches []cache.Cache) (hidden, auxHidden *mlx.Array) {
mlx.Eval(b.InputIDs)
ids := b.InputIDs.Ints()
m.forwards = append(m.forwards, forwardCall{offset: b.SeqOffsets[0], n: int32(len(ids))})
@@ -78,7 +78,8 @@ func (m *fakeMTPModel) Forward(b *batch.Batch, caches []cache.Cache) *mlx.Array
for i, id := range ids {
preds[i] = m.predict[int32(id)]
}
- return oneHotLogits(preds)
+ out := oneHotLogits(preds)
+ return out, out
}
func (m *fakeMTPModel) Unembed(x *mlx.Array) *mlx.Array { return x }
@@ -108,7 +109,7 @@ func (d *fakeMTPDraft) LoadWeights(map[string]*mlx.Array) error { return nil }
func (d *fakeMTPDraft) DraftCaches([]cache.Cache) []cache.Cache { return nil }
-func (d *fakeMTPDraft) Draft(b *batch.Batch, caches []cache.Cache) (hidden, projected *mlx.Array) {
+func (d *fakeMTPDraft) Draft(b *batch.Batch, caches []cache.Cache) (hidden, auxHidden *mlx.Array) {
mlx.Eval(b.InputIDs)
prev := int32(b.InputIDs.Ints()[0])
d.calls = append(d.calls, draftCall{position: b.SeqOffsets[0], from: prev})
@@ -125,7 +126,7 @@ var _ base.DraftModel = (*fakeMTPDraft)(nil)
// offset like a real KV write), and records each call's offset, ids, and
// the identity of every fused hidden row. A target hidden row is one-hot
// (its hot index identifies which position it came from); the head's own
-// projected hidden is all-zero and records as -1.
+// aux hidden is all-zero and records as -1.
type fakeKVDraft struct {
predict map[int32]int32
extends []extendCall
@@ -133,7 +134,7 @@ type fakeKVDraft struct {
// extendCall is one recorded Draft call: the absolute slot of the first
// entry written, the look-ahead token ids, and the hot index of each fused
-// hidden row (-1 for the head's own projected hidden).
+// hidden row (-1 for the head's own aux hidden).
type extendCall struct {
offset int32
ids []int32
@@ -146,7 +147,7 @@ func (d *fakeKVDraft) DraftCaches(caches []cache.Cache) []cache.Cache {
return caches[len(caches)-1:]
}
-func (d *fakeKVDraft) Draft(b *batch.Batch, caches []cache.Cache) (hidden, projected *mlx.Array) {
+func (d *fakeKVDraft) Draft(b *batch.Batch, caches []cache.Cache) (hidden, auxHidden *mlx.Array) {
mlx.Eval(b.InputIDs, b.Hidden)
rawIDs := b.InputIDs.Ints()
ids := make([]int32, len(rawIDs))
diff --git a/x/mlxrunner/pipeline.go b/x/mlxrunner/pipeline.go
index fb96e82ee..bc4403ea7 100644
--- a/x/mlxrunner/pipeline.go
+++ b/x/mlxrunner/pipeline.go
@@ -145,12 +145,12 @@ func (r *Runner) prefill(ctx context.Context, session *cacheSession, spec *specu
n := min(prefillChunk, total-processed-1)
chunkIDs := mlx.FromValues(tokens[processed:processed+n], 1, n)
- hidden := r.Model.Forward(&batch.Batch{
+ _, auxHidden := r.Model.Forward(&batch.Batch{
InputIDs: chunkIDs,
SeqOffsets: []int32{int32(position)},
SeqQueryLens: []int32{int32(n)},
}, caches)
- spec.committed(chunkIDs, hidden, position)
+ spec.committed(chunkIDs, auxHidden, position)
mlx.Sweep()
materializeCaches()
processed += n
@@ -303,12 +303,12 @@ func (r *Runner) pipelinedDecoder(spec *speculationSession, caches []cache.Cache
// value, so it is in flight before the previous token is synchronized.
func (t *pipelinedDecoder) dispatch(token *mlx.Array) sampler.Result {
r := t.r
- hidden := r.Model.Forward(&batch.Batch{
+ hidden, auxHidden := r.Model.Forward(&batch.Batch{
InputIDs: token,
SeqOffsets: []int32{int32(t.position)},
SeqQueryLens: []int32{int32(token.Dim(1))},
}, t.caches)
- t.spec.committed(token, hidden, t.position)
+ t.spec.committed(token, auxHidden, t.position)
t.position += token.Dim(1)
logits := r.Model.Unembed(hidden)
next := r.Sampler.Sample([]int{pipelineSlot}, logits.Slice(mlx.Slice(), mlx.Slice(logits.Dim(1)-1), mlx.Slice()).Squeeze(1))
diff --git a/x/mlxrunner/speculate.go b/x/mlxrunner/speculate.go
index f5d278d56..22535a911 100644
--- a/x/mlxrunner/speculate.go
+++ b/x/mlxrunner/speculate.go
@@ -413,7 +413,7 @@ func (s *speculationSession) accept(position *int, current sampler.Result, candi
}
defer commit(0)
- hiddenSeq := r.Model.Forward(&batch.Batch{
+ hiddenSeq, auxHiddenSeq := r.Model.Forward(&batch.Batch{
InputIDs: current.Token.ExpandDims(-1).Concatenate(1, candidates.tokens),
SeqOffsets: []int32{int32(before)},
SeqQueryLens: []int32{int32(draftCount + 1)},
@@ -439,7 +439,7 @@ func (s *speculationSession) accept(position *int, current sampler.Result, candi
// chain and this validation forward's intermediates are freed as the eval
// consumes them, the way the plain decode dispatch sweeps before its eval.
// current and the candidate tokens stay pinned by the caller across the call.
- live := []*mlx.Array{hiddenSeq, acceptedMask, residualTokens, bonusToken}
+ live := []*mlx.Array{hiddenSeq, auxHiddenSeq, acceptedMask, residualTokens, bonusToken}
mlx.Pin(live...)
defer mlx.Unpin(live...)
mlx.Sweep()
@@ -488,7 +488,7 @@ func (s *speculationSession) accept(position *int, current sampler.Result, candi
runIDs := append([]int32{int32(current.Token.Int())}, commitIDs[:keep]...)
s.drafter.committed(
mlx.FromValues(runIDs, 1, len(runIDs)),
- hiddenSeq.Slice(mlx.Slice(), mlx.Slice(0, len(runIDs)), mlx.Slice()),
+ auxHiddenSeq.Slice(mlx.Slice(), mlx.Slice(0, len(runIDs)), mlx.Slice()),
before)
results = draftResults(draftIDs[:accepted])
diff --git a/x/models/cohere2_moe/cohere2_moe.go b/x/models/cohere2_moe/cohere2_moe.go
index 60925fb3b..dde0988bf 100644
--- a/x/models/cohere2_moe/cohere2_moe.go
+++ b/x/models/cohere2_moe/cohere2_moe.go
@@ -728,7 +728,7 @@ func (l *Layer) Forward(x *mlx.Array, b *batch.Batch, c cache.Cache, positions *
return mlx.Add(x, mlx.Add(attnOut, mlpOut))
}
-func (m *Model) Forward(b *batch.Batch, caches []cache.Cache) *mlx.Array {
+func (m *Model) Forward(b *batch.Batch, caches []cache.Cache) (hidden, auxHidden *mlx.Array) {
dims := b.InputIDs.Dims()
B, L := int32(dims[0]), int32(dims[1])
positions := mlx.FromValues(b.SeqOffsets, len(b.SeqOffsets))
@@ -742,7 +742,8 @@ func (m *Model) Forward(b *batch.Batch, caches []cache.Cache) *mlx.Array {
h = layer.Forward(h, b, c, positions, B, L, m.Config)
}
- return m.Norm.Forward(h)
+ out := m.Norm.Forward(h)
+ return out, out
}
func (m *Model) Unembed(x *mlx.Array) *mlx.Array {
diff --git a/x/models/gemma3/gemma3.go b/x/models/gemma3/gemma3.go
index 014b2fe29..7ee11d884 100644
--- a/x/models/gemma3/gemma3.go
+++ b/x/models/gemma3/gemma3.go
@@ -403,7 +403,7 @@ func (m *Model) LoadWeights(tensors map[string]*mlx.Array) error {
return nil
}
-func (m *Model) Forward(b *batch.Batch, caches []cache.Cache) *mlx.Array {
+func (m *Model) Forward(b *batch.Batch, caches []cache.Cache) (hidden, auxHidden *mlx.Array) {
dims := b.InputIDs.Dims()
B, L := int32(dims[0]), int32(dims[1])
positions := mlx.FromValues(b.SeqOffsets, len(b.SeqOffsets))
@@ -419,7 +419,8 @@ func (m *Model) Forward(b *batch.Batch, caches []cache.Cache) *mlx.Array {
h = layer.Forward(h, b, c, positions, B, L, m.TextConfig)
}
- return mlx.RMSNormFn(h, m.NormScaled, m.RMSNormEps)
+ out := mlx.RMSNormFn(h, m.NormScaled, m.RMSNormEps)
+ return out, out
}
func (m *Model) Unembed(x *mlx.Array) *mlx.Array {
diff --git a/x/models/gemma4/assistant.go b/x/models/gemma4/assistant.go
index 36b675049..b448bb7f6 100644
--- a/x/models/gemma4/assistant.go
+++ b/x/models/gemma4/assistant.go
@@ -277,7 +277,7 @@ func (m *AssistantModel) DraftCaches([]cache.Cache) []cache.Cache { return nil }
// last target-seen position, so it anchors RoPE and the mask there — from the
// non-moving target full-attention cache — regardless of the advancing offset
// in b. The input fuses the target's scaled token embedding with b.Hidden.
-func (m *AssistantModel) Draft(b *batch.Batch, caches []cache.Cache) (hidden, projected *mlx.Array) {
+func (m *AssistantModel) Draft(b *batch.Batch, caches []cache.Cache) (hidden, auxHidden *mlx.Array) {
inputsEmbeds := m.target.TokenEmbeddings(b.InputIDs).Concatenate(-1, b.Hidden)
dims := inputsEmbeds.Dims()
B, L := int32(dims[0]), int32(dims[1])
@@ -303,8 +303,8 @@ func (m *AssistantModel) Draft(b *batch.Batch, caches []cache.Cache) (hidden, pr
}
hidden = mlx.RMSNormFn(h, m.NormScaled, m.TextConfig.RMSNormEps)
- projected = m.PostProjection.Forward(hidden)
- return hidden, projected
+ auxHidden = m.PostProjection.Forward(hidden)
+ return hidden, auxHidden
}
func (m *AssistantModel) sharedHistories(b *batch.Batch, caches []cache.Cache) (sliding, full *nn.KVHistory) {
diff --git a/x/models/gemma4/gemma4.go b/x/models/gemma4/gemma4.go
index 515c4a5d7..d1e81a4dd 100644
--- a/x/models/gemma4/gemma4.go
+++ b/x/models/gemma4/gemma4.go
@@ -984,7 +984,7 @@ func (m *Model) LoadWeights(tensors map[string]*mlx.Array) error {
return nil
}
-func (m *Model) Forward(b *batch.Batch, caches []cache.Cache) *mlx.Array {
+func (m *Model) Forward(b *batch.Batch, caches []cache.Cache) (hidden, auxHidden *mlx.Array) {
dims := b.InputIDs.Dims()
B, L := int32(dims[0]), int32(dims[1])
positions := mlx.FromValues(b.SeqOffsets, len(b.SeqOffsets))
@@ -1033,7 +1033,8 @@ func (m *Model) Forward(b *batch.Batch, caches []cache.Cache) *mlx.Array {
}
}
- return mlx.RMSNormFn(h, m.NormScaled, m.RMSNormEps)
+ out := mlx.RMSNormFn(h, m.NormScaled, m.RMSNormEps)
+ return out, out
}
func (m *Model) Unembed(x *mlx.Array) *mlx.Array {
diff --git a/x/models/glm4_moe_lite/glm4_moe_lite.go b/x/models/glm4_moe_lite/glm4_moe_lite.go
index bc625c1f4..c38365e5d 100644
--- a/x/models/glm4_moe_lite/glm4_moe_lite.go
+++ b/x/models/glm4_moe_lite/glm4_moe_lite.go
@@ -743,7 +743,7 @@ func (m *Model) LoadWeights(tensors map[string]*mlx.Array) error {
}
// Forward computes the forward pass of the model
-func (m *Model) Forward(b *batch.Batch, caches []cache.Cache) *mlx.Array {
+func (m *Model) Forward(b *batch.Batch, caches []cache.Cache) (hidden, auxHidden *mlx.Array) {
dims := b.InputIDs.Dims()
B, L := int32(dims[0]), int32(dims[1])
positions := mlx.FromValues(b.SeqOffsets, len(b.SeqOffsets))
@@ -759,7 +759,7 @@ func (m *Model) Forward(b *batch.Batch, caches []cache.Cache) *mlx.Array {
}
h = m.Norm.Forward(h, m.RMSNormEps)
- return h
+ return h, h
}
// Unembed applies the LM head to get logits.
diff --git a/x/models/laguna/laguna.go b/x/models/laguna/laguna.go
index 494aa030f..876d1752f 100644
--- a/x/models/laguna/laguna.go
+++ b/x/models/laguna/laguna.go
@@ -1387,13 +1387,13 @@ func (l *Layer) Forward(x *mlx.Array, b *batch.Batch, c cache.Cache, positions *
return mlx.Add(h, r)
}
-func (m *Model) Forward(b *batch.Batch, caches []cache.Cache) *mlx.Array {
+func (m *Model) Forward(b *batch.Batch, caches []cache.Cache) (hidden, auxHidden *mlx.Array) {
dims := b.InputIDs.Dims()
B, L := int32(dims[0]), int32(dims[1])
return m.forward(b, caches, B, L)
}
-func (m *Model) forward(b *batch.Batch, caches []cache.Cache, B, L int32) *mlx.Array {
+func (m *Model) forward(b *batch.Batch, caches []cache.Cache, B, L int32) (hidden, auxHidden *mlx.Array) {
positions := mlx.FromValues(b.SeqOffsets, len(b.SeqOffsets))
h := m.EmbedTokens.Forward(b.InputIDs)
for i, layer := range m.Layers {
@@ -1403,7 +1403,8 @@ func (m *Model) forward(b *batch.Batch, caches []cache.Cache, B, L int32) *mlx.A
}
h = layer.Forward(h, b, c, positions, B, L, m.Config)
}
- return m.Norm.Forward(h, m.RMSNormEps)
+ out := m.Norm.Forward(h, m.RMSNormEps)
+ return out, out
}
func (m *Model) Unembed(x *mlx.Array) *mlx.Array {
diff --git a/x/models/laguna/laguna_test.go b/x/models/laguna/laguna_test.go
index 8560b1a32..d342adf0d 100644
--- a/x/models/laguna/laguna_test.go
+++ b/x/models/laguna/laguna_test.go
@@ -254,7 +254,7 @@ func TestTinyLagunaLoadAndForward(t *testing.T) {
}
}
}()
- hidden := m.Forward(&batch.Batch{
+ hidden, _ := m.Forward(&batch.Batch{
InputIDs: tokens,
SeqOffsets: []int32{0},
SeqQueryLens: []int32{int32(tokens.Dim(1))},
diff --git a/x/models/llama/llama.go b/x/models/llama/llama.go
index 1780f065e..e39240d9b 100644
--- a/x/models/llama/llama.go
+++ b/x/models/llama/llama.go
@@ -237,7 +237,7 @@ func (m *Model) LoadWeights(tensors map[string]*mlx.Array) error {
return nil
}
-func (m *Model) Forward(b *batch.Batch, caches []cache.Cache) *mlx.Array {
+func (m *Model) Forward(b *batch.Batch, caches []cache.Cache) (hidden, auxHidden *mlx.Array) {
dims := b.InputIDs.Dims()
B, L := int32(dims[0]), int32(dims[1])
positions := mlx.FromValues(b.SeqOffsets, len(b.SeqOffsets))
@@ -251,7 +251,8 @@ func (m *Model) Forward(b *batch.Batch, caches []cache.Cache) *mlx.Array {
h = layer.Forward(h, b, c, positions, B, L, m.Config)
}
- return m.Norm.Forward(h, m.RMSNormEps)
+ out := m.Norm.Forward(h, m.RMSNormEps)
+ return out, out
}
func (m *Model) Unembed(x *mlx.Array) *mlx.Array {
diff --git a/x/models/qwen3/qwen3.go b/x/models/qwen3/qwen3.go
index a929f6425..505d69857 100644
--- a/x/models/qwen3/qwen3.go
+++ b/x/models/qwen3/qwen3.go
@@ -254,7 +254,7 @@ func (m *Model) LoadWeights(tensors map[string]*mlx.Array) error {
return nil
}
-func (m *Model) Forward(b *batch.Batch, caches []cache.Cache) *mlx.Array {
+func (m *Model) Forward(b *batch.Batch, caches []cache.Cache) (hidden, auxHidden *mlx.Array) {
dims := b.InputIDs.Dims()
B, L := int32(dims[0]), int32(dims[1])
positions := mlx.FromValues(b.SeqOffsets, len(b.SeqOffsets))
@@ -268,7 +268,8 @@ func (m *Model) Forward(b *batch.Batch, caches []cache.Cache) *mlx.Array {
h = layer.Forward(h, b, c, positions, B, L, m.Config)
}
- return m.Norm.Forward(h, m.RMSNormEps)
+ out := m.Norm.Forward(h, m.RMSNormEps)
+ return out, out
}
func (m *Model) Unembed(x *mlx.Array) *mlx.Array {
diff --git a/x/models/qwen3_5/qwen3_5.go b/x/models/qwen3_5/qwen3_5.go
index 6c5d44abf..4684ef0c7 100644
--- a/x/models/qwen3_5/qwen3_5.go
+++ b/x/models/qwen3_5/qwen3_5.go
@@ -1194,7 +1194,7 @@ func (l *Layer) Forward(x *mlx.Array, b *batch.Batch, c cache.Cache, positions *
return mlx.Add(h, r)
}
-func (m *Model) Forward(b *batch.Batch, caches []cache.Cache) *mlx.Array {
+func (m *Model) Forward(b *batch.Batch, caches []cache.Cache) (hidden, auxHidden *mlx.Array) {
dims := b.InputIDs.Dims()
B, L := int32(dims[0]), int32(dims[1])
positions := mlx.FromValues(b.SeqOffsets, len(b.SeqOffsets))
@@ -1208,7 +1208,7 @@ func (m *Model) Forward(b *batch.Batch, caches []cache.Cache) *mlx.Array {
h = layer.Forward(h, b, c, positions, B, L, m.Config)
}
out := m.Norm.Forward(h, m.RMSNormEps)
- return out
+ return out, out
}
func (m *Model) Unembed(x *mlx.Array) *mlx.Array {
@@ -1233,9 +1233,9 @@ func (m *Model) SelfDraft() base.DraftModel {
return m
}
-// Draft runs one MTP step; the head's hidden also serves as the projected
+// Draft runs one MTP step; the head's hidden also serves as the aux
// hidden seeding the next step.
-func (m *Model) Draft(b *batch.Batch, caches []cache.Cache) (hidden, projected *mlx.Array) {
+func (m *Model) Draft(b *batch.Batch, caches []cache.Cache) (hidden, auxHidden *mlx.Array) {
dims := b.InputIDs.Dims()
B, L := int32(dims[0]), int32(dims[1])
positions := mlx.FromValues(b.SeqOffsets, len(b.SeqOffsets))