boss_bench

boss_bench.models

Contents

boss_bench.models#

Trained models from the BoSS paper, in PyTorch.

boss_bench.models.download(name, path, onnx=False)[source]#

Download a trained PyTorch or ONNX model baseline from Hugging Face.

Three models are available:

  • "loss_fraction" (LossFractionModel), a neural surrogate which predicts the loss fraction of the alpha particles born on \(s_0 = 0.1\) from the plasma boundary and profiles, without a VMEC run.

  • "heat_flux" (HeatFluxModel), a flow matching model which samples the locations at which lost fast ions strike the boundary.

  • "inverse_design" (InverseDesignModel), a flow matching model which generates plasma boundaries with a desired loss fraction, shape, field and profiles.

This function downloads the model’s config.json and model.safetensors into the folder path, which the model’s load then reads, e.g. HeatFluxModel.load(path). With onnx=True, it also downloads the model’s ONNX export, to run with ONNX Runtime: model.onnx, or encoder.onnx, velocity.onnx and decoder.onnx for the two flow matching models; config.json describes their inputs. Files already in the folder are not downloaded again.

Parameters:
  • name (str) – "loss_fraction", "heat_flux" or "inverse_design".

  • path (str) – the folder to download the model into; it is created if needed.

  • onnx (bool) – whether to also download the ONNX files.

Returns:

path.

Return type:

str

Raises:

ValueError – if the model name is unknown.