swfsql/mamba-minimal-dfdx-example

An example of using mamba (minimal) with dfdx

Rust

1

23 commits

updated Aug 9, 2026

See the code
dfdx
mamba
webassembly

README

mamba-minimal-dfdx-example

Click here to run the model in your browser.

Information

Adapted from huggingface/candle/mamba-minimal.

Building

Native
RUSTFLAGS="-C target-cpu=native" cargo run --release --no-default-features --features "native"
WASM
# no-ui (web console only)
wasm-pack build --release --target web --no-default-features

# yew web ui
wasm-pack build --release --target web --no-default-features --features "wasm_yew_ui"

# serve
http -a 127.0.0.1

Benchmarks

Whole-model timings for both execution modes — see bench.md. Nothing is downloaded: the model is built with random weights in the checkpoint's exact topology. Everything is single-threaded f32 on the CPU, so -C target-cpu=native is worth only a few percent.

./bench.sh                  # both builds (generic vs target-cpu=native) → bench.md
cargo bench --bench model   # just this build

Each case measures for at most BENCH_BUDGET_MS (default 60s): after the warm-up the bench times one iteration and plans from it, taking between 10 and 100 — so a slow case buys fewer samples rather than a longer run. One iteration costing more than a tenth of the budget is the one thing the cap cannot help with, since criterion takes no fewer than ten samples; stateless is such a case and is logged over-budget.

BENCH_SEQ (default 256) sets the prompt length the stateless pass runs over. That default, and the cap, match the Burn port's burn-mamba-example bench, so the two reports compare directly: stateless against its forward/mamba1 and stateful against its step/mamba1, in its single-threaded CPU (flex) column.

Contributors

swfsql

23 commits

swfsql/mamba-minimal-dfdx-example

An example of using mamba (minimal) with dfdx

Rust

1

23 commits

updated Aug 9, 2026

See the code
dfdx
mamba
webassembly

README

mamba-minimal-dfdx-example

Click here to run the model in your browser.

Information

Adapted from huggingface/candle/mamba-minimal.

Building

Native
RUSTFLAGS="-C target-cpu=native" cargo run --release --no-default-features --features "native"
WASM
# no-ui (web console only)
wasm-pack build --release --target web --no-default-features

# yew web ui
wasm-pack build --release --target web --no-default-features --features "wasm_yew_ui"

# serve
http -a 127.0.0.1

Benchmarks

Whole-model timings for both execution modes — see bench.md. Nothing is downloaded: the model is built with random weights in the checkpoint's exact topology. Everything is single-threaded f32 on the CPU, so -C target-cpu=native is worth only a few percent.

./bench.sh                  # both builds (generic vs target-cpu=native) → bench.md
cargo bench --bench model   # just this build

Each case measures for at most BENCH_BUDGET_MS (default 60s): after the warm-up the bench times one iteration and plans from it, taking between 10 and 100 — so a slow case buys fewer samples rather than a longer run. One iteration costing more than a tenth of the budget is the one thing the cap cannot help with, since criterion takes no fewer than ten samples; stateless is such a case and is logged over-budget.

BENCH_SEQ (default 256) sets the prompt length the stateless pass runs over. That default, and the cap, match the Burn port's burn-mamba-example bench, so the two reports compare directly: stateless against its forward/mamba1 and stateful against its step/mamba1, in its single-threaded CPU (flex) column.

Contributors

swfsql

23 commits

Languages

Rust

91.1%

Shell

8.3%