もくじIndex

イメージでわかる INT8 と FP32

Visual Guide: INT8 vs FP32

Visual INT8 vs FP32

シリーズ: イメージでわかる

数字の持ち方の違いが、速さや得意不得意にどうつながるのかを、箱の大きさやメモの細かさで説明します。

How the way numbers are stored affects speed and capability — explained through box sizes and notebook detail.

1. 数字の「入れ物」がちがう

1. Different "Containers" for Numbers

コンピュータの中では、数字を「ビット」という 0/1 の列で表します。使うビット数が違えば、入れ物のサイズが変わります。

Inside a computer, numbers are represented as sequences of 0s and 1s called "bits." Different bit counts mean different container sizes.

📦

FP32

32 ビット(大きな箱)
32 bits (large box)
小数も扱える
精度が高い
でも重い・遅い
Handles decimals
High precision
But heavy & slow
🗃️

INT8

8 ビット(小さな箱)
8 bits (small box)
整数だけ(−128〜127)
精度は低い
でも軽い・速い
Integers only (−128 to 127)
Lower precision
But light & fast
📓 たとえ話: 📓 Analogy: FP32 は「大きなノートにこまかく書く」。 INT8 は「付箋にザックリ書く」。ノートは正確だけど、書いたり読んだりに時間がかかる。付箋はあいまいだけど超速い。 FP32 is like "writing in fine detail in a large notebook." INT8 is like "jotting it roughly on a sticky note." The notebook is accurate but slow to read and write; sticky notes are imprecise but super fast.

2. なぜ小さい箱が注目されてるの?

2. Why Is the Smaller Box Getting Attention?

AI が推論(学習ずみモデルを使って答えを出すこと)をするとき、箱が小さいとこんなメリットがあります。

When AI runs inference (using an already-trained model to produce answers), smaller boxes have these advantages:

メモリが少なくてすむ — 同じ量の数字でも、入れ物が1/4のサイズなのでメモリ使用量も約1/4。
計算が速い — GPU の中には「小さい整数専用の速い計算ユニット」を持つものがある。
消費電力が低い — 小さなデータを運ぶので電気も少なくてすむ。

Less memory — same number of values, 1/4 the container size ≈ ~1/4 memory.
Faster — some GPUs have dedicated fast compute units for small integers.
Lower power — moving smaller data uses less electricity.

🤔 ここが引っかかりやすい: 「INT8 のほうが雑で小さいなら、むしろ昔からありそう。なんで最新機能なの?」と思いやすいです。答えは、INT8 という数字の種類が新しいのではなく、INT8 をまとめて高速化する専用回路のほうが新しいからです。 🤔 This is the easy place to get stuck: "If INT8 is smaller and rougher, shouldn't it be older and simpler? Why is it treated like a newer feature?" The key is that INT8 as a number format is not the new part; the newer part is the dedicated hardware that accelerates INT8 in bulk.
🧮 たとえ話: 🧮 Analogy: 足し算そのものは昔からあります。でも、最近できたスーパーの自動レジは「小銭をまとめて一気に数える機械」を積んでいます。INT8 もこれに近くて、計算そのものが新しいのではなく、それ専用の近道が後から増えたと考えると自然です。 Addition itself has existed forever. But a modern self-checkout may include a machine that counts many coins at once. INT8 is similar: the math itself is not the new part; the dedicated shortcut built for it came later.
⚡ 数字でみると: ⚡ Numbers: FP32 → INT8 に切り替えると、メモリ使用量は約 1/4 になり、推論速度は最大 2〜4 倍になるとされます(GPU やモデル構造により異なる)。 Switching from FP32 to INT8 can reduce memory use to ~1/4 and boost inference speed by 2–4× (varies by GPU and model architecture).

3. デメリットはないの?

3. Are There Downsides?

あります。箱を小さくすると、数字の「こまかさ」が失われます。

Yes. Shrinking the box loses numerical "precision."

