Fix rotary compatibility edge cases and document Qwen qualification

This commit is contained in:
hazyumps authored and StillDeadcode committed 2026-10-07 11:09:27 +02:00
1 parent 59d36ae928
commit 6fd7421f79
7 files changed
+306 -6

No files matched your search

+20
View File
@@ -1824,6 +1824,26 @@ TEST(yarn_rotary_matches_independent_vllm_vectors) {
}
}
TEST(disabled_yarn_ignores_auxiliary_coefficients) {
for (double magnitude : {2.0, (double)NAN}) {
T pos(RAD_I32, {1}); pos.n({0});
T qkv(RAD_F32, {1, 4}); qkv.f({1, 2, 3, 4});
A direct; direct.t(qkv).t(pos).i("M", 1).i("head_dim", 4)
.i("n_head", 1).i("n_head_kv", 0).d("theta", 10000).d("scale", 1)
.s("mode", "neox").d("yarn_factor", 0).d("yarn_low", NAN)
.d("yarn_high", NAN).d("yarn_magnitude", magnitude);
CHECK_OK(run("rope", direct));
for (int i = 0; i < 4; ++i) CHECK_EQ(qkv.at(i), (float)(i + 1));
T table(RAD_F32, {1, 4});
A ta; ta.t(pos).t(table).i("M", 1).i("rot", 4).d("theta", 10000)
.d("scale", 1).s("dtype", "f32").d("yarn_factor", 0)
.d("yarn_low", NAN).d("yarn_high", NAN).d("yarn_magnitude", magnitude);
CHECK_OK(run("rope_table", ta));
CHECK_EQ(table.at(0), 1.0f); CHECK_EQ(table.at(1), 1.0f);
CHECK_EQ(table.at(2), 0.0f); CHECK_EQ(table.at(3), 0.0f);
}
}
TEST(yarn_multimodal_positions_and_invalid_parameters) {
const int rot = 64, hd = 80;
T positions(RAD_I32, {3, 1}); positions.n({262144, 500000, 524287});
+16
View File
@@ -46,6 +46,22 @@ TEST(yarn_metadata_rejects_bad_inputs_and_preserves_default) {
CHECK_OK(yarn_from(g, &m, "", 64)); CHECK_EQ(g.rope_scale, 2.0f);
}
TEST(linear_metadata_rejects_fp32_overflow_and_underflow) {
const char* keys[] = {"rope_parameters.rope_type", "rope_parameters.factor"};
const char* vals[] = {"linear", "2"};
RadModelMeta m{}; m.n_kv = 2; m.kv_key = keys; m.kv_val = vals;
Geom g{};
for (const char* bad : {"1e300", "1e-300", "0", "-2", "nan", "inf"}) {
vals[1] = bad;
g.rope_scale = 3.0f;
CHECK_EQ(yarn_from(g, &m, "", 64), RAD_E_INVAL);
CHECK_EQ(g.rope_scale, 3.0f);
}
vals[1] = "0.5";
CHECK_OK(yarn_from(g, &m, "", 64));
CHECK_EQ(g.rope_scale, 0.5f);
}
TEST(yarn_legacy_explicit_magnitude_and_fractional_bounds) {
const char* keys[] = {"rope_scaling.type", "rope_scaling.factor",
"rope_scaling.original_max_position_embeddings", "rope_scaling.attention_factor",