Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: sqliteai/sqlite-ai
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1.0.4
Choose a base ref
...
head repository: sqliteai/sqlite-ai
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 1.0.5
Choose a head ref
  • 5 commits
  • 6 files changed
  • 5 contributors

Commits on May 11, 2026

  1. Update README.md

    marcobambini authored May 11, 2026
    Configuration menu
    Copy the full SHA
    b18e70e View commit details
    Browse the repository at this point in the history

Commits on Aug 21, 2026

  1. ci: fix the Vulkan build, and make the test suite deterministic (#27)

    Four independent problems, none caused by the code under test in the run that
    surfaced them.
    
    1. linux-gpu-x86_64 could not build. The LunarG tarball keeps the loader in
       $VULKAN_SDK/lib/VulkanLoader/lib, and two places assumed it sat directly
       under lib/: CMake's FindVulkan, and Makefile:199's -L$(VULKAN_SDK)/lib.
       The install step now locates libvulkan.so wherever the tarball puts it and
       exports the directory as CMAKE_LIBRARY_PATH and LIBRARY_PATH. A future
       layout change fails in that step with a listing, not 300 lines into a
       CMake trace. The SDK version is pinned for reproducibility, not as the fix
       - 1.4.350.1 has the same layout as 1.4.357.1.
    
    2. A single failing test reported 37 failures, because
       assert_sqlite_memory_clean() asserted a PROCESS-GLOBAL counter was back to
       zero: one test bailing without a clean teardown failed every test after it.
       It now compares against a baseline captured per test, and the summary names
       the first failure. Injecting one unclosed connection: 32 failures before,
       1 after.
    
    3. The 15 chat tests never created a sampler, so they inherited
       llm_chat_check_context()'s default chain, which uses LLAMA_DEFAULT_SEED -
       a random seed. Reply length varied 32-238 characters run to run, and a bad
       draw ran the context out and failed the decode. install_seeded_chat_sampler()
       installs the same chain with a fixed seed, after llm_model_load() so it
       survives #26's ownership change. chat_default_sampler_autocreate covers the
       default-creation path the seeding displaces, without generating a token.
    
    4. src/sqlite-ai.c:2736 infers "context_size was not set" by comparing against
       llama_context_default_params().n_ctx, which is 512 - so every test asking
       for 512 silently ran with the model's full 32768-token window. The tests now
       ask for 1024. That is what made the arm64 jobs take 19 minutes; they now
       take 2. The sentinel collision itself is filed in #28.
    
    Also unpacks llama_decode()'s return code at every call site. It distinguishes
    no-KV-slot (1), aborted (2), invalid batch (-1) and fatal (< -1), and we were
    discarding it - which is what identified 3 as a full context rather than
    resource exhaustion.
    
    Tests now use sqlite3_close_v2(), which cannot silently leave a connection -
    and the extension's whole ai_context - alive on SQLITE_BUSY.
    
    Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
    Claude-Session: https://claude.ai/code/session_012KRojTrn4Q4SaZQpqcwpAt
    andinux and claude authored Aug 21, 2026
    Configuration menu
    Copy the full SHA
    ab89ebe View commit details
    Browse the repository at this point in the history
  2. fix(sampler): allow llm_text_generate() to be called more than once

    llm_text_generate() could not be called a second time on a connection.
    With no sampler configured the second call segfaulted; with a grammar
    sampler it silently returned ''. This made the most natural use of the
    extension - inference over a set of rows - crash the process:
    
        SELECT llm_text_generate(prompt, 'n_predict=60') FROM prompts;
    
    Two separate defects:
    
    1. llm_sampler_check() always publishes the chain it creates into
       ai->sampler, and llm_text_run()'s success path freed that chain
       without nulling the field. The next call read ai->sampler != NULL as
       "the user configured a sampler", skipped the rebuild and passed freed
       memory to llama_sampler_sample(). The error path did null it, so only
       the success path was affected. llm_text_run_vision() was identical.
       It also corrupted the chat path: a llm_text_generate() followed by
       llm_chat_respond() left llm_chat_check_context() using the freed chain.
    
    2. llama_sampler_reset() was never called. The KV cache is cleared at the
       top of every generation but the sampler was not, so a grammar sampler
       stayed in its terminal accept state and sampled EOG immediately on
       every later call.
    
    The implicit default chain is now ephemeral: built locally, never stored
    in ai->sampler, freed on every exit path. That makes "ai->sampler is NULL
    or a live user-owned chain" an invariant rather than four assignments
    that each had to be remembered, and lets the error_sampler: label - which
    existed only to undo the published chain - go away in both functions.
    Sampler state is reset alongside the KV cache before each generation.
    
    With that invariant, ai_free() can free the chain again; the comment
    claiming this caused a double free was describing the dangling pointer
    above. It is freed before the ctx and model because grammar, infill and
    mirostat samplers cache a const llama_vocab * borrowed from the model.
    
    Behaviour change: llm_model_free() and llm_model_load() now destroy a
    user-configured sampler. That is correct - a grammar sampler bound to the
    old vocab must not survive a model swap.
    
    Also guards the empty-chain case: llm_sampler_create() followed by
    llm_text_generate() used to abort() the process, since a chain with no
    selector trips a GGML_ASSERT inside llama_sampler_sample(). An empty user
    chain now falls back to the defaults.
    
    The chat path is deliberately untouched: a chat is one growing sequence,
    keeps its KV cache across turns and correctly never frees the chain.
    
    Adds two regression tests, both verified to fail against the pre-fix
    build (exit 139, and "call 2 expected 'yes', got ''") and pass after.
    
    Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
    Claude-Session: https://claude.ai/code/session_012KRojTrn4Q4SaZQpqcwpAt
    andinux and claude committed Aug 21, 2026
    Configuration menu
    Copy the full SHA
    61c6103 View commit details
    Browse the repository at this point in the history

Commits on Aug 22, 2026

  1. Merge pull request #26 from sqliteai/fix/sampler-reuse-across-generat…

    …ions
    
    fix(sampler): allow llm_text_generate() to be called more than once
    marcobambini authored Aug 22, 2026
    Configuration menu
    Copy the full SHA
    aa98c5e View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    918e8d0 View commit details
    Browse the repository at this point in the history
Loading