Skip to content

QVAC-20987 feat[api]: add llm reasoning budget caps#2366

Merged
gianni-cor merged 75 commits into
tetherto:mainfrom
zoq:qvac-b9341
Jun 22, 2026
Merged

QVAC-20987 feat[api]: add llm reasoning budget caps#2366
gianni-cor merged 75 commits into
tetherto:mainfrom
zoq:qvac-b9341

Conversation

@zoq

@zoq zoq commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator

🎯 What problem does this PR solve?

  • Makes llm-llamacpp reasoning-channel control more useful by allowing positive reasoning_budget values to cap <think> output instead of only supporting unrestricted/disabled modes.
  • Aligns reasoning-budget sampling with template-provided thinking tags so Qwen/Gemma-style chat templates can expose balanced reasoning output without hard-coded <think> assumptions.
  • Hardens backend defaults and CI coverage around flash attention, OpenCL KV-cache support, mobile grouping, and long-running integration tests.

📝 How does it solve it?

  • Extends load-time and per-request reasoning_budget parsing so -1 is unrestricted, 0 disables thinking, and positive integers cap the reasoning channel at that many tokens.
  • Exports thinking start/end metadata from chat-template formatting, reconfigures the common sampler with those template-specific tags, and emits the matching visible forced-open reasoning text.
  • Defaults flash attention on for non-BitNet/non-finetuning models, while rejecting unsupported quantized KV-cache types on OpenCL with an early validation error.
  • Refreshes llm-llamacpp tests and platform scheduling: reasoning-budget unit/model coverage, chat-template helper coverage, tools-compact session flush fencing, continuous-batching mobile wiring, Windows/macOS skip adjustments, and VLM performance skip cleanup.

🧪 How was it tested?

  • Added C++ unit coverage for generation-parameter override application, positive reasoning budgets, chat-template thinking metadata, forced-open reasoning text, and tune-config backend defaults.
  • Added/updated integration coverage for per-request reasoning budgets, tools-compact session persistence, continuous batching, sliding-context overflow, multi-instance/multi-GPU scheduling, and VLM perf test platform skips.
  • Verified the PR diff has no whitespace/conflict-marker issues with git diff --check upstream/main...HEAD.

💥 Breaking Changes

  • OpenCL now rejects quantized KV-cache types (q4_*, q5_*, q8_0, iq4_nl, tbq*, pq*) during config validation. Use f32, f16, or bf16 on OpenCL, or switch to Vulkan/CPU for quantized KV-cache modes.

🔌 API Changes

await model.run(prompt, {
  generationParams: {
    reasoning_budget: 128
  }
})

Positive reasoning_budget values now cap the reasoning channel. -1 keeps reasoning unrestricted and 0 disables it.


…#144 (b9341).

Signed-off-by: Marcus Edel <marcus.edel@collabora.com>
@zoq zoq requested review from a team as code owners June 1, 2026 14:29
Signed-off-by: Marcus Edel <marcus.edel@collabora.com>
Comment thread packages/llm-llamacpp/addon/src/model-interface/LlamaModel.cpp Outdated
Comment thread packages/embed-llamacpp/CMakeLists.txt Outdated
Comment thread packages/llm-llamacpp/vcpkg.json Outdated
Comment thread packages/embed-llamacpp/vcpkg.json Outdated
Comment thread packages/embed-llamacpp/vcpkg/ports/qvac-fabric/portfile.cmake Outdated
Signed-off-by: Marcus Edel <marcus.edel@collabora.com>
@gianni-cor gianni-cor added the verified Authorize secrets / label-gate in PR workflows label Jun 1, 2026
Assisted-by: GPT-5.5
Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions

Copy link
Copy Markdown
Contributor

🧪 C++ Test Coverage Report

Coverage:

