MCPcopy Create free account
hub / github.com/lingeringlight/START / create_block

Function create_block

models_mamba.py:144–180  ·  view source on GitHub ↗
(
    d_model,
    ssm_cfg=None,
    norm_epsilon=1e-5,
    drop_path=0.,
    rms_norm=False,
    residual_in_fp32=False,
    fused_add_norm=False,
    layer_idx=None,
    device=None,
    dtype=None,
    if_bimamba=False,
    bimamba_type="none",
    if_devide_out=False,
    init_layer_scale=None,
    START_flag=0,
)

Source from the content-addressed store, hash-verified

142
143
144def create_block(
145 d_model,
146 ssm_cfg=None,
147 norm_epsilon=1e-5,
148 drop_path=0.,
149 rms_norm=False,
150 residual_in_fp32=False,
151 fused_add_norm=False,
152 layer_idx=None,
153 device=None,
154 dtype=None,
155 if_bimamba=False,
156 bimamba_type="none",
157 if_devide_out=False,
158 init_layer_scale=None,
159 START_flag=0,
160):
161 if if_bimamba:
162 bimamba_type = "v1"
163 if ssm_cfg is None:
164 ssm_cfg = {}
165 factory_kwargs = {"device": device, "dtype": dtype}
166 mixer_cls = partial(Mamba, START_flag=START_flag, layer_idx=layer_idx, bimamba_type=bimamba_type, if_devide_out=if_devide_out, init_layer_scale=init_layer_scale, **ssm_cfg, **factory_kwargs)
167 # mixer_cls = partial(Mamba, START_flag=START_flag, layer_idx=layer_idx, bimamba_type=bimamba_type, if_devide_out=if_devide_out, init_layer_scale=init_layer_scale, **ssm_cfg, **factory_kwargs)
168 norm_cls = partial(
169 nn.LayerNorm if not rms_norm else RMSNorm, eps=norm_epsilon, **factory_kwargs
170 )
171 block = Block(
172 d_model,
173 mixer_cls,
174 norm_cls=norm_cls,
175 drop_path=drop_path,
176 fused_add_norm=fused_add_norm,
177 residual_in_fp32=residual_in_fp32,
178 )
179 block.layer_idx = layer_idx
180 return block
181
182
183# https://github.com/huggingface/transformers/blob/c28d04e9e252a1a099944e325685f14d242ecdcd/src/transformers/models/gpt2/modeling_gpt2.py#L454

Callers 1

__init__Method · 0.85

Calls 1

BlockClass · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…