Skip to main content

Module team

Module team 

Source
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:

  1. Lifetime: Team::linear_q8 does not return until every worker has decremented remaining to zero, so the pointers outlive every access.
  2. Aliasing: workers write only out[row * n + col] for col inside 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 (to out) and blocks.
  3. One parallel owner: dispatch_gate serializes 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.

Structs§

Team
The process-wide team. Exists only when FTTS_INT8_THREADS requests more than one thread.

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.