feat(sparse-inference): TernarySparseFfn -- dual sparsity via ternary weights#605
Open
simeon-kepp wants to merge 7 commits into
Open
feat(sparse-inference): TernarySparseFfn -- dual sparsity via ternary weights#605simeon-kepp wants to merge 7 commits into
simeon-kepp wants to merge 7 commits into
Conversation
Built from commit dd5e145 Platforms updated: - linux-x64-gnu - linux-x64-musl - linux-arm64-gnu - linux-arm64-musl - darwin-x64 - darwin-arm64 - win32-x64-msvc Generated by GitHub Actions
Built from commit dd5e145 Platforms updated: - linux-x64-gnu - linux-x64-musl - linux-arm64-gnu - linux-arm64-musl - darwin-x64 - darwin-arm64 - win32-x64-msvc - wasm Generated by GitHub Actions
Built from commit dd5e145 Platforms: linux-x64-gnu, linux-arm64-gnu, darwin-x64, darwin-arm64, win32-x64-msvc Co-Authored-By: claude-flow <ruv@ruv.net>
Built from commit dd5e145 Platforms updated: - linux-x64-gnu - linux-arm64-gnu - darwin-x64 - darwin-arm64 - win32-x64-msvc 🤖 Generated by GitHub Actions
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
Builds on the
LinearBitNetlayer merged in #477 to integrate ternary weight quantization directly into the sparse FFN pipeline.TernarySparseFfnis a drop-in alternative toSparseFfnthat stores W1 and W2 asi8ternary weights{-1, 0, +1}instead of f32. This adds a second, independent axis of sparsity:LowRankPredictorskips inactive neuronsCombined at BitNet b1.58 realistic numbers: ~15 % of dense f32 multiply-accumulate operations remain.
What changed
crates/ruvector-sparse-inference/src/sparse/ternary_ffn.rs— newTernarySparseFfnstruct implementing theFeedForwardtrait, withfrom_f32()constructor,forward_sparse(),forward_dense(), andw1_sparsity()/w2_sparsity()accessors. 9 unit tests including a sparse-vs-dense agreement check.src/sparse/mod.rs—mod ternary_ffn; pub use ternary_ffn::TernarySparseFfn;src/lib.rs—TernarySparseFfnadded to the crate-level re-exportAdditive only
SparseFfn,SparseInferenceEngine, and all existing APIs are completely unchangedLinearBitNetis already in the crate from feat(ops): add LinearBitNet — ternary weight GEMV with zero-skip #477TernarySparseFfnis always available once the crate compilesUsage