state-spaces / mamba

Mamba SSM architecture
Apache License 2.0
12.71k stars 1.07k forks source link

RuntimeError: causal_conv1d with channel last layout requires strides (x.stride(0) and x.stride(2)) to be multiples of 8 #351

Open xiaoxudaxfcv opened 3 months ago

xiaoxudaxfcv commented 3 months ago

from mamba_ssm import Mamba2 model = Mamba(

This module uses roughly 3 expand d_model^2 parameters

d_model=64, # 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") NameError: name 'Mamba' is not defined. Did you mean: 'Mamba2'? Change to model = Mamba2 to solve the above problem, but using Mamba on the original task will not cause an error, but using from mamba_ssm to import Mamba2 model = Mamba2, the error message RuntimeError: causal_conv1d with channel last layout requires strides (x.stride(0) and x.stride(2)) to be multiples of 8
改成model = Mamba2,解决上面问题,但是在原来的任务上使用Mamba不会报错,但使用from mamba_ssm import Mamba2 model = Mamba2,会报错RuntimeError: causal_conv1d with channel last layout requires strides (x.stride(0) and x.stride(2)) to be multiples of 8

yimgg commented 3 months ago

from mamba_ssm import Mamba2 model = Mamba( #该模块大约使用了3 expand d_model^2 个参数 d_model=64, #模型维度 d_model d_state=64, # SSM状态扩展因子,通常为 64 或 128 d_conv=4, #局部清晰度宽度 expand=2, #块扩展因子 ).to("cuda") NameError: 名称 'Mamba' 未定义。您的意思是: 'Mamba2'? 改成model = Mamba2即可解决上述问题,原来的任务使用Mamba不会报错,但是使用from mamba_ssm import Mamba2 model = Mamba2时,报错信息RuntimeError: causal_conv1d with channel last layout require strides (x.stride(0) and x.stride(2)) to be multiples of 8 改成model = Mamba2,解决上面问题,原来的任务使用Mamba不会报错,但是使用from mamba_ssm import Mamba2 model = Mamba2,会报错RuntimeError: causal_conv1d with channel last layout require strides (x.stride(0) and x.stride(2)) to be multiples of 8

I also encountered the same problem

LMD0311 commented 3 months ago

https://github.com/state-spaces/mamba/issues/345#issuecomment-2145035818 You may try this.

liujiaozhiren commented 3 months ago

maybe add .contiguous() guess the author forget

WuJammy commented 3 months ago

same problem Has anyone solve it?

Dexterp37 commented 3 months ago

maybe add .contiguous() guess the author forget

Thank you for your tip. I created a PR based on your suggestion #362

liujiaozhiren commented 3 months ago

maybe add .contiguous() guess the author forget

Thank you for your tip. I created a PR based on your suggestion #362

i remember the backward and the forward both need to fix. hope U miss nothing.XD

yedadasd commented 3 months ago

still dontwork

bio-mlhui commented 3 months ago

You can skip causual_1d_conv (comment out and set the causual_conv_1d=None). It will use the nn.Conv1d function. Finally, you need to make the transposed tensor to be contiguous()

Dexterp37 commented 3 months ago

You can skip causual_1d_conv (comment out and set the causual_conv_1d=None). It will use the nn.Conv1d function. Finally, you need to make the transposed tensor to be contiguous()

Indeed, the second commit addresses the latter.

Dexterp37 commented 3 months ago

maybe add .contiguous() guess the author forget

Thank you for your tip. I created a PR based on your suggestion #362

i remember the backward and the forward both need to fix. hope U miss nothing.XD

Sadly it still won't work even after making it contiguous in the second part. It would now fail with a different error.

WuJammy commented 3 months ago

Mamba2 has same problem on my two devices(3080 , 3090).

I also try to run Mamba2 on colab(T4). It doesn't have this issue, but other error emerged.

LinYuXuan168 commented 3 months ago

也许添加 .contigious() 猜作者忘记了

谢谢你的提示。我根据你的建议创建了一个 PR #362

我记得向后和向前都需要修复。希望你没有错过任何事情。XD

遗憾的是,即使在第二部分中使其连续之后,它仍然无法工作。现在它会因不同的错误而失败。

I used the method you mentioned, but I encountered a strange mistake: Attributeerror: Module 'Triton. Language' Has No Attribute 'Cumsum'

AmadFat commented 3 months ago

也许添加 .contigious() 猜作者忘记了

谢谢你的提示。我根据你的建议创建了一个 PR #362

我记得向后和向前都需要修复。希望你没有错过任何事情。XD

遗憾的是,即使在第二部分中使其连续之后,它仍然无法工作。现在它会因不同的错误而失败。

I used the method you mentioned, but I encountered a strange mistake: Attributeerror: Module 'Triton. Language' Has No Attribute 'Cumsum'

version problem

liujiaozhiren commented 3 months ago

也许添加 .contigious() 猜作者忘记了

谢谢你的提示。我根据你的建议创建了一个 PR #362

我记得向后和向前都需要修复。希望你没有错过任何事情。XD

遗憾的是,即使在第二部分中使其连续之后,它仍然无法工作。现在它会因不同的错误而失败。

I used the method you mentioned, but I encountered a strange mistake: Attributeerror: Module 'Triton. Language' Has No Attribute 'Cumsum'

update the triton

catalpaaa commented 3 months ago

just make sure d_model * expand / headdim = multiple of 8

i had d_model = 192, expand = 2 and i changed headdim from 64 to 48, everything runs fine after

Xxiaoshan commented 3 months ago

just make sure d_model * expand / headdim = multiple of 8

i had d_model = 192, expand = 2 and i change headdim from 64 to 48, everything runs fine after

I use your make sure method , d_model= 128 , expand=2, headdim= 4, I works,THANKS

By the way , it sames slow than mamba1

Zhou-CyberSecurity-AI commented 3 months ago

['/usr/bin/gcc', '/tmp/tmp9a7rbp53/main.c', '-O3', '-I/home/cpz/anaconda3/envs/mamba/lib/python3.10/site-packages/triton/common/../third_party/cuda/include', '-I/home/cpz/anaconda3/envs/mamba/include/python3.10', '-I/tmp/tmp9a7rbp53', '-shared', '-fPIC', '-lcuda', '-o', '/tmp/tmp9a7rbp53/cuda_utils.cpython-310-x86_64-linux-gnu.so', '-L/lib64', '-L/lib', '-L/lib64', '-L/lib']' returned non-zero exit status 1.

After soving this question, I continue to meet a new error.

fff-wang commented 2 months ago

['/usr/bin/gcc', '/tmp/tmp9a7rbp53/main.c', '-O3', '-I/home/cpz/anaconda3/envs/mamba/lib/python3.10/site-packages/triton/common/../third_party/cuda/include', '-I/home/cpz/anaconda3/envs/mamba/include/python3.10', '-I/tmp/tmp9a7rbp53', '-shared', '-fPIC', '-lcuda', '-o', '/tmp/tmp9a7rbp53/cuda_utils.cpython-310-x86_64-linux-gnu.so', '-L/lib64', '-L/lib', '-L/lib64', '-L/lib']' returned non-zero exit status 1.

After soving this question, I continue to meet a new error.

me too, did u solve this problem?