mamba icon indicating copy to clipboard operation
mamba copied to clipboard

Decouple from Triton

Open richardburleigh opened this issue 2 years ago • 6 comments

Congratulations team! This is a seriously impressive model.

Thank you also for sharing the weights and supporting the open-source community!

FYI - I was able to successfully fine-tune the 2.8B model and completely demolish squad, showing strong reasoning abilities.

I'm wanting to see how far we can push the inference speed of this model, but the triton dependency is preventing loading it on CPU or doing an ONNX conversion.

Do you have any advice to decouple this dependency or alternative approaches?

Any help would be appreciated!

richardburleigh avatar Dec 08 '23 05:12 richardburleigh

Great to hear about the Squad result!

I don't have much experience with CPU or ONNX deployment. I mostly work with GPUs. The model architecture is quite different from what's commonly used (Transformers), so there's probably quite a bit to do to make it compatible with the ecosystem. Some of the operations are implemented in CUDA (selective scan), idk if that would work with ONNX. The causal_conv1d has a CUDA implementation but you can also just call pytorch. Triton is used for RMS norm I think, and you can replace that with a reference Pytorch implementation.

tridao avatar Dec 08 '23 05:12 tridao

I was also interested in a CPU implementation; I was curious if the functions suffixed with _ref are reference implementations (like this one https://github.com/state-spaces/mamba/blob/main/mamba_ssm/ops/selective_scan_interface.py#L311) that can be used to guide new implementations?

In the past I had quite some success porting CUDA/OpenCL kernels to CPU using ISPC (which has very similar programming model) but I saw that C10 & CUB are used here and I don't know them very well.

maedoc avatar Dec 15 '23 14:12 maedoc

Modified version to work on CPU is available on this fork

I chopped a lot of code, but it works (for inference only)

kroggen avatar Jan 03 '24 04:01 kroggen

Congratulations! But I have a question that why the 130M model doesn't preform well in training, only 15% accuracy. Am I doing something wrong?

Fiona-cn avatar Jun 03 '24 20:06 Fiona-cn

Thanks for your contribution @kroggen ! I used your mamba-cpu, and it works correctly. But converting it to ONNX took really long time. And do you have any suggestions for this?

liuyamjune avatar Aug 13 '25 06:08 liuyamjune

@liuyamjune I have no knowledge on ONNX

Have you seen if there is already some port of Mamba/Mamba2 to ONNX?

kroggen avatar Aug 14 '25 00:08 kroggen