---
tags: IEEE, uncomplete
title: 2 | Posits, a New Kind of Number, Improves the Math of AI
---
# 2 | Posits, a New Kind of Number, Improves the Math of AI
[**原文章**](https://spectrum.ieee.org/floating-point-numbers-posits-processor)
原文時間:2022.9.25
本篇撰寫日期:2022.10.1
By:蘇雋勛
# 大綱
在現代的 AI 背後 訓練大型的神經網絡往往需要強大的計算能力
例如 OpenAI 的最先進語言模型 [GPT-3](https://spectrum.ieee.org/large-language-models-meta-openai)
需要非常非常非常非常多的訓練步驟
而在這{訓練的時間內也耗費巨資|cost about US $5 million in compute time}
於是科學家為了減緩這種困境 想了一種新的表達實數的方式 --- ==Posits==
---
## John Gustafson
[John Gustafson](http://www.johngustafson.net/) 在2017就發明了一種新的表達實數的方式叫做 ==Posits==
用來改善浮點數運算處理器(floating-point arithmetic processors)
## David Mallasén Quintana | Complutense
現在 Complutense 團隊成功做出以 Posits 表達實數的處理器
並且發現在一些基礎的運算作業中
跟傳統處理器相比 精細度多了了{四個數量級|four orders of magnitude}
David Mallasén Quintana 是一位 Complutense 的 [ArTeCS group](https://artecs.dacya.ucm.es/) {研究員|graduate researcher}
他說:
:::info
「摩爾定律開始趨緩,我們必須得在相同的機器上,以其他的方式獲得更多的效能。
而其中一個方式就是改變我們表達實數的方式」
:::
Complutense 不是唯一在改變實數表示方式上 {挑戰極限|pushing the envelope} 的團隊
[參考](https://www.businessweekly.com.tw/careers/blog/16137)
Nvidia、Arm、和 Intel 在上週 同意在機器學習的應用上
[以 8 bit {浮點數|FP8} 替代 16 和 32 bit 浮點數](https://arxiv.org/abs/2209.05433)
使用較小且比較不精確的 8 bit 浮點數
是以計算的準確度換取計算效率 以及節省記憶體用量
---
# Posits
## 概念
實數不像常見的有理數可以表示成有限的小數
因此在表示時會被削去一些位數
Posits 的好處是他是**沿著數線的分部去表示實數的**
>準確來說 是因為在機器學習中時數的運算大多落在特定範圍
在 1 到 -1 的範圍內 他可以比 浮點數表示更多的實數
而且在無限遠處 也就是正負無限大
Posits 的準確度衰減也比浮點數來的柔和(gracefully)
Gustafson 說:
>「在計算中去符合數字的自然分布比較好
這就是你要的動態範圍、這就是當你需要準確度時你所要的準確度
在浮點數算術中有太多從來未被使用的數字 太浪費了」
>“It’s a better match for the natural distribution of numbers in a calculation,” says Gustafson.
“It’s the right dynamic range, and it’s the right accuracy where you need more accuracy.
There’s an awful lot of bit patterns in floating-point arithmetic no one ever uses.
And that’s waste.”
## 細節
Posits 可以在 1 ~ -1 間有更大的精確度
是因為他在正常表示浮點數的方式中 增加了 ==regime== 的區塊
代表的是 ==指數的指數== 並且有著{**動態大小的特性**|**vary in bit length**}
所以在較小的實數中 也就是 1 ~ -1 的區間
只會使用較少的 ==regime== 進而保留更多位置給 ==mantissa== 也就增加了精確度

而深層神經網絡往往都會使用{**標準化的參數**|normalized parameters} 或叫權重
因此十分受益於 Posits 的「甜蜜區間」
## 深層神經網絡
由於大多數的神經網絡 每次的計算是由乘法和加法組成
而在每次的計算結束後 總和都要重新截斷 導致精細度損失
而在 Complutense 的晶片中 有一個特別的暫存器叫 quire
可以有效率的執行上述的加總動作進而減少喪失精確度
不過對於現今到目前為止的硬體 因為只能藉由軟體實現 Posits 獲得的乘積結果
但這會因為格式轉換導致精確度損失 所以不是十分獲得 {青睞|largely overshadowed}
## 他們的晶片
他們用FPGA(field-programmable gate array) 合成的晶片
使他們可以比較 32 bit 的 Floats 跟 Posit 計算
比較的方式是將計算所得到的結果以 *雖花費空間但更為精確的* 64 bit 浮點數格式表示
最後 在神經網絡訓練中一直在做的事情 也就是**矩陣乘法中**
Posit 的結果的精確度比 Floats 多了 4 個數量級
並且也沒有多花費計算時間 只有稍為增加的晶片面積和功耗
不過這到底會如何影響大型的 AI 訓練 結果還未定
## 未來
Mallasén 說 Posits 是 有可能加快訓練速度的
因為減少了資料損失 但是還沒有硬體的實際測試結果
>現在應該有了
而其他上述的 team 也利用了 posits 的優點 使用著自行設計的晶片
Gustafson 說:
>Posits 正朝著我所希望的方向前進,並且被瘋狂的採取使用,他火了
>Other teams are working on their own hardware implementations to advance posit usage. “It’s doing exactly what I hoped it would do; it’s getting adopted like crazy,” Gustafson says. “The posit number format caught fire, and there are dozens of groups, both companies and universities, that are using it.”