Skip to content
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
8092edd
QVAC-23752 feat[bc]: remove sliding-context support from the llm-addon
yingying0906 Aug 24, 2026
d0bdab7
QVAC-23752 feat[bc]: address review on the sliding-context removal
yingying0906 Aug 24, 2026
bb2d1e1
QVAC-23752 feat[bc]: verify the KV shift against memory, pin the outc…
yingying0906 Aug 24, 2026
6ba8395
QVAC-23752 fix: wipe instead of claiming KV intact when the shift did…
yingying0906 Aug 24, 2026
9a07544
Merge branch 'main' into feat/QVAC-23752-remove-sliding-context
gianni-cor Aug 24, 2026
6808776
QVAC-23752 feat[bc]: replay the answer instead of shifting the context
yingying0906 Aug 25, 2026
3a67dfc
QVAC-23752 fix: count generated tokens where they are produced
yingying0906 Aug 25, 2026
4682f3c
QVAC-23752 feat: replay a multi-token reasoning close marker
yingying0906 Aug 25, 2026
d4e7115
QVAC-23752 doc: drop comments describing the removed shift path
yingying0906 Aug 25, 2026
f9be66c
QVAC-23752 fix: close the gaps a review pass found in the replay path
yingying0906 Aug 25, 2026
1b9bc92
QVAC-23752 fix: do not replay the opener of an unfinished reasoning span
yingying0906 Aug 25, 2026
ee38b9c
QVAC-23752 fix: unlock around finalize, count batch tokens at the com…
yingying0906 Aug 25, 2026
4e2142c
QVAC-23752 fix: anchor compaction before the reasoning span
yingying0906 Aug 26, 2026
64710b0
QVAC-23752 fix[bc]: reject unknown generationParams keys instead of d…
yingying0906 Aug 26, 2026
f548e69
QVAC-23752 fix: anchor the reasoning boundary on the batch prefill path
yingying0906 Aug 26, 2026
d201da0
QVAC-23752 doc: correct the contracts the sliding removal retired
yingying0906 Aug 26, 2026
c8dc9fd
QVAC-23752 doc: correct comments the shift removal left stale
yingying0906 Aug 26, 2026
0db08f4
QVAC-23752 fix: stamp batch TTFT from the token the caller sees
yingying0906 Aug 26, 2026
79127fd
QVAC-23752 doc: name the reasoning boundary for what it is
yingying0906 Aug 26, 2026
68f3187
QVAC-23752 fix: anchor the multimodal reasoning boundary before the o…
yingying0906 Aug 26, 2026
7e146e0
QVAC-23752 test: keep session caches out of the source checkout
yingying0906 Aug 26, 2026
f14a49f
QVAC-23752 doc: retire the last comments describing the shift design
yingying0906 Aug 26, 2026
64387a4
QVAC-23752 doc: drop the last recurrent-only and sliding wording
yingying0906 Aug 26, 2026
ec04b1f
QVAC-23752 refactor: drop the boundary policy's dead inputs
yingying0906 Aug 26, 2026
13427a7
Merge branch 'main' into feat/QVAC-23752-remove-sliding-context
yingying0906 Aug 26, 2026
45f94c8
Merge branch 'main' into feat/QVAC-23752-remove-sliding-context
gianni-cor Aug 26, 2026
1cefa7e
QVAC-23752 fix: replay the close marker instead of splitting the prefill
yingying0906 Aug 27, 2026
f0cdb21
QVAC-23752 refactor: remove the dead prefill-boundary pause plumbing
yingying0906 Aug 28, 2026
bb579d5
Merge branch 'main' into feat/QVAC-23752-remove-sliding-context
yingying0906 Aug 28, 2026
014651f
QVAC-23752 chore: clang-format the advance signature
yingying0906 Aug 28, 2026
a093f02
QVAC-23752 doc: describe the close-marker replay in the mtmd test com…
yingying0906 Aug 28, 2026
c6cef11
QVAC-23752 fix: seed the close marker on the mtmd EOS substitution
yingying0906 Aug 28, 2026
9754bab
QVAC-23752 fix: count the prediction-limit sample on the batch path
yingying0906 Aug 28, 2026
6268f5a
Merge branch 'main' into feat/QVAC-23752-remove-sliding-context
yingying0906 Aug 31, 2026
99bba44
Merge branch 'main' into feat/QVAC-23752-remove-sliding-context
gianni-cor Aug 31, 2026
d3071e0
Merge branch 'main' into feat/QVAC-23752-remove-sliding-context
yingying0906 Aug 31, 2026
3efbd4e
Merge branch 'main' into feat/QVAC-23752-remove-sliding-context
yingying0906 Aug 31, 2026
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
1 change: 0 additions & 1 deletion docs/website/content/docs/addons/llm-llamacpp/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ const config = {
| frequency_penalty | float | 0 | Frequency penalty for sampling |
| tools | `"true"` or `"false"` | `"false"` | Enable tool calling with jinja templating |
| verbosity | 0 – 3 (0=ERROR, 1=WARNING, 2=INFO, 3=DEBUG) | 0 | Logging verbosity level |
| n_discarded | integer | 0 | Tokens to discard in sliding window context |
| main-gpu | integer, `"integrated"`, or `"dedicated"` | — | GPU selection for multi-GPU systems |


Expand Down
4 changes: 0 additions & 4 deletions packages/llm-llamacpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ endif()
${PROJECT_SOURCE_DIR}/addon/src/handlers/LoadConfigHandlers.cpp
${PROJECT_SOURCE_DIR}/addon/src/model-interface/AsyncWeightsLoader.cpp
${PROJECT_SOURCE_DIR}/addon/src/model-interface/CacheManager.cpp
${PROJECT_SOURCE_DIR}/addon/src/model-interface/ContextSlider.cpp
${PROJECT_SOURCE_DIR}/addon/src/model-interface/ContinuousBatchScheduler.cpp
${PROJECT_SOURCE_DIR}/addon/src/model-interface/GenerationParamsApply.cpp
${PROJECT_SOURCE_DIR}/addon/src/model-interface/LlamaLazyInitializeBackend.cpp
Expand All @@ -93,7 +92,6 @@ endif()
${PROJECT_SOURCE_DIR}/addon/src/model-interface/MtmdLlmContext.cpp
${PROJECT_SOURCE_DIR}/addon/src/model-interface/MultiRequestBatcher.cpp
${PROJECT_SOURCE_DIR}/addon/src/model-interface/TextLlmContext.cpp
${PROJECT_SOURCE_DIR}/addon/src/model-interface/ContextShifter.cpp
${PROJECT_SOURCE_DIR}/addon/src/model-interface/ReasoningBlockCompactor.cpp
${PROJECT_SOURCE_DIR}/addon/src/model-interface/ModelMetadata.cpp
${PROJECT_SOURCE_DIR}/addon/src/utils/LoggingMacros.cpp
Expand Down Expand Up @@ -141,7 +139,6 @@ if(BUILD_CLI)
${PROJECT_SOURCE_DIR}/addon/src/handlers/LoadConfigHandlers.cpp
${PROJECT_SOURCE_DIR}/addon/src/model-interface/AsyncWeightsLoader.cpp
${PROJECT_SOURCE_DIR}/addon/src/model-interface/CacheManager.cpp
${PROJECT_SOURCE_DIR}/addon/src/model-interface/ContextSlider.cpp
${PROJECT_SOURCE_DIR}/addon/src/model-interface/ContinuousBatchScheduler.cpp
${PROJECT_SOURCE_DIR}/addon/src/model-interface/GenerationParamsApply.cpp
${PROJECT_SOURCE_DIR}/addon/src/model-interface/LlamaLazyInitializeBackend.cpp
Expand All @@ -153,7 +150,6 @@ if(BUILD_CLI)
${PROJECT_SOURCE_DIR}/addon/src/model-interface/MtmdLlmContext.cpp
${PROJECT_SOURCE_DIR}/addon/src/model-interface/MultiRequestBatcher.cpp
${PROJECT_SOURCE_DIR}/addon/src/model-interface/TextLlmContext.cpp
${PROJECT_SOURCE_DIR}/addon/src/model-interface/ContextShifter.cpp
${PROJECT_SOURCE_DIR}/addon/src/model-interface/ReasoningBlockCompactor.cpp
${PROJECT_SOURCE_DIR}/addon/src/model-interface/ModelMetadata.cpp
${PROJECT_SOURCE_DIR}/addon/src/utils/LoggingMacros.cpp
Expand Down
3 changes: 1 addition & 2 deletions packages/llm-llamacpp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ const config = {
| frequency_penalty | float | 0 | Frequency penalty for sampling |
| tools | `"true"` or `"false"` | `"false"` | Enable tool calling with jinja templating |
| verbosity | 0 – 3 (0=ERROR, 1=WARNING, 2=INFO, 3=DEBUG) | 0 | Logging verbosity level |
| n_discarded | integer | 0 | Tokens to discard in sliding window context. In batch mode the sliding window is the per-sequence slot (`n_ctx / n_parallel`), so `n_discarded` is clamped to that per-slot window, not the full context; a value `>=` the slot cap is clamped and logs a warning |
| main-gpu | integer, `"integrated"`, or `"dedicated"` | — | GPU selection for multi-GPU systems |
| split-mode | `"none"`, `"layer"`, or `"row"` | `"none"` | How to split the model across GPUs ([details](./docs/multi-gpu.md)) |
| tensor-split | comma-separated proportions (e.g. `"1,1"`) | — | GPU split ratios for layer/row parallelism ([details](./docs/multi-gpu.md)) |
Expand All @@ -190,7 +189,7 @@ const config = {
The addon picks a safe KV-cache type when `cache-type-k`/`cache-type-v` are unset, and validates any explicit choice per backend:

- **Auto-default:** on a **Metal / Vulkan GPU** (with flash attention on) both K and V default to **`q8_0`** — quality-neutral vs `f16` and ~47% smaller KV cache. **CPU** and **OpenCL (Adreno)** keep **`f16`** (ARM CPU `q8_0` has a quality/throughput cost; quantized KV is unsafe on OpenCL — see below). Finetuning manages its own KV types and is left untouched.
- **OpenCL (Adreno) accepts only `f16`/`f32`/`bf16`:** any other cache type — quantized (`q8_0`, `q4_0`, `q4_1`, `q5_0`, …) or unrecognized — throws a `StatusError`. A quantized K or V cache aborts in `llama_kv_cache::update` on KV-cache shifts / cache management (sliding context, state restore) because ggml-opencl has no `F32→quantized` requantize kernel. Use `f16`/`f32`/`bf16`, or a Vulkan GPU / CPU.
- **OpenCL (Adreno) accepts only `f16`/`f32`/`bf16`:** any other cache type — quantized (`q8_0`, `q4_0`, `q4_1`, `q5_0`, …) or unrecognized — throws a `StatusError`. A quantized K or V cache aborts in `llama_kv_cache::update` on cache management (reasoning-block compaction, state restore) because ggml-opencl has no `F32→quantized` requantize kernel. Use `f16`/`f32`/`bf16`, or a Vulkan GPU / CPU.
- **Mixed K≠V is a warning, not an error:** if K and V differ and at least one is quantized, the addon logs a warning (asymmetric quantized K/V falls off the fused flash-attention path — a notable GPU decode penalty — for no quality benefit, and is unsupported on Adreno OpenCL) but proceeds. Prefer a symmetric type. (This may be relaxed once qvac-fabric handles asymmetric quantized K/V efficiently.)


Expand Down
2 changes: 2 additions & 0 deletions packages/llm-llamacpp/addon/src/addon/LlmErrors.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ enum LlmErrorCode : uint32_t {
UnableToLoadMetadata = 23,
ReloadNotSupportedForStreamedModel = 24,
UnableToSaveSessionFile = 25,
// Retired with sliding-context support and never thrown now. Kept so a new
// code does not reuse 26, which builds up to 0.45.0 still emit.
ContextSlideFailed = 26,
Cancelled = 27,
// mode llm spesific errors here
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "CacheManager.hpp"

#include <array>
#include <filesystem>
#include <system_error>

Expand All @@ -19,58 +18,9 @@ using namespace qvac_lib_inference_addon_llama::errors;
using namespace qvac_lib_inference_addon_cpp::logger;
using namespace qvac_lib_inference_addon_llama::logging;

namespace {

struct SessionMetadata {
std::array<llama_token, SESSION_METADATA_FIELD_COUNT> tokens = {};

static SessionMetadata fromContext(const LlmContext& context) {
SessionMetadata metadata;
auto& tokens = metadata.tokens;
using Field = SessionMetadataField;
tokens[static_cast<size_t>(Field::NPast)] =
static_cast<llama_token>(context.getNPast());
tokens[static_cast<size_t>(Field::FirstMsgTokens)] =
static_cast<llama_token>(context.getFirstMsgTokens());
tokens[static_cast<size_t>(Field::CacheTokens)] =
static_cast<llama_token>(context.getCacheTokens());
tokens[static_cast<size_t>(Field::FirstMsgCacheTokens)] =
static_cast<llama_token>(context.getFirstMsgCacheTokens());
return metadata;
}

llama_token* data() { return tokens.data(); }
const llama_token* data() const { return tokens.data(); }
size_t size() const { return tokens.size(); }

llama_token field(SessionMetadataField which) const {
return tokens[static_cast<size_t>(which)];
}
llama_token nPast() const { return field(SessionMetadataField::NPast); }
llama_token firstMsgTokens() const {
return field(SessionMetadataField::FirstMsgTokens);
}
llama_token cacheTokens() const {
return field(SessionMetadataField::CacheTokens);
}
llama_token firstMsgCacheTokens() const {
return field(SessionMetadataField::FirstMsgCacheTokens);
}

void applyTo(LlmContext& context) const {
context.setNPast(nPast());
context.setFirstMsgTokens(firstMsgTokens());
context.setCacheTokens(cacheTokens());
context.setFirstMsgCacheTokens(firstMsgCacheTokens());
}
};

} // namespace

CacheManager::CacheManager(
LlmContext* llmContext, llama_pos configuredNDiscarded,
std::function<void(bool)> resetStateCallback)
: llmContext_(llmContext), configuredNDiscarded_(configuredNDiscarded),
LlmContext* llmContext, std::function<void(bool)> resetStateCallback)
: llmContext_(llmContext),
resetStateCallback_(std::move(resetStateCallback)) {}

bool CacheManager::isFileInitialized(const std::filesystem::path& path) {
Expand Down Expand Up @@ -255,14 +205,6 @@ bool CacheManager::loadCache() {
}
sessionMetadata.applyTo(*llmContext_);

if (configuredNDiscarded_ >
llama_n_ctx(ctx) - llmContext_->getFirstMsgTokens()) {
llmContext_->setNDiscarded(
llama_n_ctx(ctx) - llmContext_->getFirstMsgTokens() - 1);
} else {
llmContext_->setNDiscarded(configuredNDiscarded_);
}

auto* mem = llama_get_memory(ctx);
if (mem == nullptr) {
throw qvac_errors::StatusError(
Expand Down Expand Up @@ -371,7 +313,7 @@ void CacheManager::writeCacheFile(const std::string& path) {
Priority::DEBUG,
string_format("%s: saving cache to '%s'\n", __func__, path.c_str()));
const SessionMetadata sessionMetadata =
SessionMetadata::fromContext(*llmContext_);
SessionMetadata::capture(*llmContext_);
if (llama_state_seq_save_file(
ctx,
tmpPath.c_str(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ struct ParsedPromptPayload {
class CacheManager {
public:
CacheManager(
LlmContext* llmContext, llama_pos configuredNDiscarded,
std::function<void(bool)> resetStateCallback);
LlmContext* llmContext, std::function<void(bool)> resetStateCallback);

bool handleCache(
ParsedPromptPayload& parsedPrompt, const std::string& inputPrompt,
Expand All @@ -54,7 +53,6 @@ class CacheManager {
static bool isParentDirectoryMissing(const std::filesystem::path& path);

LlmContext* llmContext_;
llama_pos configuredNDiscarded_;
std::function<void(bool)> resetStateCallback_;
std::string sessionPath_;
bool cacheDisabled_ = true;
Expand Down

This file was deleted.

This file was deleted.

Loading
Loading