特别节目·中文精读

克里斯·拉特纳:编译器、LLVM、Swift、TPU 与机器学习加速器

Chris Lattner: Compilers, LLVM, Swift, TPU, and ML Accelerators

LLVM 与 Swift 之父回顾编译器设计历程,并谈 TPU 等机器学习加速器的工程取舍。

官方音频00:00 / --:--
中文精读由 AI 基于原始访谈改写,非官方翻译,可能存在偏差或错误;表述以原音频与官方文稿为准。说明

2019 年,你手里那部 iPhone 上的每一个 App,索尼用来渲染电影特效的机器集群,Google 生产服务器上跑的搜索服务,PlayStation 4 里的游戏,这些看起来毫无关系的东西,编译它们背后走的是同一套代码。

这套代码叫 LLVM。

它最初是伊利诺伊大学厄巴纳香槟分校的一个研究生项目,只有几个人在做。二十年后,它成了英特尔、AMD、英伟达、苹果、Google 这些平时在市场上往死里打的公司共同维护的公共地基。做这件事的人是克里斯·拉特纳(Chris Lattner)。他还顺手写了 Clang,那个今天几乎所有人都在间接使用的 C/C++/Objective-C 编译器,然后在苹果内部发起了 Swift。

这期 Lex Fridman 的访谈长达一小时十三分钟,信息密度极高。拉特纳几乎没讲什么励志故事,他讲的都是具体的:一个 for 循环怎么从语法树变成控制流图,寄存器分配为什么是编译器最硬的骨头之一,bfloat16 为什么把比特挪个位置就能让 TPU 快起来,以及他在特斯拉那五个月到底看到了什么。

一个只想读一年硕士的人,写出了二十年的基础设施

拉特纳的第一段程序是照着父母买的一本 Basic 教材敲进去的。他的回忆里没有什么顿悟时刻,只有一件事:敲进去,跑起来,敲错一个字符,然后盯着屏幕找原因。

“我开始的时候就是把书上的程序打出来,看看它们怎么工作,然后打错,再搞明白为什么跑不起来。”(克里斯·拉特纳)

这条路走得挺有意思。Basic 之后是 GW-Basic、QBasic、QuickBasic,都是微软系的,一层层往上叠。然后是 Pascal,然后是汇编,然后才是 C++。中间他还摸过 Smalltalk。Fridman 在节目里开玩笑说他走了黑魔法那条路,本来可以走 Lisp 那条更高层、更哲学、更嬉皮士的路线,结果一头扎进了机器。

这个选择很关键。Pascal 给了拉特纳两样东西:字符串类型、更强的抽象,以及第一次意识到“资源是要管理的”。真正改变他的却是 C。用 Pascal 的时候你写字符串,不用想它在内存里长什么样。用 C 的时候你必须想:这些东西是怎么被摆到内存里的。

他后来做的所有事情,都发生在这一层。

编译器在两头之间搭桥,两头都很麻烦

要理解拉特纳做了什么,得先理解编译器是什么。

他的定义很朴素:这是一道双边问题。一边是写代码的人,人不想写二进制,也不想为每一块硬件重新想一遍;另一边是跑程序的机器,机器的种类越来越多,x86、ARM、GPU,现在还有一堆专门为机器学习设计的加速器。编译器做的事,就是让人在想问题的抽象层级上思考,然后把他们写下的东西变成某块具体硬件能跑的东西。

“编译器的艺术,是让人类用他们想用的抽象层级去思考,然后让他们写的东西在某一块具体的硬件上跑起来。”(克里斯·拉特纳)

工程上的解法是把这个问题切成三段。前端负责解析某一种语言,C 的前端、C++ 的前端、JavaScript 的前端各不一样。中间是优化器。最后是后端,负责针对具体硬件生成机器码。

这样切是为了复用。编译器是极其庞大的软件,如果每种语言、每种硬件都要从头写一遍,成本谁都扛不住。所以大家把中间和后端标准化,让所有语言共用同一套优化和代码生成。LLVM 干的就是这件事。

今天跑在 LLVM 上的语言有一长串:Swift、Rust、Julia,还有 Clang 处理的 C、C++、Objective-C。它们语法差别巨大,语义模型完全不同,JavaScript 里“什么算假值”这件事和 C 里根本不是一回事,但这些差异全部留在前端。到了中间,它们变成同一种东西。

从语法树到控制流图:一个 for 循环的变形记

这是整期访谈里技术密度最高的一段,值得慢慢看。

前端解析完之后,代码变成一棵抽象语法树(AST)。你写了 a 加 b,树上就有一个加号节点,下面挂着两个子节点。你写了一次函数调用,树上就是一个 call 节点,挂着函数和参数。

然后开始“下降”(lowering)。语法树被转成中间表示,LLVM 用的那种叫控制流图(control flow graph)。

这里的差别用 for 循环最能说明。在语法树里,一个 for 节点下面挂着四个指针:初始化的表达式、条件的表达式、递增的表达式、循环体。层层嵌套,像俄罗斯套娃。

到了控制流图里,它变成几个基本块。一个块放初始化代码,一个块放循环体和递增,块与块之间用跳转连接。循环体执行完跳到条件判断,条件成立跳回循环体开头,不成立跳到出口。

每个块内部是一串直线排列的简单操作:这个加法,那个乘法,这里调用一次。没有嵌套,只有顺序和跳转。

为什么要费这么大劲换一种形状?因为这种形状更接近汇编,也更语言无关。JavaScript 那套让人抓狂的假值规则、Python 的隐式类型转换,全部可以留在前端处理掉。到了中间表示这一层,剩下的是纯粹的、干净的计算和跳转,所有语言共享同一套优化器。

编译器和神经网络图,像是同一个念头的两个版本

Fridman 在节目里问了一个很聪明的问题:你描述的这些东西,听起来和神经网络的图结构太像了。

拉特纳的回答点出了一个区别。

神经网络是层层不同的表示。输入进来是一层表示,经过一层变换变成另一种表示,越深层的表示越抽象。每一层都在做不同的事。

编译器是一种表示,反复变换。

同一个中间表示在编译器里被反复揉搓。找出循环里不随迭代变化的表达式提到外面去,找出重复计算,把 2 乘 x 换成左移一位,把常量提前算出来。这些变换是迭代进行的,一轮优化完了再来一轮,有时候一个 pass 会跑几十次。

两者都在做“变换表示”这件事,方向与层次完全不同。做机器学习系统的人可以从中拿到一个有用的判断:如果一层表示只被用一次,它大概是中间产物;如果一层表示被反复打磨几十轮,它才是真正的地基。

寄存器分配:编译器替你打的最硬的一仗

问编译器优化里最值钱的是什么,拉特纳直接说:寄存器分配。

场景是这样的。现代处理器里,内存慢,寄存器快,但寄存器数量极其有限。x86 在某些模式下只有十六个寄存器。而你写代码的时候随手就是几十个临时变量,循环里还套着循环,这段代码可能要执行几百万次。

如果循环里每个值都要往内存里读写一次,性能就废了。如果能把循环里所有活跃的值都塞进寄存器,速度会快一个数量级。

问题是怎么塞。同一个变量在函数的不同位置,活跃状态不一样。你在第三行定义了 x,在第五行用了它,之后再也不碰,那 x 在第五行之后就是“死的”,它占的寄存器可以给别人用。编译器要做的事情,是把整个程序看成一个有时间维度的图,然后在这个图里给每一个活着的值分配物理资源。

“你写的是 x,编译器看到的是四个不同的值,每一个都有它在整个函数里的生命周期,每一个都可能被放进寄存器、放进内存、或者在某些位置干脆重新算一遍,而不是从内存里读出来。”(克里斯·拉特纳)

这一步难在组合爆炸。可能的分配方案有无数种,而且这个决定会连锁影响后面所有的优化。寄存器分配做砸了,前面所有的优化都白搭。

另一场硬仗是指令调度。RISC 架构把流水线塞进了处理器,处理器能同时处理多条指令,前提是指令之间的顺序不能让流水线卡住。编译器的活是把指令重新排序,让流水线一直有活干。这一步的约束条件极其复杂,牵扯到各个指令的延迟、依赖关系、硬件端口数量。

这些技术都被研究了几十年,教材里都有。把一个算法变成能在几百人协作的代码库里稳定工作的实现,是另一回事。拉特纳反复强调,编译器的难点落在软件工程上。

让死对头坐到一张桌子上

LLVM 最了不起的地方,跟技术创新关系不大。

拉特纳自己说得很清楚:LLVM 里实现的各种算法,大部分在学术界早就有了,教科书上都写着。他的贡献是标准化,是把中间表示和后端做成一个大家都能用的公共层,然后把这件事做对了。

对到什么程度?Google 和苹果在同一个代码库上提交代码,AMD 和英特尔在同一个代码库上提交代码,英伟达和 AMD 在图形这部分提交代码。这些公司平时在法律诉讼和市场份额上打得不可开交。

它们为什么愿意合作?因为自己实现一遍太贵了,而且更缺的是人。编译器工程师是极难招的一类人,就算是大公司,也没办法为一个内部项目凑出一支顶级团队。共享基础设施是唯一理性选择。

更有意思的是这个基础设施被用到了它从没被设计过的地方。索尼把 LLVM 用在了电影制作的图形编译流程里,用拉特纳的话说,这让他们能做更好的特效。这说明分层做对了,接口抽象做得干净,才会有人拿它去做原设计者完全没想到的事。

反过来看 GCC。GCC 在它擅长的领域里非常强,但它是一个 C 编译器,一个基础设施。它的代码里塞满了全局变量,为特定用途设计,很难被复用到别的地方去。差别出在架构决策上,而这种差别要十年、二十年才显现出来。

社区治理也是同一套逻辑。今天 LLVM 有几百个贡献者,靠的是一套“代码所有者”制度。硬件厂商拥有自己硬件相关的那些代码,负责确保补丁被及时 review,负责这个方向上的架构决策。拉特纳名义上还在这个金字塔的顶端,他早就不 review 每一个补丁了,他做的事是调解技术分歧,保证整个社区在往前走。七年前还成立了 LLVM 基金会,管钱、管活动,不碰技术方向。

有意思的是,拉特纳在研究生阶段写的第一版寄存器分配器,后来被一个“比他聪明得多的人”整个换掉了。他把这件事当成 LLVM 设计成功的证据:模块化的好处就是别人能替换你的代码。

Clang 的起点,只是想把报错信息写清楚

2005 年拉特纳加入苹果。LLVM 在苹果内部落地,赶上了好几次大的架构迁移:转向英特尔、转向 64 位、iPhone 转向 ARM。因为是模块化的,每次迁移的成本都低得惊人。

开发者体验却很糟糕。当时的 Objective-C 程序员面对的报错信息、编译速度、工具链,都不怎么样。

