Repository navigation
LoRA Integration for Dynamic RoPE Rotation Patterns - #933
Merged
Merged
Conversation
Co-authored-by: makr-code <[email protected]>
Co-authored-by: makr-code <[email protected]>
Co-authored-by: makr-code <[email protected]>
Co-authored-by: makr-code <[email protected]>
…er, update docs, remove unused variable Co-authored-by: makr-code <[email protected]>
Copilot
AI
changed the title
[WIP] Integrate LoRA with RoPE for dynamic rotation patterns
LoRA Integration for Dynamic RoPE Rotation Patterns
Jan 27, 2026
makr-code
approved these changes
Jan 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Extends Rotary Position Embeddings (RoPE) with LoRA adapter support, enabling domain-specific rotation patterns (medical, legal, technical) without model retraining. Adapters use low-rank factorization (B @ A matrices) for 75% memory savings vs full modification.
Type of Change
Related Issues
Changes Made
Core Implementation:
LoRARopeAdapter: Low-rank adaptation structure with B/A matrices, theta deltas, domain metadataLoRARopeAdapterRegistry: Thread-safe adapter registry with enable/disable, registration, and queryingLoRARotaryEmbedding: Extended RoPE class with adapter support, backward compatible with baseRotaryEmbeddingKey Features:
rotateWithAdapter(): Single adapter rotation with LoRA-modified anglesrotateBatchWithAdapter(): Batch processing for efficiencyrotateWithAdapterBlend(): Weighted average of multiple adapters for hybrid domainscreateRandom()for training,createZero()for baselineExample Usage:
Performance:
Testing
Test Environment
Test Results
Test Commands
Test Coverage:
Checklist
Code Quality
Documentation
Documentation Added:
docs/features/lora-rope-integration.md: Complete feature documentation with architecture, API reference, usage examples, performance analysis, and best practicesBranch Strategy Compliance
developfor features,mainfor releases/hotfixes)feature/,bugfix/,hotfix/,release/)mainordevelopPerformance Impact
Performance Notes:
Breaking Changes
RotaryEmbeddingAPISecurity Considerations
Additional Notes
Design Decisions:
LORA_INIT_STD_DEV)shared_ptrfor efficient adapter reuseFuture Enhancements:
Screenshots/Logs
N/A - Backend feature with no UI components
For Maintainers:
Review Checklist
Merge Strategy
Original prompt
This section details on the original issue you should resolve
<issue_title>[RoPE] LoRA Integration for Dynamic Rotation Patterns</issue_title>
<issue_description>## Feature Description
Integrate Rotary Position Embeddings (RoPE) with ThemisDB's LoRA (Low-Rank Adaptation) framework to enable dynamic, context-aware rotation patterns. This allows different LoRA adapters to modify rotation behavior for specific domains or tasks without retraining the entire embedding model.
Problem Statement
Current RoPE implementation uses static rotation parameters for all use cases. However, different domains (medical, legal, technical) or tasks (search, classification, clustering) may benefit from different rotation patterns. Retraining embeddings is expensive; LoRA adapters provide a lightweight alternative.
Proposed Solution
Core Components
LoRA-Enhanced RoPE Layer (
include/index/lora_rope.h)LoRA RoPE Adapter (
include/lora/lora_rope_adapter.h)VectorIndexManager Integration
Technical Design
LoRA Adaptation Formula
Base RoPE:
θᵢ = base^(-2i/d)LoRA-Adapted RoPE:
Memory Efficiency:
Adapter Training
Training Data:
Training Process:
Storage Format (HDF5):
Implementation Considerations
Dependencies
include/lora/lora_manager.h)CMakeLists.txt Integration
Adapter Selection Strategy
Performance Impact
Mitigation:
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.