Home

Awesome

:snake::battery: SambaMixer: State of Health Prediction of Li-ion Batteries using Mamba State Space Models

Authors: <br> Sascha Kirch, José Ignacio Olalde-Verano , Sergio Martín & Clara Pérez-Molina

arXiv PWC

[BibTex]

Oficial code base of our paper: SambaMixer: State of Health Prediction of Li-ion Batteries using Mamba State Space Models.

:bulb: Contribution

  1. Introducing Mamba state space models to the problem of Li-Ion battery SOH prediction.
  2. Using an anchor-based resampling scheme to resample time signals to have the same number of samples while serving as a data augmentation method.
  3. Applying a sample time-based positional encoding scheme to the input sequence to tackle sample jitter, time signals of varying length and recuperation effects of Li-ion batteries.

:question: Never heard of Mamba Selective State Space models?

Here we provide free access to Sascha's series: Towards Mamba State Space Models Images, Videos and Time Series.

And here free access to all his other articles

:fire: News

:star: Framework

<img src="media/architecture.png" alt="SambaMixer Architecture" width="800%">

:medal_military: Results

<table> <tr> <td> <img src="media/soh_prediction_bat6.png" alt="soh_prediction_bat6" width = 100% ></td> <td><img src="media/soh_prediction_bat7.png" alt="soh_prediction_bat7" width = 100%></td> <td><img src="media/soh_prediction_bat47.png" alt="soh_prediction_bat47" width = 100%></td> </tr> </table>
BatteryModelMAERMSEMAPE
#06Mazzi et al. (2024)2.4483.1771.579
SambaMixer (ours)1.1732.0681.406
#07Mazzi et al. (2024)1.8612.2521.114
SambaMixer (ours)1.1971.2851.498
#47Mazzi et al. (2024)2.5493.0941.969
SambaMixer (ours)0.5120.6450.822

:hammer_and_wrench: Installation

Step 1: Docker container

first change into ./environment directory.

Then build an image from the docker file.

Note that you can provide different build-args here. Ones often used are: --build-arg HTTP_PROXY, --build-arg USER_ID=$UID and --build-arg GROUP_ID=<YOUR_GROUPID>

docker build -t samba-mixer -f Dockerfile .

Create a container from the image.

docker container create --gpus all --name samba-mixer --network=host --mount=type=tmpfs,target=/dev/shm -v ~/git/sascha-kirch/samba-mixer:/home/dev_user/samba-mixer -it samba-mixer:latest

Note that --gpus might be set to 1 to not block all existing GPUs in a shared environment and that the port mapping might be used already, so you must specify another port.

Further note that --mount=type=tmpfs,target=/dev/shm is used to mount a larger filesystem to the shared memory /dev/shm heavily used by pytorch. Docker defaults this memory to have 64MB and even though docker build has --shm-size command, it apperently is ignored in some versions of docker. In my case, I end up with 13GB for /dev/shm after I mount the tmpfs.

To start the container in an interactive bash:

docker container start -i samba-mixer

Or you can connect to the container via attaching VS Code to it.

Step 2: Install the samba_mixer package inside the docker

python -m pip install -e .

Step 3: Install the Mamba Package inside the docker

cd ./third_party_packages/mamba
python -m pip install -e .
cd ..

Note: It might happen that the installation crashes with an error message related to: ImportError: connot import name 'packaging' from ..... In that case you need to down grade setuptools via python -m pip install -U setuptools==69.2.*

Step 4: Install the causal-conv-1d Package inside the docker

cd ./third_party_packages/causal-conv1d-1.2.2
python -m pip install -e .
cd ..

:battery: Add NASA dataset to ./datasets

Only needs to be done once during the initial setup of this repo.

Step 1: Download and uzip all files

mkdir datasets
cd ./datasets
wget https://phm-datasets.s3.amazonaws.com/NASA/5.+Battery+Data+Set.zip
unzip "5.+Battery+Data+Set.zip"
mv "5. Battery Data Set"/ nasa_batteries_orig
cd ./nasa_batteries_orig
unzip "1. BatteryAgingARC-FY08Q4.zip" -d "1. BatteryAgingARC-FY08Q4"
unzip "2. BatteryAgingARC_25_26_27_28_P1.zip" -d "2. BatteryAgingARC_25_26_27_28_P1"
unzip "3. BatteryAgingARC_25-44.zip" -d "3. BatteryAgingARC_25-44"
unzip "4. BatteryAgingARC_45_46_47_48.zip" -d "4. BatteryAgingARC_45_46_47_48"
unzip "5. BatteryAgingARC_49_50_51_52.zip" -d "5. BatteryAgingARC_49_50_51_52"
unzip "6. BatteryAgingARC_53_54_55_56.zip" -d "6. BatteryAgingARC_53_54_55_56"
cd ..
rm -rfv **/*.zip

if wgeet fails, retry and add oprion --no-check-certificate to the wget comand

Note: in case those unzip commands do not work or you end up with a different file tree you need to endup with the following file tree

|-- samba_mixer
    |-- datasets
        |-- nasa_bateries_orig
            |-- 1. BatteryAgingARC-FY08Q4
            |-- 2. BatteryAgingARC_25_26_27_28_P1
            |-- 3. BatteryAgingARC_25-44
            |-- 4. BatteryAgingARC_45_46_47_48
            |-- 5. BatteryAgingARC_49_50_51_52
            |-- 6. BatteryAgingARC_53_54_55_56

Step 2: preprocess to obtain dataset as needed by samba

cd ./scripts/utils
# Get unfiltered datasets
python convert_nasa_dataset_discharge.py

# Apply filters and pre processing as determined in the dataset analysis
python convert_nasa_dataset_discharge.py --filter

:swimmer: Train and Eval Model

# Train a model using ./configs/train_config.yaml
python scripts/train.py

# Train a multiple models using ./configs/experiment_train_model_scaling.yaml
python scripts/train.py -m --config-name experiment_train_model_scaling

# Evaluate a model using ./configs/eval_config.yaml
python scripts/eval.py

# Evaluate multiple models using ./configs/eval_config.yaml
python scripts/eval.py -m

# Start all ablation training runs
sh scripts/start_ablations.sh

# Start all experiment training runs
sh scripts/start_experiments.sh

NOTE: Before you can eval the models, make sure to copy the checkpoint paths into the respect eval configs.

:chart_with_upwards_trend: Experiment Logging

We use tensorboard to log experiements. You can either install a Tensorboard plugin within VS code or start the tensorboard via the CLI

tensorboard --logdir <PATH_TO_LOGS>

:warning: Trouble Shooting

Running out of space in the Dev container

Delete Temp Build Files

You can delete the build files of ./third_party_packages/mamba/build and ./third_party_packages/causal-conv1d-1.2.2/build since the built so-file is copied into the root of mamba and the build files and temp files are not cleaned automatically by mamba

:black_nib: Citation

If you find our work helpful for your research, please consider citing the following BibTeX entry.

@misc{olalde_kirch_2024_sambamixer,
      title={SambaMixer: State of Health Prediction of Li-ion Batteries using Mamba State Space Models},
      author={José Ignacio Olalde-Verano and Sascha Kirch and Clara Pérez-Molina and Sergio Martin},
      year={2024},
      eprint={2411.00233},
      archivePrefix={arXiv},
      primaryClass={cs.LG},
      url={https://arxiv.org/abs/2411.00233},
}