{"id":19132418,"url":"https://github.com/taichi-dev/quantaichi","last_synced_at":"2025-08-22T00:31:08.786Z","repository":{"id":38405445,"uuid":"362865949","full_name":"taichi-dev/quantaichi","owner":"taichi-dev","description":"QuanTaichi evaluation suite","archived":false,"fork":false,"pushed_at":"2023-11-21T06:19:25.000Z","size":13940,"stargazers_count":149,"open_issues_count":2,"forks_count":16,"subscribers_count":10,"default_branch":"main","last_synced_at":"2024-12-11T15:49:42.138Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/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}},"created_at":"2021-04-29T15:37:37.000Z","updated_at":"2024-12-07T19:42:06.000Z","dependencies_parsed_at":"2023-11-21T07:51:06.861Z","dependency_job_id":null,"html_url":"https://github.com/taichi-dev/quantaichi","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taichi-dev%2Fquantaichi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taichi-dev%2Fquantaichi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taichi-dev%2Fquantaichi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taichi-dev%2Fquantaichi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/taichi-dev","download_url":"https://codeload.github.com/taichi-dev/quantaichi/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230542288,"owners_count":18242332,"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":[],"created_at":"2024-11-09T06:18:10.609Z","updated_at":"2024-12-20T06:06:35.375Z","avatar_url":"https://github.com/taichi-dev.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# QuanTaichi: A Compiler for Quantized Simulations (SIGGRAPH 2021)\n\n*Yuanming Hu, Jiafeng Liu, Xuanda Yang, Mingkuan Xu, Ye Kuang, Weiwei Xu, Qiang Dai, William T. Freeman, Fredo Durand*\n\n![](./pics/teaser.jpg)\n\n[[Paper]](https://yuanming.taichi.graphics/publication/2021-quantaichi/quantaichi.pdf) [[Video]](https://youtu.be/0jdrAQOxJlY)\n\nThe QuanTaichi framework is now officially part of [Taichi](https://github.com/taichi-dev/taichi). This repo only contains examples.\n\n**Updates**: Examples are now compatible with Taichi v1.1.0. Please update Taichi if you are using an old version.\n\n### Simulate more with less memory, using a quantization compiler.\nHigh-resolution simulations can deliver great visual quality, but they are often limited by available memory. We present a compiler for physical simulation that can achieve both high performance and significantly reduced memory costs, by enabling flexible and aggressive quantization.   \n\nTo achieve that, we implemented an extension of the type system in `Taichi`. Now, programmers can define custom data types using the following code:\n```python\ni8 = ti.types.quant.int(bits=8, signed=True)\nqfixed12 = ti.types.quant.fixed(frac=12, signed=False, range=3.0)\nqfloat16 = ti.types.quant.float(exp=5, frac=11, signed=True)\n```\nThe compiler will automatically encode/decode numerical data to achieve an improved memory efficiency (storage \u0026 bandwidth). Since custom data types are not natively supported by hardware, we propose two useful types of bit adapters: `Bit structs` and `Bit arrays` to pack thses types into hardware supported types with bit width `8`, `16`, `32`, `64`. For example, The following code declears 2 fields with custom types, and materialized them into two 2D 4 x 2 arrays with `Bit structs`:\n```python\nu4 = ti.types.quant.int(bits=4, signed=False)\ni12 = ti.types.quant.int(bits=12, signed=True)\np = ti.field(dtype=u4)\nq = ti.field(dtype=i12)\nti.root.dense(ti.ij, (4, 2)).bit_struct(num_bits=16).place(p, q)\n```\nThe `p` and `q` fields are laid in an array of structure (AOS) order in memory. Note the containing bit struct of a (`p[i, j]`, `q[i, j]`) tuple is 16-bit wide. For more details of the usage of our quantization type system, please refer to our paper or see the examples in this repo.\n\nUnder proper quantization, we achieve 8× higher memory efficiency on each Game of Life cell, 1.57× on each Eulerian fluid simulation voxel, and 1.7× on each material point method particle. To the best of our knowledge, this is the first time these high-resolution simulations can run on a single GPU. Our system achieves resolution, performance, accuracy, and visual quality simultaneously.\n\n## How to run\n\n### Install Taichi 1.6.0 first.\nInstall Taichi 1.6.0 by:\n```\npython3 -m pip install —U taichi==1.6.0\n```\n\n### Game of Life (GoL)\n\n![gol_pic](./pics/teaser_gol.jpg)\n\nTo reproduce the GOL galaxy:\n```\ncd gol \u0026\u0026 python3 galaxy.py -a [cpu/cuda] -o output\n```\nWe suggest you run the script using GPU (`--arch cuda`). Because to better observe the evolution of metapixels, we set the steps per frame to be 32768 which will take quite a while on CPUs.\n\nTo reproduce the super large scale GoL:\n\n1. Download the pattern `quant_sim_meta.rle` from our [Google Drive](https://drive.google.com/file/d/1kCg2fSAlQgy42cGAatVwuvGZd7RlqLF-/view?usp=sharing) and place it in the same folder with `quant_sim.py`\n\n2. Run the code\n```\npython3 quant_sim.py -a [cpu/cuda] -o output\n```\n\nFor more details, please refer to this [documentation](gol/README.md).\n\n### MLS-MPM\n![mpm-pic](./pics/mpm-235.jpg)\n\nTo test our system on hybrid Lagrangian-Eulerian methods where both particles and grids are used, we implemented the Moving Least Squares Material Point Method with G2P2G transfer. The latest version is now maintained at [Taichi Elements](https://github.com/taichi-dev/taichi_elements).\n\n### Eulerian Fluid\n\n![smoke_simulation](./pics/smoke_result.png)\n\nWe developed a sparse-grid-based advection-reflection fluid solver to evaluate our system on grid-based physical simulators.\n\nTo reproduce the large scale smoke simulation demo, please first change the directory into `eulerain_fluid`, and run:\n```\npython3 run.py --demo [0/1] -o outputs\n```\nSet the arg of `demo` to `0` for the bunny demo and `1` for the flow demo. `-o outputs` means the set the output folder to `outputs`.\n\nFor more comparisons of this quantized fluid simulation, please refer to the [documentation](eulerian_fluid/readme.md) of this demo.\n\n### Microbenchmarks\nTo reproduce the experiments of microbenchmarks, please run\n\n```\ncd microbenchmarks\nchmod +x run_microbenchmarks.sh\n./run_microbenchmarks.sh\n```\nPlease refer to this [Readme](microbenchmarks/README.md) to get more details.\n\n\nBibtex\n```\n@article{hu2021quantaichi,\n  title={QuanTaichi: A Compiler for Quantized Simulations},\n  author={Hu, Yuanming and Liu, Jiafeng and Yang, Xuanda and Xu, Mingkuan and Kuang, Ye and Xu, Weiwei and Dai, Qiang and Freeman, William T. and Durand, Frédo},\n  journal={ACM Transactions on Graphics (TOG)},\n  volume={40},\n  number={4},\n  year={2021},\n  publisher={ACM}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftaichi-dev%2Fquantaichi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftaichi-dev%2Fquantaichi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftaichi-dev%2Fquantaichi/lists"}