You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
npu-pack: a pack without config.json loses partial_rotary_factor (Phi-4-mini 1.7.1 hybrid drifts after a few tokens); its cos_cache states it #2571
The AMD Phi-4-mini 1.7.1 hybrid packs (Phi-4-mini-instruct_rai_1.7.1_hybrid, Phi-4-mini-reasoning_rai_1.7.1_hybrid) import with 0 gaps and a passing head self-check (corr 0.9963). On --device npu (kernels kernels-3072-8192-qkv5120-b8), though:
instruct gets the first answer right ("The capital of France is Paris.") and then drifts: 'To calculate 12 times 7, you would multiply 12 by 7, you would multiply 12 by 7 by 7 by 7, ...' and '... Neil Armstrong on the Moon on the Moon on the 1969 Moon ...'.
reasoning is garbage from the first token.
Cause
Phi-4-mini rotates only 96 of each head's 128 dims (HF partial_rotary_factor: 0.75). These packs ship no config.json, and genai_config.json says nothing about rotary. The importer therefore writes no partial_rotary_factor, and the forward rotates all 128 dims ([semantics] rotary_dim=0).
The pack does state its span: the attention's cos_cache has 48 frequency columns, which is rotary_dim / 2. The importer already reads that cache to verify rope_theta (corr 1.0000), but never records the span.
Measured fix
With partial_rotary_factor: 0.75 in the container's config (rotary_dim=96), the same container on the same kernels answers '12 times 7 equals 84.' and 'The first person to walk on the Moon was Neil Armstrong. He achieved this historic milestone on July 20, 1969, during the Apollo 11 mission.'; both finish with stop.
The importer change: when the config does not state a factor and 2 * cos_cache.dims[1] < head_dim, write partial_rotary_factor = 2*half/head_dim. This applies to both the hybrid and the external-data writers. LongRoPE short/long factors are not needed at chat lengths, as the measurement above shows; long-context behaviour is a separate question.
Activity
bong-water-water-bong commentedon Nov 15, 2026
Taking this (cl-npuperf); fix PR follows.