Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Doc] Revise "Why a new programming language" #4306

Merged
merged 6 commits into from
Feb 17, 2022

Conversation

k-ye
Copy link
Member

@k-ye k-ye commented Feb 16, 2022

@netlify
Copy link

netlify bot commented Feb 16, 2022

✔️ Deploy Preview for docsite-preview ready!

🔨 Explore the source changes: dde36a4

🔍 Inspect the deploy log: https://app.netlify.com/sites/docsite-preview/deploys/620df3fcf0620500077300a0

😎 Browse the preview: https://deploy-preview-4306--docsite-preview.netlify.app


Going forward, we see many new opportunities lying ahead this path, and would like to share some of our vision with you.

**Academia**
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional input regarding this part :-)? @ltt1598

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can echo the high productivity using Taichi at first: 90% of the research code will be trashed due to the nature of research where assumptions keep being broken and ideas keep being iterated. Swiftly coding without thinking too much about performance may lead to incorrect conclusions, while pre-matured code optimization can be a waste of time and often produces a tangled mess. The high performance and productivity are, therefore, extremely helpful for research projects.

The key features we have (or plan to have) for high-performance computing research projects include small-scale linear algebra (inside kernels), large-scale sparse systems, and efficient neighbor accessing for both structured and unstructured data.

We also provide an automatic differentiation module via source code transformation (at IR level), making Taichi a sweet differentiable simulation tool for machine learning projects.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Truly appreciated!

@k-ye
Copy link
Member Author

k-ye commented Feb 16, 2022

/format

