This example demonstrates how to use the Skala machine learning functional in C++ CPU applications using LibTorch.
Install the locked Pixi environment from the repository root:
pixi install --locked -e cpp-integrationConfigure and build the example with CMake and Ninja in the Pixi environment:
pixi run -e cpp-integration cmake -B build_example -S model/examples/cpp/cpp_integration -G Ninja
pixi run -e cpp-integration cmake --build build_exampleDownload the Skala model from Hugging Face:
pixi run -e cpp-integration hf download microsoft/skala-1.1 \
skala-1.1-rev1.fun --local-dir .Prepare the molecular features for a test molecule (H2) using the provided script:
pixi run -e default python examples/cpp/cpp_integration/prepare_inputs.py \
--output-dir featuresFinally, run
pixi run -e cpp-integration ./build_example/skala_cpp_integration ./skala-1.1-rev1.fun ./featuresNote: You are expected to add D3 dispersion correction (using b3lyp settings) to the final energy of Skala.
This guide from Intel provides useful tips on how to tune performance of PyTorch models on CPU.