Skip to content

npu: chatglm3's GQO states rotary_interleaved=1, but the forward rotates half-split pairs (fluent but wrong text on both 1.7 packs) #2673

Closed

Description

@bong-water-water-bong

chatglm3-6b-onnx-ryzenai-npu and chatglm3-6b-onnx-ryzenai-1.7-hybrid (Ryzen AI 1.7) import with 0 gaps and serve fluent but wrong text. Both packs behave identically:

  • "What is 12 times 7?" -> 12 times 7 and then end-of-sequence (8 tokens, no answer);
  • the Moon prompt -> "...was Neil Armstrong. Neil Armstrong." then stop;
  • France -> correct.

The serve stops only on </s> (2), and the model emitted that token itself.

Measured cause, from the pack's own graph (fusion.onnx, 28 com.ryzenai:GQO nodes): every GQO states do_rotary = 1, rotary_interleaved = 1 and rotary_embedding_dim = 64. GLM rotates consecutive pairs (2i, 2i+1) over the first 64 of 128 head dims.

  • The importer gets the 64 right (partial_rotary_factor 0.5 taken from the pack's cos_cache) and verifies theta (corr 1.0000).
  • But it ignores rotary_interleaved, and the forward's RoPE (q4nx_forward.cpp, "half-split over the first rot channels") pairs (i, i + rot/2). So q and k are rotated in the wrong pair order at every position. Position 0 is untouched, which is why short answers start right and then drift.
  • mla_rope() already uses (2i, 2i+1) for deepseek2, and its comment names this bug class (MiniCPM4/5).

Fix: read rotary_interleaved from GQO / GroupQueryAttention into the container config (rope_interleaved), parse it in q4nx_semantics, and rotate (2i, 2i+1) in the main RoPE when it is set. Proof needs an arithmetic arm (interleaved vs half-split on one vector), a mutant, and the two NPU rows re-run. Found in the TAMDCOL 1.7 sweep (cl-npuperf).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions