Kolosal AI Documentation

repository·main·Indexed 19 days ago

https://github.com/kolosalai/kolosal

A lightweight, open-source desktop application for local LLM training and inference, optimized for edge devices and privacy-focused on-premise deployment. The repository includes documentation for integrated external libraries such as GLFW for window and input management, Dear ImGui for immediate mode graphical user interfaces, and imgui_md for rendering Markdown within ImGui.

Tokens
56.4K
Snippets
161
Records
248
Agent score
66%

What's inside Kolosal AI

  1. Overview of Kolosal AI

    main

    Kolosal AI is an open-source desktop application designed for simplified training and inference of large language models (LLMs) on local devices. It is optimized for edge computing and on-premise solutions, maintaining privacy and reducing cloud costs.

    Key Capabilities:

    • Hardware Support: Works with AVX2-enabled CPUs, and AMD or NVIDIA GPUs.
    • Model Compatibility: Supports popular models like Mistral, LLaMA, and Qwen.
    • Engine: Powered by the Genta Personal Engine (built on llama.cpp).
    • Lightweight: The compiled application is approximately 20 MB, making it suitable for low-power devices like Raspberry Pi.
  2. What is Dear ImGui?

    main

    Dear ImGui is a bloat-free, fast, and portable graphical user interface library for C++. It is designed specifically for programmers to create content creation tools, visualization tools, and debug tools rather than consumer-facing UIs.

    Key characteristics:

    • Renderer Agnostic: It outputs optimized vertex buffers and command lists that you can render in your own 3D pipeline.
    • Self-Contained: No external dependencies; you can simply compile the core .cpp and .h files from the root folder into your project.
    • Immediate Mode: It minimizes state synchronization and UI-related state storage on the user side.
    • Targeted Use Cases: Ideal for game engines, real-time 3D applications, embedded systems, and console platforms.
  3. Overview of GLFW window-related functions

    main

    This guide serves as an entry point for managing windows in GLFW. It covers window objects, creation, destruction, and creation hints. For specific function details, refer to the core window documentation.

    Related guides for other GLFW subsystems include:

    • Introduction guide
    • Context guide
    • Vulkan guide
    • Monitor guide
    • Input guide
  4. Overview of GLFW

    main

    GLFW is an open-source, multi-platform library designed for developing applications using OpenGL, OpenGL ES, and Vulkan. It provides a platform-independent API for managing windows, creating contexts and surfaces, reading input, and handling events.

    Supported Platforms:

    • Windows
    • macOS
    • Linux/Unix-like systems (supports both Wayland and X11 on Linux)

    License:

  5. Overview of GLFW capabilities

    main

    GLFW is a free, open-source, multi-platform library designed for developing applications using OpenGL, OpenGL ES, and Vulkan. It provides a platform-independent API for several core graphics application tasks, including:

    • Creating windows, contexts, and surfaces.
    • Reading user input.
    • Handling system events.
    • Managing monitors and video modes.
  6. Supported Markdown features in imgui_md

    main

    The following Markdown syntax is supported:

    • Text Formatting: Wrapped text, Emphasis (bold/italic), Underline, Strikethrough, Backslash Escapes.
    • Structure: Headers, Ordered and unordered lists (including sub-lists), Horizontal rules.
    • Media & Links: Links, Images.
    • Complex Elements: Tables (Note: Column width is defined by header, cells are always left-aligned).
    • HTML Elements: <br>, <hr>, <u>, <div>, &nbsp;.
  7. How the ID Stack system works in Dear ImGui

    main

    Dear ImGui uses a unique ID system to track active widgets and associate state (like whether a window is open or a tree node is expanded). IDs are implicitly built by hashing the "path" to the UI element, which typically includes the parent window's ID, any parent containers (like TreeNode), and the widget's own label.

    Common Pitfalls:

    • ID Collisions: If two interactive widgets in the same scope have the same label, they will share the same ID. Interacting with one will trigger the other.
    • Empty Labels: Using an empty label "" is treated as having the same ID as the parent widget, which causes collisions.

    Solutions:

    1. Inline ID modification: Use ## to append a unique string to a label. The part after ## is used for the ID but is not visible to the user.
    2. Label hiding: Use ## at the start of a string (e.g., "##MyID") to create a widget with no visible label but a unique ID.
    3. Stable IDs with ###: Use ### to provide a label that changes (e.g., for animation) while keeping the ID constant. Everything after ### is used for the ID and ignored for the visible label.
    4. PushID() / PopID(): The most robust way to handle loops or programmatic UI. You can push integers, strings, or pointers onto the stack to create unique scopes.
    // Solution 1: Inline ID modification
    ImGui::Begin("Correct!");
    ImGui::DragFloat2("My value##2", &objects[1]->pos.x);
    ImGui::DragFloat2("My value##3", &objects[2]->pos.x);
    ImGui::End();
    
    // Solution 2: Using PushID/PopID for loops
    ImGui::Begin("Also Correct!");
    for (int n = 0; n < 3; n++)
    {
        ImGui::PushID(n);
        ImGui::DragFloat2("My value", &objects[n]->pos.x);
        ImGui::PopID();
    }
    ImGui::End();
    
    // Solution 3: Changing label while preserving ID
    // The label changes every frame, but the ID remains "MyGame"
    sprintf(buf, "My game (%f FPS)###MyGame", fps);
    ImGui::Begin(buf);
  8. Handle window closing and input events

    main

    Checking the close flag

    Monitor glfwWindowShouldClose(window) in your main loop to determine when the user has requested to close the window (e.g., via Alt+F4 or the close button).

    Receiving input

    Set callbacks to handle specific events like key presses. For example, use glfwSetKeyCallback to handle keyboard input. To make these callbacks trigger, you must regularly call an event processing function like glfwPollEvents().

    // Key callback example
    static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
    {
        if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
            glfwSetWindowShouldClose(window, GLFW_TRUE);
    }
    
    // In your setup
    glfwSetKeyCallback(window, key_callback);
    
    // In your main loop
    while (!glfwWindowShouldClose(window))
    {
        // ... rendering ...
        glfwPollEvents();
    }
  9. How the Platform Interface manages platform-specific state

    main

    The Platform Interface provides the implementation for platform-specific operations. It uses two primary mechanisms to manage state and selection:

    1. Runtime Selection: Window system operations (creation, input, monitors, Vulkan surfaces) are accessed through the _GLFWplatform struct of function pointers located in the global _glfw struct.

      • Example: _glfw.platform.createWindow
    2. Platform-Specific Structs: Platform-specific global and per-object state is stored in structs that mirror internal interface names with an interface-specific suffix. These are incorporated into internal structs using macros to prevent accidental access from shared code.

      • Examples: _GLFWwindowX11, _GLFWcontextWGL
      • Access pattern: window->win32.handle or _glfw.x11.display.

    Note: Timer, threading, and module loading bits use plain functions with a _glfwPlatform prefix, as they are considered independent of the window system.

  10. Copyright and License Agreement

    main

    By submitting code to the Dear ImGui repository, you agree to the following:

    • Your code will be distributed under the Dear ImGui license.
    • You grant the project maintainer all transferable rights to the code, including re-licensing, modifying, and distributing in source or binary forms.
    • You assign copyright to the project maintainer.
    • Important: Do not modify any existing copyright statements in files within your Pull Requests.
  11. When to use GitHub Issues vs Discussions

    main

    The project distinguishes between technical support/discussion and bug reporting/feature requests:

    Use GitHub Discussions if:

    • You cannot BUILD or LINK examples.
    • You cannot BUILD, LINK, or RUN Dear ImGui in your application or custom engine.
    • You cannot LOAD a font.

    Use GitHub Issues if:

    • Dear ImGui is successfully showing in your application and you have used it before.
    • You are submitting a bug report, feature request, or suggestion.
    • You are asking for technical advice or help with specific implementation details.