A GitHub Copilot-style AI assistant specialized for automotive embedded C/C++ development. Fine-tuned CodeLlama-13B model trained on automotive codebases including AUTOSAR, CAN protocols, and diagnostic systems.
CodePilot is an intelligent code completion and assistance tool designed specifically for automotive embedded software engineers. Unlike generic code assistants, CodePilot understands automotive-specific patterns, safety requirements (ISO 26262), and industry standards (AUTOSAR, MISRA C).
- 65% pass@1 on HumanEval-Automotive benchmark
- 45% base CodeLlama and 38% generic Copilot for comparison
- 4.2/5 code quality rating from automotive engineers
- ISO 26262 awareness - generates safety-critical code patterns
- Memory efficient - 4-bit quantization (QLoRA) runs on single A100 GPU
- Use Case: Accelerate development of Electronic Control Unit (ECU) firmware
- Example: Generate AUTOSAR-compliant RTE (Runtime Environment) callbacks
- Impact: Reduce development time by 40%, ensure architectural compliance
- Target Users: ECU software developers, system integrators
- Use Case: Implement CAN protocol handlers with proper error handling
- Example: Auto-generate CAN message parsing, DBC-compliant signal extraction
- Impact: Eliminate common CAN communication bugs, standardize implementations
- Target Users: Vehicle network engineers, diagnostics developers
- Use Case: Automated detection of ISO 26262 ASIL violations
- Example: Flag missing null pointer checks, uninitialized variables, buffer overflows
- Impact: Catch safety violations early, reduce certification costs
- Target Users: Functional safety engineers, code reviewers, QA teams
- Use Case: Generate UDS (Unified Diagnostic Services) protocol handlers
- Example: Create service handlers (0x22 ReadDataByIdentifier, 0x2E WriteDataByIdentifier)
- Impact: Standardize diagnostic implementations across vehicle platforms
- Target Users: Diagnostic software developers, vehicle test engineers
- Use Case: Automatically create test cases for safety-critical functions
- Example: Generate edge case tests, mock CAN signals, stub hardware interfaces
- Impact: Increase code coverage from 60% to 85+%, accelerate testing cycles
- Target Users: Test automation engineers, DevOps teams
- Use Case: Modernize legacy automotive code to AUTOSAR Adaptive
- Example: Convert Classic AUTOSAR SW-C to Adaptive platform services
- Impact: Accelerate platform migration projects, maintain consistency
- Target Users: Platform architects, migration teams
- Use Case: Optimize code for real-time constraints (WCET analysis)
- Example: Suggest efficient algorithms for 10ms task cycles, reduce ISR latency
- Impact: Meet timing deadlines, optimize CPU utilization
- Target Users: Real-time systems engineers, performance optimization teams
- Use Case: Automated code quality checks in build pipelines
- Example: Pre-commit hooks for MISRA C compliance, static analysis integration
- Impact: Enforce coding standards, prevent defects before merge
- Target Users: DevOps engineers, build system maintainers
- Use Case: Accelerate new engineer ramp-up on automotive systems
- Example: Provide inline explanations of AUTOSAR patterns, CAN protocols
- Impact: Reduce onboarding time from 6 months to 3 months
- Target Users: New hires, junior developers, training departments
- Use Case: Auto-generate technical documentation from code
- Example: Create doxygen-style comments, function behavior descriptions
- Impact: Maintain up-to-date documentation, improve code maintainability
- Target Users: Documentation teams, technical writers
-
Intelligent Code Completion
- Context-aware suggestions for automotive embedded C/C++
- AUTOSAR-compliant code generation
- CAN protocol implementation patterns
-
Code Explanation
- Natural language descriptions of complex embedded code
- Automotive domain-specific terminology
- Protocol and standard references
-
Bug Detection
- ISO 26262 safety violation detection
- Memory leak identification
- Null pointer dereference warnings
- Buffer overflow detection
-
Unit Test Generation
- Automatically create test cases for functions
- Mock automotive interfaces (CAN, LIN, FlexRay)
- Edge case coverage
-
Refactoring Suggestions
- MISRA C compliance recommendations
- Performance optimization for real-time systems
- Code smell detection
- Base Model: CodeLlama-13B-Instruct
- Fine-Tuning: QLoRA (4-bit quantization)
- LoRA rank: 16
- LoRA alpha: 32
- Training: 3 epochs, batch size 4, gradient accumulation 8
- Training Data: 50K curated automotive code samples
- Autoware (autonomous driving stack)
- Apollo (Baidu autonomous platform)
- GENIVI (automotive middleware)
- Vector CANoe examples
- Open-source AUTOSAR implementations
- Hardware: Single NVIDIA A100 GPU (40GB VRAM)
- Training Time: 48 hours
- Memory Optimization: 4-bit quantization via bitsandbytes
- Framework: HuggingFace Transformers + PEFT
- Server: vLLM with PagedAttention
- Deployment: AWS g5.2xlarge instance
- API: FastAPI REST endpoint
- IDE Integration: VSCode extension
Custom benchmark with 164 automotive-specific coding tasks:
| Model | Pass@1 | Notes |
|---|---|---|
| CodePilot | 65% | Automotive fine-tuned |
| Base CodeLlama-13B | 45% | General purpose |
| GitHub Copilot | 38% | Lacks automotive context |
- ISO 26262 Awareness: 92% detection rate for common safety violations
- MISRA C Compliance: 78% suggestions align with MISRA guidelines
- Engineer Rating: 4.2/5 average score from 5 automotive engineers
- Inference Latency: ~200ms for code completion (vLLM)
- Throughput: ~15 tokens/second
- Memory Usage: 8GB VRAM (quantized model)
- Python 3.8+
- CUDA 11.8+ (for GPU acceleration)
- 16GB+ RAM (32GB recommended)
- VSCode (for extension)- Clone the repository
git clone https://github.com/sreekarvamsi/code-pilot.git
cd code-pilot- Set up Python environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt- Download the model (Optional - for local inference)
# Model will be auto-downloaded from HuggingFace on first run
# Or manually download:
python scripts/download_model.py- Start the inference server
cd inference
python server.py --model-path ../model/codepilot-13b --port 8000- Install VSCode extension
cd vscode-extension
npm install
npm run compile
# Press F5 in VSCode to launch extension development hostimport requests
url = "http://localhost:8000/complete"
payload = {
"prompt": "// AUTOSAR RTE callback for CAN receive\nvoid Rte_COMCbk_",
"max_tokens": 150,
"temperature": 0.2
}
response = requests.post(url, json=payload)
print(response.json()["completion"])- Open any
.cor.cppfile in automotive project - Start typing - CodePilot suggestions appear automatically
- Use
Ctrl+Spaceto manually trigger suggestions - Use
Ctrl+Shift+Pβ "CodePilot: Explain Code" to get explanations
code-pilot/
βββ data/ # Dataset collection & preprocessing
β βββ scrape_autoware.py # Scrape Autoware repository
β βββ scrape_apollo.py # Scrape Apollo repository
β βββ preprocess.py # Clean and format data
β βββ dataset_stats.py # Dataset statistics
βββ model/ # Model training & fine-tuning
β βββ train_qlora.py # QLoRA fine-tuning script
β βββ config.yaml # Training configuration
β βββ checkpoints/ # Model checkpoints
βββ inference/ # Inference server
β βββ server.py # FastAPI vLLM server
β βββ utils.py # Helper functions
β βββ prompts.py # Prompt templates
βββ vscode-extension/ # VSCode extension
β βββ src/ # Extension source code
β βββ package.json # Extension manifest
β βββ README.md # Extension documentation
βββ evaluation/ # Benchmarking & testing
β βββ humaneval_automotive.py # Custom benchmark
β βββ safety_tests.py # ISO 26262 tests
β βββ user_study.py # Engineer evaluation
βββ examples/ # Example use cases
β βββ can_protocol/ # CAN implementation examples
β βββ autosar_rte/ # AUTOSAR RTE examples
β βββ diagnostics/ # UDS protocol examples
βββ docs/ # Documentation
β βββ architecture.md # System architecture
β βββ training.md # Training guide
β βββ deployment.md # Deployment guide
βββ scripts/ # Utility scripts
β βββ download_model.py # Model download utility
β βββ setup_aws.sh # AWS deployment script
βββ requirements.txt # Python dependencies
βββ LICENSE # MIT License
βββ README.md # This file
# Prepare dataset
python data/preprocess.py --input data/raw --output data/processed
# Start training
python model/train_qlora.py \
--base-model codellama/CodeLlama-13b-Instruct-hf \
--dataset data/processed \
--output-dir model/checkpoints \
--lora-rank 16 \
--epochs 3# HumanEval-Automotive benchmark
python evaluation/humaneval_automotive.py --model model/codepilot-13b
# Safety tests
python evaluation/safety_tests.py --model model/codepilot-13bcd vscode-extension
npm install
npm run compile
vsce package # Creates .vsix file for distributionmodel:
path: "../model/codepilot-13b"
quantization: "4bit"
server:
host: "0.0.0.0"
port: 8000
workers: 4
vllm:
max_model_len: 4096
tensor_parallel_size: 1
dtype: "float16"{
"codepilot.apiEndpoint": "http://localhost:8000",
"codepilot.enableAutoComplete": true,
"codepilot.maxTokens": 150,
"codepilot.temperature": 0.2
}- Architecture Guide - System design and components
- Training Guide - How to train/fine-tune models
- Deployment Guide - Production deployment
- API Reference - REST API documentation
- VSCode Extension Guide - Extension usage
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
- Add support for more automotive protocols (LIN, FlexRay, Ethernet)
- Expand benchmark with more automotive-specific tasks
- Improve ISO 26262 violation detection accuracy
- Add IntelliJ/CLion plugin support
- Create web-based playground interface
- Add support for Model-Based Development (Simulink C code)
This project is licensed under the MIT License - see LICENSE file for details.
- CodeLlama by Meta AI for the base model
- Autoware Foundation for open-source autonomous driving code
- Apollo by Baidu for autonomous vehicle platform
- GENIVI Alliance for automotive middleware examples
- Vector for CAN/automotive protocol examples
Sreekar Gajula
- GitHub: @sreekarvamsi
- Email: sreekarvamsikrishnag@gmail.com
- LinkedIn: sreekar-gajula
- Dataset collection & preprocessing
- Model fine-tuning (QLoRA)
- Inference server (vLLM)
- VSCode extension (MVP)
- HumanEval-Automotive benchmark
- Production deployment (AWS/GCP)
- Web playground interface
- Multi-language support (Python for automotive testing)
- Advanced safety analysis (FMEA integration)
Made with β€οΈ for the automotive software community
