refactor: collapse Llama/Qwen/Voxtral NetworkDef onto shared decoder body#110
Merged
Merged
Conversation
…body Each architecture's `xNetwork(metadata)` is now a thin (~5 line) caller of the shared `decoderTransformerNetwork` builder added in #109, instead of either duplicating the transformer DAG or stub-delegating across modules. Wire-level changes: - LlamaModelMetadata implements DecoderModelMetadata (override-only diff; field names already aligned). - llamaNetwork: collapsed from a ~50-line sequential{} block to a thin decoderTransformerNetwork call with qkNorm = false. Same module tree as before, eps and ropeBase now flow from metadata defaults instead of being hardcoded. - qwenNetwork: was a 3-line stub delegating to llamaNetwork; now a real function passing qkNorm through from the loader. Qwen3-specific knobs (ropeFreqBase, rmsNormEps) propagate via the shared metadata defaults. - QwenNetworkLoader auto-detects QK-norm from `*.attn_q_norm.weight` presence in the loaded weights — same pattern Gemma uses (GemmaNetworkLoader.fromWeights). Real Qwen3 GGUFs always carry these tensors, synthetic test fixtures don't, so both keep working. - voxtralBackboneNetwork: dropped the cross-model import of llamaNetwork; now calls decoderTransformerNetwork directly. No model module imports another model's network builder. Architectures intentionally NOT touched: - Gemma 4: legitimate divergence (geGluFFN, sandwich norms, layer output scale, KV sharing, PLE hooks, custom GemmaModel wrapper). - Apertus: legitimate divergence (xIELU activation, ungated FFN with separate up/down dense + xielu, no swiGluFFN). - Voxtral acoustic: 3-layer flow-matching transformer, no embedding / output projection, custom name prefix — different beast. - BERT: encoder-only, bidirectional, LayerNorm not RMSNorm, GELU FFN. Tests pass across :llm-core, :llm-inference:{llama,qwen,voxtral,apertus, gemma,bert}, :llm-runtime:{kllama,kqwen}, :llm-api, :llm-agent. DSL-vs-LlamaRuntime numerical parity test deferred to a follow-up PR. Refs the no-model-duplication plan and the closed #46. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2 tasks
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.
Summary
xNetwork(metadata)is now a thin (~5 line) caller ofdecoderTransformerNetworkfrom feat(llm-core): shared decoder transformer body + DecoderModelMetadata #109, instead of duplicating the transformer DAG or stub-delegating across modules.qwenNetwork()is no longer a stub — it now actually applies QK-norm and metadata-driven RoPE base / eps, the architectural difference from Llama that issue Wire QwenNetworkLoader into CLI for proper Qwen3 inference #46 originally called out.voxtralBackboneNetworkno longer importsllamaNetworkfrom:llm-inference:llama, removing the last cross-model import flagged by the no-model-duplication plan.Changes per file
LlamaModelMetadata: now implementsDecoderModelMetadata. Override-only diff; field names were already aligned.llamaNetwork: collapsed from ~50-linesequential{}block to a thindecoderTransformerNetwork(..., qkNorm = false)call. Same module tree as before;epsandropeBasenow flow through metadata defaults.qwenNetwork: was a 3-line stub delegating tollamaNetwork; now a real function exposingqkNorm: Boolean = true. Per-architecture knobs (ropeFreqBase,rmsNormEps) propagate via metadata.QwenNetworkLoader: auto-detects QK-norm from*.attn_q_norm.weightpresence in loaded weights — same pattern Gemma uses. Real Qwen3 GGUFs always carry these tensors; synthetic test fixtures don't, so both keep working.voxtralBackboneNetwork: drops the cross-model import; callsdecoderTransformerNetworkdirectly.Intentionally NOT touched
GemmaModelwrapper).denseup/down).Test plan
./gradlew :llm-core:jvmTest :llm-inference:llama:jvmTest :llm-inference:qwen:jvmTest :llm-inference:voxtral:jvmTest./gradlew :llm-inference:apertus:jvmTest :llm-inference:gemma:jvmTest :llm-inference:bert:jvmTest./gradlew :llm-runtime:kllama:jvmTest :llm-runtime:kqwen:jvmTest :llm-api:jvmTest :llm-agent:jvmTestDSL-vs-
LlamaRuntimenumerical parity test deferred to a focused follow-up PR with careful tolerance choice. Refs the closed #46.🤖 Generated with Claude Code