Skip to content

fix: KimiLinear MLP applies silu to gate_proj, not up_proj - #257

Merged
solderzzc merged 3 commits into
mainfrom
sl63/kimilinear-mlp-act
Nov 4, 2026
Merged

solderzzc merged 3 commits into
mainfrom
sl63/kimilinear-mlp-act

Conversation

@solderzzc

Copy link
Copy Markdown
Member

What

KimiMLP computed down(gate(x) * silu(up(x))). SwiGLU is down(silu(gate(x)) * up(x)): the activation belongs on gate_proj. The old form has no shape error, so it silently produces wrong activations for every KimiLinear MLP layer.

One-line fix in Sources/SwiftLM/KimiLinearDFlash.swift; KimiMLP is made internal so the test can use @testable.

Test

tests/SwiftLMTests/KimiLinearMLPTests.swift builds the MLP with fixed, non-symmetric weights and compares against a hand-computed SwiGLU.

Run locally (this branch with main merged in, 69bc71c):

  • swift test --filter KimiLinearMLPTests: 1 test, 0 failures, EXIT=0.
  • Same test with the fix reverted to the old expression: 1 test, 8 assertion failures, so the test does catch the bug.

Tracks SL-63 / the KimiLinear item in #254.

🤖 Generated with Claude Code

solderzzc and others added 3 commits November 2, 2026 11:38
SwiGLU is down(silu(gate(x)) * up(x)); the code had silu on up_proj. Adds a
hand-computed SwiGLU regression test (KimiMLP made internal for @testable access).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@solderzzc
solderzzc merged commit 3a702cf into main Nov 4, 2026
15 checks 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.

1 participant