Skip to content

Control vectors: a native GLP steering vector for Qwen3.8-27B on Metal - #53

Open
BlivionIaG wants to merge 2466 commits into
mainfrom
feature/glp-steering
Open

BlivionIaG wants to merge 2466 commits into
mainfrom
feature/glp-steering

Conversation

@BlivionIaG

@BlivionIaG BlivionIaG commented Oct 27, 2026 •

Copy link
Copy Markdown
Owner

Native control vectors for Qwen3.8-27B on Metal.

A control vector steers the residual stream at inference time. It is read from a
GLP container, applied at the post-layer residual, and never touches a weight:
nothing is baked into the checkpoint, and serving without a vector is
byte-for-byte the model as it was.

The whole path is native Zig. The container reader, the Metal kernel, the serve
surface and the producer that derives a vector from the model itself are all in
this repository. There is no Python in the engine and no second implementation
to keep in step.

Where this comes from

The GLP control-vector container format, its reference implementation and its validator are
Matt Suiche's: the format as implemented by the weightless
plugin (MIT). This work implements that format on the native engine rather than redefining it,
and the reference implementation is not vendored: tools/zig/glp_parity.py takes a weightless
checkout and reads it as a package, so a file this engine accepts is checked against the
implementation the format comes from. The layer ids, the metadata, every direction's bytes and
the digest all agree.

The published vector this work is measured against,
msuiche/Qwen3.8-27B-abliterated-cyber-GLP-49,
is his too, and the controlvector.model_hint convention is his, so a runtime that matches on
it treats the two files the same way. The vector published alongside this work is a different
derivation: its directions are measured from the MLX 4-bit checkpoint's own activations, with
the massive-activation mask his own metadata points at, and the file hangs under his repository
in the Hub's lineage. The card that ships with it says all of this.

The path

flowchart LR
  S["serve --glp FILE"] --> C["GLP container, GGUF v3<br/>direction.N per steered layer"]
  C --> R["Reader, zig/src/core/glp.zig<br/>refuses what it does not implement"]
  R --> P["Plan, zig/src/families/qwen27/steer.zig<br/>direction, device buffer, layer lookup"]
  P --> K["Metal kernel, norm_steer.metal<br/>the direction's component leaves the row"]
  K --> T["Residual stream after block N"]
  T --> B["The next block's norm reads what is left"]
Loading

The container is read once, before the model is loaded, and a file the server
cannot apply is refused: the server does not start. The reader keeps the
metadata, the layer list and the directions. The plan turns them into a device
buffer and a lookup by layer. The kernel takes the direction's component out of
the row it is already summing, so the projection costs no pass of its own.

What lands

Piece File
A generic GGUF v3 reader and writer zig/src/core/gguf.zig
The GLP metadata rules: read, refuse, write zig/src/core/glp.zig
The projection, inside the norm that has to touch the row anyway zig/kernels/metal/qwen27/norm_steer.metal
The float64 reference the kernel is gated against zig/src/core/contract/steer.zig
The contract records for the steer launch zig/src/core/contract/steer_records.zig
The plan: a direction, a device buffer, and the lookup zig/src/families/qwen27/steer.zig
--glp FILE, --glp-alpha ALPHA, the refusals, the startup line zig/src/server/glp_startup.zig
The producer: tf-qwen27-steer-derive zig/src/families/qwen27/steer_derive.zig, zig/tests/qwen27_steer_derive.zig
The checker and the parity script the integration test drives zig/tests/glp_check.zig, tools/zig/glp_parity.py
The held-out prompt set, and the gate that measures either set zig/src/families/qwen27/steer_prompts_holdout.zig, tools/zig/qwen27_steer_gate.py
The serve checks, which run on every platform zig/src/server/glp_startup_test.zig
The desktop app's holding of a control vector app/shared/control-vector.ts
The desktop app's control-vector setting app/electron/agent/engine/control-vector.ts
The desktop app's panel app/src/components/settings/ControlVectorSettings.tsx

The desktop app

