Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
d91fd7c
fixed issue: crashed on deleting chat
rifkybujana Jan 15, 2025
e5975a2
- Added persistence KV Cache method\
rifkybujana Jan 22, 2025
4728dbf
added qwen 2.5 code 0.5b - 14b, and added qwen 2.5 14b models
rifkybujana Jan 22, 2025
6a78b30
Merge branch 'main' into dev
rifkybujana Jan 22, 2025
74a586f
merge with main
rifkybujana Jan 22, 2025
8daed41
fix model won't generate if we switch the model on a non empty chat
rifkybujana Jan 22, 2025
ba9446c
added deepseek r1
rifkybujana Jan 23, 2025
535bd81
removed deepseek unsupported
rifkybujana Jan 23, 2025
812cd45
Revert "added deepseek r0"
rifkybujana Jan 23, 2025
ccfc310
Revert "removed deepseek unsupported"
rifkybujana Jan 23, 2025
69268ad
added deepseek r1 support
rifkybujana Jan 23, 2025
517bd1f
added base markdown rendering
rifkybujana Jan 26, 2025
4135ddf
added ImGuiColorTextEdit for handling code rendering on markdown
rifkybujana Jan 26, 2025
847c726
added markdown renderer
rifkybujana Jan 28, 2025
e9e827a
added modified imgui_md
rifkybujana Jan 28, 2025
66c18f2
added cancel button and fix the model card duplication issue
rifkybujana Feb 1, 2025
e8bde60
fix last selected model issue
rifkybujana Feb 1, 2025
60b686e
added tps
rifkybujana Feb 1, 2025
c1ba124
don't show empty thought
rifkybujana Feb 1, 2025
899a8c2
add automation to detect number of thread to use
rifkybujana Feb 1, 2025
67c2a3a
add fallback to failed model loading
rifkybujana Feb 1, 2025
c813e6b
Merge branch 'main' into dev
rifkybujana Feb 1, 2025
42fb04a
fix model loaded syncronization on start and code rendering block glitch
rifkybujana Feb 1, 2025
d73ab5e
remove text debugging
rifkybujana Feb 1, 2025
dbfb365
refactored history sidebar
rifkybujana Feb 5, 2025
65f45b2
refactored preset sidebar
rifkybujana Feb 5, 2025
5d53b90
fix preset selection
rifkybujana Feb 7, 2025
0ea6802
re-refactor chat history sidebar
rifkybujana Feb 7, 2025
c00e99f
refactor model manager
rifkybujana Feb 7, 2025
83c12cd
rename constant namespace
rifkybujana Feb 7, 2025
4a25059
refactor chat history render
rifkybujana Feb 7, 2025
c00d90a
refactor chat_section
rifkybujana Feb 7, 2025
b58f1db
refactor main code and fixed preset selection duplication bug
rifkybujana Feb 8, 2025
90ebc27
fixed kv cache deletion and renaming
rifkybujana Feb 8, 2025
090a986
moved tab manager to ui/tab_manager.hpp
rifkybujana Feb 8, 2025
36af3a1
added stop generation button
rifkybujana Feb 10, 2025
ea59aaa
refactor input field rendering
rifkybujana Feb 10, 2025
73d2e71
added regenerate button
rifkybujana Feb 10, 2025
141aaf6
added regenerate functionality
rifkybujana Feb 10, 2025
88f0b90
stop all jobs on exit
rifkybujana Feb 10, 2025
8a20091
track job ids within model manager
rifkybujana Feb 10, 2025
d564491
restyle loading bar
rifkybujana Feb 10, 2025
9a5bfa8
[workaround] fixed the delete model button didn't work
rifkybujana Feb 10, 2025
19d35c1
handle model loading asynchronously
rifkybujana Feb 11, 2025
d1b6d30
refactored progress bar widget
rifkybujana Feb 11, 2025
8d31c98
fixed can't find IndeterminedProgressBar error, and progress bar pos…
rifkybujana Feb 11, 2025
abeda36
add unload model functionality
rifkybujana Feb 12, 2025
c1d4967
fixed chat code block ui glitch
rifkybujana Feb 12, 2025
88f38f5
fixed bug model trying to regenerate even if no model loaded, and add…
rifkybujana Feb 12, 2025
7c9c368
added context shifting on the engine
rifkybujana Feb 13, 2025
67bcfc7
if max_new_token set to be 0, don't stop until eos (infinitely generate)
rifkybujana Feb 13, 2025
8df4d2c
update engine
rifkybujana Feb 13, 2025
626967e
update the kv cache loading for context shifting
rifkybujana Feb 13, 2025
ac70696
Merge branch 'main' into dev
rifkybujana Feb 13, 2025
c09aa85
fix delete chat doesn't have to pass model name and variant name
rifkybujana Feb 13, 2025
9b6f5f0
Merge branch 'dev' of https://github.com/genta-technology/kolosal int…
rifkybujana Feb 13, 2025
bdd81f3
fixed merge with main branch
rifkybujana Feb 13, 2025
9139b34
Merge branch 'main' into dev
rifkybujana Feb 13, 2025
5eb446d
refactor model generation callback
rifkybujana Mar 2, 2025
959fcd1
added kolosal server library
rifkybujana Mar 3, 2025
6456ce7
model server tab
rifkybujana Mar 5, 2025
c49bb59
added server logs, model selection, tab selection buttons, and loadin…
rifkybujana Mar 6, 2025
f975644
added server functionality
rifkybujana Mar 7, 2025
96ce0d4
added reload model buttons
rifkybujana Mar 7, 2025
0b6eb1c
update installer version
rifkybujana Mar 7, 2025
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 @@ -24,4 +24,6 @@ build/*
out/*

# debugging files
*.pdb
*.pdb

**/**/__pycache__/*
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@
[submodule "external/imspinner"]
path = external/imspinner
url = https://github.com/dalerank/imspinner
[submodule "kolosal-server"]
path = kolosal-server
url = https://github.com/genta-technology/kolosal-server
branch = dev
19 changes: 18 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ target_include_directories(kolosal_lib PUBLIC
${EXTERNAL_DIR}/imspinner
${CMAKE_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/assets
${CMAKE_SOURCE_DIR}/kolosal-server/include
${CURL_INCLUDE_DIR}
)

Expand Down Expand Up @@ -165,6 +166,9 @@ else()
)
endif()

# ==== Kolosal Server Shared Library ====
add_subdirectory(${CMAKE_SOURCE_DIR}/kolosal-server)

# ==== Main Executable ====
if (DEBUG)
add_executable(KolosalDesktop
Expand All @@ -178,7 +182,11 @@ else()
)
endif()

target_link_libraries(KolosalDesktop PRIVATE kolosal_lib)
# Link both the engine (kolosal_lib) and the Kolosal server shared library.
target_link_libraries(KolosalDesktop PRIVATE
kolosal_lib
kolosal_server
)

# ==== Post-Build Commands ====
# Copy fonts
Expand Down Expand Up @@ -219,6 +227,15 @@ add_custom_command(
"${EXTERNAL_DIR}/curl/bin" "$<TARGET_FILE_DIR:KolosalDesktop>"
)

# Copy Kolosal Server DLL
add_custom_command(
TARGET KolosalDesktop POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"$<TARGET_FILE:kolosal_server>"
"$<TARGET_FILE_DIR:KolosalDesktop>"
COMMENT "Copying Kolosal Server DLL to output directory"
)

# Copy Inference Engine DLLs
add_custom_command(
TARGET KolosalDesktop POST_BUILD
Expand Down
3 changes: 1 addition & 2 deletions CMakeSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
"cmakeCommandArgs": "-DDEBUG=ON",
"buildCommandArgs": "",
"ctestCommandArgs": "",
"inheritEnvironments": [ "msvc_x64_x64" ],
"variables": []
"inheritEnvironments": [ "msvc_x64_x64" ]
}
]
}
Binary file modified external/genta-personal/bin/InferenceEngineLib.dll
Binary file not shown.
Binary file modified external/genta-personal/bin/InferenceEngineLibVulkan.dll
Binary file not shown.
2 changes: 1 addition & 1 deletion external/genta-personal/include/inference.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class INFERENCE_API InferenceEngine : public IInferenceEngine
public:
explicit InferenceEngine();

bool loadModel(const char* engineDir, const int mainGpuId = -1);
bool loadModel(const char* engineDir, const LoadingParameters lParams, const int mainGpuId = -1);

bool unloadModel();

Expand Down
2 changes: 1 addition & 1 deletion external/genta-personal/include/inference_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class IInferenceEngine {
public:
virtual ~IInferenceEngine() = default;

virtual bool loadModel(const char* engineDir, const int mainGpuId = -1) = 0;
virtual bool loadModel(const char* engineDir, const LoadingParameters lParams, const int mainGpuId = -1) = 0;
virtual bool unloadModel() = 0;
virtual int submitCompletionsJob(const CompletionParameters& params) = 0;
virtual int submitChatCompletionsJob(const ChatCompletionParameters& params) = 0;
Expand Down
26 changes: 26 additions & 0 deletions external/genta-personal/include/job.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
#include <memory>
#include <exception>

#include "types.h"
#include "llama.h"
#include "common.h"
#include "sampling.h"

struct Job {
int jobId;
std::mutex mtx;
Expand All @@ -20,6 +25,27 @@ struct Job {
std::string errorMessage;
float tps = 0;
std::atomic<bool> cancelRequested{ false };
CompletionParameters params;

bool isDecodingPrompt = true;

int n_past;
int n_remain;
int i_prompt;
int n_prompt;
size_t n_matching_session_tokens;

std::vector<llama_token> session_tokens;
std::vector<llama_token> embd_inp;
std::string path_session;
struct common_sampler* smpl = nullptr;
int batch_pos = 0;

~Job() {
if (smpl) {
common_sampler_free(smpl);
}
}
};

#endif // JOB_H
12 changes: 12 additions & 0 deletions external/genta-personal/include/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,16 @@ struct CompletionResult
float tps;
};

struct LoadingParameters
{
int n_ctx = 4096;
int n_keep = 2048;
bool use_mlock = true;
bool use_mmap = false;
bool cont_batching = true;
bool warmup = false;
int n_parallel = 1;
int n_gpu_layers = 100;
};

#endif // TYPES_H
Binary file modified external/genta-personal/lib/InferenceEngineLib.lib
Binary file not shown.
Binary file modified external/genta-personal/lib/InferenceEngineLibVulkan.lib
Binary file not shown.
7 changes: 7 additions & 0 deletions include/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ namespace Config
constexpr float MAX_SIDEBAR_WIDTH = 400.0F;
} // namespace ModelSettings

namespace DeploymentSettingsSidebar
{
constexpr float SIDEBAR_WIDTH = 200.0F;
constexpr float MIN_SIDEBAR_WIDTH = 200.0F;
constexpr float MAX_SIDEBAR_WIDTH = 400.0F;
} // namespace DeploymentSettingsSidebar

namespace Color
{
constexpr ImVec4 TRANSPARENT_COL = ImVec4(0.0F, 0.0F, 0.0F, 0.0F);
Expand Down
113 changes: 113 additions & 0 deletions include/model/model_loader_config_manager.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
#ifndef MODEL_LOADER_CONFIG_MANAGER_HPP
#define MODEL_LOADER_CONFIG_MANAGER_HPP

#include "model_loader_config_persistence.hpp"

#include <string>
#include <json.hpp>
#include <types.h>
#include <iostream>

namespace Model
{
/**
* @brief Class for managing LLM model loading configuration
*/
class ModelLoaderConfigManager {
public:
/**
* @brief Get singleton instance of config manager
* @param configFilePath Path to the configuration file (optional on first call)
* @return Reference to the singleton instance
*/
static ModelLoaderConfigManager& getInstance(const std::string& configFilePath = "")
{
static ModelLoaderConfigManager instance(configFilePath.empty() ? "model_config.json" : configFilePath);

if (!configFilePath.empty() && configFilePath != instance.configFilePath_) {
// Log a warning that the config file path is being ignored after initialization
std::cerr << "Warning: Config file path '" << configFilePath
<< "' is ignored as the instance is already initialized with '"
<< instance.configFilePath_ << "'" << std::endl;
}

return instance;
}

// Delete copy constructor and assignment operator
ModelLoaderConfigManager(const ModelLoaderConfigManager&) = delete;
ModelLoaderConfigManager& operator=(const ModelLoaderConfigManager&) = delete;

/**
* @brief Get the current configuration
* @return Reference to the current configuration
*/
const LoadingParameters& getConfig() const {
return config_;
}

/**
* @brief Set a complete new configuration
* @param config The new configuration
*/
void setConfig(const LoadingParameters& config) {
config_ = config;
}

/**
* @brief Save current configuration to disk
* @return true if successful, false otherwise
*/
bool saveConfig() {
return persistence_.saveToFile(config_, configFilePath_);
}

/**
* @brief Load configuration from disk
* @return true if successful, false otherwise
*/
bool loadConfig() {
return persistence_.loadFromFile(configFilePath_, config_);
}

// Getters
int getContextSize() const { return config_.n_ctx; }
int getKeepSize() const { return config_.n_keep; }
bool getUseMlock() const { return config_.use_mlock; }
bool getUseMmap() const { return config_.use_mmap; }
bool getContinuousBatching() const { return config_.cont_batching; }
bool getWarmup() const { return config_.warmup; }
int getParallelCount() const { return config_.n_parallel; }
int getGpuLayers() const { return config_.n_gpu_layers; }

// Setters
void setContextSize(int size) { config_.n_ctx = size; }
void setKeepSize(int size) { config_.n_keep = size; }
void setUseMlock(bool use) { config_.use_mlock = use; }
void setUseMmap(bool use) { config_.use_mmap = use; }
void setContinuousBatching(bool enable) { config_.cont_batching = enable; }
void setWarmup(bool enable) { config_.warmup = enable; }
void setParallelCount(int count) { config_.n_parallel = count; }
void setGpuLayers(int layers) { config_.n_gpu_layers = layers; }

private:
explicit ModelLoaderConfigManager(const std::string& configFilePath)
: configFilePath_(configFilePath) {
// Try loading from file, if it fails, use default values
if (!loadConfig()) {
std::cout << "Using default configuration values" << std::endl;
}
}

LoadingParameters config_;
std::string configFilePath_;
ModelLoaderConfigPersistence persistence_;
};

