Skip to content

glm5_next W9c-2: lift the RouteTopk and KDA CPU-only refusals - #3133

Merged
localai-org-maint-bot merged 1 commit into
mainfrom
row/MODEL-MM-GLM53-FLASH-W9C2-MOE-DEV
Sep 12, 2026
Merged

localai-org-maint-bot merged 1 commit into
mainfrom
row/MODEL-MM-GLM53-FLASH-W9C2-MOE-DEV

Conversation

@localai-org-maint-bot

@localai-org-maint-bot localai-org-maint-bot commented Sep 11, 2026

Copy link
Copy Markdown
Collaborator

glm5_next W9c-2: lift the RouteTopk and KDA CPU-only refusals

RouteTopk and Glm5NextKdaLayerForward each refused any non-CPU queue
by name because vt::MoeRouterTopK and vt::KdaGatedDeltaRule dispatch on
the queue's device, and handing them host pointers on a GPU queue is a
crash, not a fallback. The device arm was deferred to the assembled
text forward (W9c-3), so the refusal prevented the KDA and MoE layers
from reaching the CUDA and ROCm providers they already call.

This change adds a dense_attn::Dev* dev = nullptr parameter to both
functions. When dev is non-null the routing and recurrence operands
are uploaded via dense_attn::DBuf, the op runs on dev->q, and the
outputs are downloaded back to the host vectors. The projections, conv,
gates, norms and the host arm's original error path are unchanged. When
dev is null the host arm runs exactly as before and still refuses a
non-CPU queue by name.

DecoderLayerForward threads dev into the KDA call site; the MoeForward
call site already carried dev from the prior placement work (PR #3128).

The KDA device-arm test iterates over CUDA and ROCm backends (mirroring
the k-pool device test's KpoolDeviceTypes pattern), runs the device arm
against the host arm oracle, and asserts a non-zero NMSE band. On a
CPU-only build it skips loudly. The existing MoE CUDA device-arm test
(W9c-3a) already exercises RouteTopk's new device arm through MoeForward.

Issue: #2410 (W9c-2 wave)

FOLLOWING_AGENTS_PROTOCOL

Following-Agents-Protocol: true
AI-Assisted: true
Assisted-by: AGENT:regolo-glm5.2 [maki]

@mudler
mudler force-pushed the row/MODEL-MM-GLM53-FLASH-W9C2-MOE-DEV branch 2 times, most recently from 456d961 to d41567f Compare September 12, 2026 00:32
localai-org-maint-bot added a commit that referenced this pull request Sep 12, 2026
…h the ViewOn contract (#3154)

test_rocm_f16_contract (introduced in #3095) failed on clean main
because its check lambda expected `OwnedTensor::View()` and `ViewOn()`
to propagate the layout markers `repacked`, `q8_0_aligned`, and
`elem_kn_repacked`. `ViewOn` deliberately carries only
`weight_value_dtype`: each `ResidentWeight` arm owns a different marker
set and sets them explicitly after the call, and copying them centrally
changed the CPU-alias lane for every model that shares the helper. The
test and the code contradicted each other in the same commit, and
`build-test-cpu` was skipping when #3095 merged so the failure was never
caught.

The fix corrects the check lambda to verify the actual contract:
`weight_value_dtype` IS propagated, layout markers are NOT. The `Slice`
guard is removed because `View()` no longer propagates `repacked`, so
`Slice()` never throws on a view from an `OwnedTensor` that happens to
have `repacked` set.

This unblocks every PR that runs `build-test-cpu` (#3133, #3140, #2906,
and others).

Closes #3153.

FOLLOWING_AGENTS_PROTOCOL

Following-Agents-Protocol: true
AI-Assisted: true
Assisted-by: AGENT:regolo/glm5.2 [maki]

Co-authored-by: Ettore Di Giacinto <mudler@localai.io>
…ls (W9c-2)

RouteTopk and Glm5NextKdaLayerForward each refused any non-CPU queue
by name because vt::MoeRouterTopK and vt::KdaGatedDeltaRule dispatch on
the queue's device, and handing them host pointers on a GPU queue is a
crash, not a fallback. The device arm was deferred to the assembled
text forward (W9c-3), so the refusal prevented the KDA and MoE layers
from reaching the CUDA and ROCm providers they already call.

This change adds a `dense_attn::Dev* dev = nullptr` parameter to both
functions. When `dev` is non-null the routing and recurrence operands
are uploaded via `dense_attn::DBuf`, the op runs on `dev->q`, and the
outputs are downloaded back to the host vectors. The projections, conv,
gates, norms and the host arm's original error path are unchanged. When
`dev` is null the host arm runs exactly as before and still refuses a
non-CPU queue by name.

DecoderLayerForward threads `dev` into the KDA call site; the MoeForward
call site already carried `dev` from the prior placement work (PR #3128).

The KDA device-arm test iterates over CUDA and ROCm backends (mirroring
the k-pool device test's KpoolDeviceTypes pattern), runs the device arm
against the host arm oracle, and asserts a non-zero NMSE band. On a
CPU-only build it skips loudly. The existing MoE CUDA device-arm test
(W9c-3a) already exercises RouteTopk's new device arm through MoeForward.

Issue: #2410 (W9c-2 wave)

FOLLOWING_AGENTS_PROTOCOL

Following-Agents-Protocol: true
AI-Assisted: true
Assisted-by: AGENT:regolo-glm5.2 [maki]
@mudler
mudler force-pushed the row/MODEL-MM-GLM53-FLASH-W9C2-MOE-DEV branch from d41567f to 3cd917b Compare September 12, 2026 07:15
@localai-org-maint-bot
localai-org-maint-bot merged commit ce726c3 into main Sep 12, 2026
22 of 26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants