Skip to content

fix: resume-incremental write + role-specific ubatch (INC-6C62) - #37

Merged
ManSio merged 3 commits into
mainfrom
feat/resume-ubatch-2026-09-20
Sep 20, 2026
Merged

ManSio merged 3 commits into
mainfrom
feat/resume-ubatch-2026-09-20

Conversation

@ManSio

@ManSio ManSio commented Sep 20, 2026

Copy link
Copy Markdown
Owner

Что сделано

Commit 1 — fix(indexing): resume-incremental write + table integrity

  • IndexProjectRunner: WRITE_FLUSH_FILES=32, инкрементальный flush порциями, RAM освобождается после каждой порции (_flush_pending)
  • _verify_and_repair_table_integrity(): проверка целостности LanceDB до индексации, физический recreate при мёртвых фрагментах (INC-6C62)
  • Resume: на перезапуске known_hashes пропускают записанные файлы, обрабатывается только незавершённый хвост
  • 6 тестов: полнота, инкрементальный flush, краш-сохранение, resume, double-write guard, RAM-инвариант

Commit 2 — perf(rerank): role-specific ubatch + query truncate

  • resolve_ubatch(role): embed→512, rerank→1024 (ceil до 128), env override LLAMA_UBATCH_SIZE
  • _ubatch_arg(model_key) в llama_runner, _truncate_rerank_pair в multi_provider
  • remote_embedder: LLAMA_EMBED_MAX_TOKENS вместо хардкода 480
  • A/B на 2227 чанках: 596 MB / 18.9 ch/s vs 1686 MB / 16.1 ch/s

Commit 3 — docs: research notes KI-R1..R11 + diary + experiments log

Верификация

  • 18/18 pytest зелёных (test_ubatch_roles + test_index_resume_incremental)
  • ruff clean по изменённым файлам
  • verified_from_clean_state: ⚠️ не прогонялся (clean-clone требует сети)

Связанные задачи

  • KI-101 (cache-hit пропускал dense-уровень)
  • KI-R1..R11 (исследовательские задачи поискового качества)

MSCodeBase Agent added 3 commits September 20, 2026 13:39
IndexProjectRunner.run() previously accumulated all embeddings in
memory and wrote them in a single bulk_write at the end. A crash
on a large project (330K chunks, ~9h) lost all work: empty table
-> empty known_hashes -> full re-embed on restart.

Fix:
- WRITE_FLUSH_FILES=32: completed files flushed incrementally via
  _flush_pending(), RAM freed (embeddings zeroed + gc.collect)
- _verify_and_repair_table_integrity() run once at start of run():
  detects dead fragment refs from drop+create inheritance, recreates
  table physically before indexing starts
- Resume: on restart, known_hashes (table) skip already-written files;
  only the unfinished tail is re-processed
- Double-write guard: test_no_double_write_of_completed_files
- Crash preservation: test_crash_preserves_written_files_in_db
- RAM invariant: test_ram_is_freed_after_flush

Red Team 5/5: concurrency/idempotent, BATCH_SIZE boundary, TOCTOU
crash during bulk_write, runner restart, integrity-recreate vs skip.
- resolve_ubatch(role): embed->512, rerank->1024 (ceil to 128)
  env LLAMA_UBATCH_SIZE is hard override for both roles
- _ubatch_arg(model_key): selects ubatch by role in llama_runner
- _truncate_rerank_pair(query, passages): heuristic trim so
  query+max_passage <= ubatch tokens (1 token ~ 2 chars)
- remote_embedder uses LLAMA_EMBED_MAX_TOKENS instead of hardcoded 480

A/B on 2227 real chunks, port 8082:
  ubatch 512 -> 596 MB / 18.9 ch/s
  ubatch 2048 -> 1686 MB / 16.1 ch/s

Tests: test_ubatch_roles.py (6 cases), ruff clean.
- ISSUE.md: 11 research tasks (KI-R1..R11) for search quality / E13
- AGENT_DIARY.md: [2026-09-20] entry with priority order
- EXPERIMENTS_LOG.md: E13 context + plan
- KNOWN_ISSUES.md: auto-sync (entry added)
- README.md, .env.example: minor updates

Not committed: experiments/ search_quality artifacts (scratch).
@coderabbitai

coderabbitai Bot commented Sep 20, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: c165b3b8-f1e2-4726-bb4f-f5e6dacbfbd4


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.

@ManSio
ManSio merged commit 0104285 into main Sep 20, 2026
12 of 13 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