Skip to content

fix: segmenter tail latent registered before gallocr alloc (DBCache crash) - #3

Merged
KakaruHayate merged 1 commit into
mainfrom
feature/eff-fix-cache-crash
Aug 16, 2026
Merged

fix: segmenter tail latent registered before gallocr alloc (DBCache crash)#3
KakaruHayate merged 1 commit into
mainfrom
feature/eff-fix-cache-crash

Conversation

@KakaruHayate

@KakaruHayate KakaruHayate commented Aug 16, 2026

Copy link
Copy Markdown
Owner

Problem

With DBCache enabled (--cache-threshold), the 3-stage segmenter split path
built \outs.latent\ after \ggml_gallocr_alloc_graph, leaving the latent
nodes unallocated. Computing them is UB — on the medium model (latent at
layer 6, fn_blocks=1) the CLI crashed with ACCESS_VIOLATION
(exit 0xC0000005) at the first D3PM step. CI only runs --version, so this
was never caught.

Fix

Register both outputs (x_run + latent) and build the graph before allocating;
alloc only once both are in the graph.

Verified (local CPU build, 30s 44.1k mono, Q8_0, nsteps=4)

  • Before: crash 0xC0000005
  • After: exit 0, timer 34.3s vs 40.7s cache-off segmenter time
    (DBCache gives ~16% end-to-end, ~20% segmenter speedup at nsteps=4)
  • Notes identical (83 == 83) with --seed 42 — same output as cache off.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed processing for configurations that use optional latent outputs, preventing missing graph elements during computation.
    • Improved segmenter initialization to ensure all outputs are prepared before processing begins.

…BCache)

Building latent after ggml_gallocr_alloc_graph leaves it unallocated and
computing it is UB — with DBCache enabled (--cache-threshold) on the medium
model (latent_layer_idx=6, fn_blocks=1) this crashed with ACCESS_VIOLATION.
Build both outputs first, then alloc.
@KakaruHayate

Copy link
Copy Markdown
Owner Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Aug 16, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: c4a2444d-24f6-4b34-8ae5-a50afc7030df

📥 Commits

Reviewing files that changed from the base of the PR and between b4b5863 and e5c0e80.

📒 Files selected for processing (1)
  • src/model.cpp

Included review availability: Your plan includes up to 1 review per rolling hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The segmenter tail now registers and expands the main output and optional latent output before backend graph allocation. It then checks backend support, creates the allocator, and allocates the complete graph.

Changes

Segmenter graph allocation

Layer / File(s) Summary
Allocate the complete output graph
src/model.cpp
The segmenter tail replaces s.finalize with explicit output registration and expansion. It prepares outs.x_run and optional outs.latent before backend validation and graph allocation.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to e5c0e

This localized change registers the segmenter outputs before graph allocation and reports successful verification with matching notes; no actionable merge-blocking risk remains beyond normal checks and review.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the segmenter latent-registration fix and the DBCache crash it prevents.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/eff-fix-cache-crash

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai

coderabbitai Bot commented Aug 16, 2026

Copy link
Copy Markdown
✅ Action performed

Full review finished.

@KakaruHayate
KakaruHayate merged commit 58f1810 into main Aug 16, 2026
17 checks passed
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.

1 participant