MCPcopy Create free account
hub / github.com/antirez/llama.cpp-deepseek-v4-flash / test_backends

Function test_backends

tests/test-llama-archs.cpp:470–605  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

468}
469
470static int test_backends(const llm_arch target_arch, const size_t seed, const ggml_log_level log_level) {
471 struct user_data_t {
472 struct {
473 ggml_log_callback callback;
474 void * user_data;
475 } original_logger;
476 ggml_log_level min_level; // prints below this log level go to debug log
477 };
478 user_data_t ud;
479 llama_log_get(&ud.original_logger.callback, &ud.original_logger.user_data);
480 ud.min_level = log_level;
481
482 llama_log_set([](ggml_log_level level, const char * text, void * user_data) {
483 const user_data_t * ud = (const user_data_t *) user_data;
484 const ggml_log_level level_eff = level >= ud->min_level ? level : GGML_LOG_LEVEL_DEBUG;
485 ud->original_logger.callback(level_eff, text, ud->original_logger.user_data);
486 }, &ud);
487
488 const std::vector<llama_token> tokens = get_tokens(128, 128, seed);
489
490 struct device_config {
491 std::vector<ggml_backend_dev_t> devs;
492 std::string label;
493 llama_split_mode split_mode;
494
495 device_config(std::vector<ggml_backend_dev_t> devs, std::string name, llama_split_mode split_mode)
496 : devs(std::move(devs)), label(std::move(name)), split_mode(split_mode) {}
497 };
498
499 std::vector<device_config> dev_configs;
500 {
501 std::vector<ggml_backend_dev_t> devices_meta;
502 {
503 const size_t device_count = ggml_backend_dev_count();
504 for (size_t i = 0; i < device_count; i++) {
505 ggml_backend_dev_t dev = ggml_backend_dev_get(i);
506 dev_configs.emplace_back(std::vector<ggml_backend_dev_t>{dev}, ggml_backend_dev_description(dev), LLAMA_SPLIT_MODE_LAYER);
507
508 // cpu-based devices cannot be used in tensor split mode
509 if (ggml_backend_dev_buffer_type(dev) != ggml_backend_cpu_buffer_type()) {
510 devices_meta.push_back(dev);
511 }
512 }
513 }
514
515 dev_configs.emplace_back(devices_meta, "Meta", LLAMA_SPLIT_MODE_TENSOR);
516 }
517
518 bool all_ok = true;
519 common_log_flush(common_log_main());
520 printf("|%16s|%30s|%6s|%15s|%9s|\n", "Model arch.", "Device", "Config", "NMSE vs. CPU", "Roundtrip");
521 printf("|----------------|------------------------------|------|---------------|---------|\n");
522 for (const llm_arch & arch : llm_arch_all()) {
523 if (arch == LLM_ARCH_UNKNOWN) {
524 continue;
525 }
526 if (target_arch != LLM_ARCH_UNKNOWN && arch != target_arch) {
527 continue;

Callers 1

mainFunction · 0.85

Calls 15

llama_log_getFunction · 0.85
llama_log_setFunction · 0.85
get_tokensFunction · 0.85
ggml_backend_dev_countFunction · 0.85
ggml_backend_dev_getFunction · 0.85
common_log_flushFunction · 0.85
common_log_mainFunction · 0.85
llm_arch_allFunction · 0.85
moe_implementedFunction · 0.85

Tested by

no test coverage detected