Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/include/AutoModel/all_models.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ inline std::pair<std::string, std::unique_ptr<AutoModel>> get_auto_model(const s


if (available_models.is_model_supported(model_tag) == false) {
header_print("Error", "Model tag '" << model_tag << "' is not supported. Please check the model list.");
header_print_r("ERROR", "Model tag '" << model_tag << "' is not supported. Please check the model list.");
return std::make_pair("llama3.2:1b", std::make_unique<Llama3>(npu_device_inst));
}

Expand Down Expand Up @@ -116,7 +116,7 @@ inline std::pair<std::string, std::unique_ptr<AutoModel>> get_auto_model(const s
case SupportedModelFamily::error_whiper:
case SupportedModelFamily::error_embedding:
default:
header_print("Error", "Unsupported model family or non-llm: " << model_info["details"]["family"]);
header_print_r("ERROR", "Unsupported model family or non-llm: " << model_info["details"]["family"]);
auto_chat_engine = std::make_unique<Llama3>(npu_device_inst);
new_model_tag = "llama3.2:1b";
}
Expand Down
6 changes: 3 additions & 3 deletions src/include/model_list.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,16 @@ class model_list {
if (!model_found) {
if (last_error_tag != new_tag) {
last_error_tag = new_tag;
header_print("ERROR", "Model not found: " + model_size + " in subset " + model_type);
header_print("ERROR", "Using default model: llama3.2-1B");
header_print_r("ERROR", "Model not found: " + model_size + " in subset " + model_type);
header_print_r("ERROR", "Using default model: llama3.2-1B");
}
return std::make_pair("llama3.2:1b", this->config["models"]["llama3.2"]["1b"]);
}
}
else{
if (last_error_tag != new_tag) {
last_error_tag = new_tag;
header_print("ERROR", "Model subset not found: " << model_type << "; using default model: llama3.2-1B");
header_print_r("ERROR", "Model subset not found: " << model_type << "; using default model: llama3.2-1B");
}
return std::make_pair("llama3.2:1b", this->config["models"]["llama3.2"]["1b"]);
}
Expand Down
12 changes: 6 additions & 6 deletions src/include/npu_utils/npu_instr_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -478,22 +478,22 @@ class npu_sequence{
constexpr int wrap_bits = 10;

if(size[3] > (1<< wrap_bits)){
header_print("ERROR", ": step_3 out ouf range");
header_print_r("ERROR", ": step_3 out ouf range");
}
if(stride[3] > (1<< step_bits)){
header_print("ERROR", ": stride_3 out of range");
header_print_r("ERROR", ": stride_3 out of range");
}
if(size[2] > (1<< wrap_bits)){
header_print("ERROR", ": step_2 out ouf range");
header_print_r("ERROR", ": step_2 out ouf range");
}
if(stride[2] > (1<< step_bits)){
header_print("ERROR", ": stride_2 out of range");
header_print_r("ERROR", ": stride_2 out of range");
}
if(size[1] > (1<< wrap_bits)){
header_print("ERROR", ": step_1 out ouf range");
header_print_r("ERROR", ": step_1 out ouf range");
}
if(stride[1] > (1<< step_bits)){
header_print("ERROR", ": stride_1 out of range");
header_print_r("ERROR", ": stride_1 out of range");
}
// inverse of human's order
cmd->dim0_size = size[3];
Expand Down
4 changes: 2 additions & 2 deletions src/include/npu_utils/npu_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class npu_app {
NULL, 0, (void**)elf_buf, NULL, 0, "", "", NULL, 0);
assert(elf_buf_size > 0);
if (elf_buf_size == 0){
header_print("error", "Failed to get elf from ctrl_seq");
header_print_r("ERROR", "Failed to get elf from ctrl_seq");
exit(1);
}
return elf_buf_size;
Expand Down Expand Up @@ -210,7 +210,7 @@ class npu_app {
uint32_t elf_buf_size = this->_gen_elf(&elf_buf, data);
std::ofstream fout(elf_name, std::ios::binary);
if (fout.is_open() == false) {
header_print("error", "Failed to open file: " << elf_name);
header_print_r("ERROR", "Failed to open file: " << elf_name);
exit(1);
}
fout.write((char*)elf_buf, elf_buf_size);
Expand Down
2 changes: 1 addition & 1 deletion src/include/utils/debug_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
do { \
std::ostringstream oss; \
oss << msg; \
std::cout << "\033[31m[" << header << "] " << oss.str() << "\033[0m" << std::endl; \
std::cerr << "\033[31m[" << header << "] " << oss.str() << "\033[0m" << std::endl; \
} while (0)


Expand Down
6 changes: 3 additions & 3 deletions src/src/benchmarking.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ inline void write_bench_csv(const BenchmarkResults_t& results, const std::string

std::ofstream out(filename, std::ios::out | std::ios::trunc);
if (!out.is_open()) {
header_print("ERROR", "Failed to open output file: " + filename);
header_print_r("ERROR", "Failed to open output file: " + filename);
return;
}

Expand Down Expand Up @@ -260,7 +260,7 @@ BenchmarkResults_t run_benchmarks(std::string model_tag, std::string bench_confi
else {
std::ifstream input_file(bench_config_file);
if (!input_file.is_open()) {
header_print("ERROR", "Failed to open input file: " + bench_config_file);
header_print_r("ERROR", "Failed to open input file: " + bench_config_file);
return results;
}
bench_config = nlohmann::json::parse(input_file);
Expand All @@ -270,7 +270,7 @@ BenchmarkResults_t run_benchmarks(std::string model_tag, std::string bench_confi
xrt::device npu_device_inst = xrt::device(0);
std::unique_ptr<AutoModel> auto_chat_engine;
if (!availble_models.is_model_supported(model_tag)) {
header_print("ERROR", "Model not found: " << model_tag << "; Please check with `flm list` and try again.");
header_print_r("ERROR", "Model not found: " << model_tag << "; Please check with `flm list` and try again.");
return results;
}
auto [new_tag, model_info] = availble_models.get_model_info(model_tag);
Expand Down
36 changes: 28 additions & 8 deletions src/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/resource.h>
#include <linux/types.h>
#include <libdrm/drm.h>
#include <sys/utsname.h>
Expand Down Expand Up @@ -242,11 +243,11 @@ static bool sanity_check_npu_stack(bool quiet) {
sscanf(u_name.release, "%d.%d", &major, &minor);
bool kernel_ok = (major > 6) || (major == 6 && minor >= 14);
if (!kernel_ok) {
header_print("ERROR", "Kernel version incompatible with this version of FLM. Please update your kernel!");
header_print_r("ERROR", "Kernel version incompatible with this version of FLM. Please update your kernel!");
return false;
}
if (!quiet) {
header_print("Linux", "Kernel Version: " << u_name.release);
header_print("Linux", "Kernel: " << u_name.release);
}

// Check firmware version of all AMD devices
Expand Down Expand Up @@ -276,7 +277,7 @@ static bool sanity_check_npu_stack(bool quiet) {
// ENOTTY means it's not an AMD device, just ignore it.
if (errno != ENOTTY) {
if (!quiet) {
std::cout << "Error code: " << ret << " on " << dev_name << std::endl;
header_print_r("ERROR", "Error code: " << ret << " on " << dev_name);
perror("Failed to get firmware version");
}
}
Expand All @@ -286,22 +287,41 @@ static bool sanity_check_npu_stack(bool quiet) {
amd_device_found = true;

if (!quiet) {
header_print("Linux", "Found AMD NPU at " + dev_name);
header_print("Linux", "NPU FW Version: " << query_fw_version.major << "." << query_fw_version.minor << "." << query_fw_version.patch << "." << query_fw_version.build);
header_print_g("Linux", "NPU: " + dev_name);
header_print_g("Linux", "NPU FW Version: " << query_fw_version.major << "." << query_fw_version.minor << "." << query_fw_version.patch << "." << query_fw_version.build);
}

bool fw_ok = (query_fw_version.major > 1 || (query_fw_version.major == 1 && query_fw_version.minor >= 1));
if (!fw_ok) {
all_fw_ok = false;
header_print("ERROR", "NPU firmware version on " + dev_name + " is incompatible. Please update NPU firmware!");
header_print_r("ERROR", "NPU firmware version on " + dev_name + " is incompatible. Please update NPU firmware!");
}
}

if (!amd_device_found && !quiet) {
header_print("ERROR", "No AMD NPU device found.");
header_print_r("ERROR", "No NPU device found.");
}

return amd_device_found && kernel_ok && all_fw_ok;
// Check memlock limit
bool memlock_ok = true;
struct rlimit rl;
if (getrlimit(RLIMIT_MEMLOCK, &rl) == 0) {
if (rl.rlim_cur != RLIM_INFINITY && rl.rlim_cur < 100 * 1024 * 1024) {
header_print_r("ERROR", "Memlock limit is too low (" << (rl.rlim_cur / 1024 / 1024) << "MB). Please raise the limit or set to infinity.");
memlock_ok = false;
} else if (!quiet) {
if (rl.rlim_cur == RLIM_INFINITY) {
header_print_g("Linux", "Memlock Limit: infinity");
} else {
header_print("Linux", "Memlock Limit: " << (rl.rlim_cur / 1024 / 1024) << " MB");
}
}
} else {
if (!quiet)
perror("Failed to get memlock limit");
}

return amd_device_found && kernel_ok && all_fw_ok && memlock_ok;
#else
return true;
#endif
Expand Down