Developer Guidance
Operational guidance for benchmarking, CI gates, and rollout safety.
Latest Strict Gate Status
Benchmark Workflow
Use three profiles consistently:
baselinehybrid-fp8-bf16sageattention2-intent
Run with:
bench-multilora-zipf.shfor a single profilebench-matrix-advanced.shfor full matrix + gate evaluationbench-compare.shfor baseline-vs-candidate delta reports
CI Modes
- Smoke (
bench-matrix-smoke.yml)- deterministic mock-backed check
- safe default for PR merge protection
- Strict (
bench-matrix-strict.yml)- manual run against real endpoints
- preferred before release cut
- emits trend artifacts (
trends/matrix-gates.csv,trends/matrix-gates.json) in each run - emits gate alert artifacts (
gate-alert.txt,gate-alert.md) in each run - can send optional webhook alert on failure (
GOLLEK_BENCH_ALERT_WEBHOOK)
Gate Guidance
Default hybrid gate targets:
- throughput uplift:
>= 20%(req/sortokens/s) - latency p95 regression:
<= 10% - absolute error-rate regression:
<= 0.005
Runtime-tag policy:
--runtime-tag-gate auto|on|off- recommended:
onfor strict runs,autofor mixed environments
Metal Runner Modes (Apple Silicon)
Metal runners are controlled with a single mode flag that supports auto-detect and manual forcing:
gollek.runners.metal.enabled=true
gollek.runners.metal-offload.enabled=true
gollek.runners.metal.mode=auto # auto|standard|offload|force|disabled
Behavior:
auto: detect availability and pick standard vs offload based on model size vs unified memorystandard: force the in-memory Metal runneroffload: force the weight-offload runnerforce: keep Metal runners active even when detection failsdisabled: remove Metal runners from selection
Configuration sources:
gollek.runners.metal.modeviaGOLLEK_METAL_MODEenv vargollek.runners.metal.enabledviaGOLLEK_METAL_ENABLEDenv vargollek.runners.metal-offload.enabledviaGOLLEK_METAL_OFFLOAD_ENABLEDenv var
Engine device preference (routing defaults):
gollek.engine.device.preference=auto|metal|cuda|cpu|none(default:auto)autosetspreferredDevice=METALon Apple Silicon, otherwise no preference- Request override (default on):
device=metal|cuda|cpu|rocm|tpu|npuin request parameters - Disable request overrides:
gollek.engine.device.preference.allow-request-override=false
Runner auto-Metal toggles:
- GGUF:
gguf.provider.gpu.auto-metal=trueandgguf.provider.gpu.auto-metal.layers=-1 - GGUF:
gguf.provider.coalesce.enabled=true,gguf.provider.coalesce.window-ms=3,gguf.provider.coalesce.seq-max=1(setseq-max > 1to enable multi-sequence micro-batching)- Metrics:
gollek.gguf.coalesce.seq.max,gollek.gguf.coalesce.seq.avg,gollek.gguf.coalesce.seq.total
- Metrics:
- GGUF Converter: set
dryRun=trueon/v1/converter/gguf/convertto resolve paths without converting. - GGUF Converter:
POST /v1/converter/gguf/convert/previewresolves paths without converting and returnsderivedOutputName,inputBasePath, andoutputBasePath. - CLI:
gollek convert --input ~/models/llama-2-7b --output ~/conversions --quant q4_k_m - LiteRT:
litert.provider.gpu.auto-metal=true - LibTorch:
libtorch.provider.gpu.auto-mps-enabled=true - ONNX Runtime:
onnx.runner.execution_provider=coreml(Apple Silicon CoreML EP) - Global Metal switches (
gollek.runners.metal.enabled=falseorgollek.runners.metal.mode=disabled) also disable ONNX CoreML. - CoreML smoke test (optional): set
gollek.onnx.library-path=/path/to/libonnxruntime.dyliband run the ONNX module tests. - ONNX device selection tests cover:
~/.gollek/libs/fallback whengollek.runners.onnx.library-pathis missing.- Apple Silicon +
coreMlAvailable=trueexposesDeviceType.METAL.
- Hugging Face ONNX integration test (optional):
set
GOLLEK_ONNX_HF_REPO,GOLLEK_ONNX_LIBRARY_PATH(must point to a real ONNX Runtime library), and optionallyGOLLEK_HF_TOKENorHF_TOKENif the repo is gated, then run the ONNX module tests. To make the test fail instead of skipping on network/404/401, setGOLLEK_ONNX_HF_REQUIRED=true. You can also enable strict mode via Maven:mvn -f gollek/extension/runner/onnx/gollek-runner-onnx/pom.xml -Phf-integration-required test. If strict mode fails with DNS errors, check local DNS/VPN/proxy settings or run in non-strict mode. Quick ONNX test matrix:- Optional integration:
GOLLEK_ONNX_HF_REPO=onnx-community/tiny-random-bert - Required integration:
GOLLEK_ONNX_HF_REPO=... GOLLEK_ONNX_HF_REQUIRED=true - Library path:
GOLLEK_ONNX_LIBRARY_PATH=~/.gollek/libs/libonnxruntime.dylib - Tokens (if gated):
GOLLEK_HF_TOKEN=$HF_TOKEN
- Optional integration:
CLI Native Build (GraalVM):
- Build:
mvn -f inference-gollek/ui/gollek-cli/pom.xml -Pnative -DskipTests clean package - Output binary:
inference-gollek/ui/gollek-cli/target/gollek - Temp directory override (sandbox-friendly):
-H:TempDirectory=/tmp(already wired in CLI build args) - File logging toggle:
- Disable file logging:
GOLLEK_CLI_FILE_LOG_ENABLED=false - Override log path:
GOLLEK_CLI_LOG_FILE=/tmp/gollek/cli.log - Default path:
~/.gollek/logs/cli.log
- Disable file logging:
- CLI run example:
GOLLEK_CLI_FILE_LOG_ENABLED=false inference-gollek/ui/gollek-cli/target/gollek --help
- Native CLI wrapper (cleans deprecated env keys):
inference-gollek/ui/gollek-cli/scripts/run-native.sh --help
SafeTensors provider:
- Default backend is
auto, which prefers GGUF conversion (fast, Metal-aware) when the converter is available. - Configure backend explicitly:
safetensor.provider.backend=auto|gguf|libtorch. - Conversion output directory:
safetensor.provider.ggufOutputDir=~/.gollek/models/gguf/converted. - GGUF conversion uses the built-in Java converter in
gollek/extension/runner/gguf/gollek-gguf-converter. - Install ONNX Runtime (prebuilt):
make -C gollek/extension/runner/onnx/gollek-runner-onnx/src/main/cpp/onnxruntime install(copieslibonnxruntime.*into~/.gollek/libs/which the runner will auto-detect if the configured path is missing).
LiteRT (TFLite):
- Base path for
.litertlmmodels:litert.provider.model.base-path=~/.gollek/models/litert - LiteRT module tests:
mvn -f gollek/extension/runner/litert/gollek-runner-litert/pom.xml test - Optional real-model integration test:
LITERT_LIBRARY_PATH=~/.gollek/libs/libtensorflowlite_c.dylibGOLLEK_TFLITE_MODEL_URL=https://storage.googleapis.com/download.tensorflow.org/models/mobilenet_v1_2018_08_02/mobilenet_v1_1.0_224_quant.litertlm- Strict mode:
GOLLEK_TFLITE_REQUIRED=true(fails instead of skip on download errors) - The LiteRT loader auto-searches
~/.gollek/libs/forlibtensorflowlite_c.*if no override is set.
- Sample model helper:
bash gollek/extension/runner/litert/gollek-runner-litert/scripts/download-sample-model.sh
- LiteRT runtime helper:
bash gollek/extension/runner/litert/gollek-runner-litert/scripts/download-litert-runtime.sh- Optional:
GOLLEK_TFLITE_RUNTIME_URL=https://.../libtensorflowlite_c.dylibto download directly
- GitHub Releases auto-download (if assets are published):
GOLLEK_LITERT_RUNTIME_REPO=bhangun/gollekGOLLEK_LITERT_RUNTIME_RELEASE=latestGOLLEK_LITERT_RUNTIME_ASSET=litert-runtime-macos-arm64.tar.gz- Asset naming details:
gollek/extension/runner/litert/gollek-runner-litert/docs/RELEASE_ASSETS.md - Release checklist:
gollek/extension/runner/litert/gollek-runner-litert/docs/RELEASE_CHECKLIST.md - Release notes template:
gollek/extension/runner/litert/gollek-runner-litert/docs/RELEASE_NOTES_TEMPLATE.md - GitHub Actions workflow:
.github/workflows/litert-runtime-release.yml - Build + release workflow:
.github/workflows/litert-runtime-build-and-release.yml
- Make targets:
make litert-samplemake litert-runtimemake litert-runtime-package
Release How-To (LiteRT runtime assets):
- Build or obtain
libtensorflowlite_c.*for each target OS/arch. - Package with
make litert-runtime-package(producesdist/litert-runtime-*.tar.gz). - Upload assets to a GitHub release (manual or via
LiteRT Runtime Releaseworkflow). - Verify download + smoke test using the commands in the release checklist.
Diagnostics:
- Auto mode will skip offload when the model fits unified memory.
- Force mode keeps Metal runners active even if detection reports unavailable.
- If Metal is unavailable and mode is not
force, the Metal runners are removed from selection. - Build/install note:
make -C gollek/extension/kernel/gollek-backend-metal/src/main/cpp/metal installcopieslibgollek_metal.dylibto~/.gollek/libs/(and resources for packaging).
Decision flow (auto + manual):
flowchart TD
A["Start"] --> B["Read gollek.runners.metal.mode"]
B --> C{"Mode = disabled?"}
C -->|Yes| X["Disable all Metal runners"]
C -->|No| D{"Metal available?"}
D -->|No| E{"Mode = force?"}
E -->|Yes| F["Keep Metal runners (forced)"]
E -->|No| X
D -->|Yes| G{"Mode = standard?"}
G -->|Yes| H["Select standard Metal only"]
G -->|No| I{"Mode = offload?"}
I -->|Yes| J["Select offload Metal only"]
I -->|No| K["Auto: estimate model vs unified memory"]
K -->|Fits| H
K -->|Does not fit| J
Example logs:
INFO [MetalRunner] Metal runner enabled (mode=auto, metalAvailable=true)
INFO [MetalWeightOffloadingRunner] Metal offload skipped (auto) — model fits in unified memory
GPU smoke test (Apple Silicon only):
- Opt-in by setting
-Dgollek.metal.tests=true - Optional strict mode:
-Dgollek.metal.tests.strict=true(fails on Metal init errors instead of skipping) - Provide the dylib path via
-Dgollek.metal.library-path=/path/to/libgollek_metal.dylib,-Dgollek.runners.metal.library-path=..., orGOLLEK_METAL_LIBRARY_PATH - Default search paths:
~/.gollek/libs/libgollek_metal.dylib,/usr/local/lib/libgollek_metal.dylib,/Library/Gollek/libgollek_metal.dylib - The test skips automatically if Metal is unavailable or the dylib is missing
- Headless CI can report
No Metal device found; run on a logged-in desktop session for GPU validation. - CI/profile shortcut:
mvn -f gollek/extension/kernel/gollek-backend-metal/pom.xml -Pmetal-gpu-tests test - JVM note: the profile sets
--enable-native-access=ALL-UNNAMEDto satisfy FFM access.
Troubleshooting checklist:
- Metal not selected: confirm
gollek.runners.metal.enabled=trueand the device is Apple Silicon. - Metal unavailable in logs: set
gollek.runners.metal.mode=forceto test manual override. - Offload never used: try a larger model or set
gollek.runners.metal.mode=offload. - Unexpected CPU fallback: verify other runners are enabled and the Metal mode is not
disabled. No Metal device found: run tests in a logged-in desktop session (headless CI may not expose Metal).
Build note:
- If you see
class not founderrors after moving SPI types, run a clean build to clear stale reactor output:mvn -f gollek/pom.xml clean install.
Failure Triage
When matrix fails:
- Open
gate-summary.txtfirst. - Map failure to gate type:
- throughput
- latency
- error
- SA2 runtime tag
- Use
compare/report.txtandresults.csvto isolate impact. - Roll back to baseline flags if regression is user-visible.
Update website badge data after strict run:
./scripts/publish-latest-gate-summary.sh \
--gate-json /path/to/strict-run/gate-summary.json \
--output ../website/gollek-ai.github.io/assets/data/latest-gate-summary.json
Trend Tracking
Generate trend snapshots:
./scripts/bench-trend-snapshot.sh \
--matrix-root ops/benchmarks/matrix \
--out-csv ops/benchmarks/trends/matrix-gates.csv \
--out-json ops/benchmarks/trends/matrix-gates.json \
--limit 100
Use the CSV for quick review and JSON for automation. In strict CI, this snapshot is generated automatically; use manual script runs for local/offline aggregation.
Back to Docs Index Architecture
Modular Tokenizer Architecture
The Gollek platform has migrated to a unified Tokenizer SPI (tech.kayys.gollek.tokenizer.spi), replacing the legacy HuggingFaceTokenizer with a pluggable, format-aware architecture.
Key Features
- Universal Support: Seamlessly handles both BPE (
tokenizer.json) and SentencePiece (tokenizer.model) variants. - Automatic Discovery:
TokenizerFactoryintelligently detects the model format and loads the optimal backend (BPE vs. SPM). - Native SPM Bridge: High-performance SentencePiece decoding via a native Rust-based bridge (
libspm_bridge). - Streaming Stability: Integrated
StreamingDecoderhandles multi-byte UTF-8 sequences and BPE merge boundaries, preventing character garbling in streaming responses.
Common Usage
// Centralized loading (auto-detects format)
Tokenizer tokenizer = TokenizerFactory.loadFromDirectory(modelDir);
// Options-based API
long[] promptTokens = tokenizer.encode(prompt, EncodeOptions.defaultOptions());
// Stateful streaming decoder (for robust output)
StreamingDecoder decoder = new StreamingDecoder(tokenizer, DecodeOptions.defaultOptions());
for (long token : modelOutput) {
String piece = decoder.decodeNext(token); // Handles partial UTF-8
System.out.print(piece);
}
Native Library Management
Standard Location
Native libraries are stored in ~/.gollek/libs/:
~/.gollek/libs/
├── llama/ # GGUF/llama.cpp libraries
├── onnxruntime/ # ONNX Runtime libraries
├── libtorch/ # LibTorch libraries
├── native/ # Shared native bridges (e.g., spm_bridge)
└── litert/ # TensorFlow Lite libraries
Quick Setup
# Install all native libraries
make -f Makefile.native install-native-libs
# Verify installation
make -f Makefile.native verify-libs
Configuration
# Override default directory
export GOLLEK_NATIVE_LIB_DIR=/opt/gollek/libs
# Explicit library paths
export GOLLEK_LLAMA_LIB_PATH=~/.gollek/libs/llama/libllama.dylib
export GOLLEK_ONNX_LIB_PATH=~/.gollek/libs/onnxruntime/libonnxruntime.dylib
export GOLLEK_NATIVE_LIB=~/.gollek/libs/native/ # Path for spm_bridge
Documentation
- Git Repository Cleanup - Repository maintenance guide
- Native Library Management Guide - Complete technical guide