Research: Freivalds verification for llama.cpp backends#171
Draft
michaelneale wants to merge 1 commit intomainfrom
Draft
Research: Freivalds verification for llama.cpp backends#171michaelneale wants to merge 1 commit intomainfrom
michaelneale wants to merge 1 commit intomainfrom
Conversation
Measures whether Freivalds' algebraic check can verify that remote peers run the correct model weights, using llama.cpp's eval callback to capture intermediate activations during inference. Results on CPU (Apple M4 Max): - Qwen2.5-0.5B Q4_K_M: max 6.4% relative residual, avg 1.6% - SmolLM2-135M Q8_0: max 2.9% relative residual - Qwen3-8B Q4_K_M: max 23.5% (last layer outlier), avg 4.6% Model substitution (wrong model entirely) would produce ~100% residual, so there is clear separation for detecting basic cheating. The last-layer outlier on larger models needs investigation. GPU residuals (Metal/CUDA) not yet measured — this is the key open question. Contains: - freivalds-check.cpp: measurement tool (builds inside llama.cpp tree) - README.md: full writeup with protocol design and analysis
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.
What
Experiment measuring whether Freivalds' algebraic check can verify that remote mesh peers are running the correct model weights. This is a backend-agnostic alternative to CommitLLM's vLLM-specific kernel instrumentation.
How it works
cb_evalcallbackv·y ≈ (v·W)·xwherevis a secret random vectorIf the peer used different weights, the check fails with high probability. The secret vector
vis never shared, so the peer can't pre-compute a fake that passes.Results (CPU inference, Apple M4 Max)
*Last-layer outlier — other layers are <7%
Model substitution (running a wrong model) produces ~100% residual → clear separation for detecting basic cheating.
Key findings
What's next
See
research/freivalds/README.mdfor full writeup and protocol design.