📊 Detailed Coverage
Filename                         Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
NmtLazyInitializeBackend.cpp          99                20    79.80%          11                 1    90.91%         157                36    77.07%          66                21    68.18%
NmtLazyInitializeBackend.hpp           2                 0   100.00%           1                 0   100.00%           1                 0   100.00%           0                 0         -
TranslationModel.cpp                 296               168    43.24%          28                 8    71.43%         506               213    57.91%         181               122    32.60%
TranslationModel.hpp                   1                 0   100.00%           1                 0   100.00%           1                 0   100.00%           0                 0         -
nmt.cpp                               72                22    69.44%           9                 1    88.89%         137                28    79.56%          44                16    63.64%
nmt.hpp                               51                 4    92.16%          11                 2    81.82%          53                 4    92.45%          28                 0   100.00%
nmt_beam_search.cpp                  116                25    78.45%          10                 3    70.00%         254                32    87.40%          76                19    75.00%
nmt_graph_decoder.cpp                164                78    52.44%          15                 7    53.33%         540               161    70.19%         112                69    38.39%
nmt_graph_encoder.cpp                 54                13    75.93%           3                 0   100.00%         268                33    87.69%          37                16    56.76%
nmt_loader.cpp                       270                67    75.19%          14                 0   100.00%         774                97    87.47%         161                67    58.39%
nmt_state_backend.cpp                253                94    62.85%          21                 0   100.00%         489               128    73.82%         165                87    47.27%
nmt_tokenization.cpp                  88                21    76.14%           8                 0   100.00%         135                36    73.33%          61                26    57.38%
nmt_utils.cpp                        120                89    25.83%           8                 3    62.50%         180               134    25.56%          78                63    19.23%
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                               1586               601    62.11%         140                25    82.14%        3495               902    74.19%        1009               506    49.85%

@github-actions

Copy link
Copy Markdown
Contributor

🧪 C++ Test Coverage Report

Coverage:

📊 Detailed Coverage
Filename                         Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
NmtLazyInitializeBackend.cpp          99                20    79.80%          11                 1    90.91%         157                36    77.07%          66                21    68.18%
NmtLazyInitializeBackend.hpp           2                 0   100.00%           1                 0   100.00%           1                 0   100.00%           0                 0         -
TranslationModel.cpp                 296               168    43.24%          28                 8    71.43%         506               213    57.91%         181               122    32.60%
TranslationModel.hpp                   1                 0   100.00%           1                 0   100.00%           1                 0   100.00%           0                 0         -
nmt.cpp                               72                22    69.44%           9                 1    88.89%         137                28    79.56%          44                16    63.64%
nmt.hpp                               51                 4    92.16%          11                 2    81.82%          53                 4    92.45%          28                 0   100.00%
nmt_beam_search.cpp                  116                25    78.45%          10                 3    70.00%         254                32    87.40%          76                19    75.00%
nmt_graph_decoder.cpp                164                78    52.44%          15                 7    53.33%         540               161    70.19%         112                69    38.39%
nmt_graph_encoder.cpp                 54                13    75.93%           3                 0   100.00%         268                33    87.69%          37                16    56.76%
nmt_loader.cpp                       270                67    75.19%          14                 0   100.00%         774                97    87.47%         161                67    58.39%
nmt_state_backend.cpp                253                94    62.85%          21                 0   100.00%         489               128    73.82%         165                87    47.27%
nmt_tokenization.cpp                  88                21    76.14%           8                 0   100.00%         135                36    73.33%          61                26    57.38%
nmt_utils.cpp                        120                89    25.83%           8                 3    62.50%         180               134    25.56%          78                63    19.23%
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                               1586               601    62.11%         140                25    82.14%        3495               902    74.19%        1009               506    49.85%

