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: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
/.vs/
/.vscode/
/nppBackup

CMakeUserPresets.json

# Coverage

Expand Down Expand Up @@ -140,3 +140,5 @@ poetry.toml
/.windsurf/
# emscripten
a.out.*

pkg-adb/
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ option(LLAMA_BUILD_TOOLS "llama: build tools" ${LLAMA_STANDALONE})
option(LLAMA_BUILD_EXAMPLES "llama: build examples" ${LLAMA_STANDALONE})
option(LLAMA_BUILD_SERVER "llama: build server example" ${LLAMA_STANDALONE})
option(LLAMA_TOOLS_INSTALL "llama: install tools" ${LLAMA_TOOLS_INSTALL_DEFAULT})
option(IGNITE_USE_SYSTEM_DVFS "Use system DVFS library" ON)

# 3rd party libs
option(LLAMA_HTTPLIB "llama: httplib for downloading functionality" ON)
Expand Down Expand Up @@ -248,6 +249,9 @@ set_target_properties(llama
PUBLIC_HEADER "${LLAMA_PUBLIC_HEADERS}")

install(TARGETS llama LIBRARY PUBLIC_HEADER)
# llama-ignite-npu links against dvfs at runtime, so package installs need to
# ship the library alongside the rest of the shared objects.
install(TARGETS dvfs LIBRARY RUNTIME ARCHIVE)

configure_package_config_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/llama-config.cmake.in
Expand Down
86 changes: 85 additions & 1 deletion common/arg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1039,7 +1039,91 @@ common_params_context common_params_parser_init(common_params & params, llama_ex
[](common_params & params, int value) {
params.max_query_number = value;
}
).set_examples({LLAMA_EXAMPLE_SERVER}));
).set_examples({LLAMA_EXAMPLE_COMPLETION}));

// ----------------------------------------------------------------------------------------
// 20260406 IGNITE DVFS
// ----------------------------------------------------------------------------------------
add_opt(common_arg(
{"--device-name", "--dvfs-device"}, "DN",
"DVFS target device name (e.g. S25, S24, Pixel9)",
[](common_params & params, const std::string & value) {
params.device_name = value;
}
).set_examples({LLAMA_EXAMPLE_COMPLETION}));
add_opt(common_arg(
{"--cpu-p"}, "IDX",
"prefill CPU DVFS index",
[](common_params & params, int value) {
params.cpu_clk_idx_p = value;
}
).set_examples({LLAMA_EXAMPLE_COMPLETION}));
add_opt(common_arg(
{"--ram-p"}, "IDX",
"prefill RAM DVFS index",
[](common_params & params, int value) {
params.ram_clk_idx_p = value;
}
).set_examples({LLAMA_EXAMPLE_COMPLETION}));
add_opt(common_arg(
{"--cpu-d"}, "IDX",
"decode CPU DVFS index",
[](common_params & params, int value) {
params.cpu_clk_idx_d = value;
}
).set_examples({LLAMA_EXAMPLE_COMPLETION}));
add_opt(common_arg(
{"--ram-d"}, "IDX",
"decode RAM DVFS index",
[](common_params & params, int value) {
params.ram_clk_idx_d = value;
}
).set_examples({LLAMA_EXAMPLE_COMPLETION}));
add_opt(common_arg(
{"--phase-pause"}, "MS",
"pause time between prefill and decode phases in milliseconds",
[](common_params & params, int value) {
params.phase_pause = value;
}
).set_examples({LLAMA_EXAMPLE_COMPLETION}));
add_opt(common_arg(
{"--token-pause"}, "MS",
"pause time between generated decode tokens in milliseconds",
[](common_params & params, int value) {
params.token_pause = value;
}
).set_examples({LLAMA_EXAMPLE_COMPLETION}));
add_opt(common_arg(
{"--layer-pause"}, "MS",
"pause time for layer-wise experiments in milliseconds",
[](common_params & params, int value) {
params.layer_pause = value;
}
).set_examples({LLAMA_EXAMPLE_COMPLETION}));
add_opt(common_arg(
{"--ignite-verbose"},
"enable verbose ignite markers for layer pause debugging",
[](common_params & params) {
params.ignite_verbose = true;
}
).set_examples({LLAMA_EXAMPLE_COMPLETION}));
add_opt(common_arg(
{"--backend-compute-profile"},
"enable backend scheduler compute profiling in ignite CSV output",
[](common_params & params) {
params.backend_compute_profile = true;
}
).set_examples({LLAMA_EXAMPLE_COMPLETION}));
add_opt(common_arg(
{"--backend-op-breakdown"},
"append per-op backend scheduler counters to ignite CSV output",
[](common_params & params) {
params.backend_compute_profile = true;
params.backend_op_breakdown = true;
}
).set_examples({LLAMA_EXAMPLE_COMPLETION}));

