Repository navigation
CPU tests: run every test; fix RoutingPins on transformers > 5.1 - #39
Merged
Merged
Conversation
… 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>
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background
#32 added
test_routing_pins_record_and_force_expertsbelow theif __name__ == "__main__":runner intests/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.RoutingPinsgathered the pinned experts' weights from that value, so with newer transformers the pinned weights were logits, not probabilities. That also affectsnpu-lora checkon MoE checkpoints (#32's default), not only the test.Changes
npu_lora/moe.py:RoutingPinstakes 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 everytest_*function regardless of position.Verification
Local, Windows, torch 2.9.1+cpu:
pytest -k routing_pinsfails (926/1024 elements differ, max abs 1.23).tests/test_cpu.py22 passed on both. (tests/test_airm.pyneedspip install -e ., which CI does.)Compatibility and limits
npu-lora checkresults 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