Skip to content

Commit c9cef85

Browse files
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

7 files changed

+752
-0
lines changed

CODEOWNERS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,12 @@
8787
/src/llama-graph.* @CISC
8888
/src/llama-model-loader.* @slaren
8989
/src/llama-model.* @CISC
90+
/src/llama-model/architectures/llama.cpp @CISC
91+
/src/llama-model/architectures/qwen2.cpp @CISC
92+
/src/llama-model/architectures/gemma.cpp @CISC
93+
/src/llama-model/loading/ @slaren
94+
/src/llama-model/registry/ @CISC
95+
/src/llama-model/interfaces/ @CISC
9096
/src/llama-vocab.* @CISC
9197
/tests/ @ggerganov
9298
/tests/test-backend-ops.cpp @slaren

0 commit comments

Comments
 (0)