// ----------------------------------------------------------------------------------------
add_opt(common_arg(
{"--strict"}, "ST",
"enable strict mode",
Expand Down
41 changes: 41 additions & 0 deletions common/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,46 @@ void common_init() {
LOG_INF("build: %d (%s) with %s for %s%s\n", LLAMA_BUILD_NUMBER, LLAMA_COMMIT, LLAMA_COMPILER, LLAMA_BUILD_TARGET, build_type);
}

void common_ignite_init(llama_context * ctx, common_params & params) {
if (!ctx) {
return;
}

llama_igparams ig{};

llama_ignite_set_active(ctx, params.is_ignite_active);
llama_ignite_set_layer_pause(ctx, params.layer_pause);

ig.max_query_number = params.max_query_number;
ig.strict_limit = params.strict_limit;
ig.strict_limit_length = params.strict_limit_length;
ig.enable_thinking = params.enable_thinking;
ig.layer_pause = params.layer_pause;
ig.phase_pause = params.phase_pause;
ig.token_pause = params.token_pause;
ig.query_interval = params.query_interval;
ig.prefill_phase = params.prefill_phase;
ig.prefill_speed = params.prefill_speed;
ig.decode_speed = params.decode_speed;
ig.backend_compute_profile = params.backend_compute_profile;
ig.backend_op_breakdown = params.backend_op_breakdown;

std::strcpy(ig.input_path, params.input_path.c_str());
std::strcpy(ig.output_dir, params.output_dir.c_str());
std::strcpy(ig.output_path_hard, params.output_path_hard.c_str());
std::strcpy(ig.output_path_infer, params.output_path_infer.c_str());

std::strcpy(ig.device_name, params.device_name.c_str());
ig.is_ignite_active = params.is_ignite_active;
ig.ignite_verbose = params.ignite_verbose;
ig.cpu_clk_idx_p = params.cpu_clk_idx_p;
ig.ram_clk_idx_p = params.ram_clk_idx_p;
ig.cpu_clk_idx_d = params.cpu_clk_idx_d;
ig.ram_clk_idx_d = params.ram_clk_idx_d;

init_ignite_params(ctx, &ig);
}

std::string common_params_get_system_info(const common_params & params) {
std::ostringstream os;

Expand Down Expand Up @@ -1225,6 +1265,7 @@ common_init_result_ptr common_init_from_params(common_params & params) {
LOG_ERR("%s: failed to create context with model '%s'\n", __func__, params.model.path.c_str());
return res;
}
common_ignite_init(lctx, params);

const llama_vocab * vocab = llama_model_get_vocab(model);

Expand Down
32 changes: 23 additions & 9 deletions common/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -621,15 +621,28 @@ struct common_params {
bool enable_thinking = false;

// llm plane
// int phase_pause = 0; // ms
// int token_pause = 0; // ms
// int layer_pause = 0; // ms
// int query_interval = 0; // ms
// bool prefill_phase = true; // prefill phase or not
// double prefill_speed = 0.0; // tokens/s
// double decode_speed = 0.0; // tokens/s
// bool is_ignite_active = false;
// bool ignite_verbose = false;
std::string device_name = "S25";
int cpu_clk_idx_p = -1;
int ram_clk_idx_p = -1;
int cpu_clk_idx_d = -1;
int ram_clk_idx_d = -1;

int phase_pause = 0; // ms
int token_pause = 0; // ms
int layer_pause = 0; // ms
bool backend_compute_profile = false;
bool backend_op_breakdown = false;
int query_interval = 0; // ms
bool prefill_phase = true; // prefill phase or not
double prefill_speed = 0.0; // tokens/s
double decode_speed = 0.0; // tokens/s
#if defined (IGNITE_USE_SYSTEM_DVFS)
bool is_ignite_active = true;
bool ignite_verbose = false;
#else
bool is_ignite_active = false;
bool ignite_verbose = false;
#endif

// basic measure configs
int max_query_number = -1; // limit of CSV questions (0=no limit) // deprecated in future
Expand All @@ -643,6 +656,7 @@ struct common_params {
// call once at the start of a program if it uses libcommon
// initializes the logging system and prints info about the build
void common_init();
void common_ignite_init(llama_context * ctx, common_params & params);

std::string common_params_get_system_info(const common_params & params);

Expand Down
51 changes: 51 additions & 0 deletions docs/backend/hexagon/CMakeUserPresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"version": 4,
"configurePresets": [
{
"name": "arm64-android-snapdragon",
"hidden": true,
"architecture": { "value": "arm64", "strategy": "external" },
"toolset": { "value": "host=x86_64", "strategy": "external" },
"cacheVariables": {
"ANDROID_ABI": "arm64-v8a",
"ANDROID_PLATFORM": "android-31",
"CMAKE_TOOLCHAIN_FILE": "$env{ANDROID_NDK_ROOT}/build/cmake/android.toolchain.cmake",
"CMAKE_C_FLAGS": "-march=armv8.7a+fp16 -fvectorize -ffp-model=fast -fno-finite-math-only -flto -D_GNU_SOURCE",
"CMAKE_CXX_FLAGS": "-march=armv8.7a+fp16 -fvectorize -ffp-model=fast -fno-finite-math-only -flto -D_GNU_SOURCE",
"CMAKE_C_FLAGS_RELEASE": "-O3 -DNDEBUG",
"CMAKE_CXX_FLAGS_RELEASE": "-O3 -DNDEBUG",
"CMAKE_C_FLAGS_RELWITHDEBINFO": "-O3 -DNDEBUG -g",
"CMAKE_CXX_FLAGS_RELWITHDEBINFO": "-O3 -DNDEBUG -g",
"HEXAGON_SDK_ROOT": "$env{HEXAGON_SDK_ROOT}",
"PREBUILT_LIB_DIR": "android_aarch64",
"GGML_OPENMP": "OFF",
"GGML_LLAMAFILE": "OFF",
"GGML_OPENCL": "ON",
"GGML_HEXAGON": "ON",
"GGML_HEXAGON_FP32_QUANTIZE_GROUP_SIZE": "128",
"LLAMA_OPENSSL": "OFF"
}
},

{
"name": "arm64-windows-snapdragon",
"inherits": [ "base", "arm64-windows-llvm" ],
"cacheVariables": {
"HEXAGON_SDK_ROOT": "$env{HEXAGON_SDK_ROOT}",
"PREBUILT_LIB_DIR": "windows_aarch64",
"GGML_OPENMP": "OFF",
"GGML_LLAMAFILE": "OFF",
"GGML_OPENCL": "ON",
"GGML_HEXAGON": "ON",
"GGML_HEXAGON_FP32_QUANTIZE_GROUP_SIZE": "128",
"LLAMA_OPENSSL": "OFF"
}
},

{ "name": "arm64-android-snapdragon-debug" , "inherits": [ "base", "arm64-android-snapdragon", "debug" ] },
{ "name": "arm64-android-snapdragon-release", "inherits": [ "base", "arm64-android-snapdragon", "release" ] },

{ "name": "arm64-windows-snapdragon-debug" , "inherits": [ "base", "arm64-windows-snapdragon", "debug" ] },
{ "name": "arm64-windows-snapdragon-release", "inherits": [ "base", "arm64-windows-snapdragon", "release" ] }
]
}
Loading
Loading