* [taichimd](https://github.com/victoriacity/taichimd): Interactive, GPU-accelerated Molecular (& Macroscopic) Dynamics using the Taichi programming language
* [TaichiSLAM](https://github.com/xuhao1/TaichiSLAM): a 3D Dense mapping backend library of SLAM based Taichi-Lang, designed for the aerial swarm.
* [Stannum](https://github.com/ifsheldon/stannum): Fusing Taichi into PyTorch.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can also mention the fluid solver here? https://github.com/hietwll/LBM_Taichi

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was hoping to use some cases that are not simulation LOL

Co-authored-by: Haidong Lan <turbo0628g@gmail.com>
@turbo0628
Copy link
Member

I truly enjoy reading this article, LGTM!

@ltt1598
Copy link
Member

ltt1598 commented Feb 17, 2022

I like the new "why new programming language" page!

@writinwaters
Copy link
Contributor

Never in my life have I read something its equal. Inspiring, enlightening, and a breath of fresh air!

@k-ye
Copy link
Member Author

k-ye commented Feb 17, 2022

/format

@k-ye
Copy link
Member Author

k-ye commented Feb 17, 2022

Three warm compliments without a single LGTM, I'm heartbroken...

@ltt1598
Copy link
Member

ltt1598 commented Feb 17, 2022

LGTM now :)

Copy link
Contributor

@strongoier strongoier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A green LGTM!

@k-ye k-ye merged commit 61c215a into taichi-dev:master Feb 17, 2022
@k-ye k-ye deleted the why-lang-doc branch February 17, 2022 07:49

Taichi is a high-performance programming language for computer graphics
applications. The design goals are
Imagine you'd like to write a new particle-based fluid algorithm. You started simple, didn't spend much time before finding a reference C++/CUDA work online (or derived the work from your labmate, <s>un</s>fortunately). `cmake .. && make`, you typed. Oops, cmake threw out an error due to a random incompatible third party library. Installed and rebuilt, now it passed. Then you ran it, which immediately segfaulted (without any stacktrace, of course). Then you started gazing at the code, placed the necessary asset files at the right place, fixed a few dangling pointers and reran. It... actually worked, up until the point where you started plugging in your revised algorithm. Now another big fight with the GPU or CPU code. More often than not, you get lost in the language details.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Imagine you'd like to write a new particle-based fluid algorithm. You started simple, didn't spend much time before finding a reference C++/CUDA work online (or derived the work from your labmate, <s>un</s>fortunately). `cmake .. && make`, you typed. Oops, cmake threw out an error due to a random incompatible third party library. Installed and rebuilt, now it passed. Then you ran it, which immediately segfaulted (without any stacktrace, of course). Then you started gazing at the code, placed the necessary asset files at the right place, fixed a few dangling pointers and reran. It... actually worked, up until the point where you started plugging in your revised algorithm. Now another big fight with the GPU or CPU code. More often than not, you get lost in the language details.
Imagine you'd like to write a new particle-based fluid algorithm. You started simple, didn't spend much time before finding a reference C++/CUDA work online (or derived the work from your labmate, <s>un</s>fortunately). `cmake .. && make`, you typed. Oops, cmake threw out an error due to a random incompatible third party library. Installed and rebuilt, now it passed. Then you ran it, which immediately segfaulted (without any stacktrace, of course). Then you started gazing at the code, placed the necessary asset files at the right place, fixed a few dangling pointers and reran. It... actually worked, until you plugged in your revised algorithm. Now another big fight with the GPU or CPU code. More often than not, you get lost in the language details.

to the point where: refers to a place, or a situation
to the point when: refers to a point in time


## Design decisions
Originally born from the MIT CSAIL lab, Taichi was designed to facilitate computer graphics researchers' day-to-day life, by helping them quickly implement visual computing and physics simulation algorithms that are executable on GPU. The path Taichi took was an innovative one: Taichi is embedded in Python, and utilizes the modern just-in-time (JIT) frameworks (e.g., LLVM, SPIR-V) to offload the Python source code to native GPU or CPU instructions, offering the performance at both development time and runtime.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Originally born from the MIT CSAIL lab, Taichi was designed to facilitate computer graphics researchers' day-to-day life, by helping them quickly implement visual computing and physics simulation algorithms that are executable on GPU. The path Taichi took was an innovative one: Taichi is embedded in Python, and utilizes the modern just-in-time (JIT) frameworks (e.g., LLVM, SPIR-V) to offload the Python source code to native GPU or CPU instructions, offering the performance at both development time and runtime.
Born from the MIT CSAIL lab, Taichi was designed to facilitate computer graphics researchers' everyday life, by helping them quickly implement visual computing and physics simulation algorithms that are executable on the GPU. Taichi is embedded in Python and uses the modern just-in-time (JIT) frameworks (for example LLVM, SPIR-V) to offload the Python source code to the native GPU or CPU instructions. This innovative approach accelerates development and reduces runtime.

Copy link
Member Author

@k-ye k-ye Feb 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I fixed some, but prefer to keep "The path Taichi took was an innovative one..."

- Embedding in Python
To be fair, a domain-specific language (DSL) with a Python frontend is not something new. In the past few years, frameworks like Halide, PyTorch and TVM have grown ripe and become the de facto standards in areas like image processing and deep learning (DL). What differentiates Taichi the most from these frameworks is its imperative programming paradigm. Being a DSL, Taichi isn't so specialized in a particular computing pattern, thus provides better flexibility. While one may argue that flexibility usually comes at a cost of not being fully optimized, we find this is often not the case for a few reasons.

1. Taichi's workload typically does *not* exhibit an exploitable pattern (e.g., element-wise operations), meaning that the arithmetic intensity is bounded anyway. By simply switching to the GPU backend, one can already enjoy a nice performance gain.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
1. Taichi's workload typically does *not* exhibit an exploitable pattern (e.g., element-wise operations), meaning that the arithmetic intensity is bounded anyway. By simply switching to the GPU backend, one can already enjoy a nice performance gain.
- Taichi's workload typically does *not* exhibit an exploitable pattern (e.g., element-wise operations), meaning that the arithmetic intensity is bounded anyway. By simply switching to the GPU backend, one can already enjoy a nice performance gain.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only use numbered bullets for steps.


**Maybe a new frontend?**

The benefit of adopting the compiler approach is to decouple the frontend from the backend. Taichi is embedded Python, but who says it needs to stay that way? Stay tuned :-)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The benefit of adopting the compiler approach is to decouple the frontend from the backend. Taichi is embedded Python, but who says it needs to stay that way? Stay tuned :-)
The benefit of adopting the compiler approach is that you can decouple the frontend from the backend. Taichi is *currently* embedded in Python, but who says it needs to stay that way? Stay tuned :-)