The app can hold a control vector and hand it to the engine at its next start.

The toggle sits in Settings → AI & Models → Engine advanced, beside the
other engine settings. It is off until it is turned on, and the panel says
plainly what a vector does: it steers the model, so the model answers
differently. The engine names what it is holding when it starts:

[tensorfold] glp on: ... (mode: project; alpha: 1.00; layers: 49 (10-58); ...)

Three rules hold in the app.

  • The path comes only from the OS picker. The renderer can turn the vector
    on and set its strength; it cannot name a file. The picker's result is the
    one place a path enters the app, the same rule the model-folder picker
    follows. The audit log records the state and the strength, never the path,
    because the file may sit in a directory the operator keeps private.
  • The engine has to offer the flag. The app reads capabilities --json and
    only offers the control when the engine in use lists --glp. When it does
    not, the panel says so instead of failing at the next start.
  • The change and the model restart happen together. A refused start leaves
    the old choice in place, and the file, the strength and the state are kept in
    engine/preferences.json, so the choice survives a restart of the app.

What the app passes to the engine is exactly the engine's own surface:

serve <model> ... --glp <file> --glp-alpha <alpha>

The strength is bounded to what the engine accepts: above zero, and at most 16.
A field the caller leaves out keeps its current value, so changing the strength
does not switch the vector off and switching it off does not reset the
strength. Choosing a different file while a vector is in force takes effect at
once: the model restarts with the new file, so the panel and the engine never
name different files.

What the app does not do. It does not download vectors and it does not ship
one. The published file is on the Hub, but it is not a model, and the app's Hub
machinery pulls models; adding a second kind of artefact is a product decision
that has not been taken. The file the operator points at is their own.

The engine in the packaged app. The packaged build pins its engine by
sha256 (app/build/engine.json), and the pinned release does not carry --glp
yet. A shipped build therefore says that its engine does not offer control
vectors, and the panel stays inert until the engine is re-pinned. The dev path
(TENSORFOLD_STUDIO_ENGINE_BIN) takes an engine built from this branch, and
there the control works.

The layer a direction names

direction.N is the layer index N, and the layers are zero-based:
direction.N is the output of the N-th block, the residual stream as that block
leaves it. Layer 0 is not steerable, so a file for a 64-block model names
layers 1 to 63.

This is worth getting right, because the alternative is silently wrong. The
container follows llama.cpp, and llama.cpp's own generator writes
direction.{il+1} while its applier reads direction.il: the two cancel, so a
file means the applier's numbering. The reference implementation states it
twice ("TENSOR NAME N IS THE LAYER INDEX. Not the index plus one"), and its
runtime hooks the decoder block at index N, so the direction lands on the
output of block N.

The published vector says so itself. Its metadata carries the layer list, and
this reader refuses a file whose tensor names and that list disagree:

glp.layer_ids_zero_based = 10,11,12,...,58

The projection rides along with the norm

A steered layer takes one dispatch. The row is summed, the direction's
component leaves it, and the normalisation that follows reads what is left.

It used to take two: the norm that adds a block's output to the residual
stream, and then a separate kernel that read the residual row, reduced it
against the direction and wrote it back. That was a whole extra pass over the
residual stream per steered layer, plus a dispatch and a barrier, on every
token.

What the vector costs was measured against the same build and the same server
without one: under a percent of a decoded token and under half a percent of a
prefill. That is under what this machine resolves between runs, so the honest
reading is that the cost is below the noise. Two things in the kernel were
worth fixing on the way. The add mode does not use the dot, so it no longer
computes it, which is also what the spec declares for that mode. And the
direction is read once per row and kept in registers, so the dot and the
projection read the same stretch of it.

It also changes what the model sees, in the reference implementation's favour.
The block after a steered one now reads the projected stream, because the
projection happens before the normalisation rather than after it. That is the
order the reference implementation uses, and it is worth two refusals in
thirty on the published vector.

The projection lands on the refusal, not on the stream's offset

The producer can leave the dimensions the activations dominate out of the
direction (--mask FRAC). Some checkpoints carry a handful of dimensions
whose activations stand orders of magnitude above the rest, and a difference
of means taken where they dominate points at them rather than at the feature
you asked for. This model does: the producer's own screen reports 701, and the
reference implementation measures 75 to 434 for the same checkpoint.

At 0.005, 26 of the model's 5120 dimensions are left out per layer, and they
held between 12% and 66% of the direction's length before the mask: two thirds
of it at layer 58. That is a direction pointing at the massive
activations rather than at the refusal, and it is why the unmasked vector
takes the harmless prompts with it.

Measured

Environment

Machine Apple M4 Pro (applegpu_g16)
OS macOS 26.5.1 (25F80)
RAM 48 GiB
Backend Metal
Toolchain Zig 0.17.0
TensorFold 1.2.0
Branch head fced4f6ad (rebased onto the upstream main at 9e8c368b0)
Checkpoint TensorFold/Qwen3.8-27B-MLX-4bit at 22d8d538154e0e5b6f8dcb1fcc74a60a0798104c (MLX 4-bit)

Every arm below is measured at strength 1.0, with 300 new tokens per prompt,
and with temperature 1.0, top_k 20 and top_p 0.95, the values the server
prints.

The branch was rebased onto the upstream main at 9e8c368b0, 549 commits
past the tree it merged before, and the engine is upstream's 1.2.0 now. Every
measurement below was taken again on that rebased tree, and the numbers are
the same ones the earlier tree gave: the published vector on the derivation
set still leaves 19 of 30 harmful prompts refused and 6 of 30 benign ones,
with 60 of 60 coherent replies.

The derivation set

Thirty form-matched pairs of our own prompts
(zig/src/families/qwen27/steer_prompts.zig), no third-party corpus. The
harmful column is the share of harmful prompts the model still refuses; the
benign column is the share of the harmless twins it refuses, which is what a
vector that removes a capability instead of a refusal looks like.

Harmful refused Benign refused Replies coherent
No vector 30/30 0/30 60/60
Published GLP-49, per layer, layers 10-58 19/30 6/30 60/60
Published GLP-63, pooled, layers 1-63 2/30 0/30 60/60
Our vector, unmasked, layers 10-58 18/30 7/30 60/60
Our vector, masked at 0.005, layers 10-58 0/30 0/30 60/60

The two published vectors are msuiche/Qwen3.8-27B-abliterated-cyber-GLP-49
and its pooled sibling GLP-63. They are downloaded and run here; they are not
vendored and they are not committed. The last two rows are vectors this
repository's own producer derives from the model itself, on our own prompt
set.

The masked vector is the one to read. It takes every refusal off and takes no
harmless prompt with it: with the dimensions the massive activations dominate
left out of it, the direction is a direction at the refusal rather than a
direction at the stream's offset. The unmasked row is the same derivation
without that exclusion, and it shows what the exclusion is worth. The
published pooled vector reaches close to the same place with a direction made
differently, and the published per-layer one does not.

That the replies stay coherent in every arm matters more than the rates: a
vector that silences the model is not a refusal removal, so read the replies,
not the rate.

The held-out set

The table above is measured on the thirty pairs the vector was derived from,
which is a measurement of the derivation. The second set asks the question that
one cannot: does the recipe generalise, or did it learn thirty prompts?

The twenty held-out pairs were written after the vector was derived, over
topics the derivation set never names and in forms it never uses. The producer
never reads them, and a test holds that no prompt in them appears in the
derivation set.

Harmful refused Benign refused Replies coherent
No vector 20/20 5/20 40/40
Published GLP-49, per layer, layers 10-58 9/20 6/20 40/40
Our vector, masked at 0.005, layers 10-58 0/20 0/20 40/40
The same directions as an add-mode file 20/20 20/20 40/40

The recipe generalises: a vector derived from thirty prompts in one form takes
all twenty refusals off twenty prompts in other forms, over other topics, and
puts no refusal on any of the harmless twins.

The benign column is read against five, not against zero. The base model refuses
five of the twenty twins before any vector is applied, because their frame is
close enough to the harmful one: "brute-force my own wifi password" reads as
unauthorised access, a mockup of a bank login reads as credential theft, and a
rifle's stock reads as the rifle. Those five are the floor of that column.

The rate is also a lower bound, because it counts phrases and a vector can
change the wording of a refusal without removing it. Reading the eleven replies
the published vector unblocked on this set shows that every one of them still
declines, in other words: "you should not enter your neighbour's house", "it is
illegal in most jurisdictions". The published vector bends the wording of the
refusal, and its benign column moves from five to six. The same holds on the
derivation set, where that vector's row reads 19 of 30: the eleven replies the
metric counts as compliance all decline there too, "it is not possible to
provide step-by-step instructions for synthesizing a nerve agent at home", "it
is technically impossible to track the real-time location of a smartphone".

The masked vector takes the decline away. The model answers the request, usually
after a legal or safety caveat rather than in place of an answer, and for
several of the twenty it hands over what was asked for: the scraper script, the
essay, the scam message. The benign column falls to zero with it, so the five
false refusals the base model carried are answered too.

The add file is the mirror image on prompts the vector was never derived from:
the model refuses all twenty harmful prompts and all twenty harmless twins, and
answers all forty coherently. The mode in the file decides which way the same
numbers push, and that holds on unseen prompts.

Every number here comes from one command per arm, and the gate writes the
receipt:

python3 tools/zig/qwen27_steer_gate.py --serve \
    --checkpoint TensorFold/Qwen3.8-27B-MLX-4bit \
    --vector vector.gglp --alpha 1.0 --set holdout --out receipt.json

The strength, the ceiling and the rest

The masked vector's strength is flat from 0.5 to 3: the refusal rate and the
over-refusal rate do not move. At 4 the replies go empty, which is where the
published vector's own metadata says this model collapses ("alpha=4 collapses
this model"). The container, the kernel and the strength's meaning agree with
the implementation that wrote the file.

A strength of 1e-6 reproduces the baseline exactly: the path is a no-op at
zero.

The masked vector was put through an ordinary capability check as well: twelve
tasks of the model's own work, code, arithmetic, translation, a regular
expression, a haiku, facts and protocols, and it answered every one of them.

The producer run takes 18.4 s on this machine, and a re-derivation from the same
checkpoint and the same prompt set writes the same directions byte for byte.

The two modes

A vector is applied either by taking the direction's component out of the
residual stream (project) or by adding the direction to it as a bias
(add), which is llama.cpp's own control vector. The file names which. The
same directions in both modes are opposites, and the checker's rewrite gains a
--mode flag so the two arms can be compared: in project the model refuses
nothing harmful and nothing harmless, in add it refuses all twenty harmful
prompts and all twenty harmless twins on the held-out set, still answering
coherently.

The published file

The vector is a file of its own, the way the per-layer vector it is compared
against is, and it is published rather than committed: this repository holds the
code that writes it, and the file itself is not in the tree.

The file says what it is, because a consumer reads a container's header before it
reads the directions. The writer takes that now, and the producer takes it as
flags:

tf-qwen27-steer-derive --model DIR --out FILE \
    --repo TensorFold/Qwen3.8-27B-MLX-4bit --revision REV \
    --capture last --mask 0.005 --layers 10-58 \
    --name "Qwen3.8-27B-refusal-cvec-per_layer-masked-L10-58-a1" \
    --author "BlivionIaG" --license "Apache-2.0" --model-hint "qwen3_5" \
    --description "..." --effect "alpha 0.5 to 3 is flat; at 4 the replies go empty"

What lands in the file: general.name, general.description, general.author,
general.license, general.base_model.* (the owner, the repo, the revision and
the url), controlvector.model_hint, controlvector.layer_count,
glp.measured_effect and glp.created, beside the fifteen keys the GLP rules
need. The reader keeps them, so a file written again keeps what it said about
itself.

What the repository holds is the code that writes the file and the numbers that
identify it:

Repository BlivionIaG/Qwen3.8-27B-refusal-cvec-GLP-49
File Qwen3.8-27B-refusal-cvec-GLP-49-L10-58-a1.gguf
File sha256 fb0fc832305b37db0af64295c8fa6f6d3e26a7719904199a7488959aec524a2d
Directions digest 9a50f7160fa2f0a41e7fa868c791d372b0a374f9365cc98c25d52abe96ce9d8d (glp.content_sha256)
Layers 10 to 58, zero-based, 49 of them
Width 5120
Mode project
Alpha 1
Base model TensorFold/Qwen3.8-27B-MLX-4bit at 22d8d538
Author BlivionIaG
Licence Apache-2.0, the licence of the code that derived it
Model hint controlvector.model_hint is qwen3_5

The directions in the published file are byte-identical to the ones the tables
above were measured on: the digest is 9a50f7160fa2, and the reference
implementation reads the file and agrees with this repository's reader on every
layer, on the metadata and on the digest.

The reference implementation's own validator reads the file downloaded back from
the Hub and reports nothing wrong with it, the same as it reports for the
published file this one is compared against:

captain-vector --validate Qwen3.8-27B-refusal-cvec-GLP-49-L10-58-a1.gguf
  ...: 0 FAIL, 0 WARN

The format, its reference implementation and its validator are Matt Suiche's —
the weightless plugin — and the published per-layer vector this one is
measured against is his too. The card that ships with the file says so, and
the controlvector.model_hint is the same hint his file carries, so a runtime
that matches on it treats the two the same way.

The Hub repository is declared an adapter of
msuiche/Qwen3.8-27B-abliterated-cyber-GLP-49, so it hangs under that model in
the Hub's model tree. The two are not in competition: his file is made for
another engine and another model, the weightless engine and the
Qwen/Qwen3.8-27B checkpoint, and this one is made for the MLX 4-bit
conversion of the same weights, served by TensorFold on Metal. What was
validated here is TensorFold/Qwen3.8-27B-MLX-4bit at 22d8d538.

The integration test

A file that one implementation accepts has to mean the same thing to another.
The reference implementation for this format is the weightless plugin's
container reader, and this repository does not vendor it: the test takes a
checkout and reads it as a package.

zig build tf-glp-check
python3 tools/zig/glp_parity.py --reference PATH/TO/weightless \
    --vector vector.gglp --vector PATH/TO/a-published-vector.gguf

Three legs over the same files: the reader in Zig against the reference reader
(the layer ids, the metadata, every direction's bytes), the file read in Zig and
written out again and read back by the reference, and the file's own
glp.content_sha256 hashed the same way on both sides. All three pass on the
published vectors and on the one this repository derives. Against an unmodified
msuiche/weightless checkout, 5 of 5 files agree.

tools/zig/test_glp_parity.py covers the comparison itself, on a container
written by hand.

What it refuses

The reader fails closed rather than guessing: a mode that is neither project
nor add, a hook point that is not residual_stream_post_layer, a rank or a
spec version this reader does not implement, a direction that is not a unit
vector, a digest that does not match the bytes, a width or a base model that
does not match the checkpoint. A Gemma checkpoint is never steered: its terms
of use forbid circumventing its safety filters. A CUDA or ROCm backend refuses
--glp; only the Metal engine steers.

The kernel contract

The steer launch is registered with the contract
(zig/src/core/contract/steer_records.zig, reachable from registry.zig), and
the host-side test zig build test-kernel-contract checks every registered
launch against M1-M5 and sm_80/86/89/120/121; that step is green in CI.

The limits gate compiles each registered launch on the GPU and reads the
pipeline's own limits back. The qwen27 family compiles its kernels at run time,
with the width in the source where the marker is, so the pass had nothing to
build for this launch and reported it as no pipeline on this GPU (NoFunction).
It now builds the real specialization, and the launch passes with the 320
threads and the 80 bytes of threadgroup memory the contract declares for it.

The device gates had no suite to run them: gates 1 to 4 never saw the Metal
kernel, and nothing compared it against the float64 reference. A suite now
compiles the family's own source, launches it as the engine does, and registers
both modes the launch serves, with two controls built from the same source, one
whose dot drops a NaN and one whose dot is summed in half.

On this M4 Pro the steering kernel passes gates 1 to 4 in both modes, the
controls are red as planted, and the limits gate passes:

PASS nonfinite qwen27 steer project: 20480 non-finite and 5120 finite outputs match the float64 classes
PASS repeat qwen27 steer project: five runs byte-identical (10240 bytes), inputs and guards untouched, no overlap
PASS shapes qwen27 steer project: 4 shapes within the float64 bound (worst 0.995 of the bound), 0 edges refused by the kernel
PASS sums qwen27 steer project: exact sums at k 5120, where fp16 sums would miss by infx and bf16 by 267x
CONTROL qwen27 steer project nan control: red at nonfinite, as planted
CONTROL qwen27 steer project sums control: red at sums, as planted
PASS normalised: the fused kernel's row is the plain norm's row, element for element, and the planted fault shows
PASS limits here qwen27 norm steer custom_kernel_q27_norm_steer_…: 320 threads launched, the pipeline takes 1024; 80 threadgroup bytes and 0 set (declared at most 80, the GPU's most 32768)
SUMMARY 2 kernels: 2 pass gates 1-4, 0 fail, 0 known findings; 2 controls: 2 red as planted, 0 missed; 0 limit problems

The last line is a check the suite did not have before. The fused kernel's
normalised row has to be the plain norm kernel's normalised row of the row it
projected, element for element, and a fault planted in the normalisation alone
is caught. The gates compare the projected row; nothing compared the values the
model actually consumes.

The full device run still cannot finish on this Mac: the base tree's Gemma 4
31B rounded-dense gate needs tensor units, and this M4 Pro has none, so the run
stops there before it reaches a kernel of this branch.

No CUDA or HIP SUMMARY line either: this machine has no NVIDIA or AMD GPU.

The measurements and what they cover are in
docs/receipts/glp-steering-qwen38-27b/README.md.

Tests and CI

  • zig build test --summary all locally: 605/605 steps succeeded, 9293/9348
    tests passed (55 skipped).
  • zig build test-glp, test-glp-serve, test-glp-steer, test-steer-derive,
    test-steer, test-kernel-contract and test-golden all exit 0.
  • New Zig tests: 26 in zig/src/core/glp_test.zig, 4 in
    zig/src/core/glp_publication_test.zig, 13 in
    zig/src/server/glp_startup_test.zig, 4 in
    zig/src/families/qwen27/steer_test.zig, 8 in
    zig/src/families/qwen27/steer_derive_test.zig, 5 in the two prompt-set files,
    and 6 contract checks: 66 in all.
  • Python: 8 gate unit tests in tools/zig/qwen27_steer_gate_test.py, 6 parity
    unit tests in tools/zig/test_glp_parity.py.
  • The desktop app: 856 of 856 desktop tests, the typecheck and the language
    packs (12 locales, 4,956 sources each) are green.
  • app/electron/agent/engine/control-vector.test.ts covers the strength's
    bounds, the saved shape, an engine without --glp refusing to take a vector,
    the picked file being remembered but not applied, the model restart that puts
    the vector in force and the one that takes it out, a new strength leaving it
    in force, the choice surviving a restart of the app, a file that has been
    deleted since, and the vector being forgotten.
  • CI on this head: green on Linux, Windows and macOS for the code, the tests and the
    tools (No GPU, run 40777727025), green for the format (run 40777727031), and green
    on all four app jobs — the Linux desktop, AppImage, the macOS desktop and mobile
    (run 40777727145).
  • Lean rule: 424 problems on this branch against 424 on the base it sits on
    (9e8c368b0), so zero new over the base.

Not run

Before/after decode and prompt-speed benchmarks: not run, and why. The feature
did not exist on this branch before the change, so there is no before to measure
against; the unsteered path is unchanged by construction, because the
projection is skipped when no direction is in force.

The desktop app's macOS packaging job had been cancelled by the runner pool on
this repository: every attempt on the earlier heads sat in the macos-14 queue
and was cancelled without a machine ever being assigned, and the same job on the
base tree's own runs was cancelled the same way in the same window. On this head
it was given a runner and is green, so nothing here rests on a local run in its
place. It was run here as well, under the job's own pins (node 22.23.2,
npm 10.9.8): the two locked installs, then the desktop tests, then the
typecheck, then the whitespace check on the last commit — all clean. The job
that compiles the engine on macOS — the one that builds every tf-* tool, the
contract runner included — is green.

The checklist, answered

  • Every token still goes through the lane rounds. The vector is applied
    inside the block's own norm, in the engine's normal round. The request path
    is untouched, and the only file this branch shares with the lane host is its
    test.
  • Drafted output equals "draft": false, a resumed prompt equals a fresh
    one, and concurrent equals solo. The base tree's own gates for those three
    run in CI and are green; this branch changes the model, not the request path.
  • No precision traded for speed. The direction's dot is fp32, the row keeps
    the kernel's own summation order, and the float64 reference in
    zig/src/core/contract/steer.zig holds the kernel inside the bound the spec
    declares. The gates now check that on the GPU.
  • A new or changed GPU kernel is registered with the kernel contract, and
    each backend's SUMMARY line is in the receipt. Metal's is above. CUDA and
    HIP did not run: this machine has no NVIDIA or AMD GPU.
  • Prompt processing is no slower than the last release. Not measured: there
    is no earlier build of this feature to measure against. The projection rides
    in a kernel that already ran, and with no direction in force the extra work
    is skipped.
  • The description says which platforms ran and which could not. Metal ran on
    this M4 Pro. The limits for M1 to M5 are checked without a GPU. CUDA and HIP
    could not run here.
  • New tests fail before the change, pass after it, and skip cleanly without
    their dependency. The container tests need the reader, the parity tests need
    the reference implementation, and the device gates need a GPU, so they are not
    part of the CI run.
  • Comments and docstrings are one line. No measurements or history in the
    source.
  • No personal data, machine names, internal hosts or local paths. No AI
    attribution lines.

One test that waited for a stopwatch

The zig-windows job failed once on this branch, on a lane host test that has
nothing to do with control vectors: "a request that does not fit a shared cache
pool waits, in order, until a stream leaves" asked the host whether the waiting
request fit the pool and read the answer as zero. The host had not been asked
yet.

The test waited fifty milliseconds for that answer. On a loaded runner the
host's thread can be that late, and this branch makes the runner busier: a
third test step runs beside the others now, so the window is tighter than it
was. The two commits before this one passed the same job, so the failure
travelled with the runner's load and not with the code.

The test now waits for the question rather than for the stopwatch: it polls the
host's answer until it comes, for five seconds, and asserts the same number it
asserted before. What the test proves does not change. The failure was
reproduced here to be sure of the cause: with the host answering three hundred
milliseconds late, the old test prints the message CI printed and the new one
passes.

@BlivionIaG
BlivionIaG force-pushed the feature/glp-steering branch 5 times, most recently from 51cc5e2 to f57cc5d Compare November 1, 2026 14:22
@BlivionIaG
BlivionIaG force-pushed the feature/glp-steering branch 8 times, most recently from ed8c3e1 to 405e53f Compare November 5, 2026 21:34
@ashhart
ashhart force-pushed the feature/glp-steering branch from 405e53f to 3ab3c7c Compare November 6, 2026 03:00
@BlivionIaG
BlivionIaG force-pushed the feature/glp-steering branch 4 times, most recently from 731afc2 to ccac1b8 Compare November 12, 2026 17:00
@BlivionIaG
BlivionIaG force-pushed the feature/glp-steering branch 2 times, most recently from 1da7700 to c5947a8 Compare November 13, 2026 10:30
ashhart and others added 29 commits November 29, 2026 10:43
The reader implements the GLP format defined by the weightless project
(@msuiche): a GGUF v3 container of one fp32 direction per layer, applied by
adding it to the residual stream. A file with no mode is llama.cpp's additive
vector; a file that names any other mode, project included, is refused rather
than read as an add file. The reader also refuses a spec version, rank or hook
point it does not implement, a layer named twice, a direction that is not
finite, and a digest that does not match. It reports the SHA-256 of the exact
bytes it was handed, so a caller can name the file it loaded.

tf-glp-check shows the reader's view of a file for glp_parity.py to compare
with the reference reader, the file hash included.
…8-27B

A steered layer takes the dispatch an unsteered layer takes: the norm that
adds the block's output to the residual stream also adds alpha times the
layer's direction to the row, and the normalisation reads the result. The
plan holds one device buffer per layer the vector names, and a model without
one runs the plain norm. The steered norm clears the half-operand state the
plain norm leaves for the head, since its output has no such words.

The kernel contract has a float64 reference for the add, a bound for the
kernel's own fp32 product and sum, the launch's threads and threadgroup memory
for gate 5, and the GPU suite with a control that drops a NaN and one that
breaks the normalisation. The GPU half needs a Mac.
Off unless --glp is given: without it the server is as it was. The file is
read once at startup, before the model loads, and the startup line names the
file (escaped), the SHA-256 of its exact bytes and that replies are steered,
beside the strength, the layers and the checkpoint the vector came from. The
file hash is taken over the bytes already read; nothing is read twice.

A file the reader refuses, a width or base model that does not match the
checkpoint, a layer past the checkpoint's depth, a Gemma checkpoint, any other
family, and a CUDA or ROCm backend are all refused by name and the server does
not start. The engine reports the vector in force with the same file hash.

docs/control-vectors.md covers the format, the layer a direction names, the
refusals and how an operator brings a vector; the repository ships none.
glp_startup.flags is declared with cli_flag.Flag while cli.zig declared its
own identical struct, so the serve table's concatenation was a type error.
Alias Kind and Flag to cli_flag's and hold the identity in test-glp-serve.
main's qwen27_served.zig reached 600 lines, so the control vector wiring
pushed it over; the --drafter refusal joins the MTP refusal flags and the
startup report is one line. The changelog bullet returns to Unreleased.
Refuse a tensor offset or size that would wrap instead of reading past the
file, and check the alignment arithmetic. Bound metadata array recursion at
four and report the offending type or count.

Resolve a config file's relative --glp path against the TOML file's folder,
and stop advertising the control-vector flags in capabilities where every
valid use refuses them; the flags still parse there so their refusal names
the engine.

Report the tensor digest as verified only when the parsed glp.content_sha256
was checked, not when the bytes merely contain the key string, and refuse a
digest key that is not text. Host regressions cover each case.
…erved

The steer suite was freed before runAll read its probes; hold it through the run.
Build both kernels from the production specialization so the plain norm returns padded rows.
The spec's layers field is required even when the helper fills it.
…ld apart

capabilitiesFor(.., true) lists --glp even where this host's engine refuses it,
so comparing that listing with glp_startup.steers failed every non-Metal shard.
Assert the forced steering build lists it, a false build still follows the
platform's advertised bit, and the real capabilities equal steers.
Metal contracted hv + alpha * d in the steered norm into one fused multiply-add. At strengths whose products round (0.1, 0.3) that differs in the bf16 stream from the separately ordered reference the contract declares; powers of two were exact either way, and the GPU suite ran only at 1.0. The kernel now turns contraction off, and the suite checks the steered row bit for bit against the separately rounded add at 0.1 and 0.3 on rows built to sit on a bf16 tie, with a planted contracted kernel that must differ in every element.
@ashhart
ashhart force-pushed the feature/glp-steering branch from 71afb8e to 1a8a2cb Compare November 29, 2026 10:47

This branch has not been deployed

No deployments
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.