Skip to content

Configuration

The export can be set up by a TOML file of its own (guide, keys). A training run is set up by one TOML file, e.g. a copy of examples/quick_start/train.toml:

python train/train.py --config configs/my_run.toml [--epochs N] [--device cuda]
  • Every key has a default; a config sets only what differs. The defaults follow the papers of the two architectures, MeshGraphNets and MGN-T, where they give a value.
  • Command line options of train.py override the TOML when they are given (command line).
  • Unknown keys are reported at start-up, so typos do not go unnoticed.
  • The checkpoint stores the resolved config with only the settings in effect (no MGN-T settings for a MeshGraphNets run, and so on), with the source file, its SHA-256 and the overrides.

What the settings do during a run: training; the comparison protocol fixes most of them (protocol).

[data]

Key Default Description
data_dir "data/deforming_plate_s10_small" Dataset folder written by the exporter (dataset.db, normalizer.json, metadata.json)
num_dataloader_workers 0 DataLoader processes that build the graphs; 0: in the main process (CPU), 2–4 on a GPU machine
lazy false Read the frames from dataset.db on access instead of loading the splits into memory, for splits that do not fit into RAM
cache_frames 0 Lazy: frames kept per process, least recently used out; 0: no cache
static_cache_mb 1024 Lazy: static graph data (mesh edges, world edge selection, rest positions) kept per process, in MB
local_features unset Local input features the model sees: static node features of the export by name (static_feature_names in metadata.json); []: none; unset: all
global_features unset Global input features the model sees: run parameters of the export by name (global_feature_names in metadata.json); []: none; unset: all
target_fields unset Result fields the model predicts besides the velocity, by name (target_feature_names in metadata.json), with their <name>_prev inputs; []: the velocity only; unset: all
start_frame unset Raw frame of the run the training starts with: the first current frame of the samples and the initial state of the rollouts (validation, test, and by default predict/rollout.py), one of the dataset; unset: its first frame
end_frame unset Raw frame of the run the training ends with: the last target of the samples and of the rollouts, one of the dataset; unset: its last frame

[model]

Key Default Description
architecture "meshgraphnets" Model architecture; one of meshgraphnets, mgn_t
residual_target false Predict the change of every target that has a *_prev input instead of its value; needs an export with --history 1
world_edges "all" Node pairs within the contact radius that get a world edge: all (MeshGraphNets), contact (different bodies only), self_contact_aware (pairs not connected through the material)
world_edge_exclude_distance 2.0 self_contact_aware: pairs with a path along the mesh edges of the rest state shorter than this many contact radii get no world edge
world_edge_exclude_hops unset self_contact_aware: pairs at most this many mesh edges apart get no world edge; instead of world_edge_exclude_distance

[model.meshgraphnets]

Key Default Description
latent_size 128 Width of every MLP and latent (paper 128)
num_mlp_layers 2 Hidden layers of every MLP; one setting with [model.mgn_t]
num_message_passing_steps 15 Message passing steps of the processor (paper 15)
aggregation "sum" Aggregation of the messages at a node: sum (paper) or mean; one setting with [model.mgn_t]

[model.mgn_t]

Key Default Description
latent_size 64 Width of the message passing stages
token_dim 32 Width of the transformer
num_tokens 128 Physical tokens P of the physics attention (paper, deforming_plate: 16)
num_heads 4 Attention heads
num_transformer_blocks 2 Transformer blocks
num_pre_mp_steps 2 Local message passing steps before the transformer
num_post_mp_steps 2 Local message passing steps after the transformer
num_mlp_layers 2 Hidden layers of every MLP; one setting with [model.meshgraphnets]
aggregation "sum" Aggregation of the messages at a node: sum (paper) or mean; one setting with [model.meshgraphnets]
pe_frequencies 8 Frequencies of the positional encoding (not given in the paper)
ffn_ratio 4 Hidden width of the feed-forward block over token_dim (not given in the paper)
tau_init 0.5 Initial temperature of the slice weights under softplus: τ starts at tau_init + ln 2 (paper: τ₀ = 1.0; see models/mgn_t.py)
transformer_nodes "structure" Nodes of the global stage: structure (paper: without the actuator) or all (every node)

[training]

Key Default Description
epochs 100 Training epochs
batch_size 2 Graphs per optimizer step (MeshGraphNets paper 2, MGN-T paper 32)
micro_batch_size unset Machine setting: graphs per forward pass, a divisor of batch_size; batch_size / micro_batch_size passes make one optimizer step with the same result. Unset: batch_size
learning_rate 0.0001 Initial learning rate of Adam (MeshGraphNets and MGN-T papers: 1e-4)
weight_decay 0.0 Weight decay of Adam
max_grad_norm 1.0 Gradient clipping to this norm
seed 42 Seed of the weight initialization, the sample order and the noise
device "auto" auto (GPU if available), cpu or cuda

[training.scheduler]

Key Default Description
type "exponential" Learning rate schedule: per optimizer step (exponential), per epoch (cosine), at evaluations (plateau) or none; one of exponential, plateau, cosine, none
min_lr 1e-06 End learning rate (exponential), lower bound (plateau, cosine)
decay_steps 5_000_000 exponential: optimizer steps to reach min_lr (MeshGraphNets paper: 5 M); "auto" = epochs × optimizer steps per epoch, so it is reached at the end of the run
patience 8 plateau: evaluations without improvement of the first criterion before the learning rate drops
factor 0.5 plateau: factor of the drop

[training.rollout_validation]

Key Default Description
enabled false Roll out the val split at evaluations; its errors become selection criteria
every_n_epochs 1 Epochs between evaluations (also in the first and last epoch)
max_sequences unset Roll out only the first N val trajectories. Unset: all

[training.early_stopping]

Key Default Description
enabled true Stop when no criterion reaches a new low; false: all epochs, the model selection still applies
patience 30 Evaluations without a new low in any criterion before the run stops
min_epochs 30 Epochs before a run may stop
criteria ["val_loss", "rollout_mse", "rollout_pos_rmse", "rollout_pos_rmse_final"] Selection criteria; the evaluation closest to the best value in all of them at once is selected; any of val_loss, rollout_mse, rollout_pos_rmse, rollout_pos_rmse_final

[loss]

Key Default Description
type "mse" Loss on the normalized targets; one of mse, mae, huber, smooth_l1
edge_stretch_weight 0.0 Weight of the loss on the length change of the mesh edges in one step (prediction against ground truth, in units of the velocity change of the targets): keeps the predicted mesh from stretching, folding stays free; 0: off
rigid_body_weight 0.0 Weight of the loss on the mean velocity of every free rigid body (in units of the velocity change of the targets), the motion the rollout gives the body; 0: off

[noise]

Key Default Description
world_noise_std 0.0 Position noise on the free nodes, standard deviation in the length unit of the data (length_unit of the export; MeshGraphNets paper: 3e-3 m)
stress_noise_std 0.0 Noise on stress_prev, standard deviation in the stress unit of the data (stress_unit of the export, Pa by default; history layout only)

[scheduled_sampling]

Key Default Description
enabled false Replace the *_prev inputs of a share of the nodes by the model's prediction (history layout only)
start_ratio 1.0 Share of the nodes that keep the ground truth at epoch 0
end_ratio 0.3 Share of the nodes that keep the ground truth after the warmup
warmup_epochs 50 Epochs over which the share goes linearly from the start to the end ratio
steps 1 Predicted steps before the sample: the model rolls out from the ground truth this many steps back, so that its inputs carry the drift of a short rollout; with more than 1 the share applies to whole samples instead of nodes

[rollout_training]

Key Default Description
enabled false Train on windows of consecutive steps that the model rolls out on its own predictions, with the loss on every step and the gradients through the whole window (history layout only; instead of [scheduled_sampling])
steps 4 Steps of a window: the first from the ground truth, every further one from the model's prediction of the step before; every epoch the trajectories are cut into such windows at a random phase, so that every sample is trained once per epoch; 1: one-step training

[checkpointing]

Key Default Description
checkpoint_dir "checkpoints" Output folder of the run
save_every 10 Write checkpoint_epoch_N.pt every N epochs (best_model.pt always)
log_every 1 Epoch summary in the log every N epochs
resume unset Checkpoint to continue from

Export config

The keys of python -m dataset_preprocessor.export --config FILE, each with the default and the description of its command line option.

[raw]

Key Default Description
format tfrecord Raw data: DeepMind TFRecord (standard), d3plot of OpenRadioss or LS-DYNA runs (docs/guides/openradioss.md, docs/guides/ls-dyna.md) or VTK time series
dir – Directory with meta.json and the .tfrecord or the run folders (default: datasets/deforming_plate/raw_dataset; d3plot: datasets/deforming_plate/raw_d3plot; vtk: datasets/deforming_plate/raw_vtk)
sources test.tfrecord Where the runs come from, one name, or three, one per split: train val test. TFRecord: the file inside --raw-dir (test.tfrecord: 100 trajectories); d3plot / vtk: the folder below --raw-dir (<name without .tfrecord> for converted runs), else all runs below --raw-dir

[raw.vtk]