- Megakernels
- Two-scale automatic differentiation
- Embedding in Python
To be fair, a domain-specific language (DSL) with a Python frontend is not something new. In the past few years, frameworks like Halide, PyTorch and TVM have grown ripe and become the de facto standards in areas like image processing and deep learning (DL). What differentiates Taichi the most from these frameworks is its imperative programming paradigm. Being a DSL, Taichi isn't so specialized in a particular computing pattern, thus provides better flexibility. While one may argue that flexibility usually comes at a cost of not being fully optimized, we find this is often not the case for a few reasons.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
To be fair, a domain-specific language (DSL) with a Python frontend is not something new. In the past few years, frameworks like Halide, PyTorch and TVM have grown ripe and become the de facto standards in areas like image processing and deep learning (DL). What differentiates Taichi the most from these frameworks is its imperative programming paradigm. Being a DSL, Taichi isn't so specialized in a particular computing pattern, thus provides better flexibility. While one may argue that flexibility usually comes at a cost of not being fully optimized, we find this is often not the case for a few reasons.
To be fair, a domain-specific language (DSL) with a Python frontend is not something new. In the past few years, frameworks like Halide, PyTorch, and TVM have matured into the de facto standards in areas such as image processing and deep learning (DL). What distinguishes Taichi from these frameworks is its imperative programming paradigm. As a DSL, Taichi is not so specialized in a particular computing pattern. This provides better flexibility. While one may argue that flexibility usually comes at a cost of not being fully optimized, we often find this not the case for the following reasons:
  • "de facto standards". WOW!
  • differentiate xxx the most = distinguish
  • isn't -> is not. Avoid using contraction.
  • come at a cost: fine; come at the cost of xxx.
  • You can use "this" to refer to the whole preceding sentence.

Copy link
Member Author

@k-ye k-ye Feb 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx!

nit: I believe it should be "we often find this not to be the case"?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally, I prefer "I find this interesting" to "I find this to be interesting". Same for "I find this not the case".
One usage: "A closer read of the manuscript would find this not the case. "
"This is not the case" is grammatical; "This is not to be the case" is not.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, sounds good!

3. Taichi heavily optimizes the source code using various compiler technologies: common subexpression elimination, dead code elimination, control flow graph analysis, etc. These optimizations are backend neutral, because Taichi hosts its own intermediate representation layer.
4. JIT compilation provides additional optimization opportunities.

That said, Taichi is much more than just a Python JIT transpiler. One of the initial design goals is to *decouple the computation from the data structures*. The mechanism Taichi provides is a set of generic data containers, called *SNode* (/ˈsnoʊd/). SNodes can be used to compose hierarchical, dense or sparse, multi-dimensional fields conveniently. Switching between array-of-structures and structure-of-arrays layouts is usually a matter of ≤10 lines of code. This has truly enabled many use cases in numerical simulation. If you are interested to learn them, please check out [Fields (advanced)](https://docs.taichi.graphics/lang/articles/advanced/layout), [Sparse spatial data structures](https://docs.taichi.graphics/lang/articles/advanced/sparse), or [the original Taichi paper](https://yuanming.taichi.graphics/publication/2019-taichi/taichi-lang.pdf).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
That said, Taichi is much more than just a Python JIT transpiler. One of the initial design goals is to *decouple the computation from the data structures*. The mechanism Taichi provides is a set of generic data containers, called *SNode* (/ˈsnoʊd/). SNodes can be used to compose hierarchical, dense or sparse, multi-dimensional fields conveniently. Switching between array-of-structures and structure-of-arrays layouts is usually a matter of ≤10 lines of code. This has truly enabled many use cases in numerical simulation. If you are interested to learn them, please check out [Fields (advanced)](https://docs.taichi.graphics/lang/articles/advanced/layout), [Sparse spatial data structures](https://docs.taichi.graphics/lang/articles/advanced/sparse), or [the original Taichi paper](https://yuanming.taichi.graphics/publication/2019-taichi/taichi-lang.pdf).
That said, Taichi goes beyond a Python JIT transpiler. One of the initial design goals is to *decouple computation from the data structures*. The mechanism that Taichi provides is a set of generic data containers called *SNode* (/ˈsnoʊd/). SNodes can be used to compose hierarchical, dense or sparse, multi-dimensional fields conveniently. Switching between array-of-structures and structure-of-arrays layouts is usually a matter of ≤10 lines of code. This has sparked many use cases in numerical simulation. If you are interested in learning them, see [Fields (advanced)](https://docs.taichi.graphics/lang/articles/advanced/layout), [Sparse spatial data structures](https://docs.taichi.graphics/lang/articles/advanced/sparse), or [the original Taichi paper](https://yuanming.taichi.graphics/publication/2019-taichi/taichi-lang.pdf).
  • Be interested in doing

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be interested in doing

Good point, but then I actually searched for that when writing this line...

https://jakubmarian.com/interested-in-doing-vs-interested-to-do-in-english/

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You raised a good point! Go with it!

@k-ye
Copy link
Member Author

k-ye commented Feb 18, 2022

Missing content:

  • difference between Taichi and GLSL
  • btw Taichi and physics engine
  • what scenarios should you use/not use Taichi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants