{"id":13544227,"url":"https://github.com/taichi-dev/difftaichi","last_synced_at":"2025-07-16T04:42:04.550Z","repository":{"id":43735422,"uuid":"225531542","full_name":"taichi-dev/difftaichi","owner":"taichi-dev","description":"10 differentiable physical simulators built with Taichi differentiable programming (DiffTaichi, ICLR 2020)","archived":false,"fork":false,"pushed_at":"2023-11-01T09:01:54.000Z","size":353,"stargazers_count":2558,"open_issues_count":19,"forks_count":261,"subscribers_count":63,"default_branch":"master","last_synced_at":"2025-03-26T07:30:45.679Z","etag":null,"topics":["differentiable-programming","gpu","graphics","robotics","simulation","taichi"],"latest_commit_sha":null,"homepage":"","language":null,"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/taichi-dev.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}},"created_at":"2019-12-03T04:35:44.000Z","updated_at":"2025-03-24T15:36:19.000Z","dependencies_parsed_at":"2023-02-08T18:10:14.970Z","dependency_job_id":"1ee1f9e4-b2b0-462b-86a8-7d3ca4684509","html_url":"https://github.com/taichi-dev/difftaichi","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/taichi-dev/difftaichi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taichi-dev%2Fdifftaichi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taichi-dev%2Fdifftaichi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taichi-dev%2Fdifftaichi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taichi-dev%2Fdifftaichi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/taichi-dev","download_url":"https://codeload.github.com/taichi-dev/difftaichi/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taichi-dev%2Fdifftaichi/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265482198,"owners_count":23774016,"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","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":["differentiable-programming","gpu","graphics","robotics","simulation","taichi"],"created_at":"2024-08-01T11:00:43.986Z","updated_at":"2025-07-16T04:42:04.493Z","avatar_url":"https://github.com/taichi-dev.png","language":null,"funding_links":[],"categories":["**Machine Learning**","Others","Applications"],"sub_categories":["**Machine Learning**"],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003ch3\u003e python3 diffmpm.py \u003c/h3\u003e\n  \u003cimg  width=\"400px\" src=\"https://github.com/yuanming-hu/public_files/raw/master/learning/difftaichi/diffmpm80.gif\"\u003e\n\u003c/div\u003e        \n\n\n# DiffTaichi: Differentiable Programming for Physical Simulation (ICLR 2020)\n\n*Yuanming Hu, Luke Anderson, Tzu-Mao Li, Qi Sun, Nathan Carr, Jonathan Ragan-Kelley, Frédo Durand*\n\n[[Paper]](https://arxiv.org/abs/1910.00935) [[Video] (with instructions to reproduce every demo)](https://www.youtube.com/watch?v=Z1xvAZve9aE)\n\n### Differentiable programming in Taichi allows you to optimize neural network controllers efficiently with brute-force gradient descent, instead of using reinforcement learning.\n\nThe *DiffTaichi* differentiable programming framework is now officially part of [Taichi](https://github.com/yuanming-hu/taichi). This repo only contains examples.\n\nDiffTaichi significantly boosts the performance and productivity of differentiable physical simulators. For example, the differentiable elastic object simulator (ChainQueen) in DiffTaichi is 188x faster than an implementation in TensorFlow. The DiffTaichi version also runs as fast as the CUDA implementation, with the code being 4.2x shorter.\n\nMost of the 10 differentiable simulators can be implemented **within 2-3 hours**.\n\nQuestions regarding the simulators/autodiff compiler go to Yuanming Hu (yuanming __at__ mit.edu) or [Issues](https://github.com/yuanming-hu/difftaichi/issues).\n\n### Note: Updates on October 27 2021\nExamples are now compatible with Taichi `v0.8.3`. Please update Taichi if you are using an old version.\n\n## How to run\nStep 1: Install [`Taichi`](https://github.com/taichi-dev/taichi) with `pip`:\n\n(Most examples do **not** need a GPU to run.)\n```bash\npython3 -m pip install taichi\n```\nStep 2: Run example scripts in the `examples` folder: (Please wait for all GIFs to load :-)\n\n\n### Differentiable Elastic Object Simulator [`python3 diffmpm.py`]\nGradient descent iteration 0 and gradient descent iteration 80: \n\n\u003cimg width=\"400px\" src=\"https://github.com/yuanming-hu/public_files/raw/master/learning/difftaichi/diffmpm00.gif\"\u003e \u003cimg  width=\"400px\" src=\"https://github.com/yuanming-hu/public_files/raw/master/learning/difftaichi/diffmpm80.gif\"\u003e\n\n### Differentiable 3D Elastic Object Simulator [`python3 diffmpm3d.py`]\nGradient descent iteration 40: \n\n\u003cimg width=\"800px\" src=\"https://github.com/yuanming-hu/public_files/raw/master/learning/difftaichi/diffmpm3d.gif\"\u003e\n\n### Differentiable 3D Fluid Simulator [`python3 liquid.py`]\nGradient descent iteration 450: \n\n\u003cimg width=\"800px\" src=\"https://github.com/yuanming-hu/public_files/raw/master/learning/difftaichi/liquid.gif\"\u003e\n\n### Differentiable Height Field Water Simulator [`python3 wave.py`]\nGradient descent iteration 180:\n\n\u003cimg width=\"400px\" src=\"https://github.com/yuanming-hu/public_files/raw/master/learning/difftaichi/wave.gif\"\u003e\n\n### Differentiable (Adversarial) Water Renderer [`python3 water_renderer.py`]\nDifferentiable water simulation + differentiable water rendering + (differentiable) CNN\n\n**Optimization goal:** find an initial water height field, so that after simulation and shading, VGG16 thinks the squirrel image is a goldfish. Input image: VGG16=fox squirrel (42.21%)\n\n\u003cimg width=\"800px\" src=\"https://github.com/yuanming-hu/public_files/raw/master/learning/difftaichi/three-stage.jpg\"\u003e\n\n**Left:** center activation .  **Right:** An activation that fools VGG (VGG16=goldfish (99.91%))\n\n\u003cimg width=\"400px\" src=\"https://github.com/yuanming-hu/public_files/raw/master/learning/difftaichi/water_wave_center.gif\"\u003e\u003cimg width=\"400px\" src=\"https://github.com/yuanming-hu/public_files/raw/master/learning/difftaichi/water_wave_iter10.gif\"\u003e\n\n\n### Differentiable Rigid Body Simulator [`python3 rigid_body.py [1/2] train`]\n2048 time steps. Gardient descent iteration 20: \n\n\u003cimg width=\"400px\" src=\"https://github.com/yuanming-hu/public_files/raw/master/learning/difftaichi/rb_final1.gif\"\u003e \u003cimg  width=\"400px\" src=\"https://github.com/yuanming-hu/public_files/raw/master/learning/difftaichi/rb_final2.gif\"\u003e\n\n### Differentiable Mass-Spring Simulator [`python3 mass_spring.py [1/2/3] train`]\n682 time steps.\nGardient descent iteration 20: \n\n\u003cimg width=\"266px\" src=\"https://github.com/yuanming-hu/public_files/raw/master/learning/difftaichi/ms1_final-cropped.gif\"\u003e  \u003cimg width=\"266px\" src=\"https://github.com/yuanming-hu/public_files/raw/master/learning/difftaichi/ms2_final-cropped.gif\"\u003e  \u003cimg width=\"266px\" src=\"https://github.com/yuanming-hu/public_files/raw/master/learning/difftaichi/ms3_final-cropped.gif\"\u003e \n\n### Differentiable Billiard Simulator [`python3 billiards.py`]\nGardient descent iteration 0 and gradient descent iteration 100: \n\n\u003cimg width=\"400px\" src=\"https://github.com/yuanming-hu/public_files/raw/master/learning/difftaichi/billiard0000.gif\"\u003e \u003cimg  width=\"400px\" src=\"https://github.com/yuanming-hu/public_files/raw/master/learning/difftaichi/billiard0100.gif\"\u003e\n\nSee the video for the remaining two simulators.\n\n## Bibtex\n\n```\n@article{hu2019difftaichi,\n  title={DiffTaichi: Differentiable Programming for Physical Simulation},\n  author={Hu, Yuanming and Anderson, Luke and Li, Tzu-Mao and Sun, Qi and Carr, Nathan and Ragan-Kelley, Jonathan and Durand, Fr{\\'e}do},\n  journal={ICLR},\n  year={2020}\n}\n@article{hu2019taichi,\n  title={Taichi: a language for high-performance computation on spatially sparse data structures},\n  author={Hu, Yuanming and Li, Tzu-Mao and Anderson, Luke and Ragan-Kelley, Jonathan and Durand, Fr{\\'e}do},\n  journal={ACM Transactions on Graphics (TOG)},\n  volume={38},\n  number={6},\n  pages={201},\n  year={2019},\n  publisher={ACM}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftaichi-dev%2Fdifftaichi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftaichi-dev%2Fdifftaichi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftaichi-dev%2Fdifftaichi/lists"}