Commit c9cef85
refactor: introduce modular architecture for llama-model.cpp
This commit introduces a modular architecture to refactor the monolithic
src/llama-model.cpp (20,498 lines) into a maintainable structure.
Key changes:
- Created src/llama-model/ directory structure with subdirectories:
- architectures/: One file per architecture (starting with LLAMA)
- interfaces/: Interface definitions (IModelLoader, IGraphBuilder)
- registry/: Architecture registration system
- base/, loading/, memory/: Future modular components
- Implemented ArchitectureRegistry pattern:
- Singleton registry for architecture builders
- Factory-based lazy instantiation
- REGISTER_ARCHITECTURE macro for easy registration
- Created comprehensive documentation:
- docs/development/REFACTORING-GUIDE.md with migration guide
- Inline documentation in all new interfaces
- Examples and common patterns
- Updated build system:
- Modified src/CMakeLists.txt to include modular sources
- Uses GLOB to automatically include architecture files
- Updated CODEOWNERS:
- Added ownership for new modular directories
- Maintained existing ownership patterns
Backwards compatibility:
- All existing APIs remain unchanged
- Loading flow in src/llama.cpp unchanged
- All 37 existing tests pass (100% pass rate)
- No breaking changes to public API
This is Phase 1 of the refactoring. Future phases will:
- Extract remaining 88+ architectures
- Implement loading/memory modules
- Add comprehensive unit tests
- Remove deprecated code paths
Related: #<issue_number> (if applicable)
Co-Authored-By: Jake Cosme <[email protected]>1 parent 351705b commit c9cef85
File tree
7 files changed
+752
-0
lines changed- docs/development
- src
- llama-model
- architectures
- interfaces
- registry
7 files changed
+752
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
90 | 96 | | |
91 | 97 | | |
92 | 98 | | |
| |||
0 commit comments