Four-Level Plugin System Architecture
Complete plugin architecture for the Gollek Inference Engine with four levels of extensibility and platform-specific optimization.
π Whatβs New:
- Enhanced Kernel Plugin System v2.0 with ClassLoader isolation, hot-reload, and comprehensive validation. Learn more
- Enhanced Runner Plugin System v2.0 with type-safe operations, lifecycle management, and model management. Learn more
Overview
The Gollek Inference Engine implements a four-level plugin architecture that provides:
- Flexibility: Hot-reload, selective deployment
- Performance: Up to 30x speedup with all optimizations
- Efficiency: 70% code reuse, minimal duplication
- Portability: Platform-specific kernels with auto-detection
- Extensibility: Easy to add new plugins at any level
- Observability: Comprehensive metrics and health monitoring (v2.0)
Enhanced Features (v2.0)
The kernel plugin system has been completely redesigned with production-ready features:
| Feature | v1.0 | v2.0 |
|---|---|---|
| Type Safety | Basic | β Generic operations |
| Lifecycle | Simple | β validate/initialize/health/shutdown |
| Isolation | None | β ClassLoader per plugin |
| Hot-Reload | Limited | β Full support |
| Validation | Basic | β Comprehensive with errors/warnings |
| Error Handling | Generic | β Specific exception hierarchy |
| Metrics | Basic | β Comprehensive observability |
| Configuration | Map-based | β Type-safe with builder |
| CDI Integration | Manual | β Automatic producers |
| Engine Integration | Partial | β Full integration |
Learn more about Enhanced Plugin Architecture β
Complete Architecture
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Application Layer β
β InferenceRequest β Engine β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Gollek Inference Engine β
β - PluginSystemIntegrator β
β - InferenceOrchestrator β
β - Metrics & Monitoring β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Level 1: Runner Plugins β
β ββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββ β
β β GGUF β β Safetensorβ β ONNX β βTensorRT β β
β β (llama) β β (HF) β β (onnx) β β (TRT) β β
β ββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββ β
β ββββββββββββ ββββββββββββ β
β βLibTorch β β TFLite β β
β β(PyTorch) β β (TF) β β
β ββββββββββββ ββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Level 2: Feature Plugins (Optional) β
β ββββββββββββ ββββββββββββ ββββββββββββ β
β β Audio β β Vision β β Text β β
β β Feature β β Feature β β Feature β β
β ββββββββββββ ββββββββββββ ββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Level 3: Optimization Plugins (Optional) β
β ββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββ β
β β FA3 β β FA4 β β Paged β β Prompt β β
β β β β β β Attentionβ β Cache β β
β ββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Level 4: Kernel Plugins (Platform-Specific) β
β ββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββ β
β β CUDA β β ROCm β β Metal β β DirectML β β
β β (NVIDIA) β β (AMD) β β (Apple) β β(Windows) β β
β ββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Native Backends β
β cuBLAS | rocBLAS | Metal Performance Shaders | DML β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Plugin Levels
Level 1: Runner Plugins
Purpose: Model format support
Available Runners: | Runner | Format | Backend | GPU Support | Size | |βββ|βββ|βββ|ββββ-|ββ| | GGUF | .gguf | llama.cpp | β CUDA/Metal | ~500 MB | | Safetensor | .safetensors | Direct/GGUF | β CUDA/MPS | ~20 GB | | ONNX | .onnx | ONNX Runtime | β Multi | ~800 MB | | TensorRT | .engine | TensorRT | β NVIDIA | ~2 GB | | LibTorch | .pt/.bin | PyTorch | β CUDA | ~3 GB | | TFLite | .litertlm | TensorFlow Lite | β GPU | ~500 MB |
Integration:
@Inject
RunnerPluginManager runnerManager;
// Auto-detect format and select runner
Optional<RunnerSession> session = runnerManager.createSession(
"models/llama-3-8b.gguf",
config
);
Level 2: Feature Plugins
Purpose: Domain-specific capabilities
Available Features: | Feature | Capabilities | Models | Size | |βββ|ββββ-|βββ|ββ| | Audio | STT, TTS | Whisper, SpeechT5 | ~52 MB | | Vision | Classification, Detection | CLIP, ViT, DETR | ~800 MB | | Text | LLM, Classification | Llama, Mistral, BERT | ~15 GB |
Integration:
@Inject
FeaturePluginManager featureManager;
// Enable specific features
Map<String, Object> config = Map.of(
"features", Map.of(
"audio", Map.of("enabled", true),
"vision", Map.of("enabled", false)
)
);
Level 3: Optimization Plugins
Purpose: Performance enhancements
Available Optimizations: | Optimization | Speedup | Compatible Runners | GPU Requirement | |βββββ|βββ|ββββββ-|ββββββ| | FlashAttention-3 | 2-3x | Safetensor, LibTorch | Hopper (CC 9.0+) | | FlashAttention-4 | 3-5x | Safetensor, LibTorch | Blackwell (CC 10.0+) | | PagedAttention | 2-4x | GGUF, Safetensor, LibTorch | Any CUDA | | Prompt Cache | 5-10x* | GGUF, Safetensor, ONNX | Any |
*For repeated prompts
Integration:
@Inject
OptimizationPluginManager optimizationManager;
// Apply optimizations based on hardware
Map<String, Object> config = Map.of(
"optimizations", Map.of(
"flash-attention-3", Map.of("enabled", true),
"paged-attention", Map.of("enabled", true)
)
);
Level 4: Kernel Plugins
Purpose: Platform-specific GPU kernels
Available Kernels: | Kernel | Platform | GPU Vendor | OS | Size | |βββ|βββ-|ββββ|β-|β-| | CUDA | CUDA | NVIDIA | Linux/Windows | ~50 MB | | ROCm | ROCm | AMD | Linux | ~40 MB | | Metal | Metal | Apple | macOS | ~30 MB | | DirectML | DirectML | Any | Windows | ~35 MB |
Auto-Detection:
// Auto-detect platform
String platform = KernelPlugin.autoDetectPlatform();
// Returns: "cuda", "rocm", "metal", "directml", or "cpu"
// Load only kernel for detected platform
kernelManager.initialize();
Engine Integration
PluginSystemIntegrator
The PluginSystemIntegrator coordinates all four plugin levels:
@ApplicationScoped
public class PluginSystemIntegrator {
@PostConstruct
public void initialize() {
// Initialize in order (bottom-up)
initializeKernelPlugins(); // Level 4
initializeOptimizationPlugins(); // Level 3
initializeFeaturePlugins(); // Level 2
initializeRunnerPlugins(); // Level 1
logPluginStatus();
}
}
Initialization Order
- Level 4 - Kernel Plugins: Auto-detect platform, load appropriate kernel
- Level 3 - Optimization Plugins: Check hardware compatibility, apply optimizations
- Level 2 - Feature Plugins: Initialize domain-specific capabilities
- Level 1 - Runner Plugins: Initialize model format support
Shutdown Order (Reverse)
- Level 1 - Runner Plugins
- Level 2 - Feature Plugins
- Level 3 - Optimization Plugins
- Level 4 - Kernel Plugins
Configuration
Complete Configuration Example
gollek:
engine:
plugin-system:
enabled: true
auto-detect: true
# Level 4: Kernel Plugins
kernels:
auto-detect: true
cuda:
enabled: true
device_id: 0
memory_fraction: 0.9
# Level 3: Optimization Plugins
optimizations:
flash-attention-3:
enabled: true
tile_size: 128
paged-attention:
enabled: true
block_size: 16
prompt-cache:
enabled: true
max_cache_size_gb: 8
# Level 2: Feature Plugins
features:
audio:
enabled: true
default_model: whisper-large-v3
vision:
enabled: false
text:
enabled: true
default_model: llama-3-8b
# Level 1: Runner Plugins
runners:
gguf-runner:
enabled: true
n_gpu_layers: -1
n_ctx: 4096
safetensor-runner:
enabled: true
backend: direct
onnx-runner:
enabled: false
Performance
Complete Stack Performance (H100)
| Configuration | Tokens/s | VRAM | Speedup |
|---|---|---|---|
| CPU Only (Baseline) | 20 | 16 GB | 1.0x |
| + CUDA Kernel | 100 | 16 GB | 5.0x |
| + FlashAttention-3 | 280 | 16 GB | 14.0x |
| + PagedAttention | 350 | 13 GB | 17.5x |
| + Prompt Cache* | 500 | 18 GB | 25.0x |
| All Combined | 600 | 14 GB | 30.0x |
*For cached prompts
Deployment Size
| Scenario | Components | Size | Reduction |
|---|---|---|---|
| Edge (CPU) | GGUF + Text + Prompt Cache | 6 GB | 74% |
| Audio Service | Safetensor + Audio + CUDA | 52 MB | 99.8% |
| LLM Service | GGUF + Text + PagedAttn + CUDA | 6 GB | 74% |
| Multi-Modal | Safetensor + All Features + FA3 + CUDA | 15 GB | 34% |
| Full Dev | All plugins | 22.7 GB | 0% |
Monitoring
Plugin Status
# Get plugin system status
curl http://localhost:8080/api/v1/plugins/status
# Response:
{
"initialized": true,
"fully_operational": true,
"levels": {
"kernel": {
"enabled": true,
"active_platform": "cuda"
},
"optimization": {
"enabled": true,
"active_optimizations": ["flash-attention-3", "paged-attention"]
},
"feature": {
"enabled": true,
"active_features": ["audio", "text"]
},
"runner": {
"enabled": true,
"active_runners": ["gguf-runner", "safetensor-runner"]
}
}
}
Health Checks
# Get health status for all levels
curl http://localhost:8080/api/v1/plugins/health
# Response:
{
"kernel": {
"cuda": { "healthy": true, "available": true }
},
"optimization": {
"flash-attention-3": { "healthy": true },
"paged-attention": { "healthy": true }
},
"feature": {
"audio": { "healthy": true },
"text": { "healthy": true }
},
"runner": {
"gguf-runner": { "healthy": true },
"safetensor-runner": { "healthy": true }
}
}
Creating Custom Plugins
Level 1: Custom Runner Plugin
public class CustomRunnerPlugin implements RunnerPlugin {
@Override
public String id() { return "custom-runner"; }
@Override
public Set<String> supportedFormats() {
return Set.of(".custom");
}
@Override
public RunnerSession createSession(String modelPath, Map<String, Object> config) {
return new CustomRunnerSession(modelPath, config);
}
}
Level 2: Custom Feature Plugin
public class CustomFeaturePlugin implements SafetensorFeaturePlugin {
@Override
public String id() { return "custom-feature"; }
@Override
public Set<String> supportedModels() {
return Set.of("custom-model");
}
@Override
public Object process(Object input) {
return processCustom(input);
}
}
Level 3: Custom Optimization Plugin
public class CustomOptimizationPlugin implements OptimizationPlugin {
@Override
public String id() { return "custom-opt"; }
@Override
public Set<String> compatibleRunners() {
return Set.of("gguf-runner", "safetensor-runner");
}
@Override
public boolean apply(OptimizationContext context) {
return applyOptimization(context);
}
}
Level 4: Custom Kernel Plugin
public class CustomKernelPlugin implements KernelPlugin {
@Override
public String id() { return "custom-kernel"; }
@Override
public String platform() { return "custom"; }
@Override
public boolean isAvailable() {
return customHardwareAvailable();
}
@Override
public Object execute(String operation, Map<String, Object> params) {
return executeCustom(operation, params);
}
}
Troubleshooting
Plugin Not Loading
Error: Plugin not found: custom-runner
Solution:
- Check if plugin JAR is in
~/.gollek/plugins/ - Verify plugin manifest:
unzip -p plugin.jar META-INF/MANIFEST.MF - Check logs:
tail -f ~/.gollek/logs/gollek.log | grep plugin
Platform Detection Failed
Warning: No available kernel for platform cuda, falling back to CPU
Solution:
- Verify GPU is present:
nvidia-smi - Check drivers are installed
- Verify CUDA installation:
nvcc --version
Optimization Not Applied
Warning: FlashAttention-3 not applied - GPU not compatible
Solution:
- Check GPU architecture:
nvidia-smi --query-gpu=compute_cap - Verify compute capability >= 9.0 for FA3
- Check logs for details
Resources
- Plugin System Guide: Four-Level Plugin System
- Runner Plugins: Runner Plugin Documentation
- Feature Plugins: Feature Plugin Documentation
- Optimization Plugins: Optimization Plugin Documentation
- Kernel Plugins: Kernel Plugin Documentation
- Engine Integration: Engine Integration Guide
Back to Architecture Β Runner Plugins Β Feature Plugins Β Optimization Plugins