mamba icon indicating copy to clipboard operation
mamba copied to clipboard

Mamba2 instance failed

Open L1lBURY opened this issue 1 year ago • 8 comments

Hi! When I run the mamba2 usage case provided by the author, an error message says:

File "test.py", line 9, in model = Mamba2( File "/root/miniconda3/lib/python3.8/site-packages/mamba_ssm/modules/mamba2.py", line 77, in init assert self.d_ssm % self.headdim == 0 AssertionError

Can anyone solve this problem. I would greatly appreciate it

L1lBURY avatar Jun 26 '24 01:06 L1lBURY

Set dim = 32

Like so

import torch

from mamba_ssm.modules.mamba2 import Mamba2

batch, length, dim = 2, 64, 32
x = torch.randn(batch, length, dim).to('cuda')

model = Mamba2(
    # This module uses roughly 3 * expand * d_model^2 parameters
    d_model=dim,  # Model dimension d_model
    d_state=64,  # SSM state expansion factor, typically 64 or 128
    d_conv=4,  # Local convolution width
    expand=2,  # Block expansion factor
).to("cuda")
y = model(x)
assert y.shape == x.shape

JulienSiems avatar Jun 27 '24 08:06 JulienSiems

What is your causal_conv1d version? Is there a pytorch version? I still get an error: RuntimeError: causal_conv1d with channel last layout requires strides (x.stride(0) and x.stride(2)) to be multiples of 8

ly510244856 avatar Jun 28 '24 16:06 ly510244856

What is your causal_conv1d version? Is there a pytorch version? I still get an error: RuntimeError: causal_conv1d with channel last layout requires strides (x.stride(0) and x.stride(2)) to be multiples of 8

I also have this issue, have you fixed this issue?

hhhhpaaa avatar Jun 29 '24 06:06 hhhhpaaa

Set dim = 32

Like so

import torch

from mamba_ssm.modules.mamba2 import Mamba2

batch, length, dim = 2, 64, 32
x = torch.randn(batch, length, dim).to('cuda')

model = Mamba2(
    # This module uses roughly 3 * expand * d_model^2 parameters
    d_model=dim,  # Model dimension d_model
    d_state=64,  # SSM state expansion factor, typically 64 or 128
    d_conv=4,  # Local convolution width
    expand=2,  # Block expansion factor
).to("cuda")
y = model(x)
assert y.shape == x.shape

$ pip install -U causal_con1d $ python

import torch from mamba_ssm.modules.mamba2 import Mamba2 Traceback (most recent call last): File "", line 1, in ModuleNotFoundError: No module named 'mamba_ssm.modules.mamba2'

StorywithLove avatar Jul 03 '24 07:07 StorywithLove

Set dim = 32 Like so

import torch

from mamba_ssm.modules.mamba2 import Mamba2

batch, length, dim = 2, 64, 32
x = torch.randn(batch, length, dim).to('cuda')

model = Mamba2(
    # This module uses roughly 3 * expand * d_model^2 parameters
    d_model=dim,  # Model dimension d_model
    d_state=64,  # SSM state expansion factor, typically 64 or 128
    d_conv=4,  # Local convolution width
    expand=2,  # Block expansion factor
).to("cuda")
y = model(x)
assert y.shape == x.shape

$ pip install -U causal_con1d $ python

import torch from mamba_ssm.modules.mamba2 import Mamba2 Traceback (most recent call last): File "", line 1, in ModuleNotFoundError: No module named 'mamba_ssm.modules.mamba2'

I used 'dim=256 * n' to successfully run Mamba2. Anyway, thanks for the info.

ly510244856 avatar Jul 03 '24 13:07 ly510244856

File "/home/dl/anaconda3/envs/mypogevon/lib/python3.8/site-packages/mamba_ssm/ops/triton/ssd_combined.py", line 762, in forward causal_conv1d_cuda.causal_conv1d_fwd(rearrange(xBC, "b s d -> b d s"), RuntimeError: causal_conv1d with channel last layout requires strides (x.stride(0) and x.stride(2)) to be multiples of 8 I also have this problem when d_model=32,and after setting d_model = 256, successfully run Mamba2 too

duansanshi avatar Jul 04 '24 02:07 duansanshi

Set dim = 32

Like so

import torch

from mamba_ssm.modules.mamba2 import Mamba2

batch, length, dim = 2, 64, 32
x = torch.randn(batch, length, dim).to('cuda')

model = Mamba2(
    # This module uses roughly 3 * expand * d_model^2 parameters
    d_model=dim,  # Model dimension d_model
    d_state=64,  # SSM state expansion factor, typically 64 or 128
    d_conv=4,  # Local convolution width
    expand=2,  # Block expansion factor
).to("cuda")
y = model(x)
assert y.shape == x.shape

AttributeError: 'NoneType' object has no attribute 'causal_conv1d_fwd'

AlphaMind123 avatar Jul 11 '25 01:07 AlphaMind123

Set dim = 32 Like so

import torch

from mamba_ssm.modules.mamba2 import Mamba2

batch, length, dim = 2, 64, 32
x = torch.randn(batch, length, dim).to('cuda')

model = Mamba2(
    # This module uses roughly 3 * expand * d_model^2 parameters
    d_model=dim,  # Model dimension d_model
    d_state=64,  # SSM state expansion factor, typically 64 or 128
    d_conv=4,  # Local convolution width
    expand=2,  # Block expansion factor
).to("cuda")
y = model(x)
assert y.shape == x.shape

AttributeError: 'NoneType' object has no attribute 'causal_conv1d_fwd'

install mamba from the source code, and i recommand u to install mamba2.2.2 and causal-conv1d1.4.0. you will find you can run mamba. if you want to run mamba2. i am also trying to solve the problems.

LiulianC avatar Oct 14 '25 17:10 LiulianC