Post-Training Quantization for MeshGraphNet using NVIDIA Modulus: Cardiovascular Flow Simulation Implementation
This project explores the application of post-training quantization (PTQ) to the MeshGraphNet model for simulating cardiovascular flow. The goal is to reduce computational demands, enabling deployment on resource-limited devices without significant loss of accuracy. The study details the quantization process, evaluates performance, and compares the quantized model with the original.
-
Clone the NVIDIA Modulus Repository: Follow the instructions provided in the NVIDIA Modulus repository to set up the Modulus framework:
- NVIDIA Modulus Repository
- Refer to the README in the Modulus repo for detailed setup instructions.
-
Prepare the Bloodflow Example: Navigate to the
examples/healthcare/bloodflow_1d_mgndirectory in the Modulus repository and prepare the example as per the instructions provided in the respective README file.
After setting up the NVIDIA Modulus repository and preparing the bloodflow example, add the quantized files from this project to the examples/healthcare/bloodflow_1d_mgn directory:
- Copy Quantized Files:
Copy the
train_quantized.pyandinference_quantized.pyfiles to theexamples/healthcare/bloodflow_1d_mgndirectory.
-
Run
train.py: This script trains the original MeshGraphNet model.python train.py
-
Run
inference.py: This script performs inference using the trained original model and generates output graphs.python inference.py
-
Run
train_quantized.py: This script applies post-training quantization to the MeshGraphNet model.python train_quantized.py
-
Run
inference_quantized.py: This script performs inference using the quantized model and generates output graphs.python inference_quantized.py
-
Compare Results: Compare the results of
pressure.pngandflowrate.pngfrom the original model withpressure_quantized.pngandflowrate_quantized.pngfrom the quantized model.
| Metric | Original Model | PTQ Model |
|---|---|---|
| Relative error in pressure | 0.83% | 17.91% |
| Relative error in flow rate | 4.00% | 33.35% |
| Rollout time | 0.653 seconds | 0.535 seconds |
Figure 1: Original Model Rollout and Relative Error Values
Figure 2: Quantized (PTQ) Model Rollout and Relative Error Values
Figure 3: Original Model Pressure Graph
Figure 4: Quantized (PTQ) Model Pressure Graph
Figure 5: Original Model Flow Rate Graph
Figure 6: Quantized (PTQ) Model Flow Rate Graph
Post-training quantization reduces the model size and memory usage, making it feasible to run large models on resource-limited hardware. PTQ specifically optimizes models for efficient inference, with the trade-off between computational efficiency and accuracy.
The quantization process and model evaluations are performed on a single RTX 3090 GPU. Different hardware setups, particularly variations in CPU capabilities, may yield varying outcomes in terms of training/inference speed and performance.
Special thanks to:
- Authors and Contributors of the MeshGraphNet model and the underlying datasets.
- NVIDIA Modulus Team for their framework and support.
- Vascular Model Repository for providing the dataset.
- Learning Mesh-Based Simulation with Graph Networks
- PD-Quant: Post-Training Quantization based on Prediction Difference Metric
- Recipes for Post-Training Quantization of Deep Neural Networks
cff-version: 1.2.0
message: If you use this software, please cite it as below.
title: NVIDIA Modulus
version: 0.6.0
authors:
- family-names: NVIDIA Modulus Team
url: https://github.com/NVIDIA/modulus/tree/main




