Skip to main content

The Taichi Programming Language

Project description


Latest Release downloads CI Docker Cloud Build Status Python Codecov Status

import taichi as ti

Taichi (太极) is an open-source, imperative, parallel programming language for high-performance numerical computation. It is embedded in Python and uses just-in-time (JIT) compiler frameworks (e.g. LLVM) to offload compute-intensive Python code to the native GPU or CPU instructions.

Advantages of Taichi:

  • Built around Python: Taichi shares almost the same syntax with Python, allowing you to write algorithms with minimal language barrier. It is also well integrated into the Python ecosystem, such as NumPy and PyTorch.
  • Flexibility: Taichi provides a set of generic data containers known as SNode (/ˈsnoʊd/), an effective mechanism for composing hierarchical, multi-dimensional fields. This can cover many use patterns in numerical simulation (e.g. spatially sparse computing).
  • Performance: Through the @ti.kernel decorator, Taichi's JIT compiler automatically compiles your Python functions into efficient GPU or CPU machine code for parallel execution.
  • Portability: Write your code once and run it everywhere. Currently, Taichi supports most mainstream GPU APIs, such as CUDA and Vulkan.
  • ... and many more features! A cross-platform, Vulkan-based 3D visualizer, differentiable programming, quantized computation (experimental), etc.

Getting Started

Installation

You can easily install Taichi with Python's package installer pip:

pip install taichi

If you want to try out the latest features, we also provide a nightly package:

pip install -i https://test.pypi.org/simple/ taichi-nightly

The nightly package can and will break from time to time!

Supported environments

  • Operating systems
    • Windows1
    • Linux
    • macOS
  • Python: 3.6 ~ 3.9 (64-bit only)
  • Compute backends
    • x64/ARM CPUs
    • CUDA
    • Vulkan
    • OpenGL (4.3+)
    • Apple Metal
    • WebAssembly (experiemental)

1. On Windows, please install Microsoft Visual C++ Redistributable first.

Your first Taichi program

Here's how you can program a 2D fractal in Taichi:

# python/taichi/examples/simulation/fractal.py

import taichi as ti

ti.init(arch=ti.gpu)

n = 320
pixels = ti.field(dtype=float, shape=(n * 2, n))


@ti.func
def complex_sqr(z):
    return ti.Vector([z[0]**2 - z[1]**2, z[1] * z[0] * 2])


@ti.kernel
def paint(t: float):
    for i, j in pixels:  # Parallelized over all pixels
        c = ti.Vector([-0.8, ti.cos(t) * 0.2])
        z = ti.Vector([i / n - 1, j / n - 0.5]) * 2
        iterations = 0
        while z.norm() < 20 and iterations < 50:
            z = complex_sqr(z) + c
            iterations += 1
        pixels[i, j] = 1 - iterations * 0.02


gui = ti.GUI("Julia Set", res=(n * 2, n))

for i in range(1000000):
    paint(i * 0.03)
    gui.set_image(pixels)
    gui.show()

If Taichi is properly installed, you should get the animation below 🎉:

Documentation

Taichi's documentation is available at https://docs.taichi.graphics.

Contacts

We use these channels to report bugs, discuss design, show off demos and send announcements on a daily basis:

Should you spot any security issue, do not hesitate to report it by mailing to security@taichi.graphics.

Contributing

If you would like to contribute to Taichi, please check out the Contribution Guidelines.

A huge thanks to all of our amazing contributors!

Contributor avatars are randomly shuffled.

Resources

Demos

Lectures & talks


If you use Taichi in your research, please cite related papers:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

taichi-0.9.1-cp39-cp39-win_amd64.whl (17.8 MB view hashes)

Uploaded CPython 3.9 Windows x86-64

taichi-0.9.1-cp39-cp39-manylinux1_x86_64.whl (27.2 MB view hashes)

Uploaded CPython 3.9

taichi-0.9.1-cp39-cp39-macosx_11_0_arm64.whl (23.1 MB view hashes)

Uploaded CPython 3.9 macOS 11.0+ ARM64

taichi-0.9.1-cp39-cp39-macosx_10_15_x86_64.whl (27.5 MB view hashes)

Uploaded CPython 3.9 macOS 10.15+ x86-64

taichi-0.9.1-cp39-cp39-macosx_10_14_x86_64.whl (23.6 MB view hashes)

Uploaded CPython 3.9 macOS 10.14+ x86-64

taichi-0.9.1-cp38-cp38-win_amd64.whl (17.8 MB view hashes)

Uploaded CPython 3.8 Windows x86-64

taichi-0.9.1-cp38-cp38-manylinux1_x86_64.whl (27.2 MB view hashes)

Uploaded CPython 3.8

taichi-0.9.1-cp38-cp38-macosx_11_0_arm64.whl (23.1 MB view hashes)

Uploaded CPython 3.8 macOS 11.0+ ARM64

taichi-0.9.1-cp38-cp38-macosx_10_15_x86_64.whl (27.5 MB view hashes)

Uploaded CPython 3.8 macOS 10.15+ x86-64

taichi-0.9.1-cp38-cp38-macosx_10_14_x86_64.whl (23.6 MB view hashes)

Uploaded CPython 3.8 macOS 10.14+ x86-64

taichi-0.9.1-cp37-cp37m-win_amd64.whl (17.8 MB view hashes)

Uploaded CPython 3.7m Windows x86-64

taichi-0.9.1-cp37-cp37m-manylinux1_x86_64.whl (27.2 MB view hashes)

Uploaded CPython 3.7m

taichi-0.9.1-cp37-cp37m-macosx_10_15_x86_64.whl (27.4 MB view hashes)

Uploaded CPython 3.7m macOS 10.15+ x86-64

taichi-0.9.1-cp37-cp37m-macosx_10_14_x86_64.whl (23.6 MB view hashes)

Uploaded CPython 3.7m macOS 10.14+ x86-64

taichi-0.9.1-cp36-cp36m-win_amd64.whl (17.8 MB view hashes)

Uploaded CPython 3.6m Windows x86-64

taichi-0.9.1-cp36-cp36m-manylinux1_x86_64.whl (27.2 MB view hashes)

Uploaded CPython 3.6m

taichi-0.9.1-cp36-cp36m-macosx_10_15_x86_64.whl (27.4 MB view hashes)

Uploaded CPython 3.6m macOS 10.15+ x86-64

taichi-0.9.1-cp36-cp36m-macosx_10_14_x86_64.whl (23.6 MB view hashes)

Uploaded CPython 3.6m macOS 10.14+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page