server: add dynamic control vector management endpoints#1223
Conversation
|
Thanks for making this PR. I remember being interested in ggml-org/llama.cpp#6289 way back when, and dissapointed it went nowhere. |
This implements the ability to load, unload, and scale control vectors (representation engineering) mid-inference, following the existing task-queue pattern used by LoRA adapters. New Endpoints: - GET /control-vectors - POST /control-vectors/load - POST /control-vectors/unload - POST /control-vectors/apply (handles scaling) Technical Notes: - Centralizes vector aggregation logic to share implementation between load, unload, and apply tasks. - Vectors are applied globally to the model context. - Enforces dimension validation on load to safely reject incompatible vectors.
|
@saood06 Thanks, I'm glad to hear there's interest! I hadn't seen that previous PR. This implementation is modelled after the current LoRA adapter slot persistence and server_task queue architecture, which sidesteps those issues. @jukofyork Haha glad you liked the cat test! It's arguably the rigorous proof that the vectors are shifting semantics without breaking syntax, and I figured it demonstrates the feature at a glance rather than asking everyone to read 2000 word short stories. It also works for css/website mock-ups. If anyone wants to test the endpoints quickly, here are the curl snippets and some vectors I used: Devstral 123B |
ikawrakow
left a comment
There was a problem hiding this comment.
Thank you for the PR.
I wasn't aware that people are actually using control vectors with ik_llama.cpp. Hence, they are not taken seriously for graph parallel, so graph parallel performance with control vectors is likely lower than it could be.


This implements the ability to load, unload, and update control vectors (representation engineering) mid-inference via the server API. It follows the existing SERVER_TASK queue pattern used by LoRA adapters to ensure thread safety within the main loop.
New Endpoints:
Implementation Notes:
Stability:
I have been using this implementation as my daily driver for inference steering for the last ~2-3 months.
Validation:
Verified using Devstral-2-123B. Control vectors successfully steer output semantics while maintaining syntax consistency.
Example: "Draw an SVG of a cute cat"