Skip to content

hrx: fix non-FA attention path for MoE models (500 "Compute error") (#95) - #101

Closed
bong-water-water-bong wants to merge 1 commit into
mainfrom
fix/issue-95-hrx-nonfa-alias
Closed

bong-water-water-bong wants to merge 1 commit into
mainfrom
fix/issue-95-hrx-nonfa-alias

Conversation

@bong-water-water-bong

@bong-water-water-bong bong-water-water-bong commented Sep 25, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #95.

Problem

tests/serve_e2e.sh build/1bit <model> hrx returned HTTP 500 {"error":{"code":500,"message":"Compute error."}} for MoE models whose full context exceeds HRX0's flash-attention KV cap (32768 tokens). At 262144 tokens HRX0 declines flash attention, llama.cpp disables FA for the whole model, and the non-FA attention path fails to compile on HRX0:

Model GGUF arch Before After
Qwen3-Coder-30B-A3B-Instruct Q4_K_M qwen3moe 500 200
GLM-4.7-Flash Q4_K_M deepseek2 500 200
Qwen3.6-35B-A3B Q8_0 qwen35moe pass pass

Root cause & fix (in the llama.cpp submodule, 1bit-MONSTER/llama.cpp@d7ff3afb9)

Three bugs in the HRX backend's non-FA path:

  1. Zero-byte alias validation — tensor_storage_relative_offset rejected a zero-byte (empty) source tensor whenever a degenerate view into it had a non-zero offset (relative_offset > ggml_nbytes(source) → 8192 > 0). Empty per-expert FFN views then failed graph-cache validation with metadata does not match. Fixed by accepting a zero-byte source when the view is also zero-byte.

  2. Invalid in-place alias — the fused attention-output and routed-FFN dispatches requested an in-place buffer alias (residual_input → output) whose target is the layer output (l_out), an external/persistent buffer, so alias_storage failed with value alias target is not transient. The dispatches now only request the in-place alias when both source and target are transient, otherwise they fall back to non-fused ops.

  3. Sigmoid-router SUM_ROWS — GLM-4.7-Flash's sigmoid MoE router left an unsupported SUM_ROWS on HRX0. Narrowed the SUM_ROWS/CLAMP claim to the top-k router chain (SOFT_MAX → ARGSORT → GET_ROWS), so a sigmoid router leaves those nodes to another backend.

Verification

  • tests/serve_e2e.sh build/1bit <model> hrx passes (answers "Paris") on Qwen3-Coder-30B-A3B-Instruct Q4_K_M and Qwen3.6-35B-A3B Q8_0 (no regression).
  • A ~2048-token prompt returns HTTP 200 (previously 500) on Qwen3-Coder-30B-A3B and GLM-4.7-Flash.

Notes / remaining gaps

  • GLM-4.7-Flash still fails the answers Paris check: the 500 is gone (HTTP 200), but the reply is wrong. This is a separate correctness bug in a fused batched dispatch (correct at small ubatch, wrong at larger ubatch), being investigated in parallel — it is not the 500 "Compute error." this PR fixes.
  • The explicit -fa off flag still fails on the non-FA attention postprocess (qwen attention postprocess matcher rejected node): the non-FA attention input reshape has no standalone dispatch. The default serve (FA declined at full context) exercises the non-FA path and works.

Bump the llama.cpp submodule to d7ff3afb9, which fixes the non-flash-attention
attention path on HRX0 so MoE models whose full context exceeds HRX0's 32768
flash-attention KV cap no longer fail with HTTP 500 "Compute error.":

- tensor_storage_relative_offset now accepts zero-byte (empty) source tensors,
  so empty per-expert FFN views pass the graph-cache validation.
- the fused attention-output and routed-FFN dispatches only request the in-place
  buffer alias when both source and target are transient (the layer output is an
  external buffer), avoiding "value alias target is not transient".
- the MoE router SUM_ROWS/CLAMP claim is narrowed to the top-k router chain, so
  GLM-4.7-Flash's sigmoid router no longer leaves an unsupported SUM_ROWS on HRX0.

Together with the #97 context default this makes serve_e2e pass on
Qwen3-Coder-30B-A3B-Instruct Q4_K_M and Qwen3.6-35B-A3B Q8_0, and a 2048-token
prompt returns HTTP 200 (was 500) on Qwen3-Coder-30B-A3B and GLM-4.7-Flash.
@context7

context7 Bot commented Sep 25, 2026

Copy link
Copy Markdown

Docs7 for 1bit-monster/engine

Result Status Action
Deployment ➖ Not used —
Content review ➖ Did not run. This site has no agent runs available this month. Wait for the monthly reset or check your Docs7 plan. —

Commit e4e2a1d

@github-actions

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

95 - Partially compliant

Compliant requirements:

  • Fix HTTP 500 "Compute error" for MoE models on HRX backend
  • Apply fix in the llama.cpp submodule

Non-compliant requirements:

  • Validate that non-MoE models still work (not directly tested in diff)
  • Ensure no regression in performance or correctness (not directly tested in diff)

Requires further human verification:

  • Manual testing of the fixed models with tests/serve_e2e.sh build/1bit <model> hrx
  • Verification that non-MoE models still work correctly
⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Subproject commit update

The PR updates the llama.cpp submodule to a new commit (d7ff3afb90a5bb35bf2577fffc7d567c7ef064ed) which contains the fixes for the HRX non-FA attention path. While this is a necessary change, it's important to verify that this specific commit contains only the intended fixes and does not introduce any regressions or unexpected behavior in the broader context of the engine.

Subproject commit d7ff3afb90a5bb35bf2577fffc7d567c7ef064ed

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Superseded by #104: this PR's llama.cpp commit is in the pin 96f6b89 (1bit-MONSTER/llama.cpp#4), with the MUL_MAT_ID route-stride fix and the FA value_stride range fix. All 7 HRX models pass serve_e2e.

@bong-water-water-bong
bong-water-water-bong deleted the fix/issue-95-hrx-nonfa-alias branch October 12, 2026 01:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HRX: chat on Qwen3-Coder-30B-A3B and GLM-4.7-Flash fails with 500 "Compute error."

1 participant