Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
fmz committed Jul 24, 2024
1 parent aad25b4 commit 043b9df
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 200 deletions.
256 changes: 62 additions & 194 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -1,197 +1,65 @@
{
"version": 4,
"configurePresets": [
{
"name": "base",
"hidden": true,
"generator": "Ninja",
"binaryDir": "${sourceDir}/build-${presetName}",
"cacheVariables": {
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
"CMAKE_INSTALL_RPATH": "$ORIGIN;$ORIGIN/.."
}
},
{
"name": "sycl-base",
"hidden": true,
"generator": "Ninja",
"binaryDir": "${sourceDir}/build-${presetName}",
"cacheVariables": {
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
"CMAKE_CXX_COMPILER": "icx",
"CMAKE_C_COMPILER": "cl",
"GGML_SYCL": "ON",
"CMAKE_INSTALL_RPATH": "$ORIGIN;$ORIGIN/.."
}
},
{
"name": "debug",
"hidden": true,
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "release",
"hidden": true,
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "reldbg",
"hidden": true,
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
}
},
{
"name": "static",
"hidden": true,
"cacheVariables": {
"GGML_STATIC": "ON"
}
},
{
"name": "arm64-windows-msvc",
"hidden": true,
"architecture": {
"value": "arm64",
"strategy": "external"
},
"toolset": {
"value": "host=x86_64",
"strategy": "external"
},
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": "${sourceDir}/cmake/arm64-windows-msvc.cmake"
}
},
{
"name": "arm64-windows-llvm",
"hidden": true,
"architecture": {
"value": "arm64",
"strategy": "external"
},
"toolset": {
"value": "host=x86_64",
"strategy": "external"
},
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": "${sourceDir}/cmake/arm64-windows-llvm.cmake"
}
},
{
"name": "arm64-windows-llvm-debug",
"inherits": [
"base",
"arm64-windows-llvm",
"debug"
]
},
{
"name": "arm64-windows-llvm-release",
"inherits": [
"base",
"arm64-windows-llvm",
"reldbg"
]
},
{
"name": "arm64-windows-llvm+static-release",
"inherits": [
"base",
"arm64-windows-llvm",
"reldbg",
"static"
]
},
{
"name": "arm64-windows-msvc-debug",
"inherits": [
"base",
"arm64-windows-msvc",
"debug"
]
},
{
"name": "arm64-windows-msvc-release",
"inherits": [
"base",
"arm64-windows-msvc",
"reldbg"
]
},
{
"name": "arm64-windows-msvc+static-release",
"inherits": [
"base",
"arm64-windows-msvc",
"reldbg",
"static"
]
},
{
"name": "x64-windows-msvc-debug",
"inherits": [
"base",
"debug"
]
},
{
"name": "x64-windows-msvc-release",
"inherits": [
"base",
"reldbg"
]
},
{
"name": "x64-windows-msvc+static-release",
"inherits": [
"base",
"reldbg",
"static"
]
},
{
"name": "x64-windows-sycl-debug",
"inherits": [
"sycl-base",
"debug"
]
},
{
"name": "x64-windows-sycl-release",
"inherits": [
"sycl-base",
"release"
]
},
{
"name": "clang10",
"displayName": "Clang 10.0.0 x86_64-pc-linux-gnu",
"description": "Using compilers: C = /usr/bin/clang, CXX = /usr/bin/clang++",
"binaryDir": "${sourceDir}/out/build/${presetName}",
"cacheVariables": {
"CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}",
"CMAKE_C_COMPILER": "/usr/bin/clang",
"CMAKE_CXX_COMPILER": "/usr/bin/clang++",
"CMAKE_RC_COMPILER": "/usr/bin/llvm-rc-10",
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "gcc8.4",
"displayName": "GCC 8.4.0 x86_64-linux-gnu",
"description": "Using compilers: C = /usr/bin/gcc, CXX = /usr/bin/g++",
"binaryDir": "${sourceDir}/out/build/${presetName}",
"cacheVariables": {
"CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}",
"CMAKE_C_COMPILER": "/usr/bin/gcc",
"CMAKE_CXX_COMPILER": "/usr/bin/g++",
"CMAKE_BUILD_TYPE": "Debug"
}
"version": 4,
"configurePresets": [
{
"name": "base",
"hidden": true,
"generator": "Ninja",
"binaryDir": "${sourceDir}/build-${presetName}",
"cacheVariables": {
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
"CMAKE_INSTALL_RPATH": "$ORIGIN;$ORIGIN/.."
}
]
},
{
"name": "sycl-base",
"hidden": true,
"generator": "Ninja",
"binaryDir": "${sourceDir}/build-${presetName}",
"cacheVariables": {
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
"CMAKE_CXX_COMPILER": "icx",
"CMAKE_C_COMPILER": "cl",
"GGML_SYCL": "ON",
"CMAKE_INSTALL_RPATH": "$ORIGIN;$ORIGIN/.."
}
},
{ "name": "debug", "hidden": true, "cacheVariables": { "CMAKE_BUILD_TYPE": "Debug" } },
{ "name": "release", "hidden": true, "cacheVariables": { "CMAKE_BUILD_TYPE": "Release" } },
{ "name": "reldbg", "hidden": true, "cacheVariables": { "CMAKE_BUILD_TYPE": "RelWithDebInfo" } },
{ "name": "static", "hidden": true, "cacheVariables": { "GGML_STATIC": "ON" } },

{
"name": "arm64-windows-msvc", "hidden": true,
"architecture": { "value": "arm64", "strategy": "external" },
"toolset": { "value": "host=x86_64", "strategy": "external" },
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": "${sourceDir}/cmake/arm64-windows-msvc.cmake"
}
},

{
"name": "arm64-windows-llvm", "hidden": true,
"architecture": { "value": "arm64", "strategy": "external" },
"toolset": { "value": "host=x86_64", "strategy": "external" },
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": "${sourceDir}/cmake/arm64-windows-llvm.cmake"
}
},

