rust-lstm-1025
A Rust implementation of a BMI (Basic Model Interface) adapter for LSTM-based streamflow prediction, providing a drop-in replacement for the Python BMI LSTM implementations found in CIROH-UA/lstm, NOAA-OWP/lstm, and jmframe/lstm.
Status
⚠️ Active Development - This package is currently under active development. The outputs produced match those of the Python BMI LSTM implementation and it runs faster, but the code quality is not yet at the same level as the Python implementation.
Acknowledgments
This project would not have been possible without:
- Contributors to NOAA-OWP/lstm and jmframe/lstm
- @aaraney for the excellent bmi-rs Rust BMI bindings
- The NextGen and CIROH communities
Features
- Native Rust implementation using the Burn deep learning framework
- Compatible with existing PyTorch model weights from jmframe/lstm and NextGen-In-A-Box
- Drop-in replacement for Python BMI LSTM adapter
- Supports ensemble model configurations
- Built on bmi-rs Rust BMI bindings
Dependencies
Usage
The adapter is designed to work with NextGen framework configurations:
# Install Astral UV
|
# Install rust
| &&
# the shared object is located at target/release/librust_lstm_1025.so
Model Compatibility
This implementation works with:
- Trained models from jmframe/lstm
- Models included in NextGen-In-A-Box
- Any PyTorch LSTM model following the neuralhydrology 1 layer lstm + 1 linear layer architecture
Weight conversion from PyTorch to Burn format is handled automatically on first run.
Nextgen realization
To use the model update your NextGen configuration file with the module like this:
NGIAB patch
To patch this into nextgen in a box, run this Dockerfile
FROM awiciroh/ciroh-ngen-image AS build
RUN dnf install -y gcc clang git
RUN curl https://sh.rustup.rs -sSf | bash -s -- -y
RUN echo 'source $HOME/.cargo/env' >> $HOME/.bashrc
WORKDIR /build
RUN git clone https://github.com/aaraney/bmi-rs
RUN git clone https://github.com/ciroh-ua/rust-lstm-1025
WORKDIR /build/rust-lstm-1025
RUN cargo build --release
FROM awiciroh/ciroh-ngen-image AS final
COPY --from=build /build/rust-lstm-1025/target/release/librust_lstm_1025.so /dmod/shared_libs/librust_lstm_1025.so
License
[License information pending]