然后他做了一件很拉特纳的事:谁也没告诉,下班之后自己写一个 C 编译器试试。

“我不会跟任何人承诺,也不告诉任何人。我就是晚上和周末开始写。”(克里斯·拉特纳)

写着写着他撞上了预处理器。这个东西人人都不喜欢,它极其复杂,里面塞着一堆古怪的历史包袱,比如三字符组(trigraph)这种鬼东西。而且它正是编译性能问题的一个关键症结。写到这里他发现,难和不可能之间有一道鸿沟,很多人一辈子没跨过去。

他跟经理说了。经理的反应是:太好了,这个问题我们确实要解决,我再给你一个人。

Clang 的目标定得很务实:更好的报错信息,更快的编译速度,还有 GCC 从来不支持的新的工具能力,比如重构工具和静态分析。要做到这些,编译器必须在内部维护大量额外的信息,还要保证这些信息不拖慢编译。这是个很精细的平衡。

C++ 是这里面最难啃的部分。规范文档厚得像砖头,语义规则之间的相互作用极其复杂。拉特纳的说法是:它几乎不可能实现,差一点就真的不可能。

跨过去的办法只有一个:一块一块地建,增量地做。还得招到真正懂各个子系统细节的工程师,一个人不可能同时精通模板推导、异常表、ABI 兼容性这些完全不同的深水区。

Swift 真正的阻力来自会议室

C++ 支持刚做完第一版,拉特纳脑子里冒出来一个念头:这语言有太多丑陋的地方,实现它的过程中你不可能不想到“一定存在更好的东西”。

于是他又一次开始了夜间项目。没有承诺,没有汇报,就是玩玩看。做完一些原型之后,他觉得这条路走得通,才去找当时的软件高级副总裁伯特兰·塞莱特(Bertrand Serlet)聊。塞莱特本身对语言有兴趣,给了不少早期指导,也鼓励他把这事推下去。之后才是告诉经理、告诉更多人。

技术上最难的部分已经过去了,剩下的是社会层面的阻力。

当时苹果内部的共识是:iPhone 之所以成功,是因为 Objective-C。这话背后有真实的文化支撑。当年苹果招软件工程师,招的就是喜欢 Objective-C 的人;很多高层和骨干工程师的文化记忆一路追溯到 NeXT 时代,那是 Objective-C 真正成型的年代。他们是“写 Objective-C 长大的”。

在这种氛围里提“我们做个新语言”,接近于异端。

拉特纳的观察角度不太一样。他觉得苹果内部喜欢 Objective-C 的人确实很多,最敢说话的那批人也确实是真爱,还有一大批人每天都在被这门语言的尖角割伤。它难学,它有各种奇怪的边界情况,它对新人不友好。

真正让这件事从“异端”变成“必须做”的,是一个词:内存安全。

Objective-C 的对象系统整个建立在 C 的指针之上,它本身就是 C 的一层扩展。指针不安全,这件事没得商量。只要你保留指针,你就没法在语言层面解决内存安全问题。你不能靠给 Objective-C 打补丁解决,因为指针就是它的地基。

这句话把讨论从“要不要”变成了“怎么做”。一旦承认 Objective-C 修不好,剩下的问题就是:新语言该长什么样?这完全是另一个阶段的工作了。

渐进式披露:为什么第一行代码必须能跑起来

Swift 的设计里,拉特纳最看重的一条原则来自 UI 设计:复杂度的渐进式披露。

它的意思是,一门语言应该允许人从最简单的入口进来。Swift 的第一课是打印一行 hello world。一行,没有 main 函数,没有头文件,没有 Java 那句 public static void main。Python 也是这样,这正是 Python 能成为编程第一课的原因。

然后往下走。加变量,写一句 var x = 4,什么叫变量,x 加 1 是什么意思。加控制流,if 怎么回事,for 怎么回事,while 怎么回事。加函数。加类。加泛型。加模块。每一层都比上一层复杂,每一层都能独立地跑起来。

“这在编译型语言里非常不典型。”(克里斯·拉特纳)

为什么编译型语言做不到这一点?因为它们必须在编译期知道所有类型、所有边界。这些信息对性能、对重构工具、对一切都有好处,代价是初学者一进门就要面对一堆声明和样板代码。Swift 想做的是保留静态类型的全部好处,同时把入口的门槛降到和 Python 一样低。

这件事的另一面是给不同的人留不同的层级。写库的人想要能钻到底层去抠细节,用库的人只想在高层拼装。一门语言如果只能服务其中一种人,它就废掉了一半的生态。

还有一个容易被忽略的点:Swift 不只做静态编译。它在 Colab 和 Jupyter 里被当作脚本语言用。你敲一行代码,背后发生的事情是这样的:先起一个 Unix 进程,然后每一行输入都过一遍 Swift 编译器前端、优化器、代码生成,最后把机器码注入到那个正在跑的进程里,边跑边替换。你在页面上敲代码的时候,它在原地打补丁。

“它能做到这件事,是因为设计时就考虑到了。”(克里斯·拉特纳)

拉特纳对编译这件事的看法也因此变得很不一样:静态编译、动态编译、解释执行,这些选项处在一条光谱上,彼此之间没有墙。把栈分好层,你就能在光谱上自由移动,不会把自己锁死在某一头。

一千二百行 Swift 代码,把 Python 拖了进来

Swift for TensorFlow 里有一个看起来像魔术的功能:在 Swift 里 import numpy,然后直接用。

拉特纳解释了实现原理,简单得出人意料。

一个动态类型语言可以有两种理解方式。大多数人会说 Python 没有类型。另一种理解是:Python 只有一种类型,就是那个 python object,所有东西都是它,正因为只有一种,类型才是隐式的。

Swift 有很多类型,数组、字符串、各种类。现在给它加上第二种:python object。

于是 import numpy 拿回来的是一个 python object,也就是那个模块。你调用 np 点 exp,Swift 做的事情是:告诉 Python 解释器“我要取这个对象上叫 exp 的成员”,拿回来又是一个 python object;再告诉解释器“把这个对象用这些参数调一下”,拿回来还是 python object。每一次都只是动态查表加一次跨界调用。

这一层胶水,纯 Swift 写的,只有一千二百行左右。它建在 Swift 跟 C 的互操作能力之上,因为跟 Python 解释器打交道本质上就是 C 层面的调用。

要让这一千二百行能写出来,Swift 语言本身必须先加两个特性:动态成员查找和动态调用。这两个特性的提案、实现、标准化、进入语言,花了一年。

用户看到的是一行 import。支撑这一行的是语言层面的新能力。这正是 Swift 这类有社区提案流程的语言能做到、纯库方案做不到的事。Python 那边为了机器学习加过什么语言特性?拉特纳想了一下,说大概只有 @ 这个矩阵乘法运算符。

TensorFlow 本质上是一个编译器,这句话值得展开

拉特纳提了一个视角,理解 TF 生态的混乱局面很有帮助。

TensorFlow 干的事情是:拿模型进来,让它在硬件上跑得飞快。这就是编译器干的事。它有前端,有优化器,有多个后端。

按这个框架看,Swift for TensorFlow 只是又一个前端。它和 Python、Go、Rust、Julia 的绑定共享同一套图表示、同一套运行时、同一套后端。

前端之间并不平等,它们分成三类。

第一类是 Python。它特殊,因为社区绝大部分的工程投入都在这边,它有自己的自动微分方案,有自己的 API 层。它的天花板也被这个位置限死了:你只能在 Python 这个库的边界之内做优化,改不了语言本身。

第二类是其他语言的绑定。它们就是包装层,调用 TF 的运行时 C API,没有自动微分,没有太多别的东西。

第三类是 Swift,只有它一个。它的思路是:既然我们可以改整条栈上的任何一个环节,那就从头问一遍,人和编译器之间的分工应该怎么切?

切法的核心在两处。第一处是类型系统。有了类型信息,编译器可以自动帮你构图,你不用手动想这些。汇聚、融合、优化,全都是白送的。第二处是自动微分,拉特纳认为这是 Swift for TensorFlow 最关键的贡献之一。

自动微分这件事的历史比大多数人想的要长。七十年代做数值计算的人写 Fortran,那时候就有一类工具叫源到源翻译器:你把自己的代码喂进去,它吐出来一份新的 Fortran 代码,里面带着你所有函数的导数。那是一整套技术积累,包括大量的优化技巧,包括怎么处理数值不稳定的各种花招。

问题在于,这些技术很难搬到今天的执行模型里。现代框架一次只能看到一个算子,看到一个加法、一个矩阵乘,而七十年代那批工具需要看到整个函数才能推理。当语言本身集成了自动微分,你就能重新打开这四十年的积累,把它们搬过来用。只是语言集成这件事本身也有一堆设计空间和复杂度要处理。

bfloat16:把比特挪个位置,性能就上去了

TPU 是软硬件协同设计最典型的样本,拉特纳在访谈里讲得挺细。

当时已经是第三代 TPU,整块液冷机箱的算力超过一百 petaflops。他的原话是“我们还没把想法用完”。

关键是那个数字格式:bfloat16。

它是 16 位浮点,但不是 IEEE 那种 16 位。标准半精度浮点把更多的位给了尾数,牺牲了指数范围。bfloat16 反过来,尾数更短,指数更长,和 32 位浮点一样长。

代价是精度更低。收益是能表示的范围和 float32 一样大。

为什么这个交换在机器学习里划算?因为训练过程中你会遇到极小的梯度,那些数字小到标准半精度直接下溢变成零,而它们恰恰是推动模型学习的东西。同时你也会遇到数量级很大的值。两头都要覆盖,中间精度松一点没关系。

更妙的是硬件成本。乘法器的面积和延迟跟尾数位数的平方成正比,跟指数位数是线性关系。把位从尾数挪到指数,硬件便宜了,模型效果没掉。

甚至还有理论说,精度降低反而能提升泛化能力。这个说法未必站得住,结果摆在那里:便宜、够用、有效。

这个格式的来历也挺有意思。它最初来自研究侧,那批人在想办法压缩网络传输中权重的体积,找各种压缩方案,后来这个方案被直接烧进了硅片。从一个传输优化的小技巧,变成了 TPU 性能的核心组成部分。

这就是拉特纳说的那个“只有 Google 能做的三合一”:底层编译器和芯片设计、上层软件框架、以及算法本身,三层可以同时改动。算法在变,硬件从设计到量产要几年,你必须押注几年后什么算法会流行,然后把晶体管花在最值的地方。

MLIR:LLVM 二十岁了,世界变了

访谈前三周,Google 在一个编译器会议上公布了一个新项目,MLIR(Multi-Level Intermediate Representation)。

背景是这样:TF 这条栈里嵌着一堆来自不同厂商的编译器。Google 有 XLA,英伟达有 TensorRT,英特尔有 nGraph。它们各自解决一部分问题,都在重复造轮子,都在想办法接进 TF。

MLIR 想做的是给这些子系统提供一层公共基础设施。第一步是让它们能插到一起,共享代码。更长远的目标是让整个行业开始协作,不要一遍一遍重新发明同样的东西。这套逻辑在传统编译器领域已经被验证过一次。

有人开玩笑说,MLIR 就是从 LLVM 学到的一切教训的 LLVM 版本,是一次修正错误的机会。拉特纳自己也承认这一点:LLVM 在它被设计出来要解决的问题上非常强,二十年过去,人们开始解决更高层的问题,需要新的技术。

这句话背后有一个很朴素的道理:一个好的抽象层会活得比它的设计者预期的更久,然后开始显出老态。这不是失败,成功的代价本来就是如此。

开源这件事,Google 和苹果的差别在哪

Fridman 问了一个直接的问题:苹果和 Google 在开源上的文化差异。

拉特纳的回答没有绕弯:他更认可 Google 的做法。他给了苹果一个公道的解释:苹果的文化有它的历史成因,那是三十五年前形成的路径,苹果也在适应。

他的论证是这样的:一家公司关心赚钱,这完全理性。真正让你赚钱的东西是什么?是那个做得极好的产品、那个差异化的体验,不是你的字符串库。把字符串库捂住不放,今天早就不是关键的那一层了。十五年前可能还是,今天的平台竞争不在那儿。

Google 开源 TensorFlow 这件事,拉特纳看来是一次“深刻的、极其聪明的洞察”。他特意设想了一个反事实的世界:一家公司说机器学习是我们的核心竞争力,我们不给别人。那个世界完全可能发生。TensorFlow 开源改变了整个机器学习领域,引发了一场独立的革命,同时在很多层面回馈了 Google 自己。

特斯拉那五个月:他respect愿景,不respect所有方法

2017 年前后,拉特纳在特斯拉待了大约五个月,职位是自动驾驶软件副总裁。他赶上的时间点是特斯拉从 Hardware 1 切到 Hardware 2,从第三方提供的视觉栈换成自研视觉栈。

他对这段经历的评价很坦率,也很体面。

Hardware 1 最初的设计目标其实很简单:交通感知巡航、车道保持这类功能。能在这个硬件上做到后来那种程度的辅助驾驶,他认为相当惊人。当时最大的挑战,是从第三方视觉栈往自研栈上迁。这一步时间压力很大,好在他可以沿用原来那支团队的知识和经验。

然后他说了一句很重的话:

我在特斯拉的时候,经历了也目睹了我此前在任何公司见过的最高的离职率,这有点让我吃惊。(克里斯·拉特纳)

紧接着,他说他从这段经历里学到并开始尊重的一件事:马斯克能吸引到极其优秀的人,因为他有非常清晰的未来图景,并且能让人相信那个图景。街角随便一个人都能喊“我们要去火星”,真正能让别人买账、并且真的把路径搭出来的人,极少。他对这种愿景的力量评价很高。

最后那句补充很关键:“我不认同他的所有方法,但我对这一点有极大的尊重。”(克里斯·拉特纳)

什么叫工作努力

Fridman 问了一个很少被认真回答的问题:工作努力到底指什么?

拉特纳先给了最常见的答案:很多小时。这是事实,他不否认。

他说真正难的是另一件事:同时保持短期交付的专注和长期的判断。

如果你眼里只有眼前这个任务,把它干完,然后只想着下一步,你会错过那个本该跳过去的下一个大坎。反过来,如果你天天只想着三年后的架构,你交付不出任何东西。在这两端之间来回摆,是最消耗人的。

他承认自己在苹果能做到这一点,靠的是搭起了团队和领导结构,让那些人能成长、能承担责任,从而把自己解放出来去“稍微疯一点”,去想下一件事。

还有一部分是经验带来的连接能力。做过足够多的事情之后,你能看到别人看不到的关联,那些关联本身能省掉大量的试错。他把这算作时间给的一笔复利:同样一个问题,二十年前他得从头推导,今天他能在几秒钟内认出这是哪一类坑。

底层还是大量的小时。他说自己对工作生活平衡有一套自己的理论,这理论是他对自己用的,不往团队身上套。他的目标说得很直白:改变世界,让它变好一点,这就是他的动力来源。

这段话里有个容易被忽略的分寸感。他谈的是自己愿意怎么活,没有把它包装成普适标准,更没有暗示别人不够努力。这种区分在技术圈其实挺稀缺。

那个龙

LLVM 的标志是一条龙。官方说法是龙代表力量、速度、智慧,也能代表流畅、优雅、模块化。真实原因简单得多:编译器领域有一本很老很经典的教材,叫《龙书》(Compilers: Principles, Techniques, and Tools)。

当年在苹果,大家做演示要放幻灯片,总得有个 LLVM 的图标,但没有。有人问,编译器技术该配个什么标志?拉特纳说,我不知道,龙大概是我们手上能拿到最好的东西了。苹果的设计团队把图标做了出来,社区接受了它,后来越来越多的设计师参与改进,就成了今天的样子。

有个细节挺有意思。拉特纳的妻子也是编译器工程师,她负责运营 LLVM 基金会,会去 Grace Hopper 大会发贴纸,想办法让更多女性对编译器产生兴趣。结果因为《权力的游戏》,大家都喜欢那个龙的贴纸,抢着要。文化偶尔会用这种方式帮上忙,让下一代工程师对编译器多看两眼。

一条原本只是为了填满幻灯片角落的龙,最后变成了一个跨公司、跨国籍、二十年的合作符号。这件事本身挺说明问题:基础设施的生命力来自被借用,不来自被保护。

把这一小时的信息用起来

这期访谈最有价值的地方不在结论,在那种看问题的方式。拉特纳反复在做同一件事:把复杂系统拆成层,让每一层都能被独立替换,然后耐心等十年看结果。这套方法可以迁移到很多地方。

  • 设计任何长期系统时,先问“这一层会被谁替换”。拉特纳第一版寄存器分配器被别人整个换掉了,他当成好事。如果你的架构不允许这种替换发生,它就只能活到你的想法过时那天。
  • 别用“这不可能”结束讨论,改成“这有多难”。Clang 和 Swift 都起于“我只是晚上写写看”。区别在于他撞墙之后去判断的是难度等级,可行性压根不是他问的问题。
  • 遇到僵局时,去找那个修不好的地基。Swift 能立项靠的是一个不可辩驳的限制条件:指针就是内存安全问题的根,打补丁永远修不好。把争论从“要不要”转成“怎么做”,只需要这一句话。
  • 把渐进式披露用到文档、API、产品上。第一行代码必须能跑起来,然后才是第二层复杂度。任何要求用户一进门就理解全貌的设计,都会把大批人挡在门外。
  • 做软硬件或跨层项目时,接受“押注”这件事。硬件从设计到量产要几年,算法几个月就换一轮。bfloat16 之所以能成,是因为有人敢在不确定的情况下押注“指数比尾数更重要”,并且这个判断在模型层面站得住。
  • 评估一个开源项目,先看它有没有被用在设计之外的地方。索尼拿 LLVM 做电影特效的图形编译,这个信号比任何性能基准都更能说明它的分层是对的。
  • 判断一个基础设施值不值得做,看重复成本。英特尔、AMD、英伟达、Google、苹果愿意在一个代码库上合作,动力来自两个硬约束:自己实现一遍太贵,招不到足够的人。找到别人绕不过去的高成本,就是协作的入口。
  • 关于工作强度:不要只优化小时数。真正稀缺的能力是在短期交付和长期判断之间来回切换。把执行层交给能成长的人,是唯一能让自己腾出手去想下一件事的办法。

最后留一句拉特纳没有明说、但整期访谈都在示范的事:他从研究生到 2019 年,做的所有项目都有一个共同点,起点小得几乎不体面。一个夜间项目,一本教材上的程序,一个只想读一年硕士就回去工作的人。值得做的事,往往一开始看起来不值得向任何人汇报。

文稿由本站用语音识别模型(基于官方发布音频)机器转写,可能有识别错误,人名与数字请以音频为准。
[00:00:00] The following is a conversation with Chris Flattener, currently he's a senior director at Google working on several projects, including CPU, GPU, GPU accelerators for for swift returns to flow and all kinds of machine learning compiler magic going on behind the scenes. He's one of the top experts in the world on compiler technologies, which means he deeply understands the intricacies of how hardware and software come together to create efficient code. He created that allow VM Compiler Infrastructure Project and the clang compiler. [00:00:33] He led major engineering efforts at Apple, including the creation of the swift programming language. He also briefly spent time at Tesla as vice president of Autopilots Software during the transition from auto pilot hardware one to hardware to when Tesla essentially started from scratch to build an in-house software infrastructure for autopilot. I could have easily talked to Chris for many more hours. Compiling code down across the levels of abstraction is one of the most fundamental and fascinating aspects of what computers do. [00:01:05] And he is one of the world experts in this process, its rigorous science and its messy, beautiful art. This conversation is part of the Artificial Intelligence podcast, if you enjoy it. Subscribe on YouTube, iTunes or simply connect with me on Twitter at Lux. Friedman spelled Frid. And now here's my conversation with Chris Laettner. What was the first program you've ever written? Our first program back and when was it I think I started as a kid and my parents got a basic programming book, and so when I started it was typing out programs from a book and seeing how they worked and then typing them in wrong and trying to figure out why they were not working. [00:02:08] Right. That kind of stuff. [00:02:10] So basically, what was the first language that you remember yourself maybe falling in love with? Like really connecting with? I don't know. [00:02:17] I mean, I feel like I've learned a lot along the way and each of them have a different special thing about them. So I started in Basic and then went like GW Basic, which was the thing back in the dark days and then upgraded to Kubasik. And eventually Quick Basic, which are all slightly more fancy versions of Microsoft, basically made the jump to Pascall and started doing machine language programming and assembly and Pasko, which was really cool through Pasko. [00:02:43] It was amazing for its they're eventually going to see C++ and then kind of did lots of other weird things. [00:02:50] So I feel like it took the dark path, which is the you could, you could have gone lisp. Yeah. [00:02:57] You get a higher level sort of functional philosophical hippy root. Instead you went into like the dark arts of the straight into the machine. [00:03:07] So started with Basic Pasko and then assembly and then wrote a lot of assembly and y eventually eventually did small talk and other things like that. But that was not the starting point. [00:03:19] But so what, what is this journey to see is that in high school. Is that in college I was in high school. [00:03:25] Yeah. So and then that was, it was really about trying to be able to do more powerful things than what Pascall could do and also to learn a different world. So it was really confusing to me with pointers and the syntax and everything. And it took a while but. Pascale's much more. Principals in various ways seems more. I mean, it has its historical roots, but it's not as easy to learn with pointers. There's this memory management. [00:03:56] Thing they have to become conscious of is that the first time you start to understand that there's resources that you're supposed to manage well, so you have that in Pascal as well. [00:04:05] But in Pasko, these like the carrot and sort of the star. And there's some small differences like that, but it's not about point or arithmetic. And and C, you end up thinking about how things get laid out in memory a lot more. And so in Pascal, you have allocating and allocating and owning the memory. But just the programs are simpler and you don't have to. [00:04:27] Well, for example, Pascal has a string tape and so you can think about a string instead of an array of characters which are consecutive in memory. And so it's a little bit of a higher level abstraction. [00:04:37] So let's get into it. Let's talk about LVM ceiling and compilers. Sure. So can you tell me first what all the ceiling are and how is it that you find yourself the creator and lead developer or one of the most powerful compiler optimization systems in use today? [00:04:57] Sure. So. I guess they're different things, so. Let's start with what is the compiler it's a good place to start. What are the phases of a compiler where the parts. Yeah, what is it? So what does even a compiler used for? [00:05:10] So the way the way I look at this is you have a two sided problem of humans that need to write code and then you have machines that need to run the program that the human wrote. And for lots of reasons, the humans don't want to be writing in binary and want to think about every piece of hardware. And so at the same time that you have lots of humans, you also have lots of kinds of hardware. And so compilers are the art of allowing humans to think of the level of abstraction that they want to think about and then get that program, get the thing that they wrote to run on a specific piece of hardware. [00:05:43] And the interesting and exciting part of all this is that there's now lots of different kinds of hardware, chips like X 86 and her PC and arm and things like that. [00:05:53] But also High-Performance accelerators for machine learning and other things like that are also just different kinds of hardware, GPS. These are new kinds of hardware. [00:06:00] And at the same time, on the programming side of it, you have your basic you have C, you have JavaScript, you have Python, you Swift. You have like lots of other languages that are all trying to talk to the human in a different way to make them more expressive and capable and powerful. And so. Compilers are the thing that goes from one to the other now and then from the very beginning to the end to end, and so you go from what the human wrote and programming languages end up being about, expressing intent not just for the compiler and the hardware, but the programming languages job is really to to capture an expression of what the programmer wanted that then can be maintained and adapted and evolved by other humans, as well as by the interpreter, by the compiler. [00:06:46] So so when you look at this problem, you have on the one hand, humans, which are complicated, you have hardware which is complicated. [00:06:53] And so compilers typically work in multiple phases. [00:06:56] And so the software engineering challenge that you have here is try to get maximum reuse out of the the amount of code, the right, because these compilers are very complicated. And so the way it typically works out is that you have something called a front end or a parser that is language specific. And so you have a C parser and that's what Clangers or C++ or JavaScript or Python or whatever. That's the front end. Then you'll have a middle part, which is often the optimizer, and then you have a late part, which is hardware specific. [00:07:30] And so compilers end up there's many different layers often, but these three big groups that are very common and compilers and what LVM is trying to do is trying to standardize that middle and last part. And so one of the cool things about LVM is that there are a lot of different languages that compile through to it. And so things like Swift, but also Julia Rust. Clang for c c++ subjective c like these are all very different languages, and they can all use the same optimization infrastructure which gets better performance and the same cogeneration infrastructure for hardware support. [00:08:05] And so LVM is really that that layer that is common that all these different specific compilers can use. [00:08:12] And is it is it a standard like a specification or is it literally an implementation set implementation? [00:08:19] And so it's I think there's a couple of different ways of looking at it. [00:08:23] Right, because it depends on which angle you're looking at it from. LVM ends up being a bunch of code. OK, so it's a bunch of code that people reuse and they build compilers with. [00:08:33] We call it a compiler infrastructure because it's kind of the underlying platform that you build a concrete compiler on top of. [00:08:39] But it's also a community. And the Muslim community is hundreds of people that all collaborate. And one of the most fascinating things about LVM over the course of time is that we've managed somehow to successfully get harsh competitors in the commercial space to collaborate on shared infrastructure. And so you have Google and Apple, you have AMD and Intel, you have Invidia and AMD. On the graphics side, you have Quray and everybody else doing these things. [00:09:09] And like all these companies are collaborating together to make that shared infrastructure really, really great. [00:09:15] And they do this not out of the goodness of their heart, but they do it because it's in their commercial interests of having really great infrastructure that they can build on top of and facing the reality that it's so expensive that no one company, even the big companies, no one company really wants to implement it all themselves, expensive or difficult? [00:09:33] Both. That's a great point, because it's also about the skill sets. Right. And these are the skill sets are very hard, hard to find. [00:09:43] How big is the LVM? It always seems like with open source projects, the kind of open source. [00:09:50] Yes, it's open source. It's about it's 19 years old now. So it's fairly old. [00:09:55] It seems like the magic often happens in a very small circle of people. Yes, I'd like at least the early birth and whatever. [00:10:03] Yes. So LVM came from a university project, and so I was at the University of Illinois and there it was myself and my advisor and then a team of two or three research students in the research group. And we built many of the core pieces initially. I then graduated and went to Apple and an apple brought it to the products, first in the open geographic stack, but eventually to the C compiler rom and eventually built clang and eventually built Swiftian. [00:10:30] These things along the way, building a team of people that are really amazing compiler engineers that helped build a lot of that. And so as it was gaining momentum and as was using it being open source and public and encouraging contribution, many others, for example, at Google came in and started contributing. And in some cases, Google effectively owns Clanged now because it cares so much about C++ and the evolution of that that ecosystem. And so it's investing a lot in the C++ world and the tooling and things like that. [00:11:00] And so likewise, Invidia cares a lot about Khuda. And so Kuda uses clang and uses LVM for for graphics and GPP. [00:11:12] And so when you first started as a massive project, I guess, do you think is going to go as far as it went where you crazy ambitious about it now? Seems like a really difficult undertaking. A brave one. [00:11:26] Yeah, no, it was nothing like that. So I mean, my goal when I went to the University of Illinois was to get in and out with a non thesis masters and a year and get back to work. [00:11:35] So I was not I was not planning to stay for five years and and build this massive infrastructure. I got nerds sniped into staying and a lot of it was because all of it was fun. I was building cool stuff and learning really interesting things and facing both software engineering challenges, but also learning how to work on a team and things like that. [00:11:57] I had worked at many companies as interns before that, but it was really a different a different thing to have a team of people that were working together and trying to collaborate and version control. And it was it was just a little bit different. [00:12:09] Like I said, I just talked to Don Knuth and he believes that two percent of the world population have something weird with their brain, that they're geeks. They understand computers, the connected computer, he put it exactly two percent. [00:12:21] OK, so this specific guy is very specific. He says I can't prove it, but it's very empirically there. [00:12:30] Is there something that attracts you to the idea of optimizing code? And it seems like that's one of the biggest, coolest things about all of you. [00:12:38] Yeah, that's one of the major things that does. So I got into that because of a person, actually. So when I was in my undergraduate, I had an advisor or a professor named Steve Victo, and he I went to this little tiny private school, the. The seven or nine people in my computer science department, students in my in my class, so it's a very tiny, very small school, it was kind of a work on the side of the math department kind of thing at the time. [00:13:08] I think it's evolved a lot in the many years since then. [00:13:10] But but Steve Ragdoll was a compiler guy and he was super passionate and he has passion rubbed off on me. And one of the things I like about compilers is that they're large, complicated software pieces. [00:13:26] And so one of the culminating classes that many computer science departments, at least at the time, did, was to say that you take algorithms and data structures and all these core classes. But then the compilers class was one of the last classes you take because it pulls everything together and then you work on one piece of code over the entire semester. And and so you keep building on your own work, which is really interesting, is also very challenging because in many classes, if you don't get a project done, you just forget about it and move on to the next one and get your, you know, your B or whatever it is. [00:13:58] But here you have to live with the decisions you make and continue to reinvest in it. [00:14:02] And I really like that. And and so I did an extra study project with them the following semester and he was just really great. And he was also a great mentor and a lot of ways. And so from from him and from his advice, he encouraged me to go to graduate school. I wasn't super excited about going to grad school. [00:14:20] I wanted the master's degree, but I didn't want to be an academic. [00:14:24] And but like I said, I kind of got tricked into saying and was having a lot of fun, and I definitely do not regret it. [00:14:31] What aspects of compilers were the things you connected with? So LVM, there's also the other part. [00:14:39] This is really interesting. If you're interested in languages parsing and yeah. Just analyzing like. Yeah, analyzing language, breaking it up, parsing and so on. Was that interesting to you? Were you more interested in optimization? For me it was more so. [00:14:52] I'm not really a math person. I could do math. I understand some bits of it when I get into it. But math is never the thing that that attracted me. And so a lot of the parser, part of the compiler has a lot of good formal theories that Don, for example, knows quite well. Still waiting for his book on that. [00:15:08] But but the but I just like building a thing and and seeing what it could do and exploring and getting to do more things and then setting new goals and reaching for them and and with in the case of in the case of LVM, when I started working on that, my research advisor that I was working for was a compiler guy. And so he and I specifically found each other because we're both interested in compilers. And so I started working with them and taking this class. [00:15:36] And a lot of LVM initially was it's funny implementing all the standard algorithms and all the other things that people had been talking about and were well known. And they were in the the curricula for advanced days and compilers. And so just being able to build that was really fun. And I was learning a lot by sort of reading about just building. And so I enjoyed that. [00:15:57] So he said composing these complicated systems. Q Even just with language, try to describe, you know, how you turn a C++ program. Yes. [00:16:08] Into code like what are the hard parts, why is it so hard? [00:16:11] So I'll give you examples of the hard parts along the way. So C++ is a very complicated programming language is something like 400 pages in the spec. So C++ by itself is crazy. [00:16:23] Can you just say pause? What makes a language complicated in terms of what's syntactically like us? [00:16:30] So it's what they call syntax. So the actual how the characters are arranged. Yes, it's also semantics how it behaves. It's also in the case of C++, there's a huge amount of history. [00:16:40] C++ built on top of C, you play that forward and then a bunch of suboptimal in some cases decisions were made and they compound and then more and more and more things keep getting added to C++ and it will probably never stop. [00:16:54] But the language is very complicated from that perspective. And so the interactions between subsystems is very complicated. There's just a lot there. And when you talk about the front end, one of the major challenges which playing as a project, the C C++ compiler that I built, I and many people built all the challenges we took on was. [00:17:13] We looked at Jesse, Jesse at the time was like a really good industry standardized compiler that had really consolidated a lot of the other computers in the world and was was a standard, but it wasn't really great for research. [00:17:27] The design was very difficult to work with and it was full of global variables and other other things that made it very difficult to reuse in ways that it wasn't originally designed for. And so with closing, one of the things that we want to do is push forward on better user interface. So make error messages that are just better than Jinx's. And that's actually hard because you have to do a lot of bookkeeping in an efficient way to do that. [00:17:50] We want to make compile time better. And so compile time is about making it efficient, which is also a really hard way of keeping track of extra information. [00:17:57] We wanted to make new tools available, so refactoring tools and other analysis tools that the GCSE never supported. Also leveraging the extra information we kept, but enabling those new classes are tools that then get built into ideas. [00:18:13] And so that's been one of the one of the areas that clangers really helped push the world forward in is in the tooling for C and C++ and things like that. [00:18:22] But C++ and the front end pieces complicated. And you have to build syntax trees and you have to check every rule in the spec and you have to turn that back into an error message to the human human that the human can understand when they do something wrong. [00:18:34] But then you start doing the what's called lowering. So going from C++ in the way that it represents code down to the machine. And when you do that, there's many different phases you go through. [00:18:46] Often there are, I think, Alabama, something like 150 different what are called passes and the compiler that the code passes through and these get organized in very complicated ways which affect the generate code in the performance and compile time and many of the things. [00:19:03] What are they passing through? So after you do the the clang parsing, what's what's the graph? [00:19:11] What does it look like? What's the structure here. [00:19:13] Yeah. So in, in the parser it's usually a tree and it's called an abstract syntax tree. And so the idea is you, you have a node for the plus that the human wrote in their code or the function call. You'll have a node for call with the function that they call in the arguments they pass, things like that. This then gets lowered into what's called an intermediate representation, and intermediate representations are like LVM has one and there it's a it's what's called a control photograph. [00:19:44] And so you represent each operation in the program as a very simple like this is going to add two numbers. This is going to multiply two things. [00:19:53] Maybe we'll do a call, but then they get put in what are called blocks. And so you get blocks of these straight line operations where instead of being nested like in a tree, it's straight line operations. And so there's a sequence and we're going to these operations and then in the block or outside, that's within the block. [00:20:10] And so it's a straight line sequence of operations within the block. [00:20:12] And then you have branches like additional branches between blocks. And so when you write a loop, for example, in a syntax tree, you would have a four node like four for statement in a C language for node. And you have a pointer to the expression for the initialize are appointed to the expression, for the incremental pointer, to the expression for the comparison appointer to the body. OK, and these are all nested underneath it. In a controller graph, you get a block for the code that runs before the loop. [00:20:43] So the initialized code and you have a block for the body of the loop. And so the the body of the loop code goes in there, but also the increment, other things like that. [00:20:52] And then you have a branch that goes back to the top and a comparison and branch that goes out. And so it's more of an assembly level kind of representation. But the nice thing about this level of representation is it's much more language independent. [00:21:05] And so there's lots of different kinds of languages with different kinds of, you know, JavaScript has a lot of different ideas of what is false, for example, and all that can stay in the front end. [00:21:17] But then that middle part can be shared across all of those. [00:21:21] How close is that intermediate representation to a 10 year old network, for example? Are they? Because everything you describe is a kind of echoes of neural network graph. Yes, we are. [00:21:34] The neighbors are what they're quite different in details, but they're very similar in idea. So one of the things that all networks do is they learn representations for data at different levels of abstraction and then they transform those through layers. Right. [00:21:51] So the compiler does very similar things. But one of the things the compiler does is it has relatively few different representations where a neural network, often as you get deeper, for example, you get many different representations and each, you know, layer or set of ops is transforming between these different representations. In a compiler, often you get one representation and they do many transformations to it. And these transformations are often applied iteratively. [00:22:16] And for programmers that are familiar types of things, for example, trying to find expressions inside of a loop and pulling them out of a loop so they execute four times or find redundant computation or find a constant folding or other simplifications turning, you know, to times ex into shift left by one. And things like this are all of all the examples of the things that happen. [00:22:40] But compilers end up getting a lot of things improving and other kinds of algorithms that try to find higher level properties of the program that then can be used by the optimizer. [00:22:49] So what's the biggest bang for the buck with optimization? What's today? Yeah, well, no, not even today at the very beginning, the 80s, I don't know, but yeah. [00:23:00] So for the 80s, a lot of it was things like register allocation. [00:23:03] So the idea of in in a modern like a microprocessor, what you'll end up having is you'll end up having memory which is relatively slow, and then you have registers relatively fast, but registers, you don't have very many of them. [00:23:17] And so when you're writing a bunch of code, you're just saying like compute this put in temporary variable computers, computers, computers, put in temporary variable over a loop. I have some other stuff going on. Well, now you're running on an X eighty six like a desktop PC or something. Well, it only has in some cases, some modes it registers. Right. And so now the compiler has to choose what values get put in, what registers at one points in the program. [00:23:41] And this is actually a really big deal. So if you think about you have a loop and an inner loop, the excuse millions of times, maybe if you're doing loads in stores inside that loop, then it's going to be really slow. But if you can somehow fit all the values inside that loop in registers, now it's really fast. And so getting that right requires a lot of work because there's many different ways to do that. And often what the compiler ends up doing is it ends up thinking about things in a different representation than what the human wrote. [00:24:09] Right. You wrote into X while the compiler thinks about that is for different values, each which have different lifetimes across the function that it's in. And each of those could be put in a register or memory or different memory or maybe in some parts of the code recompute it instead of extraordinarily loaded. And there are many of these different kinds of techniques that can be used so that adding almost like a time. [00:24:31] Dimensioned is trying to trying to optimize across time, so it's considering when when you're programming, you're not thinking. [00:24:39] Yeah, absolutely. And so the risk error. Made the risk so so risk gips risc the risk risk chuffs as opposed to the risk chips, made things more complicated for the compiler because what they ended up doing is ending up adding pipelines to the processor or the processor can do more than one thing at a time. But this means that the order of operations matters a lot. [00:25:04] And so one of the classical compiler techniques that you use is called scheduling. And so moving the instructions around so that the processor can keep its pipelines full instead of stalling and getting blocked. And so there's a lot of things like that that are kind of bread and butter. A compiler techniques have been studied a lot over the course of decades now, but the engineering side of making them real is also still quite hard. And you talk about machine learning. This is this is a huge opportunity for machine learning because many of these algorithms are full of these like hokey handwrote heuristics, which work well on specific benchmarks that don't generalize and full of magic numbers. [00:25:41] And, you know, I hear there's some techniques that are good at handling that. [00:25:45] So what would be the if you were to apply machine learning to this? What's the thing you try to optimize is ultimately the running time? [00:25:55] Of course, you can pick your metric and there's there's running time, there's memory use. There's there's lots of different things that you can optimize for. A good size is another one that some people care about in the embedded space. [00:26:05] Is this like the thinking into the future or somebody's actually been crazy enough to try to have machine learning based parameter tuning for the optimization of composers? [00:26:18] So this is something that is, I would say, research right now. There are a lot of research systems that have been applying search in various forms and using reinforcement learning as one form, but also for search has been tried for quite a while. [00:26:31] And usually these are small, small problem spaces. [00:26:35] So find the optimal way to generate a matrix multiplier for a GPU, something like that, where you say there there's a lot of design space of do you unroll loops a lot? Do you execute multiple things in parallel? [00:26:49] And there's many different confounding factors here because graphics cards have different numbers of threads and registers and execution parts and memory bandwidth and many different constraints to interact and nonlinear ways. And so search is very powerful for that and. It gets used in in certain ways, but it's not very structured. This is something that we need. We as an industry need to fix these set 80s, but they. So have there been like big jumps in improvement and optimization? Yes. [00:27:19] Since then. What? [00:27:21] Yeah. So it's largely been driven by hardware. So Heartwell hardware and software. [00:27:27] So in the mid 90s, Java totally changed the world and I'm still amazed by how much change was introduced, by the way, or in a good way. So like reflecting back, Java introduced things like it all at once, introduced things like compilation. [00:27:43] None of these were novel, but it pulled it together and made it mainstream and and made people Envestnet compilation, garbage collection, portable code, safe code, like memory, safe code, like a very dynamic dispatch execution model. [00:27:58] Like many of these things which had been done in research systems and had been done in small ways and various places really came to the forefront, really changed how things worked and therefore changed the way people thought about the problem. JavaScript was another major world change based on the way it works, but also on the hardware side of things. [00:28:19] Multicore and vector instructions really change the problem space and are very they don't remove any of the problems the Campo's faced in the past, but they they add new kinds of problems of how do you find enough work to keep a four wide vector busy? Or if you're doing a matrix multiplication, how do you do different columns? Are that matrix and at the same time? And how do you maximally utilize the the arithmetic compute that one core has? And then how do you take it to multiple cores? [00:28:50] And how did the whole virtual machine thing change the computation pipeline. The yeah. So, so what the Java virtual machine does is it splits just like I was talking about before, where you have a front end that passes the code and then you have an intermediate representation that gets transformed, which I ever did, was they said we will pass the code and then compile to what's known as Java bytecode, and that bytecode is now a portable code representation that is industry standard and lock down and can't change. [00:29:19] And then the the back part of the compiler, the does optimization and co-generation can now be built by different vendors and Java bytecode can be shipped around across the wire. [00:29:30] It's memory safe and relatively trusted. [00:29:33] And because of that it can run in the browser and that's why it runs in the browser. Right. And so that way you can be in, you know, again back in the day you write Java applet and you'd use a as a as a web developer, you'd build this mini app to run a webpage. Well, a user of that is running a Web browser on their computer. You download that that Java bytecode, which can be trusted, and then you do all the compiler stuff on your machine. [00:29:58] So you know that you trust that that was a good idea. [00:30:00] A bad idea. It's a great idea. I mean, it's a great idea for certain problems. And I'm very much a believer that technology is itself neither good nor bad. [00:30:07] It's how you apply it. [00:30:10] You know, this would be a very, very bad thing for very low levels of the software stack. [00:30:14] But but in terms of solving some of these software portability and transparency or portability problems, I think it's been really good. [00:30:21] Now, Java ultimately didn't win out on the desktop and like there are good reasons for that, but it's been very successful on servers. And in many places it's been a very successful thing over over decades. [00:30:33] So what has been low VMS and ceilings, improvements in optimization, that is throughout its history. [00:30:45] What are some moments we had set back and really proud of what's been accomplished? [00:30:50] Yeah, I think that the interesting thing about LVM is not the innovations and compiler research. It has very good implementations of various important algorithms, no doubt. [00:31:01] And and a lot of really smart people have worked on it. But I think that the thing that's most profound about LVM is that through standardization, it made things possible that otherwise wouldn't have happened. OK, and so interesting things that have happened with LVM, for example, Sony has picked up LVM and used it to do all the graphics compilation and their movie production pipeline. And so now they're able to have better special effects because of LVM. [00:31:26] That's kind of cool, that's not what it was designed for, right, but that's that's the sign of good infrastructure when it can be used in ways it was never designed for because it has good layering and software engineering and composable and things like that, which is where, as you said, it differs from JC. [00:31:43] Yes, Jesus is also great in various ways, but it's not as good as infrastructure technology. It's it's you know, it's really a C compiler or it's or it's a forgery compiler. It's not it's not infrastructure in the same way now, is it? [00:31:57] Now you can tell I don't know what I'm talking about because I keep saying cieling. [00:32:01] You can always tell when a person is close by the way you pronounce something. I don't think. [00:32:07] Have I ever used Klencke entirely possible. Have you? Well, so you've used code. It's generated probably. So Clang is in Alabama, used to compile all the apps on the iPhone effectively and the OS as it compiles Google's production server applications. It's used to build like Game Cube games and PlayStation four and things like that, as a user I have, but just everything I've done that I experienced to Linux has been, I believe, always geeky. [00:32:40] You know, I think Linux stole the hostages. This and is the reason for that. [00:32:45] There's a big I mean, it's a combination of technical and social reasons. Many, many Linux developers, D. D clone. But the distribution's for lots of reasons. Eustachy historically. [00:32:59] And they've not switched. No, because I just anecdotally online, it seems that LVM has either reached a level GGC or superceding different features or whatever. [00:33:10] And the way I would say it is that they're so close it doesn't matter. Yeah, exactly. Like they're slightly better in some ways slightly worse than other, but it doesn't actually really matter anymore that level. [00:33:20] So in terms of optimization, breakthrough's, it's just been solid, incremental work. Yeah. Yeah. [00:33:27] Which is which describes a lot of compilers. The hard thing about compilers in my experience, is the engineering, the software engineering, making it so that you can have hundreds of people collaborating on really detailed low level work and scaling that. [00:33:42] And that's that's really hard. And that's one of the things I think LVM has done well. And that kind of goes back to the original design goals with it to be modular and things like that, and incidentally, I don't want to take all the credit for this. Right. I mean, some of the the best parts about LVM is that it was designed to be modular. And when I started, I would write, for example, or register Elkader and then something much smarter than me would come in and pull it out and replace it with something else that they would come up with. [00:34:09] And because it's modular, they were able to do that. And that's one of the challenges with what you see, for example, is replacing subsystems is incredibly difficult. It can be done, but it wasn't designed for that. And that's one of the reasons that Alvin's been very successful in the research world as well. [00:34:25] But in the in a community sense, would of an Rassam right from Python, just retired from. [00:34:35] What does a benevolent dictator for life, right, so in managing this community of brilliant, compassionate folks is there I did it for a time at least following you to to approve things. [00:34:48] Oh, yeah. [00:34:49] So, I mean, I still have something like an order of magnitude more patches in LVM than anybody else. And many of those I wrote myself. [00:34:59] But you still write I mean, you still you still close to the to the I don't know what the expression is to the metal. You still write code. [00:35:08] Yeah. Sorry, I could not as much as I was able to in grad school, but that's an important part of my identity. But the way the LVM has worked over time is that when I was a grad student, I could do all the work and steer everything and review every patch and make sure everything was done exactly the way my opinionated sense felt like it should be done. And that was fine. [00:35:28] But as a scale, you can't do that. Right. And so what ends up happening is LVM has a hierarchical system of what's called owners. These code owners are given the responsibility not to do all the work, not necessarily to review all the patches, but to make sure that the patches do get reviewed and make sure that the right things happening architecturally in their area. [00:35:49] And so what you'll see is you'll see that, for example, hardware manufacturers end up owning the the the hardware specific parts of their their their hardware. That's very common. [00:36:02] Leaders in the community that have done really good work and actually become the de facto owner of something. And then usually something else is like, how about we make them the official code of honor? [00:36:12] And then and then we'll have somebody to make sure that the patches get reviewed in a timely manner. And then I was like, yes, that's obvious. And then it happens. Right. And usually this is a very organic thing, which is great. And so I'm nominally the top of that stack still. [00:36:25] But I don't spend a lot of time reviewing patches. [00:36:28] What I do is I help negotiate a lot of the the technical disagreements that end up happening and making sure that the community as a whole makes progress and is moving in the right direction and and doing that. So we also started a non-profit six years ago, seven years ago. [00:36:46] It's times gone away. And the nonprofit, the LVM Foundation nonprofit, helps oversee all the business sides of things and make sure that the events that the community has are funded and set up and run crackly and stuff like that. But the foundation is very much stays out of the technical side of where where the project is going. Right. [00:37:06] That sounds like a lot of it is just organic and just. [00:37:10] Yeah, well, and this is LVM is almost 20 years old, which is hard to believe. Somebody pointed out to me recently that LVM is now older than Jinksy was when LVM started. [00:37:21] All right, so time has a way of getting away from you, but the good thing about that is it has a really robust, really amazing community of people that are in their professional lives right across lots of different companies. But it's a it's a community of people that are interested in similar kinds of problems and have been working together effectively for years and have a lot of trust and respect for each other. And even if they don't always agree that, you know, we're able to find a path forward. [00:37:48] So then in a slightly different flavor of effort, you started Apple in 2005 with the task of making, I guess, LVM production ready and then eventually 2013 through 2017, leading the entire developer tools department. We're talking about LVM, Xcode, Objective C to Swift. [00:38:11] So in a quick overview of your time there, what were the challenges, first of all, leading such a huge group of developers, what was the big motivator dream mission behind creating Swift, the early birth of its from projects and so on, and Xcode? [00:38:31] So these are different questions. [00:38:33] I know, but I want to talk about the other stuff. I'll stay I'll stay on the technical side, then we can talk about the big team pieces. OK, sure. So it's to really oversimplify many years of hard work. [00:38:46] Alvin started, joined Apple, became a thing, became successful and became deployed. But then there's a question about how how do we actually past the source code? So LVM is the back part, the optimizer and the code generator. And LVM is really good for Apple. As it went through a couple of hundred transitions. I joined right at the time of the Intel transition, for example, and 64 bit transitions and then the transition to arm with the iPhone. [00:39:10] And so LVM was very useful for some of these kinds of things. But at the same time, there's a lot of questions around developer experience. [00:39:17] And so if you're a programmer pounding out at the time, Objective C-code, the error message, you get, the compile time, the turnaround cycle, the the tooling and the idea were not great or not as good as they could be. [00:39:30] And so, you know, as I occasionally do, I'm like, well, OK, how hard is it to write a C compiler? [00:39:37] Right. And so I'm not going to commit to anybody. And I could tell anybody. I'm just going to just do it on nights and weekends and start working on it. [00:39:44] And then, you know, I built up and see, there's this thing called the preprocessor, which people don't like, but it's actually really hard and complicated and includes a bunch of really weird things like try graphs and other stuff like that that are that are really nasty. [00:39:58] And it's the crux of a bunch of the performance issues in the compiler sort of working on the parser and kind of got to the point where I'm like, oh, you know what we can actually do? [00:40:06] This is everything that this is impossible to do, but it's actually just hard. It's not impossible. And I eventually told my manager about it and he's like, oh, wow, this is great. [00:40:16] We do need to solve this problem. Oh, this is great. We can get you one other person to work with you on this, you know, and so the team is formed and it starts taking off. [00:40:25] And C++, for example, huge, complicated language. People always assume that it's impossible to implement and it's very nearly impossible, but it's just really, really hard. [00:40:35] And the way to get there is to build it one piece at a time, incrementally. [00:40:39] And and there that was only possible because we were lucky to hire some really exceptional engineers that that new various parts of it very well and and could do great things. [00:40:49] Swift was kind of a similar thing. [00:40:51] So Swift came from we were just finishing off the first version of C++ support in Klang. [00:40:59] And C++ is a very formidable and very important language, but it's also ugly and of ways. And you can't implement C++ without thinking there has to be a better thing. Right. [00:41:11] And so I started working on Swift again with no hope or ambition that would go anywhere just to see what could be done. Let's play around with this thing. It was, you know, me in my spare time not telling anybody about it kind of a thing. And it made some good progress. I'm like, actually, it would make sense to do this. At the same time, I started talking with the senior VP of software at the time, a guy named Transfer there. [00:41:34] And Bertran was very encouraging. He was like, well, you know, let's let's have fun. Let's talk about this. And he was a little bit of a language guy. [00:41:40] And so he helped guide some of the early work and encouraged me and like, got things off the ground and eventually told my manager and told other people and and it started making progress. [00:41:56] The the complicating thing was swift, was that the idea of doing a new language is not obvious to anybody, including myself. [00:42:04] And the tone at the time was that the iPhone was successful because of Objective C. Right. Oh, interesting. In spite of or just because of and you have to understand that at the time Apple was hiring software people that loved Objective C, right. [00:42:22] And it wasn't that they came despite Objective C, they loved objectively, and that's why they got hired. [00:42:27] And so you had a software team that the leadership and in many cases went all the way back to next where Objective C really became real. [00:42:36] And so they, quote unquote grew up writing Objective C and many of the individual engineers all were hired because they love to see. [00:42:45] And so this notion of, OK, let's do new language was kind of heretical in many ways. Right. [00:42:51] Meanwhile, my sense was that the Alawite community wasn't really in love with objectivity. Some people were and some of the most outspoken people were. [00:42:57] But other people were hitting challenges because it has very sharp corners and it's difficult to learn. [00:43:03] And so one of the challenges of making swift happen that was totally non-technical is the the social part of what do we do? [00:43:14] Like if we do a new language, which at Apple, many things happen that don't ship. Right. So if we if we ship it, what what what is the metrics of success? [00:43:22] Why would we do this? Why wouldn't we make objectively better if objectively as problems, let's file off those rough corners and edges. And one of the major things that became the reason to do this was this notion of safety, memory, safety. [00:43:36] And the way Objective C works is that a lot of the object system and everything else is built on top of pointers and see objectively as an extension on top of C. [00:43:47] And so pointers are unsafe and if you get rid of the pointers, it's not objective C anymore. [00:43:53] All right. And so fundamentally, that was an issue that you could not fix safety or memory safety without fundamentally changing the language. [00:44:02] And so once we got through that part of the the mental process and the thought process, it became a design process of saying, OK, well, if we're going to do something new, what what is good? [00:44:13] Like, how do we think about this and what are we like and what are we looking for? [00:44:16] And and that that was a very different phase of it. [00:44:19] So. Well, what are some design choices early on and swift like we're talking about Brace's. [00:44:26] Are you making a type language? You know, all those kinds of things. Yeah. [00:44:30] So so some of those were obvious given the context. [00:44:33] So I type language, for example, objectiveness, a type language and going with another type of language wasn't really seriously considered. [00:44:41] We wanted we wanted the performance and we wanted refactoring tools and other things like that to go with type languages. [00:44:46] Quick dumb question. [00:44:48] Yeah. Was it obvious? I think this would be a dumb question, but was it obvious that the language has to be a compiler language? Not a yes. [00:44:57] That's not a dumb question. Earlier, I think late 90s, Apple is seriously considering moving its development experience to Java. But that's what started in 2010, which was several years after the iPhone, was when the iPhone was definitely on an upward trajectory and the iPhone was still extremely and is still a bit memory constrained. [00:45:18] And so being able to compile the code and then ship it and then have having standalone code that is not yet compiled is a very big deal and it's very much part of the apple value system. Now, JavaScript is also a thing. [00:45:34] I mean, it's not it's not that this is exclusive and technologies are good depending on how they're applied. Right. [00:45:41] But in the design of SWIFT saying, like, how can we make objectively better objectively of statically comp. And that was the contiguous natural thing to do. [00:45:49] Just skip ahead a little bit now, right back. Just just as a question, as you think about today in 2019 in your work at Google and so on, is again, compilations, static compilation. The right the still the right thing. Yeah. [00:46:06] So the funny thing, after working on compilers for a really long time, is that and this is one of the things that LVM has helped with is that I don't look as a compilation as being static or dynamic or interpreted or not. This is a spectrum. [00:46:24] And one of the cool things about Swift is that Swift is not just statically compiled, it's actually dynamically compiled as well. And it can also be interpreted that nobody's actually done that. And so what what ends up happening when you use Swift in the workbook, for example, and Coolabah and Jupiter is it's actually dynamically compiling the statements as you execute them. And so this gets back to the the software engineering problems, right. Where if you layer the stack properly, you can actually completely change how and when things get compiled because you have the right abstractions there. [00:46:58] And so the way that a CoLab workbook works was swift is that we start tapping into it. [00:47:04] It creates a process, a Unix process, and then each line of code you type in, it compiles it through the Swift compiler, the front end part and then sends it through the optimizer compiles machine code and then injects it into that process. And so as you're typing new stuff, it's putting it's like squirting a new code and overwriting and replacing and updating code in place, and the fact that it can do this is not an accident like it was designed for this. [00:47:32] But it's an important part of how the language was set up and how it's layered. And and this is a non obvious piece. And one of the things was swift. That was, for me, a very strong design point is to make it so that you can learn it very quickly. And so from a language design perspective, the thing that I always come back to is the UI principle of progressive disclosure of complexity. And so in Swift, you can start by saying print quote, hello, world quote. [00:48:00] Right. [00:48:01] And there's no solution. Just like Python. [00:48:03] One line of code, no man, no files, no header files, no. Public static, class void blah blah blah. String like Java has. Right. One line of code. Right. And you can teach that and great. [00:48:15] They can say, well, let's introduce variables and so you can declare variable far Savar X equals four. What is a variable. You can use X, X plus one. This is what it means. Then you can say, well how about contraflow. Well this is one if statement is this is what a fourth statement is. [00:48:29] This is what a wild statement is, then you can say let's introduce functions and and many languages like Python have had this this kind of notion of let's introduce small things and they can add complexity, they can introduce classes and they can add generics in the case as well. And then you can add modules and build out in terms of the things that you're expressing. But this is not very typical for compiled languages. And so this was a very strong design point. [00:48:55] And one of the reasons that Swift in general is designed with this factoring of complexity in mind so that the language can express powerful things. [00:49:03] You can write from Rantes if you want to, but it has a very high level feel, which is really this perfect blend, because often you have very advanced library writers that want to be able to use the the nitty gritty details. But then other people just want to use the libraries and work at a higher abstraction level. It's kind of cool there so that you can just interoperability. [00:49:26] I don't think I pronounce that word enough, but you can just drag in Python. It's just you can import like so this is the most important number, how do you make that happen? Yeah, let's say is that as easy as it looks or is it. Yes. [00:49:43] Look, that's not that's not a stage magic act or anything like that. [00:49:46] I don't mean from the user perspective, I mean from the implementation perspective to make it happen. [00:49:51] So it's easy once all the pieces are in place, the way it works. So if you think about it, dynamically typed language like Python, you can think about it in two different ways. You can say it has no type's right, which is what most people would say. Or you can say it has one type. Right. And you can say it has one type. And it's like the python object and the python object is passed around. And because there's only one type, it's implicit. [00:50:14] OK. And so what happens was Swift and Python talking to each other. [00:50:18] Swift has lots of types, has arrays and it has strings and all classes and that kind of stuff. [00:50:24] But it now has a python object type. So there is one python object type. And so when you say import Nampo, what you get is a python object, which is the module. [00:50:37] Then you say expeditor says, OK, hey, hey, python object. I have no idea what you are. [00:50:42] Give me your remember. OK, cool, and just it just uses dynamic stuff, talks to the Python interpreter and says, hey, Python, what's the daughter, remember, in that python object gives you back another python object. [00:50:54] And I say parentheses for the call and the arguments are going to pass. And so then it says, hey, a python object that is the result of expeditor call with these arguments again, calling into the python interpreter to do that work. [00:51:07] And so right now, this is all really simple. And if you if you dive into the code, what you'll see is that the the python module and swift is something like twelve hundred lines of code or something is written in pure swift. [00:51:19] It's super simple and it's and it's built on top of the C interoperability because it just talks to the Python interpreter. [00:51:26] But making that possible requires us to add two major language features to Swift to be able to express these dynamic calls and the dynamic member lookups. And so what we've done over the last year is we've proposed implement standardized and contributed new language features to the swift language in order to make it so it is really trivial. Right. And this is one of the things about Swift that is critical to the 10th floor work, which is that we can actually add new language features and the bar for adding those is higher. [00:51:56] But it's it's what makes it possible. [00:51:59] So, you know, Google doing incredible work on several things, including of so terms of Flow 2.0 or whatever, leading up to 2.0 has by default in 2.0, has Eger execution in. [00:52:14] Yet in order to make code optimized for GPU, ATP or some of these systems, computation needs to be converted to a graph. So what's that process like? What are the challenges there? [00:52:26] Yeah, so I'm tangentially involved in this, but the, the way that it works with autograph is that. [00:52:34] You mark your of your function with the decorator, and when Python calls it, that decorator is invoked and then it says, before I call this function, you can transform it. And so the way autograph works is, as far as I understand, is it actually uses the python parser to go past that, turn into a syntax tree and apply compiler techniques to again transform this down into sensible graphs. And so it you can think of it as saying, hey, I have an if statement I'm going to create and if node in the graph like you say, can't you have a multiply or I'll turn that into a multiplying node in the graph and that becomes this tree transformation. [00:53:14] So where does the swift photons come in, which is you know, Perla's for one Swifties interface, like Python is an interface. It has a flow, but it seems like there's a lot more going on and just a different language interface. There's optimization methodology. [00:53:32] So so the center of the world has a couple of different what I'd call front end technologies and so Swift and Python and Go and Rostand Julia and all these things share the tenth of the graphs and all the runtime and everything that's later on. [00:53:49] And so photons flow is merely another front end for tensor flow, just like any of these other systems. Or there's a major difference between, I would say, three camps of technology. There's Python, which is a special case because the vast majority of the community effort is going to the Python interface and Python has its own approaches for automatic differentiation, has its own APIs and all this kind of stuff there. Swift, which I'll talk about in a second, and then there's kind of everything else. [00:54:19] And so the everything else in our effectively language bindings. So they call into the tense flow runtime, but they're not they usually don't have automatic differentiation or they usually don't provide anything other than APIs that call the KPIs intense workflow. [00:54:33] And so they're kind of wrappers for that Swifties really kind of special. And it's a very different approach. [00:54:39] Swift returns for that is this is a very different approach because they're saying, let's look at all the problems that need to be solved in the full stack of the Tenterfield compilation process. [00:54:51] If you think about it that way, because Tenzer Flow is fundamentally a compiler, it takes models and then it makes them go fast on hardware. [00:54:59] Mm hmm. That's what a compiler does. And it has a front end, has an optimizer, and it has many backhands. And so if you think about it the right way or in and if you look at it in a particular way, like it is a compiler. [00:55:14] And and so swift is merely another front end. [00:55:19] But it's saying in the design principle saying, let's look at all the problems that we face as machine learning practitioners and what is the best possible way we can do that, given the fact that we can change literally anything in this entire stack in Python, for example, where the vast majority of the engineering and an effort has gone into is constrained by being the best possible thing you can do with the Python library, like there are no Python language features that are added because of machine learning that I'm aware of. [00:55:49] They added a matrix multiplication operator with that, but that's as close as you get. [00:55:55] And so with Swift, you can you it's hard, but you can add language features to the language and there's a community process for that. And so we look at these things and say, well, what is the right division of labor between the human programmer and the compiler? And Swift has a number of things that shift that balance. So because it's a because it has a type system, for example, it makes certain things possible for analysis of the code and the compiler can automatically build graphs for you without you thinking about them. [00:56:25] Like that's that's a big deal for a programmer. You just get free performance, you get clustering, infusion and optimization, things like that, without you as a programmer having to manually do it because the compiler can do it for you. UniMac differentiation. There's another big deal. And I think one of the key contributions of the Swift Flow Project. [00:56:45] Is that there's this entire body of work on automatic differentiation that dates back to the fourth trend is people doing a tremendous amount of numerical computing in Fortran used to rate these what they call source to source translators, where you where you take a bunch of code and shove it into a mini compiler and push out more Fortran code. But it would generate the bakradze passes for your functions, for you, the derivatives. Right. [00:57:10] And so in that work in the 70s, a tremendous number of optimizations, a tremendous number of techniques for fixing numerical instability and other other kinds of problems were developed. [00:57:22] But they're very difficult to port into a world where in your execution you get an update at a time like you need to be able to look at entire function and be able to reason about what's going on. And so when you have a language integrated automatic differentiation, which is one of the things that the Swift Project is focusing on, you can open up and all these techniques and reuse them in familiar ways. [00:57:45] But the language integration piece has a bunch of design room and it's also complicated. [00:57:50] The other piece of the puzzle here that's kind of interesting is to use a Google. Yes. So, you know, we're in a new world with deep learning. It's constantly changing. And I imagine without disclosing anything, I imagine, you know, you're still innovating. And the CPU front, too. Indeed. [00:58:06] So how much sort of interplay between software and hardware and trying to figure out how to together move towards an optimal solution? There's an incredible amount. So we're on our third generation of TVs, which are now 100 per teraflops and a very large liquid called box virtual box with no color. And as you might imagine, we're not out of ideas yet. The great thing about TPS is that they're a perfect example of hardware, software, code design. And so it's about it's about saying what hardware do we build to solve certain classes of machine learning problems? [00:58:41] Well, the algorithms are changing, like the hardware takes, you know, some cases years to produce. Right. And so you have to make bets and decide what is going to happen. And so and what is the best way to spend the transistors to get the maximum, you know, performance per watt or area cost or whatever it is that you're optimizing for. And so one of the amazing things about TV is, is this numeric format called Beefalo 16 before 16 is a compressed 16 bit floating point format. [00:59:11] But it puts the bits in different places in numeric terms. It has a smaller amount and a larger exponent. That means that it's less precise, but it can represent larger ranges values, which in the machine learning context is really important and useful because sometimes you have very small gradients you want to accumulate and very, very small numbers that are important to to move things as you're learning. But sometimes you have very large magnitude numbers as well. And before 16 is not as precise the a small but it turns out the machine learning algorithms actually want to generalize. [00:59:48] And so there's, you know, theories that this actually increases the ability for the network to generalize across datasets. And regardless of whether it's good or bad, it's much cheaper at the hardware level to implement because the area and time of a multiplier is and squared in the number of bits in the mantis. But it's linear with size of the exponent connected to solid efforts here, both on the hardware and software side. [01:00:14] Yeah, and so that was a breakthrough coming from the research side and people working on optimizing network transport of weights across the network originally and try and find ways to compress that. But then it got burned into silicon. And it's a key part of what makes Tipu performance so amazing and and and great now to so many different aspects of it that are important. [01:00:37] But the the code design between the low level compiler bits and the software bits and the algorithms is all super important. And it's this amazing trifecta that only Google can do. [01:00:50] Yeah, that's super exciting. [01:00:51] So can you tell me about LIRR project previously? This the secretive one? [01:00:58] Yeah, so am I. Is a project that we announced at a compiler conference. Three weeks ago or something, the Compilers for Machine Learning Conference, basically, again, if you look at tensor flow as a compiler stack has a number of compiler algorithms within it. [01:01:13] It also has a number of compilers that get embedded into it, and they're made by different vendors. For example, Google has Xolair, which is a great compiler system and video has 10 30. Intel has an Grauwe. There's a number of these different compiler systems and they're very specific and they're trying to solve different parts of the problems. But they're all kind of similar in a sense of they want to integrate with Tenzer. So that has an optimizer and it has these different cogeneration technologies built in the idea. [01:01:43] Volaris to build a common infrastructure to support all these different subsystems. And initially it's to be able to make it so that they all plug in together and they can share a lot more code and can be reusable. But over time, we hope that the industry will start collaborating and sharing code. And instead of reinventing the same things over and over again, that we can actually foster some of that, that, you know, working together to solve common problem energy that has been useful in the compiler field before. [01:02:11] Beyond that, I mean, there is some people have joked that it's kind of LVM to learn a lot about what LVM has been good and what LVM has done wrong. And it's a chance to fix that. [01:02:23] And also, there are challenges in the LVM ecosystem as well, where LVM is very good at the thing it was designed to do. But, you know, 20 years later, the world has changed and people try to solve higher level problems. And we need we need some new technology. [01:02:37] And what's the future of opensource in this context? Very soon. [01:02:42] So it is not yet open source, but it will be hopefully you will believe in the value of open source and because. Oh, yeah, absolutely. [01:02:49] And I think that the sense of the community at large fully believes in open source. [01:02:54] I mean, that there is a difference between Apple, where you were previously, and Google now in spirit and culture. And I would say the open source in terms of flow was a seminal moment in the history of software, because here's this large company releasing a very large code base, open sourcing. What are your thoughts on that? How happy or not were you to see that kind of degree of open sourcing between the two? [01:03:20] I prefer the Google approach, if that's what you're saying. The Apple approach makes sense given the historical context that Apple came from, but that's been 35 years ago and I think the apple is definitely adapting. And the way I look at it is that there's different kinds of concerns in the space. Right. [01:03:40] It is very rational for a business to to care about making money like that fundamentally is what the business is about. Right. But I think it's also incredibly realistic to say it's not your string library. That's the thing that's going to make you money. It's going to be the amazing UI product, differentiating features and other things like that that you built on top of your string library. And so keeping your string library proprietary and secret and things like that, maybe not the the important thing anymore. [01:04:11] Right. Well, before platforms where we're different. [01:04:14] Right. And even 15 years ago, things were a little bit different. But the world is changing. So Google strikes a very good balance, I think. And I think the potential for being open source really changed the entire machine learning field and it caused a revolution in its own right. [01:04:31] And so I think it's amazing for amazingly forward looking, because I could have imagined and I was at Google at the time, but I could imagine a different context in a different world where a company says machine learning is critical to what we're doing. We're not going to give it to other people. Right. And so that decision is a profound, profoundly brilliant insight that I think has really led to the world being better and better for Google as well and has all kinds of ripple effects. [01:04:59] I think it is really I mean, you can't understate Google deciding that how profound that is for software. It's awesome. Well, it has been. [01:05:08] And again, I can understand the the concern about if we release our machine learning software are our competitors could go faster. [01:05:17] But on the other hand, I think that open sourcing has been fantastic for Google. And I'm sure that obviously that that that decision was very non obvious at the time. But I think it's worked out very well. [01:05:28] So let's try this real quick. You were at Teszler for five months as the VP of Autopilot Software, you led the team during the transition from each hardware one hardware to have a couple questions or one. First of all, to me, that's one of the bravest engineering decisions undertaking sort of like undertaken undertaking really ever in the automotive industry. To me, software wise, starting from scratch. It's a really brave decision. So my one question is there is what was that like? [01:05:59] What was the challenge of that? [01:06:01] Do you mean the career decision of jumping from a comfortable, good job into the unknown or that combined with the at the individual level, you making that decision and then when you show up, you know, it's a really hard engineering process. [01:06:15] So you could just stay maybe slow down the hardware one or those kinds of decisions are just taking a full on. Let's do this from scratch. What was that like? [01:06:28] Well, so, I mean, I think Tesla has a culture of taking things slow and seeing how it goes. So, I mean, one of the things that attracted me about Tesla is it's very much a gung ho. Let's change the world, let's figure it out kind of a place. And so I have a huge amount of respect for that. Tesla has done very smart things with hardware, one in particular, and the hardware one design was originally designed to be very simple automation features in the car for like traffic workers, cruise control and things like that. [01:06:57] And the fact that they were able to effectively feature creep into landholding and a very useful driver assistance feature is pretty astounding, particularly given the details of the hardware hardware to build on that a lot of ways. [01:07:11] And the challenge there was that they were transitioning from a third party provided vision stack to an in-house built vision stack. And so for the first step, which I mostly helped with, was getting onto that new vision stack. And that was very challenging. And there it was, Time-critical for various reasons, and it was a big leap. But it was fortunate that it built on a lot of the knowledge and expertise and the team that had built hardware ones, driver's license features. [01:07:40] So you spoke in a collected and kind way about your time in Tesla, but it was ultimately not a good fit. Elon Musk, we've talked on this podcast several guess the course. Elon Musk continues to do some of the most bold and innovative engineering work in the world at times at the cost some of the members of the Tesla team. What did you learn about this working in this chaotic world that John? [01:08:03] Yeah, so I guess I would say that when I was at Tesla, I experienced and saw the highest degree of turnover I'd ever seen in a company, which was a bit of a shock. [01:08:15] But one of the things I learned when I came to respect is that he was able to attract amazing talent because he has a very clear vision of the future and he can get people to buy into it because they want that future to happen. [01:08:26] Right. And the power of vision is something that I have a tremendous amount of respect for. And I think that Elon is fairly singular in the world in terms of the things he's able to get people to believe in. And it's it's a very it's very there may be people that down the street corner and say, oh, we're going to go to Mars. [01:08:46] Right. [01:08:46] But then but then there are a few people that can get other others to buy into it and believe in build the path and make it happen. And so I respect that. [01:08:56] I don't respect all of his methods, but but I have a huge amount of respect for that. [01:09:02] You've mentioned a few places, including in this context, working hard. What does it mean to work hard? And when you look back at your life, what were some of the most brutal periods of having to really sort of put everything you have into something? [01:09:20] Yeah, good question. So working hard can be defined a lot of different ways, so a lot of hours. And so that's that is true. The thing to me that's the hardest is both being short term, focused on delivering and executing and making a thing happen while also thinking about the longer term. [01:09:40] And trying to balance that right, because if you are myopically focused on solving a task and getting that done and only think about that incremental next step, you will miss the next big hurdle you should jump over to. [01:09:52] Right. And so I've been really fortunate that. [01:09:56] I've been able to kind of oscillate between the two and historically at Apple, for example, that was made possible because I was able to work some really amazing people and build up teams and leadership structures and and allow them to grow in their careers and take on responsibility, thereby freeing up me to be a little bit crazy and thinking about the next thing. [01:10:20] And so it's a lot of that, but it's also about, you know, with experience, you make connections that other people don't necessarily make. And so I think that is that's a big part as well. But. The bedrock is just a lot of hours and. You know, that's OK with me. There's different theories on work life balance and my theory for myself, which I do not project under the team, but my theory for myself is that, you know, I want to love what I'm doing and work really hard and my purpose. [01:10:49] I feel like my goal is to change the world and make it a better place. And that's that's what I'm really motivated to do. [01:10:57] So last question, LVM logo is a dragon, yeah, you explain that this is because dragons have connotations of power, speed intelligence can also be sleek, elegant and modular. So you move the modular part. What is your favorite Dragon related character from fiction video or movies? So those are all very kind of ways of explaining that, you know, the real reason is the dragon. Yeah. So there is a seminal book on compiler design called The Dragon Book. [01:11:29] And so this is a really old now book on compilers. [01:11:33] And so the Dragon logo for LVM came about because at Apple we kept talking about LVM related technologies and there was no logo to put on a slide and sort of like, what do we do? [01:11:45] And somebody is like, well, what kind of logo should a compiler technology have? And I'm like, I don't know. I mean, the dragons are the dragon is the best thing that that we've got. [01:11:54] And, you know, Apple somehow magically came up with the logo and and it was a great thing and the whole community rallied around it. And then it got better as other graphic designers got involved. But that's that's originally where it came from. [01:12:06] The story is there dragons from fiction that you connect with for that Game of Thrones, Lord of the Rings, that kind of thing? [01:12:15] A lot of the rings is great. I also like roleplaying games and things like computer playing games. And some dragons often show up in there, but but really comes back to to to the book. [01:12:24] Oh, no, we need we need a thing. Yeah. And hilariously, one of the one of the the funny things about LVM is that my wife, who's amazing, runs the the LVM Foundation and she goes to Grace Hopper and is trying to get more women involved in the she's also a compiler engineer. [01:12:41] So she's trying to get other other women to get interested in compilers and things like this. And so she hands out the stickers and people like the Altium sticker because of Game of Thrones. And so sometimes culture has this helpful effect to get the next generation of engineers engaged with the cars. OK, awesome. Chris, thanks so much for your time. [01:13:01] It's been great talking with you.

本集资源与出处