Skip to content

CPU tests: run every test; fix RoutingPins on transformers > 5.1 - #39

Merged
gspark-etri merged 2 commits into
mainfrom
fix/run-all-cpu-tests
Oct 21, 2026
Merged

gspark-etri merged 2 commits into
mainfrom
fix/run-all-cpu-tests

Conversation

@gspark-etri

@gspark-etri gspark-etri commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Background

#32 added test_routing_pins_record_and_force_experts below the if __name__ == "__main__": runner in tests/test_cpu.py, so running the file (what CI did after #37) never ran it: CI reported 21 tests, not 22. Once the test ran in CI (transformers 5.20.2), it failed: a run pinned to its own experts did not reproduce its own output.

Cause: the Qwen-MoE router returns (router_logits, scores, indices). In transformers 5.1 the first value is the softmax; in later releases (5.20) it is the raw logits. RoutingPins gathered the pinned experts' weights from that value, so with newer transformers the pinned weights were logits, not probabilities. That also affects npu-lora check on MoE checkpoints (#32's default), not only the test.

Changes

  • npu_lora/moe.py: RoutingPins takes the softmax when the router's first output is not a probability distribution (negative values or rows not summing to 1).
  • tests/test_cpu.py: the runner block moves back to the end.
  • .github/workflows/ci.yml: one step, python -m pytest -q tests, which collects every test_* function regardless of position.

Verification

Local, Windows, torch 2.9.1+cpu:

  • transformers 5.20.2, before the fix: pytest -k routing_pins fails (926/1024 elements differ, max abs 1.23).
  • transformers 5.1.0 and 5.20.2, after the fix: tests/test_cpu.py 22 passed on both. (tests/test_airm.py needs pip install -e ., which CI does.)
  • CI on this PR: see checks.

Compatibility and limits

npu-lora check results for MoE taken with transformers > 5.1 before this fix are invalid for the pinned comparison; #32's table was measured on the node's transformers 5.1 stack, which returned probabilities.

Related Issue

Related to #32 and #36.

🤖 Generated with Claude Code

gspark-etri and others added 2 commits October 21, 2026 14:57
… CI uses pytest

test_routing_pins_record_and_force_experts (#32) sat below the
'if __name__ == "__main__"' runner, so tests/test_cpu.py never ran it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rmers > 5.1)

transformers 5.1 returns the router softmax as the first output; later
releases return the raw logits. Pinning gathered the logits as weights,
so a pinned run did not reproduce its own output on transformers 5.20.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gspark-etri gspark-etri changed the title CPU tests: run every test; CI collects them with pytest CPU tests: run every test; fix RoutingPins on transformers > 5.1 Oct 21, 2026
@gspark-etri
gspark-etri merged commit cf3fb32 into main Oct 21, 2026
1 check passed
@gspark-etri
gspark-etri deleted the fix/run-all-cpu-tests branch October 21, 2026 06:05
@gspark-etri

Copy link
Copy Markdown
Contributor Author

Correction to "Compatibility and limits": #32's table does not record the transformers version it ran with. The statement that it ran on a transformers 5.1 stack was an assumption, not checked. If that run used a release later than 5.1, its pinned row should be re-measured with this fix.

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.

1 participant