load_reference_state_dict#
- load_reference_state_dict(mixer, state_dict)#
Load a reference TriHyena checkpoint into
QKVSequenceMixer(TriangleHyena).The original TriHyena
TriangleHyenamodule storeslinear_x12i(x1andx2stacked),linear_vj, a(3D, 3)causal short-conv weight over[x1 | x2 | v],siren_kernel.*,to_outand a pre-norm. This maps them ontoqkv_proj([x1 | v | x2]channel blocks),short_conv_weight(same remap, transposed to[3, 3D]),global_conv.kernelandout_proj, and zeroesqkv_proj.biasandglobal_conv.shortcutwhen the mixer has them (the reference has neither; build withqkv_bias=Falseanduse_shortcut=Falseto drop them).The mixer must be built to match:
SIRENKernelND(L_cache=2 * L - 1)with the referenceL(its SIREN grid keeps the reference tap spacing1 / (2 (L - 1))at every runtime length and spans[-0.5, 0.5]only atL),mask_cfg = BoxModulationND(max_offset=<reference max_offset>)orIdentitywhen it was0,short_conv_kernel_size=3andout_proj_bias=True.- Parameters:
mixer (QKVSequenceMixer) –
QKVSequenceMixerwhosemixeris aTriangleHyena.state_dict (Mapping[str, Tensor]) – Reference state dict, optionally prefixed with
core..
- Returns:
The reference pre-norm tensors (
weight,bias) for the caller to load into the residual block’sLayerNorm.- Raises:
ValueError – If a tensor’s shape does not match the mixer’s, or a reference key is missing.
ValueError – If a reference key other than
grid_cacheis unused.ValueError – If a mixer parameter has no reference counterpart.
- Return type: