@@ -1052,7 +1052,7 @@ def forward(self, x, residual, **kwargs):
10521052
10531053# hyper connections
10541054
1055- def sinkhorn_knopps (t , iters = 20 ):
1055+ def sinkhorn (t , iters = 20 ):
10561056 dtype = t .dtype
10571057 t = t .float ()
10581058
@@ -1072,7 +1072,7 @@ def __init__(
10721072 layer_index ,
10731073 num_residual_streams ,
10741074 num_input_views = 1 ,
1075- tanh = True ,
1075+ sinkhorn_iters = 5 ,
10761076 ** kwargs
10771077 ):
10781078 """
@@ -1104,6 +1104,8 @@ def __init__(
11041104 self .dynamic_beta_fn = nn .Parameter (torch .zeros (dim ))
11051105 self .dynamic_beta_scale = nn .Parameter (torch .ones (()) * 1e-2 )
11061106
1107+ self .sinkhorn_iters = sinkhorn_iters
1108+
11071109 def prepare (self , residuals ):
11081110 views = self .num_input_views
11091111 streams = self .num_residual_streams
@@ -1123,7 +1125,7 @@ def prepare(self, residuals):
11231125 # the sinkhorn knopps constraint for the residual mixing
11241126
11251127 alpha_residual = rearrange (alpha_residual , '... (s1 s2) -> ... s1 s2' , s2 = streams )
1126- alpha_residual = sinkhorn_knopps (alpha_residual )
1128+ alpha_residual = sinkhorn (alpha_residual , self . sinkhorn_iters )
11271129 alpha_residual = rearrange (alpha_residual , '... s1 s2 -> ... (s1 s2)' )
11281130
11291131 alpha = cat ((alpha_input , alpha_residual ), dim = - 1 )
@@ -2287,6 +2289,7 @@ def __init__(
22872289 learned_value_residual_mix = True , # seeing big improvements when the value residual mix value is learned per token - credit goes to @faresobeid for taking the first step with learned scalar mix, then @Blinkdl for taking it a step further with data dependent. here we will use per token learned
22882290 rel_pos_kwargs : dict = dict (),
22892291 residual_fn_kwargs : dict = dict (),
2292+ hyper_conn_sinkhorn_iters = 5 ,
22902293 verbose = True ,
22912294 ** kwargs
22922295 ):
@@ -2618,7 +2621,7 @@ def __init__(
26182621 layer_integrate = DynamicLIMe (dim , num_layer_hiddens , num_views = layer_integrate_num_view , use_softmax = layer_integrate_use_softmax )
26192622
26202623 if has_hyper_connections :
2621- residual_fn = partial (HyperConnection , num_residual_streams = num_residual_streams )
2624+ residual_fn = partial (HyperConnection , num_residual_streams = num_residual_streams , sinkhorn_iters = hyper_conn_sinkhorn_iters )
26222625
26232626 if layer_type == 'a' and hyper_conn_produce_diff_views :
26242627 residual_fn = partial (residual_fn , num_input_views = 3 )
0 commit comments