1. 30 Apr, 2025 1 commit
    • Daniel Hiltgen's avatar
      Fix "Stopping..." scheduler hang (#10487) · 415c8fcc
      Daniel Hiltgen authored
      * Adjust initial scheduler refCount
      
      Ensure we only set the refCount on success
      
      * sched: fix lock order inversion deadlock
      
      Under certain race conditions, there was a scenario where the scheduler would
      get into a deadlock while trying to update free space information while a model
      was trying to unload.
      415c8fcc
  2. 29 Apr, 2025 1 commit
    • Devon Rifkin's avatar
      lower default num parallel to 2 · fe5b9bb2
      Devon Rifkin authored
      this is in part to "pay" for #10452, which doubled the default context length. The combination isn't fully neutral though, because even though the old 4x2k limit and the new 2x4k limit are memory equivalent, the 1x fallback is larger with 4k
      fe5b9bb2
  3. 28 Apr, 2025 1 commit
  4. 22 Apr, 2025 1 commit
    • Devon Rifkin's avatar
      increase default context length to 4096 (#10364) · 424f6486
      Devon Rifkin authored
      * increase default context length to 4096
      
      We lower the default numParallel from 4 to 2 and use these "savings" to
      double the default context length from 2048 to 4096.
      
      We're memory neutral in cases when we previously would've used
      numParallel == 4, but we add the following mitigation to handle some
      cases where we would have previously fallen back to 1x2048 due to low
      VRAM: we decide between 2048 and 4096 using a runtime check, choosing
      2048 if we're on a one GPU system with total VRAM of <= 4 GB. We
      purposefully don't check the available VRAM because we don't want the
      context window size to change unexpectedly based on the available VRAM.
      
      We plan on making the default even larger, but this is a relatively
      low-risk change we can make to quickly double it.
      
      * fix tests
      
      add an explicit context length so they don't get truncated. The code
      that converts -1 from being a signal for doing a runtime check isn't
      running as part of these tests.
      
      * tweak small gpu message
      
      * clarify context length default
      
      also make it actually show up in `ollama serve --help`
      424f6486
  5. 09 Apr, 2025 1 commit
  6. 02 Apr, 2025 1 commit
  7. 01 Apr, 2025 1 commit
  8. 26 Mar, 2025 1 commit
    • Jesse Gross's avatar
      ggml: Support heterogeneous KV cache layer sizes in memory estimation · f66216e3
      Jesse Gross authored
      Gemma3 uses sliding windows for its context on 5/6 layers, significantly
      reducing memory usage but leading to uneven usage across layers,
      which makes allocation to the correct GPU difficult. We currently
      estimate very conservatively by assuming all layers are consistent
      at the max size.
      
      Llama3.2-vision is also inconsistent between self attention and cross
      attention layers - at moment, we calculate the correct total size
      and then average this across layers. In some cases, this may lead
      to crashes if a large layer is placed on a GPU sized by the average.
      
      This allows memory estimation to calculate per-layer KV cache size
      and take this account when placing layers onto GPUs. We already do
      this for weights that vary per-tensor, so this is a logical extension.
      
      Fixes #9730
      Fixes #9890
      f66216e3
  9. 20 Feb, 2025 1 commit
  10. 14 Feb, 2025 1 commit
    • Michael Yang's avatar
      next ollama runner (#7913) · 58245413
      Michael Yang authored
      
      
      feat: add new Ollama engine using ggml through cgo
      
      This change introduces a new way to run pretrained models. It introduces 3 high level interfaces and a bunch of smaller helper interfaces to facilitate this.
      
      - `model.Model` defines the interface for a model architecture. Models such as `llama` and `mllama`, which are provided as examples, can implement the model's forward propagation in the `Forward` method. This method will be called to generate completions. This interface can be found in `model/model.go`
      - `ml.Backend` defines the interface for a backend tensor library, in this case `ggml`. Among other things, a Backend is responsible for loading a pretrained model into hardware (GPU, CPU, etc) and providing an interface for Models to access loaded tensors. This interface can be found in `ml/backend.go`
      - `ml.Tensor` defines the interface for a tensor and tensor operations
      
      This is the first implementation of the new engine. Follow up PRs will implement more features:
      
      - non-greedy sampling (#8410)
      - integration with Ollama and KV caching (#8301)
      - more model support (#9080) with more coming soon
      Co-authored-by: default avatarBruce MacDonald <brucewmacdonald@gmail.com>
      58245413
  11. 10 Dec, 2024 1 commit
  12. 06 Nov, 2024 1 commit
    • Jesse Gross's avatar
      sched: Lift parallel restriction for multimodal models except mllama · 6cd56687
      Jesse Gross authored
      The Go runner does not have a problem with supporting parallel
      requests for most multimodal models. Now that we won't be potentially
      falling back to server.cpp, this restriction can be lifted.
      
      However, the new mllama model can't support parallel requests, so we
      will need to keep a restriction for that.
      6cd56687
  13. 17 Oct, 2024 1 commit
  14. 11 Sep, 2024 1 commit
  15. 22 Aug, 2024 1 commit
    • Daniel Hiltgen's avatar
      Fix embeddings memory corruption (#6467) · 90ca8417
      Daniel Hiltgen authored
      * Fix embeddings memory corruption
      
      The patch was leading to a buffer overrun corruption.  Once removed though, parallism
      in server.cpp lead to hitting an assert due to slot/seq IDs being >= token count.  To
      work around this, only use slot 0 for embeddings.
      
      * Fix embed integration test assumption
      
      The token eval count has changed with recent llama.cpp bumps (0.3.5+)
      90ca8417
  16. 18 Aug, 2024 2 commits
  17. 17 Aug, 2024 1 commit
  18. 13 Aug, 2024 1 commit
    • Michael Yang's avatar
      lint · 2697d7f5
      Michael Yang authored
      - fixes printf: non-constant format string in call to fmt.Printf
      - fixes SA1032: arguments have the wrong order
      - disables testifylint
      2697d7f5
  19. 02 Aug, 2024 1 commit
  20. 30 Jul, 2024 1 commit
    • Daniel Hiltgen's avatar
      Prevent partial loading on mixed GPU brands · 34542099
      Daniel Hiltgen authored
      In mult-brand GPU setups, if we couldn't fully load the model we
      would fall through the scheduler and mistakenly try to load across
      a mix of brands.  This makes sure we find the set of GPU(s) that
      best fit for the partial load.
      34542099
  21. 22 Jul, 2024 4 commits
  22. 11 Jul, 2024 1 commit
  23. 09 Jul, 2024 1 commit
  24. 07 Jul, 2024 1 commit
  25. 03 Jul, 2024 2 commits
    • Daniel Hiltgen's avatar
      Only set default keep_alive on initial model load · 955f2a4e
      Daniel Hiltgen authored
      This change fixes the handling of keep_alive so that if client
      request omits the setting, we only set this on initial load.  Once
      the model is loaded, if new requests leave this unset, we'll keep
      whatever keep_alive was there.
      955f2a4e
    • Daniel Hiltgen's avatar
      Prevent loading models larger than total memory · 3c75113e
      Daniel Hiltgen authored
      Users may not realize the siny new model they're trying to load
      fits on their disk, but can't load into system+GPU memory.  Today
      we crash, but with this fix, we'll give them a better error message
      before even trying to load it.
      3c75113e
  26. 01 Jul, 2024 1 commit
  27. 25 Jun, 2024 1 commit
    • Blake Mizerany's avatar
      llm: speed up gguf decoding by a lot (#5246) · cb42e607
      Blake Mizerany authored
      Previously, some costly things were causing the loading of GGUF files
      and their metadata and tensor information to be VERY slow:
      
        * Too many allocations when decoding strings
        * Hitting disk for each read of each key and value, resulting in a
          not-okay amount of syscalls/disk I/O.
      
      The show API is now down to 33ms from 800ms+ for llama3 on a macbook pro
      m3.
      
      This commit also prevents collecting large arrays of values when
      decoding GGUFs (if desired). When such keys are encountered, their
      values are null, and are encoded as such in JSON.
      
      Also, this fixes a broken test that was not encoding valid GGUF.
      cb42e607
  28. 21 Jun, 2024 2 commits
    • Daniel Hiltgen's avatar
      Disable concurrency for AMD + Windows · 9929751c
      Daniel Hiltgen authored
      Until ROCm v6.2 ships, we wont be able to get accurate free memory
      reporting on windows, which makes automatic concurrency too risky.
      Users can still opt-in but will need to pay attention to model sizes otherwise they may thrash/page VRAM or cause OOM crashes.
      All other platforms and GPUs have accurate VRAM reporting wired
      up now, so we can turn on concurrency by default.
      9929751c
    • Daniel Hiltgen's avatar
      Enable concurrency by default · 17b7186c
      Daniel Hiltgen authored
      This adjusts our default settings to enable multiple models and parallel
      requests to a single model.  Users can still override these by the same
      env var settings as before.  Parallel has a direct impact on
      num_ctx, which in turn can have a significant impact on small VRAM GPUs
      so this change also refines the algorithm so that when parallel is not
      explicitly set by the user, we try to find a reasonable default that fits
      the model on their GPU(s).  As before, multiple models will only load
      concurrently if they fully fit in VRAM.
      17b7186c
  29. 14 Jun, 2024 6 commits