PowerInfer Documentation

repository·main·Indexed 27 days ago

https://github.com/tiiny-ai/powerinfer

A high-speed LLM inference engine for consumer-grade GPUs that utilizes a hybrid CPU/GPU execution model based on activation locality. It supports NVIDIA (CUDA), AMD (ROCm), and CPU-only builds. The engine uses a specialized PowerInfer GGUF format and supports GBNF grammars to constrain model outputs. Compatible with models using ReLU, ReGLU, or Squared ReLU activation functions.

Tokens
138.2K
Snippets
435
Records
826
Agent score
94%

What's inside PowerInfer

  1. Overview of LLaMA.cpp HTTP Server

    main

    The LLaMA.cpp HTTP Server is a fast, lightweight, pure C/C++ HTTP server built using httplib, nlohmann::json, and llama.cpp. It provides a set of LLM REST APIs and a simple web front end for interacting with llama.cpp models.

    Key Capabilities:

    • Inference: Supports F16 and quantized models on both GPU and CPU.
    • API Compatibility: Provides OpenAI API compatible routes for chat completions and embeddings.
    • Advanced Features: Supports parallel decoding (multi-user), continuous batching, speculative decoding, and schema-constrained JSON response formats.
    • Specialized Endpoints: Includes a Reranking endpoint and monitoring endpoints.
    • Model Capabilities: Supports Multimodal inputs, Function calling/tool use, and prefilling of assistant messages (similar to the Claude API).
  2. Overview of CLI11 features

    main

    CLI11 provides a wide range of command-line parsing capabilities including:

    • Positional arguments: Arguments identified by position rather than flags.
    • Flags: Boolean switches.
    • Subcommands: Nested App instances that support callback lambda functions.
    • Configuration files: Support for reading/producing .ini files.
    • Environment variables: Using environment variables as input for options.
    • Validators: Custom and built-in validators (e.g., CLI::ExistingFile).
    • Standard shell idioms: Support for -- to stop parsing options.
  3. Overview of the {fmt} library

    main
    The {fmt} library is a high-performance C++ formatting library designed to address the limitations of printf, iostreams, Boost Format, and FastFormat. It provides a fast, safe, and feature-rich alternative for string formatting, supporting positional arguments and user-defined types. It is used by major projects including PyTorch, MongoDB, ClickHouse, and Microsoft Windows Terminal.
  4. Overview of Googletest Mocking (gMock) Framework

    main

    gMock is a C++ framework for writing and using mock classes to improve system design and testing. It provides a declarative syntax for defining mocks and supports partial (hybrid) mocks, which combine real and mock objects.

    Key features include:

    • Support for functions of arbitrary types and overloaded functions.
    • A rich set of matchers for validating function arguments.
    • Intuitive syntax for controlling mock behavior.
    • Automatic verification of expectations.
    • Support for arbitrary (partial) ordering constraints on function calls.
    • Extensibility via custom matchers and actions.
    • Exception-free design.
  5. Overview of CLI11 main classes

    main

    CLI11 is a command-line parser for C++. The core functionality is built around several key classes:

    • CLI::App: Represents the main application or a subcommand.
    • CLI::Option: Represents individual options stored within an App.
    • CLI::Validator: Used to perform checks on option values, which can influence the type name.
    • CLI::Formatter: A subclassable component used for customizing help message printing.
    • CLI::ExitCode: A scoped enum providing standardized exit codes.
    • CLI::Timer: A timer class located in CLI/Timer.hpp (note: this is not included in the main CLI11.hpp header).
    • CLI::AutoTimer: A timer that automatically prints its duration upon destruction.
  6. Understand Multimodal Support in llama.cpp

    main

    Multimodal support in llama.cpp allows language models to process non-text inputs like images and audio. This is achieved by using a separate component called a multimodal projector (mmproj) to encode inputs into embeddings, which are then fed into the core language model.

    To run a multimodal model, you typically need two distinct GGUF files:

    1. The standard language model file.
    2. A corresponding mmproj file specific to the model architecture.

    Note: Multimodal support is under heavy development and is subject to breaking changes.

  7. GoogleTest Features

    main

    GoogleTest provides a comprehensive suite of testing capabilities:

    • Test Discovery: Automatically discovers and runs tests without manual registration.
    • Assertions: A rich set of built-in assertions (equality, inequality, exceptions, etc.) and support for user-defined assertions.
    • Death Tests: Verifies that code exits in a specific way (useful for error-handling tests).
    • Failure Modes: Supports both fatal and non-fatal failures to control test execution flow.
    • Parameterized Tests:
      • Value-parameterized tests: Run the same test multiple times with different input values.
      • Type-parameterized tests: Run tests with different data types.
    • Execution Options: Supports running individual tests, specifying execution order, and running tests in parallel.
  8. Understand GBNF (GGML BNF) Grammars

    main
    GBNF is a format used to constrain Large Language Model (LLM) outputs by defining formal grammars. It allows you to force models to follow specific structures, such as valid JSON, specific notation (like chess moves), or restricted character sets (like emojis). GBNF is an extension of Backus-Naur Form (BNF) that includes regex-like features.
  9. CLI11 Overview and Features

    main

    CLI11 is a powerful, header-only command line parser for C++11 and later. It is designed to be easy to include with no external dependencies and provides a minimal syntax.

    Key Features:

    • Zero Dependencies: Header-only, single-file form available.
    • Compatibility: Works with GCC 4.8+, Clang 3.4+, AppleClang 7+, NVCC 7.0+, or MSVC 2015+ on Linux, macOS, and Windows.
    • Advanced Parsing: Supports subcommands (including nested subcommands), option groups, and optional fallthrough.
    • Configuration Files: Supports adding and producing configuration files in TOML, INI, or custom formats.
    • Type Support: Works with common types, simple custom types, and is extensible to exotic types.
    • Standard Idioms: Naturally supports grouping flags and positional separators.

    Intentional Limitations:

    • Does not support completion of partial options (to avoid guessing).
    • Autocomplete is not currently supported.
    • Non-standard option names (like -option) are supported only if explicitly enabled via the allow_non_standard_option_names() modifier.
  10. Understand gMock concepts and terminology

    main

    gMock is a C++ library for creating mock objects to test interactions between modules. It is important to distinguish between Fakes and Mocks:

    • Fake objects: Have working implementations but use shortcuts (e.g., an in-memory file system) to make operations less expensive. They are not suitable for production.
    • Mocks: Are objects pre-programmed with expectations. They form a specification of the calls they are expected to receive (which methods, in what order, how many times, with what arguments, and what they return).

    Use gMock to:

    • Experiment with interface designs early.
    • Remove slow or unreliable outbound dependencies (databases, networks).
    • Test how code handles specific failures (e.g., checksum errors).
    • Observe interactions between modules rather than just side effects.