Expand description
KernelTeam v0: the persistent worker pool for int8 GEMV/GEMM output-column partitions.
This is the doctrine’s “persistent, dispatch-free steady state” in its first shippable form: workers are spawned once per process, parked on a condvar between operations (no busy wait, no work stealing, no task submission), and each dispatch hands every worker a disjoint contiguous range of output columns. Integer accumulation makes the parallel result exactly the serial result per element — partitioning never changes a single output bit, so thread count is a pure speed knob.
§The safety argument, in full
A [Job] carries raw pointers into the caller’s slices. Three facts make that sound:
- Lifetime:
Team::linear_q8does not return until every worker has decrementedremainingto zero, so the pointers outlive every access. - Aliasing: workers write only
out[row * n + col]forcolinside their own disjoint column range; reads (x_q, scales, weights, bias) are shared and immutable for the whole dispatch because the caller holds the only&mut(toout) and blocks. - One parallel owner:
dispatch_gateserializes whole dispatches, so a second engine thread cannot overwrite the job while workers are mid-partition, and workers themselves never dispatch (their compute is a leaf loop).
A stress test drives thousands of mixed-shape dispatches and a watchdog test bounds wall
time, per the many_utterances_without_deadlock policy.
§Relation to the plan’s “sense-reversing barrier”
The doctrine text describes the steady-state rendezvous as a sense-reversing atomic
barrier. What ships here is a mutex/condvar generation-counter barrier: same protocol
shape (a monotone epoch replaces the flipped sense; workers wait for the epoch to advance,
the dispatcher waits for remaining to reach zero), but the ordering guarantees come from
the mutex, not from raw atomics — so an audit of this module should trace the lock, not
look for AtomicBool sense flags. The atomic flavor remains a candidate once dispatch
overhead itself shows up on a profile.
Structs§
- Team
- The process-wide team. Armed by default at min(6, cores) partitions on native
(
FTTS_INT8_THREADSoverrides; 1 disarms), and explicitly by the host on wasm.
Functions§
- armed
- The team for this process, if parallel execution is enabled.
- bypass_
team_ on_ this_ thread - Makes THIS thread run its int8 linears serially, never dispatching to the team.
- partitions
- Partitions the armed team runs with, or 1 when execution is serial.
- thread_
bypassed - Whether the current thread opted out of team dispatch.
- with_
team_ bypassed - Runs
bodywith team dispatch bypassed on this thread, restoring the previous state after.