Skip to content

feat(cross-encoder): add declared XLM-R runtime LoRA - #787

Merged
svonava merged 1 commit into
mainfrom
codex/issue-778-xlmr-runtime-lora
Oct 18, 2026
Merged

svonava merged 1 commit into
mainfrom
codex/issue-778-xlmr-runtime-lora

Conversation

@svonava

@svonava svonava commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Extend the explicit sie_server.adapters.cross_encoder.runtime_lora:CrossEncoderLoraAdapter from #775 to the exact standard, unquantized XLMRobertaForSequenceClassification class. Its declared LoRA targets must resolve only to roberta.encoder Linear modules. The existing BERT path, outer CrossEncoder, classifier, activation, tokenizer and inherited scoring methods are preserved.

XLM-R profiles must select that explicit adapter_path and declare lora_paths. The ordinary CrossEncoderAdapter module remains byte-identical to the baseline and does not import or construct the LoRA manager. Native BertFlash/default catalog profiles, custom or quantized models, ambiguous/head targets and adapters with saved classifier heads remain unsupported. Resident adapters remain off the native base module tree when base is selected; this is a lifecycle guarantee, not a zero-overhead claim for enabled profiles.

Current-head validation: 331 CPU tests pass with zero skips, covering real generated BERT/XLM-R checkpoints, loader routing, alias/source restrictions, rollback, capacity/eviction, original module/storage restoration, concurrent SDK/worker selection, and immutable baseline/candidate archive integration. Fourteen independently replayed controls also pass, including actual loaded ordinary/explicit profiles for both architectures. Scoped Ruff and production typechecking pass. All six original BERT fixture files are unchanged.

The pinned pretrained BGE CPU result remains evidence from 7afbec3f77b183b6cdde6ee052b36bd11af08ebc: its manager is byte-identical here and scoring methods are unchanged. This source mapping is separate from the new generated-fixture validation; it is not a new pretrained run through the moved class. No XLM-R GPU/performance, cross-precision or trained-adapter quality qualification is claimed, and historical failed #775 performance gates remain failed.

PR775 is merged as b35cfc6ee048892c7cd322d1acfdadce2272f34e. This separate four-file extension now targets main at unchanged head 100a64ff1fd8766e2475ecf4ee3a56905ebd6abf; its original ancestry and all validation evidence are preserved. Refs #778.

Summary by CodeRabbit

  • New Features

    • Added LoRA support for standard, unquantized BERT and XLM-R sequence-classification models. Adapter targets must resolve to linear layers within the model’s encoder; other model types and quantized models remain unsupported.
  • Documentation

    • Clarified model and adapter limitations, including that XLM-R profiles must explicitly select the LoRA adapter, default catalog profiles and adapters with saved classifier heads are unsupported, and benchmark coverage remains limited to the named BERT checkpoint.

@coderabbitai

coderabbitai Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Team
  • Run ID: 41a7ba11-c3b7-4ff5-927f-2633c6502176
📥 Commits

Reviewing files that changed from the base of the PR and between b35cfc6 and 100a64f.

📒 Files selected for processing: 4
  • packages/sie_server/src/sie_server/adapters/cross_encoder/_lora.py
  • packages/sie_server/src/sie_server/adapters/cross_encoder/runtime_lora.py
  • packages/sie_server/tests/adapters/test_cross_encoder_lora.py
  • tools/benchmarks/cross_encoder_lora/README.md

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.

📝 Walkthrough

The cross-encoder LoRA adapter now accepts unquantized BERT and XLM-R sequence-classification models. It validates configured targets against Linear modules under the selected encoder. Tests cover model admission, adapter lifecycle, worker batching, and HTTP and SDK scoring.

Changes: Cross-encoder LoRA support

Layer / File(s) Summary
Model admission and encoder targets
packages/sie_server/src/sie_server/adapters/cross_encoder/_lora.py, packages/sie_server/src/sie_server/adapters/cross_encoder/runtime_lora.py, packages/sie_server/tests/adapters/test_cross_encoder_lora.py, tools/benchmarks/cross_encoder_lora/README.md
The adapter accepts standard, unquantized BERT and XLM-R sequence-classification models. Configured targets must match Linear modules under the selected encoder. Tests cover supported and rejected models and fully qualified encoder targets. The documentation describes supported profiles and benchmark scope.
Adapter lifecycle and residency
packages/sie_server/src/sie_server/adapters/cross_encoder/_lora.py, packages/sie_server/tests/adapters/test_cross_encoder_lora.py
The adapter clears its stored encoder prefix on close. Tests check state preservation, resident layers, target-specific eviction, and partial-swap failure handling with checkpoint-derived expectations.
Worker and scoring integration
packages/sie_server/tests/adapters/test_cross_encoder_lora.py
Tests cover worker batches with mixed LoRA selections and concurrent SDK scoring through the HTTP test setup.

