Skip to content

npu: step_users refuses position 0 on a re-used slot, so the 'start a new sequence' reset it documents is unreachable #2978

Closed

Description

@bong-water-water-bong

Found on the device while verifying the bumped NPU runtime (npu-kernels#102/#103), with step_users_test's own re-used-slot arm — the arm that exists for exactly this.

What happens

step_users() refuses a pass whose first row for a slot is not at that slot's sequence end (rightly: a row appends at its own position and reads 0..pos). But the guard has no exception for position 0, while the loop immediately below it implements exactly that exception:

npu/forward/src/q4nx_forward.cpp:4815   if (pos[m] != have) { err_ = "step_users: slot ... holds N position(s), but this pass starts it at 0 ..."; return false; }
npu/forward/src/q4nx_forward.cpp:4824   // A slot whose FIRST row is position 0 starts a NEW sequence, so what the previous
                                        // conversation left in its caches is cleared first ... (one clear per slot)

So the reset path is unreachable: a re-used slot at position 0 is refused with the message that describes the case it is refusing.

Measured

npu-hold, Qwen3-1.7B-NPU2 pack, host-GEMM path, ONEBIT_TEST_Q4NX = the pack + kernels-qwen17-b8:

FAIL step_users on the re-used slot: step_users: slot 0 holds 7 position(s), but this pass starts it at 0
     (each row appends at its own position and reads up to it, so a start that is not the end of the slot's
      sequence reads state that is not there; position 0 starts a new sequence)

Fix

Exempt pos[m] == 0 from that check, which is what the clearing loop below it already assumes. With the exemption the same run passes the arm and completes:

ok: 3 sequences x 4 rounds, every row bit-identical to its own single-sequence run

A second defect surfaced with it, in the test rather than the engine: the re-used-slot arm resets slot 0 to a 4-position sequence, so the arm after it (a single-slot pass at slot 0's old position 7) was refused for a reason that is not a bug — invisible while the first arm failed and returned early. That arm now runs last, with a comment saying why. Both changes have to land together for the suite to be green on a device.

Whoever takes this: the serve batcher (--npu-batch-users) is the caller that would use a reset between requests, so this is the difference between "a slot can be reused" and "a slot cannot".

Activity

  1. added a commit that references this issue on Nov 20, 2026
    aaed5ac
  2. bong-water-water-bong commented on Nov 20, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Claimed → #2982 (cl-game/2978-step-users-pos0), and both halves reproduced locally, host-GEMM, no device and no ticket — a leftover NPU-enabled build tree in this worktree made that possible, which is worth noting because I had written off NPU verification on this box earlier today.

    Three states, one command (ONEBIT_TEST_Q4NX=~/models/npu/Qwen3-0.6B):

    origin/main              FAIL step_users on the re-used slot: slot 0 holds 7 position(s), but this pass starts it at 0
    exemption only           FAIL single-slot pass on slot 0: slot 0 holds 4 position(s), but this pass starts it at 7
    exemption + reordering   ok: 3 sequences x 4 rounds, every row bit-identical to its own single-sequence run
    

    The middle line is the one that matters for the fix's shape: the test-order defect the issue names is real and only becomes visible once the engine stops refusing the first arm — which is why the two changes belong in one commit.

    The exemption is pos[m] != 0 and nothing else: a row at position 3 of a slot holding 7 is still refused, which is the case the guard exists for.

  3. added 4 commits that reference this issue on Nov 20, 2026
    9fe7203
    fb46222
    7a6196e
    2b7d9da
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