{"id":20756589,"url":"https://github.com/mattjesc/ptq-meshgraphnet-nvidia-modulus","last_synced_at":"2026-05-30T10:31:42.929Z","repository":{"id":248114635,"uuid":"827744208","full_name":"Mattjesc/PTQ-MeshGraphNet-NVIDIA-Modulus","owner":"Mattjesc","description":"Post-Training Quantization for MeshGraphNet Physics-Based ML Model: Cardiovascular Flow Simulation Implementation","archived":false,"fork":false,"pushed_at":"2024-07-12T12:00:36.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-11T15:54:05.478Z","etag":null,"topics":["ai","deep-learning","deeplearning","nvidia","nvidia-cuda","nvidia-modulus","quantization"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Mattjesc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-12T09:28:26.000Z","updated_at":"2024-07-29T14:00:11.000Z","dependencies_parsed_at":"2024-07-12T14:03:45.706Z","dependency_job_id":null,"html_url":"https://github.com/Mattjesc/PTQ-MeshGraphNet-NVIDIA-Modulus","commit_stats":null,"previous_names":["mattjesc/ptq-meshgraphnet-nvidia-modulus"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Mattjesc/PTQ-MeshGraphNet-NVIDIA-Modulus","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mattjesc%2FPTQ-MeshGraphNet-NVIDIA-Modulus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mattjesc%2FPTQ-MeshGraphNet-NVIDIA-Modulus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mattjesc%2FPTQ-MeshGraphNet-NVIDIA-Modulus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mattjesc%2FPTQ-MeshGraphNet-NVIDIA-Modulus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Mattjesc","download_url":"https://codeload.github.com/Mattjesc/PTQ-MeshGraphNet-NVIDIA-Modulus/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mattjesc%2FPTQ-MeshGraphNet-NVIDIA-Modulus/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27762497,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-12-16T02:00:10.477Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","deep-learning","deeplearning","nvidia","nvidia-cuda","nvidia-modulus","quantization"],"created_at":"2024-11-17T09:33:38.204Z","updated_at":"2025-12-16T09:58:19.149Z","avatar_url":"https://github.com/Mattjesc.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Post-Training Quantization for MeshGraphNet using NVIDIA Modulus: Cardiovascular Flow Simulation Implementation\n\n## Overview\n\nThis 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.\n\n## Prerequisites\n\n1. **Clone the NVIDIA Modulus Repository**:\n    Follow the instructions provided in the NVIDIA Modulus repository to set up the Modulus framework:\n    - [NVIDIA Modulus Repository](https://github.com/NVIDIA/modulus)\n    - Refer to the README in the Modulus repo for detailed setup instructions.\n\n2. **Prepare the Bloodflow Example**:\n    Navigate to the `examples/healthcare/bloodflow_1d_mgn` directory in the Modulus repository and prepare the example as per the instructions provided in the respective README file.\n\n## Adding Quantized Files\n\nAfter 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:\n\n1. **Copy Quantized Files**:\n    Copy the `train_quantized.py` and `inference_quantized.py` files to the `examples/healthcare/bloodflow_1d_mgn` directory.\n\n## Workflow\n\n1. **Run `train.py`**: This script trains the original MeshGraphNet model.\n    ```sh\n    python train.py\n    ```\n\n2. **Run `inference.py`**: This script performs inference using the trained original model and generates output graphs.\n    ```sh\n    python inference.py\n    ```\n\n3. **Run `train_quantized.py`**: This script applies post-training quantization to the MeshGraphNet model.\n    ```sh\n    python train_quantized.py\n    ```\n\n4. **Run `inference_quantized.py`**: This script performs inference using the quantized model and generates output graphs.\n    ```sh\n    python inference_quantized.py\n    ```\n\n5. **Compare Results**: Compare the results of `pressure.png` and `flowrate.png` from the original model with `pressure_quantized.png` and `flowrate_quantized.png` from the quantized model.\n\n## Example Results\n\n| Metric                      | Original Model | PTQ Model   |\n|-----------------------------|----------------|-------------|\n| Relative error in pressure  | 0.83%          | 17.91%      |\n| Relative error in flow rate | 4.00%          | 33.35%      |\n| Rollout time                | 0.653 seconds  | 0.535 seconds |\n\n\nFigure 1: Original Model Rollout and Relative Error Values\n\n![image](https://github.com/user-attachments/assets/4f78dcf9-ffb0-4b23-b713-2c9e8a926962)\n\nFigure 2: Quantized (PTQ) Model Rollout and Relative Error Values\n\n![image](https://github.com/user-attachments/assets/2a0c97e6-7f40-40bf-a527-c9f4a41cd4b9)\n\nFigure 3: Original Model Pressure Graph\n\n![image](https://github.com/user-attachments/assets/bac7e8a2-5dc2-434e-b720-5a4c7fda808d)\n\nFigure 4: Quantized (PTQ) Model Pressure Graph\n\n![image](https://github.com/user-attachments/assets/ef9543b6-8ef0-49c3-b56d-2cdc56c37c60)\n\nFigure 5: Original Model Flow Rate Graph\n\n![image](https://github.com/user-attachments/assets/9472b233-2a4e-4ba9-9f60-d7067f651c55)\n\nFigure 6: Quantized (PTQ) Model Flow Rate Graph\n\n![image](https://github.com/user-attachments/assets/0f53f947-9c65-4905-85c2-0f7d13be6f30)\n\n\n## Justifications and Explanations\n\n### Why Quantize Using PTQ?\n\nPost-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.\n\n### Hardware Considerations\n\nThe 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.\n\n## Acknowledgements\n\nSpecial thanks to:\n- [Authors and Contributors](https://arxiv.org/abs/2010.03409) of the MeshGraphNet model and the underlying datasets.\n- [NVIDIA Modulus Team](https://developer.nvidia.com/modulus) for their framework and support.\n- [Vascular Model Repository](https://vascularmodel.com/) for providing the dataset.\n\n## References\n\n- [Learning Mesh-Based Simulation with Graph Networks](https://arxiv.org/abs/2010.03409)\n- [PD-Quant: Post-Training Quantization based on Prediction Difference Metric](https://arxiv.org/abs/2212.07048)\n- [Recipes for Post-Training Quantization of Deep Neural Networks](https://arxiv.org/abs/2007.00893)\n\n## Citation\n\n```yaml\ncff-version: 1.2.0\nmessage: If you use this software, please cite it as below.\ntitle: NVIDIA Modulus\nversion: 0.6.0\nauthors:\n  - family-names: NVIDIA Modulus Team\nurl: https://github.com/NVIDIA/modulus/tree/main\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattjesc%2Fptq-meshgraphnet-nvidia-modulus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmattjesc%2Fptq-meshgraphnet-nvidia-modulus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattjesc%2Fptq-meshgraphnet-nvidia-modulus/lists"}