iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
🐷

[AI Memo] Google's TPU is Amazing

に公開

Google's TPU is amazing.

What is TPU?

TPU is a machine learning processor developed by Google.

[Supplement] TPU stands for Tensor Processing Unit

It follows the same naming convention as CPUs and GPUs.

  • CPU: Central Processing Unit
  • GPU: Graphics Processing Unit
  • TPU: Tensor Processing Unit


Using TPU can significantly speed up deep learning. Google itself uses TPU for services like Google Photos. We can also perform machine learning using TPU via GCP (Google Cloud Platform).

In this article, I will briefly introduce TPU, which is a must-know for machine learning users. Please note that I will be providing a rough conceptual overview, so it may differ slightly from the actual technical implementation.

I hope this helps further your understanding.


If you want to know the basics of neural networks, please see here as well ↓
https://zenn.dev/nekoallergy/books/904df952389317



Created by NekoAllergy

Types of TPU


Left: TPU v2, Right: TPU v3

  1. In 2015, the 1st generation model "TPU v1" was announced.
  2. In 2017, the 2nd generation model "TPU v2" was announced.
  3. In 2018, the 3rd generation model "TPU v3" was announced.
  4. On May 18, 2021, the 4th generation model "TPU v4" was announced.

It is being upgraded year by year.

How amazing is it?


Left: Single TPU (also called a unit), Right: TPU Pod (many TPUs)

It is quite incredible.
The latest TPU v4 Pod (4096-unit configuration) can perform 1 EFLOPS of computation!
For those who aren't sure what that means, let me provide a brief explanation.

What is FLOPS?

The computing power of a processor is often compared using a unit called FLOPS. FLOPS is an indicator of "how many floating-point operations can be performed in one second." The higher the number, the more powerful it is.

What is a Pod?

When multiple TPUs are combined, it is called a Pod. A single TPU is already powerful, but linking many TPUs together is even more impressive.
Basically, TPU performance is often measured in Pod units.

What is E (Exa)?

This is a prefix for units of magnitude. Adding "k" (kilo) means 1,000 times, and "M" (mega) means 1,000,000 times.

k (kilo) 10^3 1,000
M (mega) 10^6 1,000,000
G (giga) 10^9 1,000,000,000
T (tera) 10^12 1,000,000,000,000
P (peta) 10^15 1,000,000,000,000,000
E (exa) 10^18 1,000,000,000,000,000,000
Z (zetta) 10^21 1,000,000,000,000,000,000,000
Y (yotta) 10^24 1,000,000,000,000,000,000,000,000




Based on the above:

A TPU v2 Pod (64-unit configuration) is 11.5 PFLOPS.
A TPU v3 Pod (64-unit configuration) is 100 PFLOPS.

An M1 Mac is roughly around XX GFLOPS or XX TFLOPS.
While simple comparisons are difficult due to different conditions, TPU is clearly amazing.

The latest TPU v4 Pod (4096-unit configuration) can perform 1 exaFLOPS of computation.
This is reportedly more than double the performance of a TPU v3 Pod (4096-unit configuration).
It is said to be equivalent to 10 million laptop processors.
It's so impressive it's almost hard to comprehend.

Difference Between CPU and TPU

Unlike general-purpose processors like CPUs and GPUs, TPUs are specialized for deep learning.
There are two major differences.

Point 1: Based on 8-bit/16-bit Arithmetic Units


Based on 8-bit/16-bit

As the number of bits increases, calculation accuracy improves.

General-purpose processors like CPUs mainly use 32-bit operations. However, deep learning calculations do not require that much precision. In the inference phase, 8-bit is said to be optimal.

[Supplement] What is the Inference Phase?

In machine learning, AI is created through a workflow of ① training phase → ② inference phase.
① In the training phase, the model learns by being shown a large amount of data. Once learning is complete, it is referred to as an AI.
② The inference phase is the stage where the AI is actually run to solve problems.
Generally, the training phase requires higher computational performance and takes more time.


Because of this, TPU v1 was configured with 65,536 8-bit arithmetic units. Power consumption is also kept down to 40W per unit.

[Supplement] How amazing is it?

A GPU called "Tesla K80" has 2,496 32-bit arithmetic units. In comparison, 65,536 units is quite a large number.

TPU v1 was specialized for the inference phase of machine learning.


To make it usable in the training phase as well, TPU v2 equipped four processors, each with 32,768 16-bit arithmetic units, into a single unit. One unit can deliver 180 TFLOPS of computing power.

Training requires 16 bits, and by adopting 16-bit, TPU v2 became usable in both the training and inference phases.

Point 2: Large-Scale Matrix Operation Pipeline


Minimizing memory writes.

In a CPU, memory reads and writes occur during calculations. This takes a considerable amount of time.

In a TPU, calculation results are passed directly within the arithmetic circuits. This is called a systolic array. This significantly reduces memory reads/writes, increases integration, and lowers power consumption.

It is a similar concept to why Apple's M1 chip became so fast.

TPU is Amazing. Can I Use It?

TPU can be used on GCP (Google Cloud Platform). The service name is Cloud TPU. Using Cloud TPU allows us to perform machine learning at blazing speeds, which is very convenient.

As of late 2021 (Nov), TPU v2 and TPU v3 are available. TPU v4 is also expected to become available later in 2021.

Cloud TPU allows you to choose between ① a single TPU unit or ② a TPU Pod. Single TPUs are affordable, while TPU Pods offer higher performance computing.

Pricing is as follows (as of 2021/11):


Pricing for a single TPU unit


Pricing for TPU Pods (multiple TPUs)

The "On-demand price" column shows the cost. It seems TPU v2 starts from $4.50 per hour and TPU v3 from $8.00 per hour. Using a Pod is much more expensive.

You can also choose "Preemptible pricing." Google may terminate the connection at its discretion, but it is significantly cheaper. This is a good option for trying things out.

  1. Choose between a single TPU or a TPU Pod
  2. Choose the TPU type (v2 or v3)
  3. Choose between on-demand or preemptible pricing

That's the basic flow.

Summary

I have briefly summarized TPU.

It seems TPU is truly amazing.
I'm thinking of trying out Cloud TPU.
I will write another article when I use it, so please follow and like.


Learn More About Machine Learning

I have summarized the basics of Python in a book. I would be very happy if you could check it out as well ↓
https://zenn.dev/nekoallergy/books/python-basic
I have summarized the basics of Deep Learning in a book. It would make me very happy if you could take a look ↓
https://zenn.dev/nekoallergy/books/904df952389317


NekoAllergy AI

NekoAllergy AI
I post about machine learning on YouTube. I'd be happy if you could take a look if you have time.




References

https://9to5google.com/2021/05/18/google-unveils-4th-generation-tensor-processing-unit/
https://venturebeat.com/2021/05/18/google-details-new-ai-accelerator-chips/
https://atmarkit.itmedia.co.jp/ait/articles/1807/06/news108.html
https://cloud.google.com/tpu/pricing
https://cloud.google.com/tpu





Created by NekoAllergy

Discussion