• 学習(トレーニング)には FP32 や FP16 の精度がほぼ必須
• 推論でも、モデルによっては INT8 にすると精度がガクッと落ちるものがある
• 「どこまで小さくして大丈夫か」はモデルごとに違う

• Training almost always needs FP32 or FP16 precision
• For inference, some models lose significant accuracy with INT8
• "How small is safe" varies from model to model

🎨 たとえ話: 🎨 Analogy: 細かい色の絵を16色クレヨンで描き直すようなもの。全体の雰囲気は分かるけど、グラデーションはつぶれる。それが許せるタスクなら INT8 で十分。許せないなら FP32 が必要。 It's like repainting a detailed picture with only 16 crayons. The general feel is preserved, but gradients are lost. If that's acceptable for your task, INT8 is enough. If not, you need FP32.

4. Vega(gfx900)とデータ型

4. Vega (gfx900) and Data Types

Vega 世代の GPU(gfx900)は、FP32 と FP16 の計算が得意です。しかし、最近の GPU が持つ「INT8 専用の高速ユニット」は搭載されていません。

Vega-generation GPUs (gfx900) are good at FP32 and FP16 computation. However, they lack the "dedicated fast INT8 units" found on newer GPUs.

ここで言う「最新機能」は、INT8 という数字そのものではなく、INT8 をまとめて高速処理する専用命令のことです。ROCm の調査では、これが dot4 のような命令として現れます。

Here, the "new feature" is not INT8 as a number format itself, but the dedicated instructions that process many INT8 values quickly. In ROCm-oriented investigation, this appears as instructions such as dot4.

つまり、Vega で INT8 推論をしても、新世代 GPU ほどの速度向上は得られない場合があります。一方で、メモリ節約の効果はあるため、VRAM が限られる場面ではそれでも有用です。

So running INT8 inference on Vega may not give the same speed boost as on newer GPUs. However, the memory savings still apply, which is useful when VRAM is limited.

🔑 ポイント: データ型の選択は「精度と速さのトレードオフ」。GPU ごとにどのデータ型が速いかは違う。 🔑 Key point: Choosing a data type is a "precision vs speed trade-off." Which types are fastest depends on the GPU.

5. ROCm ではデータ型をどう考える?

5. How Does ROCm Think About Data Types?

ROCm では、「その数字の入れ物に対して、その GPU に速い計算経路があるか」がとても大事です。

In ROCm, an important question is whether that number format has a fast execution path on the GPU you are using.

同じ INT8 でも、GPU 世代によって意味が少し変わります。新しい世代では「INT8 を速く回す専用の道」がありますが、Vega(gfx900)ではその道が細い、またはありません。

The meaning of INT8 changes a little across GPU generations. On newer generations there may be special fast paths for INT8, while on Vega (gfx900) those paths are narrow or missing.

だから ROCm では、INT8 を見たときに「8ビットだから簡単」とは考えません。代わりに、その GPU に INT8 専用命令や高速カーネルがあるかを見ます。ここが、日常感覚と ROCm の見方が少しずれるところです。

So ROCm does not simply think "8-bit means easy." Instead, it asks whether that GPU has dedicated INT8 instructions or fast kernels. This is where everyday intuition and the ROCm viewpoint can differ.

そのため ROCm では、INT8 を見るときに 1. VRAM をどれだけ減らせるか2. その GPU に速いカーネルがあるか を分けて考えます。小さくなることと、速くなることは、同じではありません。

So in ROCm it helps to separate 1. how much VRAM you save from 2. whether the GPU has a fast kernel for that type. Becoming smaller and becoming faster are not always the same thing.

💡 gfx900 を ROCm で見ると: 💡 Looking at gfx900 in ROCm: INT8 は「メモリ節約」の意味ではかなり役立つことがありますが、「新世代のような大きな加速」までは出ないことがあります。ROCm では 軽くなる速くなる を別々に確かめるのがコツです。 INT8 can still be very useful for saving memory on gfx900, but it may not deliver the large acceleration seen on newer generations. In ROCm, it is wise to check "lighter" and "faster" separately.