{ "name": "arm64-windows-llvm-debug" , "inherits": [ "base", "arm64-windows-llvm", "debug" ] },
{ "name": "arm64-windows-llvm-release", "inherits": [ "base", "arm64-windows-llvm", "reldbg" ] },
{ "name": "arm64-windows-llvm+static-release", "inherits": [ "base", "arm64-windows-llvm", "reldbg", "static" ] },

{ "name": "arm64-windows-msvc-debug" , "inherits": [ "base", "arm64-windows-msvc", "debug" ] },
{ "name": "arm64-windows-msvc-release", "inherits": [ "base", "arm64-windows-msvc", "reldbg" ] },
{ "name": "arm64-windows-msvc+static-release", "inherits": [ "base", "arm64-windows-msvc", "reldbg", "static" ] },

{ "name": "x64-windows-msvc-debug" , "inherits": [ "base", "debug" ] },
{ "name": "x64-windows-msvc-release", "inherits": [ "base", "reldbg" ] },
{ "name": "x64-windows-msvc+static-release", "inherits": [ "base", "reldbg", "static" ] },

{ "name": "x64-windows-sycl-debug" , "inherits": [ "sycl-base", "debug" ] },
{ "name": "x64-windows-sycl-release", "inherits": [ "sycl-base", "release" ] }
]
}
2 changes: 1 addition & 1 deletion examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ else()
endif()
add_subdirectory(save-load-state)
add_subdirectory(simple)
#add_subdirectory(speculative)
add_subdirectory(speculative)
add_subdirectory(tokenize)
add_subdirectory(train-text-from-scratch)
endif()
6 changes: 3 additions & 3 deletions examples/speculative/speculative.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ int main(int argc, char ** argv) {
// load the draft model
params.model = params.model_draft;
params.n_gpu_layers = params.n_gpu_layers_draft;
if (params.n_threads_draft > 0) {
params.n_threads = params.n_threads_draft;
if (params.draft_cpuparams.n_threads > 0) {
params.cpuparams.n_threads = params.draft_cpuparams.n_threads;
}
params.n_threads_batch = params.n_threads_batch_draft;
params.cpuparams_batch.n_threads = params.draft_cpuparams_batch.n_threads;
std::tie(model_dft, ctx_dft) = llama_init_from_gpt_params(params);

const bool vocab_type_tgt = llama_vocab_type(model_tgt);
Expand Down
4 changes: 2 additions & 2 deletions ggml/src/ggml.c
Original file line number Diff line number Diff line change
Expand Up @@ -18751,7 +18751,7 @@ static bool __thread_affinity(const bool * mask) {

for (uint32_t i = 0; i < GGML_MAX_N_THREADS; i++) {
if (mask[i]) {
printf("Thread %lx: adding %d to cpuset\n", pthread_self(), i);
GGML_PRINT_DEBUG("Thread %lx: adding %d to cpuset\n", pthread_self(), i);
CPU_SET(i, &cpuset);
}
}
Expand Down Expand Up @@ -19144,7 +19144,7 @@ static bool ggml_graph_compute_check_for_work(struct ggml_compute_state * state)
if (threadpool->poll) {
while (!threadpool->new_work && !threadpool->stop && !threadpool->pause) {
// No new work. Yield and keep polling.
//__cpu_relax();
__cpu_relax();
}
} else {
ggml_mutex_lock_shared(&threadpool->mutex);
Expand Down
2 changes: 2 additions & 0 deletions include/llama.h
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,8 @@ extern "C" {
LLAMA_API void llama_detach_batch_threadpool(struct llama_context * ctx);
LLAMA_API void llama_detach_threadpools(struct llama_context * ctx);

// Pauses all attached threadpools
LLAMA_API void llama_pause_threadpools(struct llama_context * ctx);

// Call once at the end of the program - currently only used for MPI
LLAMA_API void llama_backend_free(void);
Expand Down
9 changes: 9 additions & 0 deletions src/llama.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16416,6 +16416,15 @@ void llama_detach_threadpools(struct llama_context * ctx) {
llama_detach_batch_threadpool(ctx);
}

void llama_pause_threadpools(struct llama_context * ctx) {
if (ctx->threadpool) {
ggml_pause_threadpool(ctx->threadpool);
}
if (ctx->threadpool_batch) {
ggml_pause_threadpool(ctx->threadpool_batch);
}
}

void llama_backend_free(void) {
ggml_quantize_free();
}
Expand Down

0 comments on commit 043b9df

Please sign in to comment.