Commit e411e3d
pillar1.5(R3) ★: NEOX-ordering RoPE for pure Qwen3 + Qwen3.6 batched
Root cause of long-prompt UTF-8 garbage on Qwen3 family: RoPE
ordering mismatch with HF reference.
- llama.cpp: LLM_ARCH_QWEN3 / QWEN3MOE → LLAMA_ROPE_TYPE_NEOX
(half-split pairs: q[i] pairs with q[i+head_dim/2])
- Our engine's tq_rope and batched-prefill RoPE both used
LLaMA-style interleaved pairs (q[2i], q[2i+1])
- R34 fixed this ONLY for the partial-rotary path (Qwen3.5/3.6
hybrid); pure Qwen3 (full rotary) and tq_forward_batch were
never converted.
Changes:
1. New tq_rope_neox() in tq_ops.c — half-split variant with same
TLS sin/cos caching as tq_rope.
2. tq_engine.h exports the new entry point.
3. Per-token self_attn_forward full-rotary else branch: detect
Qwen3 via gguf arch string or delta_n_heads > 0, dispatch to
tq_rope_neox. TQ_ROPE_PAIRS=1 opt-out for legacy Qwen2/LLaMA.
4. tq_forward_batch full-rotary RoPE path: same detection and
half-split rotation for learned-freq (rope_freqs) and fallback
(tq_rope_neox) branches.
Real-world (Qwen3-0.6B Q4, 50-word synthetic input):
BEFORE: "lenameuously...catch�Williamson" UTF-8 garbage
AFTER (batched): " Let me try to understand this"
AFTER (per-token): " ... and so on... etc. So, the problem is..."
Pillar 1 R3 BPE fix was necessary (tokens correct) but not
sufficient (RoPE still wrong). Together, pure Qwen3 + Qwen3.5-4B
long-prompt coherence restored.
Qwen3.6-35B short prompts remain coherent; long-prompt partial
coherence needs further investigation (likely DeltaNet-specific
accumulation issue separate from RoPE).
Regression: 15/15 test_models + 4/4 test_tokenizer PASS.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent b6b5f09 commit e411e3d
3 files changed
Lines changed: 117 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
652 | 652 | | |
653 | 653 | | |
654 | 654 | | |
| 655 | + | |
| 656 | + | |
655 | 657 | | |
656 | 658 | | |
657 | 659 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1698 | 1698 | | |
1699 | 1699 | | |
1700 | 1700 | | |
1701 | | - | |
1702 | | - | |
| 1701 | + | |
| 1702 | + | |
| 1703 | + | |
| 1704 | + | |
| 1705 | + | |
1703 | 1706 | | |
1704 | 1707 | | |
1705 | 1708 | | |
| |||
1751 | 1754 | | |
1752 | 1755 | | |
1753 | 1756 | | |
| 1757 | + | |
| 1758 | + | |
| 1759 | + | |
| 1760 | + | |
| 1761 | + | |
| 1762 | + | |
| 1763 | + | |
| 1764 | + | |
| 1765 | + | |
| 1766 | + | |
| 1767 | + | |
| 1768 | + | |
| 1769 | + | |
| 1770 | + | |
| 1771 | + | |
| 1772 | + | |
| 1773 | + | |
| 1774 | + | |
| 1775 | + | |
| 1776 | + | |
| 1777 | + | |
| 1778 | + | |
| 1779 | + | |
| 1780 | + | |
| 1781 | + | |
| 1782 | + | |
| 1783 | + | |
| 1784 | + | |
| 1785 | + | |
| 1786 | + | |
| 1787 | + | |
| 1788 | + | |
| 1789 | + | |
| 1790 | + | |
| 1791 | + | |
| 1792 | + | |
| 1793 | + | |
| 1794 | + | |
| 1795 | + | |
| 1796 | + | |
| 1797 | + | |
| 1798 | + | |
| 1799 | + | |
| 1800 | + | |
| 1801 | + | |
| 1802 | + | |
| 1803 | + | |
| 1804 | + | |
| 1805 | + | |
| 1806 | + | |
| 1807 | + | |
1754 | 1808 | | |
1755 | 1809 | | |
1756 | 1810 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1551 | 1551 | | |
1552 | 1552 | | |
1553 | 1553 | | |
1554 | | - | |
| 1554 | + | |
| 1555 | + | |
| 1556 | + | |
| 1557 | + | |
| 1558 | + | |
| 1559 | + | |
| 1560 | + | |
| 1561 | + | |
| 1562 | + | |
| 1563 | + | |
| 1564 | + | |
| 1565 | + | |
| 1566 | + | |
| 1567 | + | |
| 1568 | + | |
| 1569 | + | |
| 1570 | + | |
1555 | 1571 | | |
1556 | 1572 | | |
1557 | 1573 | | |
| |||
3613 | 3629 | | |
3614 | 3630 | | |
3615 | 3631 | | |
| 3632 | + | |
| 3633 | + | |
| 3634 | + | |
| 3635 | + | |
3616 | 3636 | | |
3617 | 3637 | | |
3618 | 3638 | | |
| |||
3633 | 3653 | | |
3634 | 3654 | | |
3635 | 3655 | | |
3636 | | - | |
| 3656 | + | |
| 3657 | + | |
| 3658 | + | |
| 3659 | + | |
| 3660 | + | |
| 3661 | + | |
| 3662 | + | |
| 3663 | + | |
| 3664 | + | |
| 3665 | + | |
| 3666 | + | |
| 3667 | + | |
| 3668 | + | |
3637 | 3669 | | |
3638 | 3670 | | |
3639 | 3671 | | |
| |||
3651 | 3683 | | |
3652 | 3684 | | |
3653 | 3685 | | |
3654 | | - | |
3655 | | - | |
3656 | | - | |
| 3686 | + | |
| 3687 | + | |
| 3688 | + | |
| 3689 | + | |
| 3690 | + | |
| 3691 | + | |
| 3692 | + | |
| 3693 | + | |
| 3694 | + | |
3657 | 3695 | | |
3658 | 3696 | | |
3659 | 3697 | | |
| |||
3663 | 3701 | | |
3664 | 3702 | | |
3665 | 3703 | | |
3666 | | - | |
3667 | | - | |
3668 | | - | |
| 3704 | + | |
| 3705 | + | |
| 3706 | + | |
| 3707 | + | |
| 3708 | + | |
| 3709 | + | |
| 3710 | + | |
| 3711 | + | |
| 3712 | + | |
3669 | 3713 | | |
3670 | 3714 | | |
3671 | 3715 | | |
3672 | | - | |
3673 | | - | |
| 3716 | + | |
| 3717 | + | |
| 3718 | + | |
| 3719 | + | |
| 3720 | + | |
| 3721 | + | |
| 3722 | + | |
3674 | 3723 | | |
3675 | 3724 | | |
3676 | 3725 | | |
| |||
0 commit comments