Commit e5a8d439c for llama.cpp
commit e5a8d439cef31f27fad6938233da10dae1ba5631
Author: Georgi Gerganov <ggerganov@gmail.com>
Date: Thu Sep 10 13:43:43 2026 +0300
tests : drop SYCL special-casing in test-backend-ops.cpp (#28688)
diff --git a/tests/test-backend-ops.cpp b/tests/test-backend-ops.cpp
index 2deb90f6a..503998883 100644
--- a/tests/test-backend-ops.cpp
+++ b/tests/test-backend-ops.cpp
@@ -462,17 +462,9 @@ static std::string var_to_str(ggml_scale_mode mode) {
#define VARS_TO_STR16(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) VAR_TO_STR(a) + "," + VARS_TO_STR15(b, c, d, e, f, g, h, i, j, k, l, m, n, o, p)
#define VARS_TO_STR17(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q) VAR_TO_STR(a) + "," + VARS_TO_STR16(b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q)
-#ifdef GGML_USE_SYCL
-static bool inline _isinf(float f) {
- return (*(uint32_t *)&f & 0x7fffffff) == 0x7f800000;
-}
-#else
-static bool inline _isinf(float f) { return std::isinf(f); }
-#endif
-
// accept FLT_MAX as infinity
static bool isinf_or_max(float f) {
- return _isinf(f) || f == FLT_MAX || f == -FLT_MAX;
+ return std::isinf(f) || f == FLT_MAX || f == -FLT_MAX;
}
static bool ggml_is_view_op(enum ggml_op op) {
@@ -4831,51 +4823,6 @@ struct test_mul_mat : public test_case {
}
};
-#define P 1.0f
-#define N -1.0f
-
-// constant Hadamard matrix via Paley I construction
-static constexpr float H12[12][12] = {
- { P, P, P, P, P, P, P, P, P, P, P, P },
- { P, N, P, N, P, P, P, N, N, N, P, N },
- { P, N, N, P, N, P, P, P, N, N, N, P },
- { P, P, N, N, P, N, P, P, P, N, N, N },
- { P, N, P, N, N, P, N, P, P, P, N, N },
- { P, N, N, P, N, N, P, N, P, P, P, N },
- { P, N, N, N, P, N, N, P, N, P, P, P },
- { P, P, N, N, N, P, N, N, P, N, P, P },
- { P, P, P, N, N, N, P, N, N, P, N, P },
- { P, P, P, P, N, N, N, P, N, N, P, N },
- { P, N, P, P, P, N, N, N, P, N, N, P },
- { P, P, N, P, P, P, N, N, N, P, N, N }
-};
-
-static constexpr float H20[20][20] = {
- { P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, P },
- { P, N, P, N, N, P, P, P, P, N, P, N, P, N, N, N, N, P, P, N },
- { P, N, N, P, N, N, P, P, P, P, N, P, N, P, N, N, N, N, P, P },
- { P, P, N, N, P, N, N, P, P, P, P, N, P, N, P, N, N, N, N, P },
- { P, P, P, N, N, P, N, N, P, P, P, P, N, P, N, P, N, N, N, N },
- { P, N, P, P, N, N, P, N, N, P, P, P, P, N, P, N, P, N, N, N },
- { P, N, N, P, P, N, N, P, N, N, P, P, P, P, N, P, N, P, N, N },
- { P, N, N, N, P, P, N, N, P, N, N, P, P, P, P, N, P, N, P, N },
- { P, N, N, N, N, P, P, N, N, P, N, N, P, P, P, P, N, P, N, P },
- { P, P, N, N, N, N, P, P, N, N, P, N, N, P, P, P, P, N, P, N },
- { P, N, P, N, N, N, N, P, P, N, N, P, N, N, P, P, P, P, N, P },
- { P, P, N, P, N, N, N, N, P, P, N, N, P, N, N, P, P, P, P, N },
- { P, N, P, N, P, N, N, N, N, P, P, N, N, P, N, N, P, P, P, P },
- { P, P, N, P, N, P, N, N, N, N, P, P, N, N, P, N, N, P, P, P },
- { P, P, P, N, P, N, P, N, N, N, N, P, P, N, N, P, N, N, P, P },
- { P, P, P, P, N, P, N, P, N, N, N, N, P, P, N, N, P, N, N, P },
- { P, P, P, P, P, N, P, N, P, N, N, N, N, P, P, N, N, P, N, N },
- { P, N, P, P, P, P, N, P, N, P, N, N, N, N, P, P, N, N, P, N },
- { P, N, N, P, P, P, P, N, P, N, P, N, N, N, N, P, P, N, N, P },
- { P, P, N, N, P, P, P, P, N, P, N, P, N, N, N, N, P, P, N, N }
-};
-
-#undef P
-#undef N
-
// GGML_HINT_SRC0_IS_HADAMARD
struct test_mul_mat_hadamard : public test_mul_mat {
test_mul_mat_hadamard(ggml_type type_a = GGML_TYPE_F32, ggml_type type_b = GGML_TYPE_F32,
@@ -4900,58 +4847,20 @@ struct test_mul_mat_hadamard : public test_mul_mat {
void initialize_tensors(ggml_context * ctx) override {
for (ggml_tensor * t = ggml_get_first_tensor(ctx); t != NULL; t = ggml_get_next_tensor(ctx, t)) {
if (strcmp(t->name, "a") == 0) {
- const int64_t n_cols = t->ne[0];
- const int64_t n_rows = ggml_nrows(t);
+ const int64_t n_cols = t->ne[0];
+ const int64_t n_rows = ggml_nrows(t);
std::vector<float> data(n_cols * n_rows);
- float scale = 1.0f / sqrtf((float) n_cols);
-
- auto is_pow2 = [](const int64_t a) {
- return (a > 0) && ((a & (a - 1)) == 0);
- };
-#ifdef GGML_USE_SYCL
- const bool is_kronecker =
- ((n_cols % 12 == 0) && is_pow2(n_cols / 12)) || ((n_cols % 20 == 0) && is_pow2(n_cols / 20));
-#else
- const bool is_kronecker = false;
-#endif
- if (is_kronecker) {
- const int64_t B = (n_cols % 12 == 0 && is_pow2(n_cols / 12)) ? 12 : 20;
- for (int64_t r = 0; r < n_rows; r++) {
- float * row_data = data.data() + r * n_cols;
- const int64_t r_mod = r % n_cols;
- const int64_t r_b = r_mod / B;
- const int64_t r_m = r_mod % B;
-
- for (int64_t i = 0; i < n_cols; i++) {
- const int64_t c_b = i / B;
- const int64_t c_m = i % B;
-
- int pop = 0;
- int64_t val = r_b & c_b;
- while (val) {
- pop += (val & 1);
- val >>= 1;
- }
- const float sign_m = (pop % 2 == 0) ? 1.0f : -1.0f;
- const float sign_b = (B == 12) ? H12[c_m][r_m] : H20[c_m][r_m];
-
- row_data[i] = scale * sign_b * sign_m;
- }
- }
- }
-
- else if (is_pow2(n_cols)) {
- for (int64_t r = 0; r < n_rows; r++) {
- float * row_data = data.data() + r * n_cols;
- for (int64_t i = 0; i < n_cols; i++) {
- int pop_cnt = 0;
- int64_t val = r & i;
- while (val) {
- pop_cnt += (val & 1);
- val >>= 1;
- }
- row_data[i] = (pop_cnt % 2 == 0) ? scale : -scale;
+ float scale = 1.0f / sqrtf((float)n_cols);
+ for (int64_t r = 0; r < n_rows; r++) {
+ float * row_data = data.data() + r * n_cols;
+ for (int64_t i = 0; i < n_cols; i++) {
+ int pop = 0;
+ int64_t val = r & i;
+ while (val) {
+ pop += (val & 1);
+ val >>= 1;
}
+ row_data[i] = (pop % 2 == 0) ? scale : -scale;
}
}
ggml_backend_tensor_set(t, data.data(), 0, data.size() * sizeof(float));
@@ -9716,16 +9625,7 @@ static std::vector<std::unique_ptr<test_case>> make_test_cases_eval() {
test_cases.emplace_back(new test_mul_mat_hadamard(GGML_TYPE_F32, GGML_TYPE_F32, 256, 512, 256)); // many rows
test_cases.emplace_back(new test_mul_mat_hadamard(GGML_TYPE_F32, GGML_TYPE_F32, 32, 1, 32)); // too small (N<64)
test_cases.emplace_back(new test_mul_mat_hadamard(GGML_TYPE_F32, GGML_TYPE_F32, 1024, 1, 1024)); // too big (N>512)
-#ifdef GGML_USE_SYCL
- test_cases.emplace_back(new test_mul_mat_hadamard(GGML_TYPE_F32, GGML_TYPE_F32, 384, 1, 384)); // m=12 (N=384)
- test_cases.emplace_back(new test_mul_mat_hadamard(GGML_TYPE_F32, GGML_TYPE_F32, 384, 32, 384)); // m=12 (batch)
- test_cases.emplace_back(
- new test_mul_mat_hadamard(GGML_TYPE_F32, GGML_TYPE_F32, 384, 4, 384, { 2, 3 })); // m=12 (multi-dim)
- test_cases.emplace_back(new test_mul_mat_hadamard(GGML_TYPE_F32, GGML_TYPE_F32, 768, 1, 768)); // m=12 (N=768)
- test_cases.emplace_back(new test_mul_mat_hadamard(GGML_TYPE_F32, GGML_TYPE_F32, 640, 1, 640)); // m=20 (N=640)
- test_cases.emplace_back(new test_mul_mat_hadamard(GGML_TYPE_F32, GGML_TYPE_F32, 640, 32, 640)); // m=20 (batch)
- test_cases.emplace_back(new test_mul_mat_hadamard(GGML_TYPE_F32, GGML_TYPE_F32, 1280, 1, 1280)); // m=20 (N=1280)
-#endif
+
#if 0
// > 4GB A matrix. Too slow to be enabled by default.
test_cases.emplace_back(new test_mul_mat(GGML_TYPE_F16, GGML_TYPE_F16, 900000, 3, 2592, {1, 1}, {1, 1}));
@@ -11011,16 +10911,7 @@ static std::vector<std::unique_ptr<test_case>> make_test_cases_perf() {
test_cases.emplace_back(new test_mul_mat_hadamard(GGML_TYPE_F32, GGML_TYPE_F32, 128, 2048, 128));
test_cases.emplace_back(new test_mul_mat_hadamard(GGML_TYPE_F32, GGML_TYPE_F32, 256, 2048, 256));
test_cases.emplace_back(new test_mul_mat_hadamard(GGML_TYPE_F32, GGML_TYPE_F32, 512, 2048, 512));
-#ifdef GGML_USE_SYCL
- test_cases.emplace_back(new test_mul_mat_hadamard(GGML_TYPE_F32, GGML_TYPE_F32, 384, 1, 384)); // m=12 (N=384)
- test_cases.emplace_back(new test_mul_mat_hadamard(GGML_TYPE_F32, GGML_TYPE_F32, 384, 32, 384)); // m=12 (batch)
- test_cases.emplace_back(
- new test_mul_mat_hadamard(GGML_TYPE_F32, GGML_TYPE_F32, 384, 4, 384, { 2, 3 })); // m=12 (multi-dim)
- test_cases.emplace_back(new test_mul_mat_hadamard(GGML_TYPE_F32, GGML_TYPE_F32, 768, 1, 768)); // m=12 (N=768)
- test_cases.emplace_back(new test_mul_mat_hadamard(GGML_TYPE_F32, GGML_TYPE_F32, 640, 1, 640)); // m=20 (N=640)
- test_cases.emplace_back(new test_mul_mat_hadamard(GGML_TYPE_F32, GGML_TYPE_F32, 640, 32, 640)); // m=20 (batch)
- test_cases.emplace_back(new test_mul_mat_hadamard(GGML_TYPE_F32, GGML_TYPE_F32, 1280, 1, 1280)); // m=20 (N=1280)
-#endif
+
test_cases.emplace_back(new test_solve_tri(GGML_TYPE_F32, { 64, 64, 4, 4 }, { 32, 64, 4, 4 }));
test_cases.emplace_back(new test_solve_tri(GGML_TYPE_F32, { 128, 128, 4, 2 }, { 32, 128, 4, 2 }));
// qwen3next with CHUNK_SIZE 64