[PR #1010] [MERGED] Fix llama sidecar context slot sizing #4880

Closed
opened 2026-10-22 04:11:23 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/1010
Author: @cha1latte
Created: 5/19/2026
Status: ✅ Merged
Merged: 5/19/2026
Merged by: @cha1latte

Base: staging ← Head: fix/issue-993-llama-ctx-size


📝 Commits (1)

  • 14fcd0d Fix llama sidecar context slot sizing

📊 Changes

1 file changed (+6 additions, -2 deletions)

View changed files

📝 packages/server/src/services/sidecar/sidecar-launch-plan.ts (+6 -2)

📄 Description

Linked issue

Closes #993

Why this change

  • The bundled llama.cpp sidecar was launched with --parallel 2 --ctx-size 8192, which gives each llama-server slot only 4096 tokens. Tracker batches configured for an 8192-token local sidecar could still exceed the effective slot context and fail with 400 context-size errors.

What changed

  • Treat the sidecar contextSize setting as the per-request/slot budget.
  • Scale the llama-server --ctx-size total by the configured parallel slot count so two slots each receive the requested context budget.
  • Centralize the parallel slot count in the launch-plan helper so --parallel and --ctx-size stay in sync.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Manual verification notes

  • Machine proof: pnpm --filter @marinara-engine/server exec tsx ../../scratch/issue-993-ctx-size-repro.ts before reproduced the bug before the fix: --parallel 2 --ctx-size 8192 produced an effective per-slot context of 4096.
  • Machine proof: pnpm --filter @marinara-engine/server exec tsx ../../scratch/issue-993-ctx-size-repro.ts after passed after the fix: --parallel 2 --ctx-size 16384 produced an effective per-slot context of 8192.
  • Edge proof: the same scratch repro passed for 4096 context, 32768 context, and CPU/runtime gpuLayers=0.
  • Baseline: pnpm check passed locally.
  • Bunny: pre-PR Bunny review passed for the current diff.
  • Optional affected-machine smoke: restart the downloaded b9222 Windows CUDA sidecar and confirm its slot log reports n_ctx = 8192. This needs the affected runtime/model/GPU setup; the launch-argument path is covered by the scratch proof above.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Version/release files updated (only if this PR includes a version bump)

No docs, schema, dependency, or release/version files changed.

UI evidence (if applicable)

N/A - server-side launch-argument fix; no UI surface changed.

Summary by CodeRabbit

  • Refactor
    • Optimized backend service initialization for improved parallel processing efficiency and resource management.

Review Change Stack


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/1010 **Author:** [@cha1latte](https://github.com/cha1latte) **Created:** 5/19/2026 **Status:** ✅ Merged **Merged:** 5/19/2026 **Merged by:** [@cha1latte](https://github.com/cha1latte) **Base:** `staging` ← **Head:** `fix/issue-993-llama-ctx-size` --- ### 📝 Commits (1) - [`14fcd0d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/14fcd0d1cd38243d84c432095d524aed3ecf7e04) Fix llama sidecar context slot sizing ### 📊 Changes **1 file changed** (+6 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `packages/server/src/services/sidecar/sidecar-launch-plan.ts` (+6 -2) </details> ### 📄 Description <!-- Target branch: `staging`. The default base in this UI is `main` (release branch). --> <!-- Change the base to `staging` before submitting unless this is a maintainer-approved mainline change. --> <!-- See CONTRIBUTING.md § Branches. --> ## Linked issue <!-- Every PR should reference a feature request or issue report. If there isn't one yet, open one first to gather opinions: --> <!-- https://github.com/Pasta-Devs/Marinara-Engine/issues/new/choose --> Closes #993 ## Why this change <!-- What user problem, bug, or goal does this solve? --> - The bundled llama.cpp sidecar was launched with `--parallel 2 --ctx-size 8192`, which gives each llama-server slot only 4096 tokens. Tracker batches configured for an 8192-token local sidecar could still exceed the effective slot context and fail with 400 context-size errors. ## What changed <!-- List the key changes in this PR --> - Treat the sidecar `contextSize` setting as the per-request/slot budget. - Scale the llama-server `--ctx-size` total by the configured parallel slot count so two slots each receive the requested context budget. - Centralize the parallel slot count in the launch-plan helper so `--parallel` and `--ctx-size` stay in sync. ## Validation <!-- Required: include commands run and/or manual checks performed --> - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` ### Manual verification notes <!-- Describe exactly what you tested in a real browser/app, step by step. --> <!-- ⚠️ If an AI agent filled out or ticked these boxes for you, treat them --> <!-- as a TO-DO LIST, not as proof the work is done. Verify each item yourself --> <!-- before submitting. If you haven't verified it, untick the box. --> - Machine proof: `pnpm --filter @marinara-engine/server exec tsx ../../scratch/issue-993-ctx-size-repro.ts before` reproduced the bug before the fix: `--parallel 2 --ctx-size 8192` produced an effective per-slot context of 4096. - Machine proof: `pnpm --filter @marinara-engine/server exec tsx ../../scratch/issue-993-ctx-size-repro.ts after` passed after the fix: `--parallel 2 --ctx-size 16384` produced an effective per-slot context of 8192. - Edge proof: the same scratch repro passed for 4096 context, 32768 context, and CPU/runtime `gpuLayers=0`. - Baseline: `pnpm check` passed locally. - Bunny: pre-PR Bunny review passed for the current diff. - Optional affected-machine smoke: restart the downloaded b9222 Windows CUDA sidecar and confirm its slot log reports `n_ctx = 8192`. This needs the affected runtime/model/GPU setup; the launch-argument path is covered by the scratch proof above. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Version/release files updated (only if this PR includes a version bump) No docs, schema, dependency, or release/version files changed. ## UI evidence (if applicable) N/A - server-side launch-argument fix; no UI surface changed. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Refactor** * Optimized backend service initialization for improved parallel processing efficiency and resource management. <!-- review_stack_entry_start --> [![Review Change Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/Pasta-Devs/Marinara-Engine/pull/1010?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack) <!-- review_stack_entry_end --> <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:11:23 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#4880
No description provided.