| name | code2lora-hypernetwork-adapter |
| description | Code2LoRA: Hypernetwork-generated LoRA adapters for code language models under software evolution. Supports static and dynamic adaptation scenarios with zero inference overhead. Activation: code LLM adaptation, repository-specific LoRA, hypernetwork adapters, software evolution, code adaptation. |
Code2LoRA: Hypernetwork-Generated Adapters for Code Language Models
Paper Information
Title: Code2LoRA: Hypernetwork-Generated Adapters for Code Language Models under Software Evolution
arXiv ID: 2606.06492
Published: 2026-06-04
Authors: Liliana Hotsko, Yinxi Li, Yuntian Deng, Pengyu Nie
Categories: cs.SE, cs.AI, cs.CL
PDF: https://arxiv.org/pdf/2606.06492v1
Code: https://anonymous.4open.science/r/code2lora-6857
Models/Data: https://huggingface.co/code2lora
Core Contributions
1. Hypernetwork-Generated Repository-Specific Adapters
Problem: Existing methods for injecting repository knowledge:
- RAG or dependency analysis → long inference-time token overhead
- Per-repository fine-tuning/LoRA → costly at repository scale, brittle to evolving codebases
Solution: Hypernetwork generates repository-specific LoRA adapters with zero inference-time token overhead.
2. Two Usage Scenarios
Code2LoRA-Static
- Converts single repository snapshot into adapter
- Suitable for comprehension of stable codebases
- One-shot adapter generation
Code2LoRA-Evo
- Adapter backed by GRU hidden state
- Updated per code diff
- Suitable for active development of evolving codebases
- Continuous adaptation
3. RepoPeftBench Benchmark
First benchmark for evaluating repository-level PEFT methods:
- Static track: 40K training + 12K test assertion-completion tasks
- Evolution track: 215K commit-derived training + 87K commit-derived test tasks
- Scale: 604 Python repositories
Key Technical Patterns
Pattern 1: Hypernetwork Adapter Generation
class Code2LoRAHypernetwork:
"""
Hypernetwork that generates repository-specific LoRA adapters.
Architecture:
- Repository encoder (processes codebase)
- Adapter generator (outputs LoRA weights)
- Zero inference overhead (adapter merged into base model)
"""
def __init__(self, base_model, adapter_dim=64):
self.base_model = base_model
self.adapter_dim = adapter_dim
self.repo_encoder = RepositoryEncoder()
self.adapter_generator = AdapterGenerator()
def generate_adapter(self, repository_snapshot):
"""Generate LoRA adapter for repository."""
repo_embedding = self.repo_encoder.encode(repository_snapshot)
lora_A, lora_B = self.adapter_generator.generate(
repo_embedding,
dim=self.adapter_dim
)
adapted_model = self.merge_adapter(lora_A, lora_B)
return adapted_model
def merge_adapter(self, lora_A, lora_B):
"""Merge LoRA adapter into base model weights."""
return merged_model
Pattern 2: Evolution-Aware Adapter (Code2LoRA-Evo)
class Code2LoRAEvo:
"""
Evolution-aware adapter with GRU hidden state.
Features:
- GRU maintains repository state
- Per-diff updates
- Continuous adaptation for evolving codebases
"""
def __init__(self):
self.gru_state = None
self.adapter_generator = AdapterGenerator()
def update_adapter(self, code_diff):
"""Update adapter based on code diff."""
diff_embedding = self.encode_diff(code_diff)
self.gru_state = self.gru_update(
self.gru_state,
diff_embedding
)
lora_A, lora_B = self.adapter_generator.generate(
self.gru_state,
dim=self.adapter_dim
)
return lora_A, lora_B
def gru_update(self, prev_state, diff_embedding):
"""GRU-based state update."""
return new_state
Pattern 3: Variable-Speed Trajectory Augmentation (VSTA)
Although VSTA is mentioned in the paper context, the primary focus is on:
class RepositoryKnowledgeInjection:
"""
Repository knowledge injection without token overhead.
Methods:
- Static: Snapshot → Adapter (one-shot)
- Evo: Diff stream → GRU state → Adapter (continuous)
"""
def inject_static(self, repo_path):
"""One-shot knowledge injection."""
snapshot = self.load_snapshot(repo_path)
adapter = self.hypernetwork.generate_adapter(snapshot)
return self.merge(adapter)
def inject_evo(self, repo_path, commit_history):
"""Continuous knowledge injection."""
self.gru_state = self.initialize_state()
for commit in commit_history:
diff = self.extract_diff(commit)
adapter = self.update_adapter(diff)
self.merge(adapter)
return self.base_model
System Engineering Principles
1. Zero-Inference Overhead Design
Key Principle: Knowledge injection should not increase inference cost.
Implementation:
- Generate adapters offline
- Merge into base model weights
- Standard inference with adapted model
2. Evolution-Aware Architecture
GRU-Based State Maintenance:
- Sequential state updates
- Accumulated repository knowledge
- Handles code drift over time
3. Scalability at Repository Scale
Challenge: Per-repository fine-tuning is costly at scale.
Solution:
- Single hypernetwork serves all repositories
- Efficient adapter generation
- No per-repo training overhead
Implementation Guidelines
Step 1: Prepare Repository Encoder
- Design repository representation
- Encode structure + semantics
- Handle multiple file types
- Test encoding quality
Step 2: Train Hypernetwork
- Collect repository samples
- Train adapter generator
- Validate generated adapters
- Optimize generation speed
Step 3: Static Adapter Generation
- Load repository snapshot
- Generate LoRA adapter
- Merge into base model
- Test on assertion completion
Step 4: Evolution Adapter Setup
- Initialize GRU hidden state
- Process commit history
- Update adapter per diff
- Test on commit-derived tasks
Step 5: Benchmark Evaluation
- Prepare RepoPeftBench datasets
- Evaluate static track (cross-repo/in-repo)
- Evaluate evolution track (commit-derived)
- Compare with PEFT baselines
Performance Metrics
Static Track Results
- Cross-repo exact match: 63.8%
- In-repo exact match: 66.2%
- Matches: Per-repository LoRA upper bound
Evolution Track Results
- Cross-repo exact match: 60.3%
- Improvement: +5.2 pp over single shared LoRA
Benchmark Construction
RepoPeftBench Structure
604 Python repositories with two tracks:
-
Static Track:
- 40K training assertion-completion tasks
- 12K test assertion-completion tasks
- Snapshot-based evaluation
-
Evolution Track:
- 215K commit-derived training tasks
- 87K commit-derived test tasks
- Diff-based evaluation
Task Types
- Assertion completion
- API usage prediction
- Import resolution
- Convention inference
Advantages over Prior Methods
| Method | Inference Overhead | Evolution Support | Scalability |
|---|
| RAG/Dependency Analysis | High (token cost) | Limited | Moderate |
| Per-repo LoRA | Zero | Brittle | Low |
| Shared LoRA | Zero | None | High |
| Code2LoRA | Zero | Strong (Evo) | High |
Limitations
- Hypernetwork training overhead
- Adapter generation speed
- Repository encoder complexity
- GRU state maintenance for Evo mode
Related Work Connections
- LoRA: Low-rank adaptation for LLMs
- PEFT: Parameter-efficient fine-tuning
- Repository-Level Context: Code understanding
- Software Evolution: Code drift handling
Use Cases
1. Repository Comprehension
- Static analysis of stable codebases
- Convention inference
- API usage prediction
2. Active Development Support
- Continuous adaptation during development
- Code diff processing
- Real-time knowledge injection
3. Multi-Repository Management
- Scalable adapter generation
- Zero overhead inference
- Repository-specific customization
4. Assertion Completion
- Training and test tasks
- Cross-repo and in-repo evaluation
- Commit-derived task generation
Activation Keywords
- code LLM adaptation
- repository-specific LoRA
- hypernetwork adapters
- software evolution
- code adaptation
- zero overhead knowledge injection
- GRU-based adapter
- RepoPeftBench
- assertion completion
- code drift handling
References
Notes
- First repository-level PEFT benchmark (RepoPeftBench)
- 604 Python repositories
- 40K + 12K static tasks, 215K + 87K evolution tasks
- Zero inference-time overhead
- Matches per-repo LoRA upper bound (static)
- +5.2 pp improvement over shared LoRA (evo)
Citation
@article{hotsko2026code2lora,
title={Code2LoRA: Hypernetwork-Generated Adapters for Code Language Models under Software Evolution},
author={Hotsko, Liliana and Li, Yinxi and Deng, Yuntian and Nie, Pengyu},
journal={arXiv preprint arXiv:2606.06492},
year={2026}
}