Skip to content

Conversation

@mikepapadim
Copy link
Member

No description provided.

Copilot AI review requested due to automatic review settings October 28, 2025 10:04
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors model loaders and state field allocators to eliminate code duplication and improve maintainability using Template Method and Abstract Factory design patterns.

Key Changes:

  • Introduced AbstractModelLoader base class implementing Template Method pattern, reducing model loader code by ~60%
  • Created StateFieldAllocator abstract factory hierarchy to centralize state field allocation logic, reducing state class code by ~60-66%
  • Removed AOT (Ahead-of-Time) compilation support and related code
  • Added comprehensive architecture documentation (1,229 lines) covering project structure, patterns, and design principles

Reviewed Changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
AbstractModelLoader.java New abstract base class implementing Template Method pattern for model loading workflow
StateFieldAllocator.java New abstract factory for state field allocation with model-specific dimension calculations
Qwen3ModelLoader.java Refactored to extend AbstractModelLoader, implementing model-specific methods
Qwen2ModelLoader.java Refactored to extend AbstractModelLoader, implementing model-specific methods
Phi3ModelLoader.java Refactored to extend AbstractModelLoader, implementing model-specific methods
LlamaModelLoader.java Refactored to extend AbstractModelLoader, implementing model-specific methods
MistralModelLoader.java Refactored to extend AbstractModelLoader, implementing model-specific methods
ModelLoader.java Removed AOT-related code
ModelLoadException.java New exception class for model loading failures
Qwen3State.java Simplified to delegate allocation to Qwen3StateFieldAllocator
Qwen2State.java Simplified to delegate allocation to Qwen2StateFieldAllocator
Phi3State.java Simplified to delegate allocation to Phi3StateFieldAllocator
LlamaState.java Simplified to delegate allocation to LlamaStateFieldAllocator
Qwen3StateFieldAllocator.java New allocator implementing Qwen3-specific dimension calculations
Qwen2StateFieldAllocator.java New allocator implementing Qwen2-specific dimension calculations
Phi3StateFieldAllocator.java New allocator implementing Phi3-specific dimension calculations
LlamaStateFieldAllocator.java New allocator implementing Llama/Mistral dimension calculations
AOT.java Removed AOT compilation support
LlamaApp.java Removed AOT import
ARCHITECTURE.md New comprehensive architecture documentation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 33 to 35
protected StateFields createStateFields(Configuration config) {
StateFieldAllocator allocator = new Qwen3StateFieldAllocator(config, localSize);
return allocator.allocateFields();
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The StateFieldAllocator is created on every call to createStateFields(). Since State objects are reused during inference and createStateFields() is called during initialization, consider caching the allocator instance if createStateFields() could be called multiple times, or document that this is a one-time initialization method.

Copilot uses AI. Check for mistakes.
…ity and configuration handling.

# Conflicts:
#	src/main/java/org/beehive/gpullama3/model/loader/Phi3ModelLoader.java
#	src/main/java/org/beehive/gpullama3/model/loader/Qwen2ModelLoader.java
#	src/main/java/org/beehive/gpullama3/model/loader/Qwen3ModelLoader.java
Copilot AI review requested due to automatic review settings November 5, 2025 13:28
@orionpapadakis orionpapadakis force-pushed the refactor/cleanup_model_loaders branch from 27a764b to 8a08dd3 Compare November 5, 2025 13:28
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@orionpapadakis orionpapadakis force-pushed the refactor/cleanup_model_loaders branch from 8a08dd3 to eb13ea7 Compare November 6, 2025 14:27
@mikepapadim mikepapadim merged commit 6367a00 into beehive-lab:main Nov 6, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants