Repository navigation
Fix two crashes on the Mac's GPU and an unfitted-manifold error, for 5.4.1 - #67
Merged
Merged
Conversation
On MPS, every device op goes through one global command buffer that is not
thread-safe, and a copy off the device on a request thread while another
thread's model op holds it aborts the server (failed assertion _status <
MTLCommandBufferStatusCommitted). Three readers did that without the lock:
GET /probes copied each geometry probe's resident node_coords,
GET /probes/{name}/geometry copied the whitened factors, and POST
/tree/transcript folded and copied the resident basis to hash a probe. A
guard that flags MPS ops made off the GPU lock recorded about 197,000 of them
from these three while replies streamed on SmolLM2.
Attach already builds a geometry probe from a host copy, so it now keeps what
those readers need from that copy before the upload
(AttachedManifoldProbe.node_coords_host, .geometry and .digest). The listing
reads the node coords, Monitor.probe_geometry lists the inspector payload
(monitor_attach.probe_geometry_payload, moved from the Monitor with the same
output; its arrays stay fp32 host tensors that pack_to_device skips), and
GeometryInstrument.probe_hash reads the digest (monitor_attach.probe_digest,
hashing rule unchanged). The inspector stays lock-free on purpose: taking the
session lock instead made it wait out a whole streamed reply, past a 30 s
client timeout under the same stress. The token replay renders its ids, which
uploads them, inside the exclusive section.
On MPS the host digests and geometry payloads equal what the resident path
produced (every default probe plus the curved emotions manifold, digests
equal and payloads byte-identical), so 5.4.0 transcripts still verify, and a
six-round guarded stress records no off-thread MPS op.
A probe selector naming an installed manifold that is not fitted for the model falls back to extraction. For a multi-node manifold (emotions, personas) extraction reused the folder, fitted every node, wrote and adopted the fit, and only then failed to fold it into one direction with a bare ValueError, so POST /probes answered a scrubbed 500 after minutes of work (and a retry then succeeded off the fit the failure had written). Reusing a folder of more than two nodes is now a ManifoldSpecError (400) with the fit command, raised under the manifest lock before any corpus or fit work.
The affine synthesis is host-side at install while a curved manifold's basis is resident on the session device, so any affine term beside a curved % term failed to install on MPS (present since 5.4.0).
Keeps the lock-free probe readers off the GPU, refuses to extract a multi-node manifold as a vector before fitting it, and installs affine steering beside a curved term on MPS.
a9lim
enabled auto-merge
November 1, 2026 15:14
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.
Three fixes for 5.4.0 on Apple-silicon Macs, for a 5.4.1 release. 6.0 will not read 5.x saved chats, so 5.4 stays in use for a while.
Fixes
The server could abort while a reply streamed (MPS). Every device operation on MPS goes through one global command buffer that is not thread-safe. Three request handlers copied tensors off the GPU without the lock while another thread generated:
GET /probes(each geometry probe's node coordinates),GET /probes/{name}/geometry(the whitened factors) andPOST /tree/transcript(hashing a probe). The server then died onfailed assertion _status < MTLCommandBufferStatusCommitted. Attach already builds each geometry probe from a host copy, so it now keeps what those readers need from that copy, and the readers never touch the device. Digests and inspector payloads are byte-identical to 5.4.0's, so 5.4.0 transcripts still verify. A guarded six-round stress recorded no off-thread MPS operation, where the old code made about 197,000.Attaching an unfitted multi-node manifold failed after minutes of work.
POST /probesnaming an installed manifold with no fit for the model (emotions,personas) fell back to extraction: it fitted every node, wrote the fit, and only then failed with a bareValueError(a scrubbed 500). It now refuses up front with aManifoldSpecError(400) that names the fit command, before any corpus or fit work.Any flat steering term beside a curved
%term failed to install on MPS. The affine synthesis runs on the host at install, while a curved manifold's basis lives on the GPU, so orthogonalising one against the other mixed devices. The basis is now moved to the synthesis device first (drowse/steering/hooks.py).Tests
tests/server/test_probe_device_reads.py, the multi-node extraction refusal, the monitor/probe-geometry payload tests, andtests/gpu/test_session.py::TestMixedSteering(flat + curved steering on MPS).TestMixedSteeringfails on MPS without the hooks fix and passes with it.Release
The version is not bumped here. Bump
__version__indrowse/__init__.pyto5.4.1before merging; the push tomainthen tags, publishes to PyPI and cuts the release.