inline void initializeModelLoaderConfigManager(const std::string& configFilePath = "") {
ModelLoaderConfigManager::getInstance(configFilePath);
}

} // namespace Model

#endif // MODEL_LOADER_CONFIG_MANAGER_HPP
95 changes: 95 additions & 0 deletions include/model/model_loader_config_persistence.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#ifndef MODEL_LOADER_CONFIG_PERSISTENCE_HPP
#define MODEL_LOADER_CONFIG_PERSISTENCE_HPP

#include <string>
#include <json.hpp>
#include <types.h>

namespace Model
{
class ModelLoaderConfigPersistence {
public:
/**
* @brief Save configuration to a JSON file
* @param config The model loader configuration
* @param filePath Path to save the configuration
* @return true if successful, false otherwise
*/
bool saveToFile(const LoadingParameters& config, const std::string& filePath) {
try {
nlohmann::json j = configToJson(config);

std::ofstream file(filePath);
if (!file.is_open()) {
std::cerr << "Error: Could not open file for writing: " << filePath << std::endl;
return false;
}

file << j.dump(4); // Pretty print with 4 spaces indentation
file.close();

return true;
}
catch (const std::exception& e) {
std::cerr << "Error saving configuration: " << e.what() << std::endl;
return false;
}
}

/**
* @brief Load configuration from a JSON file
* @param filePath Path to the configuration file
* @param config The configuration to populate
* @return true if successful, false otherwise
*/
bool loadFromFile(const std::string& filePath, LoadingParameters& config) {
try {
std::ifstream file(filePath);
if (!file.is_open()) {
std::cerr << "Error: Could not open file for reading: " << filePath << std::endl;
return false;
}

nlohmann::json j;
file >> j;
file.close();

jsonToConfig(j, config);
return true;
}
catch (const std::exception& e) {
std::cerr << "Error loading configuration: " << e.what() << std::endl;
return false;
}
}

private:
nlohmann::json configToJson(const LoadingParameters& config) {
nlohmann::json j;

j["n_ctx"] = config.n_ctx;
j["n_keep"] = config.n_keep;
j["use_mlock"] = config.use_mlock;
j["use_mmap"] = config.use_mmap;
j["cont_batching"] = config.cont_batching;
j["warmup"] = config.warmup;
j["n_parallel"] = config.n_parallel;
j["n_gpu_layers"] = config.n_gpu_layers;

return j;
}

void jsonToConfig(const nlohmann::json& json, LoadingParameters& config) {
if (json.contains("n_ctx")) config.n_ctx = json["n_ctx"];
if (json.contains("n_keep")) config.n_keep = json["n_keep"];
if (json.contains("use_mlock")) config.use_mlock = json["use_mlock"];
if (json.contains("use_mmap")) config.use_mmap = json["use_mmap"];
if (json.contains("cont_batching")) config.cont_batching = json["cont_batching"];
if (json.contains("warmup")) config.warmup = json["warmup"];
if (json.contains("n_parallel")) config.n_parallel = json["n_parallel"];
if (json.contains("n_gpu_layers")) config.n_gpu_layers = json["n_gpu_layers"];
}
};
} // namespace Model

#endif // MODEL_LOADER_CONFIG_PERSISTENCE_HPP
Loading
Loading