Key Default Description
stress_field stress Point or cell field of the target stress: scalar, or stress tensor (6 / 9 components, gives the von Mises stress); '': no stress
node_type_field node_type Point field with the node types 0 / 1 / 3; absent: all normal
displacement_field – Positions = points + this field (exports with reference geometry)
node_id_field – Point field with node IDs: copies of a node in several parts become one node; None: the field marked as global IDs (e.g. UserID of ParaView's LS-DYNA reader), '': ignore IDs
part_field – Cell field with part IDs for --actuator-parts / --clamped-parts; None: parts named by their block or file

[dataset]

Key Default Description
out_dir data/deforming_plate_s10_small Output directory (== [data].data_dir in the config)
n_train 8 Train trajectories
n_val 2 Validation trajectories
n_test 2 Test trajectories
select_seed – Draw the trajectories of each split at random with this seed (stored in metadata.json); default: the first ones
num_steps 40 Frames per trajectory (samples per trajectory = num_steps - 1)
time_stride 10 Raw frames between two selected frames
history 0 1: append velocity_prev (+ stress_prev) to the node features (enables residual_target / scheduled sampling / rollout training); 0: the features of the deforming_plate benchmark
prev_stress --prev-stress With --history 1: include stress_prev

[units]

Key Default Description
length m Unit of the lengths in the raw data (positions, contact radius, e.g. mm for LS-DYNA models); the values are kept, the reports convert to SI
stress Pa Unit of the stress in the raw data (e.g. MPa for LS-DYNA models in mm, t, s); the values are kept, the reports convert to SI

[contact]

Key Default Description
radius – World edge radius, in the length unit of the raw data; default: collision_radius of meta.json (required for d3plot / vtk raw data without meta.json)
pairs – Contact rules of raw data with components (LS-DYNA and VTK parts): world edges only between these pairs, e.g. plate:impactor plate:plate (self-contact), also with patterns (box_*:beam_*); none given: every pair
use_deck_walls --deck-walls D3plot: use the rigid walls of the decks (*RIGIDWALL_PLANAR, /RWALL/CYL) as node features
gap --no-contact-gap Two more world edge features: the distance of the receiver from the sender's shell surface along its normal, and the clearance between the shell surfaces (that distance minus half of both thicknesses, from the static feature thickness)

[features]

Key Default Description
local – Static node features; vtk: point or cell fields of the first state (vectors: one per component); d3plot: thickness, initial_velocity and the material properties of the deck density, youngs_modulus, poisson_ratio, yield_stress (default: thickness and initial_velocity where the runs have them)
global – Run parameters in the dataset, one input per graph; default: all that the runs have
globals_file – JSON file with the run parameters of all runs, by the name of the run folder; default: a globals.json in every run folder
targets – Further result fields per state as targets, each under its own name; vtk: point or cell fields, e.g. plastic_strain (vectors: one per component); d3plot: plastic_strain, thickness (shells), mean_stress (of the membrane part, tension positive), bending_stress (shells with two or more integration points)
edges – D3plot: element properties on the mesh edges, the mean over the elements next to an edge: thickness (shells, from the deck) and the material properties density, youngs_modulus, poisson_ratio, yield_stress; unlike --static-fields they keep parts apart that share nodes

[large]

Key Default Description
block_mb 1024 LS-DYNA / VTK: read the frames of a run in blocks of about this size (MB), so a run need not fit into memory
edge_stats_stride 1 Fit the edge statistics (a contact search per frame) on every k-th sample of a trajectory only; 1 = all

[components]

What goes into the dataset: name patterns of the parts with their role (deformable, actuator, fixed, free_rigid); every other part is left out; instead of --free-rigid-parts, --exclude-parts, --actuator-parts and --clamped-parts; default: every part, roles from the raw data

Rollout config

The keys of python predict/rollout.py --config FILE, each with the default and the description of its command line option.

[rollout]

Key Default Description
checkpoint checkpoints/example_run/best_model.pt Trainer checkpoint (.pt)
data_dir data/deforming_plate_s10_small Dataset.db + normalizer.json — the dataset the checkpoint was trained on
split test Split of the dataset to roll out
output_dir – New or empty folder (default: rollouts/<time><training run><checkpoint>_<split>)
max_sequences – Roll out only the first N trajectories (default: all)
start_frame – Raw frame of the run the rollout starts from, its ground truth (default: that of the training, else the first frame of the dataset)
end_frame – Raw frame of the run the rollout ends with (default: that of the training, else the last frame of the dataset)
max_steps – Steps per trajectory (default: all)
device auto Auto: the GPU if available
export_vtu --export-vtu Write one .vtu per step (prediction / ground truth / error); needs pyvista
one_step --one-step Also compute the one-step rollout metrics RMSE-1 (a second model call per step)
lazy – Read the frames from dataset.db on access instead of loading the split (default: as in the training)

[evaluation]

Key Default Description
enabled --no-evaluate Evaluate the run on this rollout right after it (utils/evaluate_run.py)
output_dir – With --evaluate: new or empty folder for the evaluation (default: evaluations/<time>_<run>_evaluation)

[animation]

Key Default Description
enabled --no-animate Render one trajectory of this rollout as an animated GIF right after it (utils/animate_rollout.py); needs the .vtu export
trajectory – With --animate: e.g. test_traj0136 (default: the trajectory at the median of the position error)
output_dir – With --animate: new or empty folder for the GIF (default: evaluations/<time>_animation)