gianni-cor and others added 5 commits June 20, 2026 08:57
Assisted-by: GPT-5.5
Co-authored-by: Cursor <cursoragent@cursor.com>
Assisted-by: GPT-5.5
Co-authored-by: Cursor <cursoragent@cursor.com>
Assisted-by: GPT-5.5
Co-authored-by: Cursor <cursoragent@cursor.com>
Assisted-by: GPT-5.5
Co-authored-by: Cursor <cursoragent@cursor.com>
Assisted-by: GPT-5.5
Co-authored-by: Cursor <cursoragent@cursor.com>
@gianni-cor

Copy link
Copy Markdown
Contributor

Removed quantized KVcache test for OpenCL cause openCL backend has several issues with that. tracked on the fabric PR, but will not be added here

@github-actions

Copy link
Copy Markdown
Contributor

Tier-based Approval Status

**PR Tier:** TIER1

**Current Status:** ❌ PENDING

**Requirements:**
- 1 Team Member approval ❌ (0/1)
- 1 Team Lead OR Management approval ❌ (0/1)



---
*This comment is automatically updated when reviews change.*

gianni-cor and others added 2 commits June 22, 2026 10:51
Assisted-by: GPT-5.5
Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions

Copy link
Copy Markdown
Contributor

🧪 C++ Test Coverage Report

Coverage:

📊 Detailed Coverage
Filename                         Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
NmtLazyInitializeBackend.cpp          99                20    79.80%          11                 1    90.91%         157                36    77.07%          66                21    68.18%
NmtLazyInitializeBackend.hpp           2                 0   100.00%           1                 0   100.00%           1                 0   100.00%           0                 0         -
TranslationModel.cpp                 296               168    43.24%          28                 8    71.43%         506               213    57.91%         181               122    32.60%
TranslationModel.hpp                   1                 0   100.00%           1                 0   100.00%           1                 0   100.00%           0                 0         -
nmt.cpp                               72                22    69.44%           9                 1    88.89%         137                28    79.56%          44                16    63.64%
nmt.hpp                               51                 4    92.16%          11                 2    81.82%          53                 4    92.45%          28                 0   100.00%
nmt_beam_search.cpp                  116                25    78.45%          10                 3    70.00%         254                32    87.40%          76                19    75.00%
nmt_graph_decoder.cpp                164                78    52.44%          15                 7    53.33%         540               161    70.19%         112                69    38.39%
nmt_graph_encoder.cpp                 54                13    75.93%           3                 0   100.00%         268                33    87.69%          37                16    56.76%
nmt_loader.cpp                       270                67    75.19%          14                 0   100.00%         774                97    87.47%         161                67    58.39%
nmt_state_backend.cpp                253                94    62.85%          21                 0   100.00%         489               128    73.82%         165                87    47.27%
nmt_tokenization.cpp                  88                21    76.14%           8                 0   100.00%         135                36    73.33%          61                26    57.38%
nmt_utils.cpp                        120                89    25.83%           8                 3    62.50%         180               134    25.56%          78                63    19.23%
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                               1586               601    62.11%         140                25    82.14%        3495               902    74.19%        1009               506    49.85%

gianni-cor and others added 4 commits June 22, 2026 11:09
Assisted-by: GPT-5.5
Co-authored-by: Cursor <cursoragent@cursor.com>
Assisted-by: GPT-5.5
Co-authored-by: Cursor <cursoragent@cursor.com>
Assisted-by: GPT-5.5
Co-authored-by: Cursor <cursoragent@cursor.com>
Comment thread packages/llm-llamacpp/addon/src/model-interface/LlamaModel.cpp Outdated
gianni-cor and others added 3 commits June 22, 2026 12:55
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@gianni-cor

Copy link
Copy Markdown
Contributor

/review

@github-actions

Copy link
Copy Markdown
Contributor

Tier-based Approval Status

**PR Tier:** TIER1

**Current Status:** ❌ PENDING

**Requirements:**
- 1 Team Member approval ❌ (0/1)
- 1 Team Lead OR Management approval ✅ (1/1)



---
*This comment is automatically updated when reviews change.*

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants