Vim icon indicating copy to clipboard operation
Vim copied to clipboard

What's the meaning of self.if_bidirectional

Open Lxg-233 opened this issue 1 year ago • 3 comments

what‘s the self.if_bidirectional,I konw that we define bimaba_type=v1/v2 in mamba_simple.py to present we use bidirectional ssm. So what's the meaning of self.if_bidirectional in models_mamba.py,I don't know it,please help me. thanks !

       if not self.if_bidirectional: 
       ..............
        else: 
            # get two layers in a single for-loop
            for i in range(len(self.layers) // 2): #
                if self.if_rope:
                    hidden_states = self.rope(hidden_states)
                    if residual is not None and self.if_rope_residual:
                        residual = self.rope(residual)

                hidden_states_f, residual_f = self.layers[i * 2](  
                    hidden_states, residual, inference_params=inference_params
                )
                hidden_states_b, residual_b = self.layers[i * 2 + 1](   
                    hidden_states.flip([1]), None if residual == None else residual.flip([1]), inference_params=inference_params
                )
                hidden_states = hidden_states_f + hidden_states_b.flip([1]) 
                residual = residual_f + residual_b.flip([1])

Lxg-233 avatar May 21 '24 15:05 Lxg-233

I really hlep!!!

Lxg-233 avatar May 23 '24 08:05 Lxg-233

The same issue. Have u solved this question?

Btw, does the bimaba_type==v2 indicate bidirectional ssm?

Thanks!

@xinggangw

MPCheng-ZW avatar Sep 06 '24 06:09 MPCheng-ZW

If I understand correctly, the if_bidirectional option is intended for the Bidirectional Layer experiment described in Section 4.4 of the paper’s ablation study.

JsHyun0 avatar Aug 21 '25 02:08 JsHyun0