Add Vulkan longhaul support

This commit is contained in:
Owen Qwen
2026-07-30 15:09:43 -05:00
parent a673afad85
commit fa404a9d97
13 changed files with 262 additions and 81 deletions
+30 -2
View File
@@ -4,6 +4,7 @@
#include "ggml-backend.h"
#include <cstring>
#include <cstdio>
#include <memory>
#include <vector>
@@ -24,12 +25,15 @@ struct longhaul_fixture {
size_t n_slots,
uint32_t n_experts,
bool two_sources = false,
uint32_t written_experts = 0) {
uint32_t written_experts = 0,
ggml_backend_dev_t dev = nullptr) {
file = tmpfile();
GGML_ASSERT(file != nullptr);
write_experts(written_experts == 0 ? n_experts : written_experts, two_sources);
backend.reset(ggml_backend_init_by_type(GGML_BACKEND_DEVICE_TYPE_CPU, nullptr));
backend.reset(dev
? ggml_backend_dev_init(dev, nullptr)
: ggml_backend_init_by_type(GGML_BACKEND_DEVICE_TYPE_CPU, nullptr));
GGML_ASSERT(backend);
ggml_init_params params = {
@@ -152,6 +156,18 @@ static void test_read_failure_recovery(testing & t) {
t.assert_equal(uint8_t(1), fixture.slot_value(fixture.weights_a, remapped[0]));
}
static void test_staged_device_upload(testing & t, ggml_backend_dev_t dev) {
longhaul_fixture fixture(2, 4, true, 0, dev);
const auto remapped = fixture.remap({3, 1});
t.assert_equal(2u, remapped.size());
t.assert_equal(uint64_t(4 * longhaul_fixture::expert_size), fixture.cache->bytes_read_count());
t.assert_equal(uint8_t(4), fixture.slot_value(fixture.weights_a, remapped[0]));
t.assert_equal(uint8_t(36), fixture.slot_value(fixture.weights_b, remapped[0]));
t.assert_equal(uint8_t(2), fixture.slot_value(fixture.weights_a, remapped[1]));
t.assert_equal(uint8_t(34), fixture.slot_value(fixture.weights_b, remapped[1]));
}
int main(int argc, char ** argv) {
testing t;
@@ -162,6 +178,7 @@ int main(int argc, char ** argv) {
if (!t.verbose) {
llama_log_set([](ggml_log_level, const char *, void *) {}, nullptr);
}
ggml_backend_load_all();
if (argc > 1) {
t.set_filter(argv[1]);
@@ -172,5 +189,16 @@ int main(int argc, char ** argv) {
t.test("invalid_ids", test_invalid_ids);
t.test("read_failure", test_read_failure_recovery);
for (size_t i = 0; i < ggml_backend_dev_count(); ++i) {
ggml_backend_dev_t dev = ggml_backend_dev_get(i);
const char * backend = ggml_backend_reg_name(ggml_backend_dev_backend_reg(dev));
if (strcmp(backend, "Vulkan") == 0) {
t.test("vulkan_staged_upload", [dev](testing & current) {
test_staged_device_upload(current, dev);
});
break;
}
}
return t.summary();
}