mixle.experimental.ssm_hybrid module

E5 (part 2): the hybrid block – local attention + selective-scan SSM + E2’s moment-closure far field, composed in ONE ContextMechanism, with an explicit routing-mass receipt. See notes/designs/E5.md for the full design: why these three mechanisms (exact short-range, smooth long-range, sparse extreme-long-tail) are complementary rather than redundant, the exact fusion architecture (near+far combined by E2’s own joint softmax; that combined attention branch and the SSM branch fused by a separate learned 2-way gate). The routing receipt reports the forward pass’s gate and attention mass; it deliberately does not claim to attribute the fused output, because branch magnitude and cancellation make routing coefficients insufficient for output attribution.

Reuses, without reimplementing:

  • mixle.experimental.context_spine: _rope_angles/_apply_rope/SlidingWindowState (E1’s near field, exactly the code path SlidingWindowSpine.step uses).

  • mixle.experimental.moment_closure_attention: ClusterBank/_empty_cluster_bank/ mgf_cluster_attention/ingest_cluster_batch (E2’s far field, verbatim).

  • mixle.experimental.selective_scan: _scan_layer/_s4d_real_a_log_init/_dt_bias_init (E5 part 1’s S6 recurrence and its verified init, verbatim – the ONE scan implementation, not a second one).

class HybridState(near, banks=<factory>, ssm_h=<factory>, batch_size=1)[source]

Bases: object

Per-layer carried state: E1’s near-field cache, E2’s far-field ClusterBank, and E5 part 1’s SSM hidden state – one list per mechanism, indexed by layer, matching E1/E2’s existing per-layer-list convention so nothing about the state shape is new.

Parameters: