flash_xlstm_exp (fsp)
Experimental fork-and-upgrade of NX-AI's TFLA (Tiled Flash Linear Attention) mLSTM kernels, targeting further GPU/Triton-level optimization on top of the official implementation.
Built with technology from NXAI. See NOTICE and
LICENSE — this repo is derived from
NX-AI/mlstm_kernels, licensed
under the NXAI Community License Agreement, not a permissive OSS
license. Redistributing fsp (or derivatives of it) requires keeping the
LICENSE + NOTICE files and the "Built with technology from NXAI" attribution
intact. See the NXAI Community License for the (currently inapplicable to
solo/small-scale use) large-enterprise commercial terms.
Upgrade roadmap
| # | Upgrade | Status |
|---|---|---|
| 1 | Dynamic tile-size autotuner (triton.autotune in place of the static get_head_dim_block_size / hardcoded siz_b_LQ=32,siz_b_LKV=32 heuristic) |
Implemented — fsp/kernels/autotune.py |
| 2 | Fused recurrent+parallel forward kernel (avoid materializing intermediate chunk states to HBM between the two kernel launches) | Planned |
| 3 | Quantized (fp8/int8) memory state C for long-context inference |
Planned |
Why GPU-only
TFLA's kernels are written in Triton and target NVIDIA/AMD GPUs via CUDA/ROCm. There is currently no Triton backend for mobile/ARM64-without-GPU environments (e.g. Termux on Android), so fsp's kernels can be written and code-reviewed in such an environment, but must be benchmarked and numerically validated on an actual CUDA (or ROCm) GPU — a local NVIDIA GPU, or a rented cloud GPU instance.
Layout
fsp/
├── vendor/ # Baseline TFLA, vendored from NX-AI/mlstm_kernels
│ ├── triton_kernels/ # - the @triton.jit kernels themselves
│ ├── torch_fw/ # - PyTorch launchers/wrappers (forward pass only, so far)
│ └── utils/ # - small shared dtype/validation helpers
├── kernels/
│ └── autotune.py # Upgrade #1: autotuned forward-parallel kernel
└── benchmark/
└── bench_autotune_vs_baseline.py
tests/
└── test_autotune_equivalence.py
Scope note: only the forward pass (recurrent + parallel kernels) is vendored so far. Backward-pass kernels (
bw_kernel_parallel_dK/dQ/dV,bw_kernel_recurrent) will be vendored in a later batch once the forward-pass upgrades are validated on real hardware.
Install
pip install torch triton
pip install -e .
Usage
from fsp.kernels.autotune import mlstm_chunkwise__parallel_fw_Hintra_autotuned
matH_out, vecN_out, vecM_out = mlstm_chunkwise__parallel_fw_Hintra_autotuned(
matQ, matK, matV, vecI, vecF,
matC_states, vecN_states, scaMinter_states,
chunk_size=128,
)
Drop-in replacement for
fsp.vendor.torch_fw.fw_parallel.mlstm_chunkwise__parallel_fw_Hintra — same
inputs/outputs, same math, but tile sizes are chosen empirically per shape
instead of by static heuristic.
Running tests / benchmarks
Both require a CUDA-capable GPU:
pytest tests/test_autotune_equivalence.py
python -m fsp.benchmark.bench_autotune_vs_baseline
Release files for flash-xlstm-exp 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| flash_xlstm_exp-0.1.0.tar.gz | 23.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| flash_xlstm_exp-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size:56.5 kB
Release files / flash_xlstm_exp-0.1.0.tar.gz
| Download URL | flash_xlstm_exp-0.1.0.tar.gz |
|---|---|
| Size | 23.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cc1be2e9292bc281b55f6615dd6822c8a3472fc7387165df54c9ef225759b78d
|
|
BLAKE2b-256 checksum How to use checksums |
3154187f1388e06003107a743e592b8314d2398d1b081001e3eb60d6d58bed88
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.6
|
Release files / flash_xlstm_exp-0.1.0-py3-none-any.whl
| Download URL | flash_xlstm_exp-0.1.0-py3-none-any.whl |
|---|---|
| Size | 33.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3435a3a08fd44a890ba2e58abadf335d70b4b0cd0f57be4b4d8db75d499248d3
|
|
BLAKE2b-256 checksum How to use checksums |
3a0dea6c22de850e82a847d1498ad82a0a6715fd5ece36f674c389594c3e12a0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.6
|