Suggested reviewers: dragosboca

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 100a6

No actionable issue remains that should block merging after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 3.23% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 31 functions across 4 files. (1 skipped: 1… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
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.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: adding declared runtime LoRA support for XLM-R cross-encoders.
Full details: Docstring Coverage

Explanation

Docstring coverage is 3.23% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 31 functions across 4 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@svonava

svonava commented Oct 17, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

Please review current head 7afbec3f77b183b6cdde6ee052b36bd11af08ebc against the PR775 branch. This is the separate three-file XLM-R extension: exact standard class/encoder-prefix admission, documentation, and real CPU lifecycle/SDK coverage. The executable CrossEncoder scoring methods, shared worker/registry, dependencies and default BertFlash catalog profiles are unchanged. Classifier targets, ambiguous encoder/head matches, saved heads and custom/quantized models remain rejected.

The implementation passed 314 CPU tests and 55 independently replayed focused tests, including preserved warmed wire checks, SDK concurrency, rollback and no-LoRA import isolation. The PR deliberately remains draft: pinned pretrained and paired GPU qualification are still outstanding. Please assess source correctness and regressions; the CPU results do not establish GPU performance or trained-adapter quality.

@coderabbitai

coderabbitai Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
✅ Action performed

Full review finished.

coderabbitai[bot]
coderabbitai Bot previously approved these changes Oct 17, 2026
@svonava

svonava commented Oct 17, 2026

Copy link
Copy Markdown
Contributor Author

Pinned pretrained CPU validation passed on 7afbec3f77b183b6cdde6ee052b36bd11af08ebc using BAAI/bge-reranker-base revision 2cfc18c9415c912f9d8155881c133215df768a70 and the ordinary XLM-R cross-encoder profile.

  • 17 SDK requests completed; the two cold adapter loads each returned the expected loading response before success. All 15 warm/base calls succeeded in one attempt.
  • Actual model-forward observation covered base/A/B selection and concurrent worker isolation: 40 model forwards and 480 selected LoRA-layer calls. Every observed score and raw-logit comparison against its matching token/shape oracle had zero difference.
  • Frozen assertions verified restoration of original parameters, buffers, classifier, module tree, tokenizer/activation and gradient/training state. Cleanup released both model objects and emptied the owned registry.

The generated adapters are functional fixtures, not trained quality evidence. This is one CPU validation; GPU performance, cross-precision behavior and the default BertFlash catalog remain outside this result. The PR remains draft and depends on #775.

@svonava
svonava force-pushed the codex/issue-778-xlmr-runtime-lora branch from 7afbec3 to 100a64f Compare October 18, 2026 00:11
@svonava

svonava commented Oct 18, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

Please review exact head 100a64ff1fd8766e2475ecf4ee3a56905ebd6abf against its updated #775 parent fc7eeac318d429a34b9660311d72007fae077c25.

The XLM-R extension now uses the explicit cross_encoder.runtime_lora:CrossEncoderLoraAdapter contract. The ordinary adapter file is byte-identical to the baseline, the XLM-R manager is byte-identical to previously reviewed 7afbec3f77b183b6cdde6ee052b36bd11af08ebc, and the explicit class has no executable change from the new parent. The four-file delta covers the exact class/prefix mapping, explicit scope documentation and combined BERT/XLM-R tests.

Current validation passes 331 CPU cases with no skips, plus 14 independently replayed cases. Real loader/SDK and immutable B/R archive smoke confirms ordinary and explicit class routing, numerical effects/restoration and cleanup. The prior pinned BGE CPU proof remains historical component evidence, not a new pretrained run through the moved class. No GPU/performance, trained-head or quality claim is added. The PR remains a separate draft dependent on #775.

@coderabbitai

coderabbitai Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
✅ Action performed

Full review finished.

Base automatically changed from codex/cross-encoder-runtime-lora to main October 18, 2026 00:25
@svonava
svonava dismissed coderabbitai[bot]’s stale review October 18, 2026 00:25

The base branch was changed.

@svonava
svonava marked this pull request as ready for review October 18, 2026 00:27
@svonava
svonava requested a review from a team as a code owner October 18, 2026 00:27
@svonava

svonava commented Oct 18, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

Please review exact head 100a64ff1fd8766e2475ecf4ee3a56905ebd6abf against main. PR775 is now merged; this unchanged head has a four-file XLM-R extension delta. The explicit adapter routing migration has 331 passing CPU controls plus 14 independent checks. The pinned pretrained BGE result remains historical component evidence, not a new performance measurement. Please provide an actual current-head review; prior-head approval and aggregate status alone are insufficient.

@coderabbitai

coderabbitai Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
✅ Action performed

Full review finished.

@svonava
svonava merged commit 0fd7c9a into main Oct 18, 2026
16 checks passed
@svonava
svonava deleted the codex/issue-778-xlmr-runtime-lora branch October 18, 2026 00:38
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