feat(kllama-java): swap KLlamaJava facade to DSL path#123
Merged
Conversation
Phase 5b consumer migration. Mirrors PR #122 (kllama CLI) for the Java-facing facade. - `KLlamaJava.loadGGUF` and `loadSafeTensors` both use `LlamaNetworkLoader.fromWeights` + `OptimizedLLMRuntime` DIRECT mode via `DecoderGgufWeightLoader` + `DecoderGgufMemSegConverter` (GGUF) or `DecoderSafeTensorsLoader` (SafeTensors). - `KLlamaSession.runtime` type loosened from `LlamaRuntime<FP32>` (legacy concrete) to `InferenceRuntime<FP32>` (interface). The session's generate methods only used `reset()` and `generateUntilStop(...)` — both available on the interface — so this is non-breaking for `internal` callers and Java consumers (the field is `internal val`). - KLlamaJava now declares its accepted GGUF architectures as `setOf("llama", "mistral")` (was `setOf("llama")` via `LlamaIngestion`'s default — minor scope expansion to match common Llama-derivative usage). Qwen-family GGUFs are still rejected here; the kllama CLI is the entry point with Qwen dispatch. `tokenizer.eosId` (deprecated `GGUFTokenizer`-specific alias) replaced with `tokenizer.eosTokenId` (interface property) at both call sites. After this PR, `KLlamaJava` no longer references `LlamaIngestion`, `LlamaLoadConfig`, `LlamaRuntime`, `MemSegWeightConverter`, `CpuAttentionBackend`, `LlamaRuntimeWeights`, or `loadLlamaRuntimeWeightsStreaming`. `LlamaIngestionBlocking.kt` remains (still used by `:llm-apps:skainet-cli`) and is the next migration target. All `:llm-runtime:kllama` tests pass. Numerical equivalence with the legacy path on identical weights remains pinned by `QwenDslLegacyParityTest` (#120) — same `LlamaNetworkLoader.fromWeights` codepath as the CLI swap (#121, #122). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced May 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 5b consumer migration. Mirrors PR #122 (kllama CLI) for the Java facade.
What changes
KLlamaJava.loadGGUF:DecoderGgufWeightLoader(NATIVE_OPTIMIZED, {"llama", "mistral"})→DecoderGgufMemSegConverter.convert→LlamaNetworkLoader.fromWeights→OptimizedLLMRuntimeDIRECT mode. Same path the CLI uses.KLlamaJava.loadSafeTensors:DecoderSafeTensorsLoader<FP32>(ctx, FP32::class, metadata, tiedEmbeddings).loadToMap { … }→LlamaNetworkLoader.fromWeights→OptimizedLLMRuntime.KLlamaSession.runtimetype loosened fromLlamaRuntime<FP32>(legacy concrete) toInferenceRuntime<FP32>(interface). The session'sgenerate(...)methods only callreset()and thegenerateUntilStopextension — both available on the interface — so it's non-breaking forinternalcallers.tokenizer.eosId→tokenizer.eosTokenIdat both call sites (interface property; the deprecatedGGUFTokenizer-specific alias goes away with the eventualGGUFTokenizercleanup).Scope notes
KLlamaJavanow accepts{"llama", "mistral"}(was{"llama"}viaLlamaIngestion's default — minor scope expansion to match common Llama-derivative usage). Qwen-family GGUFs are still rejected here; the kllama CLI is the entry point with Qwen dispatch.LlamaIngestionBlocking.kt(Java-friendly suspend wrapper aroundLlamaIngestion) is unchanged. Still used by:llm-apps:skainet-cli— next migration target.Test plan
:llm-runtime:kllama:jvmTestpasses.llm-test-javasmoke if present) loading a real Llama GGUF; verify output coherence.Numerical parity with the legacy path on identical weights is pinned by
QwenDslLegacyParityTest(#120) — sameLlamaNetworkLoader.fromWeightscodepath the CLI swaps use.🤖 Generated with Claude Code