Skip to content

子系统地图

本页所有地址均适用于来自 libtpu-0.0.40-cp314 wheel 的 libtpu.so(build-id 89edbbe81c5b328a958fe628a9f2207d,这是无歧义锚点;运行时报告的 0.103 无法在二进制中静态验证)。其他版本会有所不同。这是整个 wiki 的根级地图;每个 Part 都会链接回这里。

摘要

libtpu.so 是一个 745 MiB 的单一共享对象,包含框架线以下的整个 Google TPU 软件栈:PJRT 插件、XLA→TPU 编译器、每一代的指令编码器、代价模型和调度器、设备端运行时、ICI/Megascale 集合通信结构,以及 profiler,全都静态链接到一个 ELF 中。没有单独的编译器二进制,也没有进程内单独的运行时守护进程;框架加载这个 .so,调用一个导出符号,并接收一张函数指针表,再由它分派到所有实现。本页是架构索引:列出主要子系统,给出每个子系统的入口点和地址带,并路由到深入记录它的 wiki Part。

最适合把它理解为 一个 ABI 表面覆盖九个协作子系统。ABI 表面是 PJRT C 插件(GetPjrtApi,一个 140 槽 struct 加扩展链),叠在第二层内部 C-ABI shim(按类划分的 TfTpu 名册)之上,后者将面向框架的插件与实现解耦。在这两个表面后面,是编译器(从 HLO 降到逐代指令 bundle)、将编译器最后一层 IR 变成字节的 ISA 编码器、编译器查询的代价模型和调度器、加载并执行所得 executable 的运行时、运行时为多芯片程序驱动的集合通信/网络结构、观察所有这些的 profiler,以及每一层都从中分配的内存子系统。熟悉的参照系是 XLA:这是 XLA:TPU 后端和 PJRT:TPU 插件,编译成单个对象,并且仅从二进制反向工程得到。

因为所有东西都在一个二进制里,除子系统名称外最有用的导航辅助就是 地址带.text 段范围为 0xe63c0000x21217484(约 300 MiB 代码),布局并非随机:PJRT/生命周期入口点聚集在低地址(0xe6a…0xf8…),编译器和 MLIR lowering 占据宽阔的中部,ISA 编码器和 codec factory 位于更高处(0x1e8…),集合通信/profiler trace 机器还要更高(trace factory 在 0xf3…0xf5…,route/fabric 代码分布在上部地址带)。可变 singleton,最显著的是 PJRT API 表,位于 .lbss0x227ba840+)。下面的一览表把每个子系统固定到一个地址带;后续逐子系统小节会展开说明。

本页的导航约定是:

  • 九个子系统及其边界 — 每个子系统拥有什么,以及一个在哪里结束、下一个从哪里开始。
  • 每个子系统的标题入口点 — 一个已确认、可在二进制中跳转到的地址。
  • 每个子系统占据的地址带 — 因此在任意地址找到的函数可以归属到某个子系统。
  • 所属 wiki Part — 每个子系统都链接到它的 overview.md 和该 Part 的详情页。
二进制libtpu.so, 745 MiB (781,691,048 B), unstripped, single ELF
插件入口GetPjrtApi @ 0xe6a83a0 (thunk)
PJRT 构建器pjrt::tpu_plugin::GetTpuPjrtApi @ 0xe6aa440 (lazy, returns the singleton)
PJRT struct 工厂pjrt::CreatePjrtApi @ 0xf874160 (140 slots, struct_size = 1120)
PJRT singletonGetTpuPjrtApi()::pjrt_api @ 0x227ba840 (start of .lbss)
Shim bootstrapTfTpu_Initialize @ 0xe6f54a0
ISA codec 工厂tpu::TpuCodec::Create(TpuVersion) @ 0x1e835fa0
Profiler codec 工厂xprof::tpu::GetTraceCodec @ 0xf5a2900
.text 地址带0xe63c0000x21217484 (all entry points above live here)
静态初始化.init_array 0x215f26f00x215f8190 (~2,900 constructors); orchestrated from init_proc @ 0xe635524

子系统一览

九个功能子系统,每个都固定到其标题入口点、粗略 .text 地址带,以及所属 wiki Part。置信度反映入口点和边界在二进制中被观察到的直接程度,而不是所属 Part 的成熟度。

子系统职责主入口点 (addr)地址带所属 Part
PJRT 插件表面面向框架的 C ABI:client/device/buffer/executable/event,140 槽 PJRT_Api + 扩展链GetPjrtApi @ 0xe6a83a0GetTpuPjrtApi @ 0xe6aa440CreatePjrtApi @ 0xf8741600xe6a…0xf87… (low .text)pjrt/
TfTpu C-API shim插件和实现之间的内部 C ABI;按类划分的函数指针名册TfTpu_Initialize @ 0xe6f54a00xe6f…0xe8d…shim/
XLA→TPU 编译器HLO → MHLO → Mosaic/tpu dialect → LLO → bundle;pass pipelinecompiler pass registry / RunHloPasses driver (mid-.text)0x10e…0x1c0… (broad middle)compiler/
逐代 ISA + 编码器TensorCore / SparseCore / BarnaCore 指令发射器;LLO → bundle 字节tpu::TpuCodec::Create(TpuVersion) @ 0x1e835fa00x1e8…0x20f…isa/
代价模型 + 调度器逐代延迟表、LatencyHidingScheduler、MSA (memory-space assignment)XlaTpuMemorySpaceAssignment* knobs; LHS / MSA drivers0x14…0x1d… (interleaved)cost/, sched/
运行时Executable 加载/执行、stream、infeed/outfeed、allocator、完成循环PJRT Execute → stream-executor adapter (low-mid .text)0xf8…0x13…runtime/
集合通信 + 网络ICI fabric、Megascale control plane、route-table 生成ICI/Megascale slice-config factories0x130…0x1f8… (upper .text)collectives/, ici/, megascale/, routing/
ProfilingPer-core trace codec → XPlane/XStat → XSpace;TraceMexprof::tpu::GetTraceCodec @ 0xf5a29000xf3…0xf5… (trace factories)profiling/
内存HBM / VMEM / SMEM / CMEM / SFLAG 池和 allocator;嵌入式 tcmallocHBM allocator + tcmalloc (MallocExtension_Internal_* @ 0xe639600)0xe63… (tcmalloc) + per-pool sitesmemory/

NOTE — 地址带会重叠,因为二进制在链接时并未按子系统分区。地址带是某个子系统代码的 重心,用于把任意地址归属给可能的 owner;它不是硬边界。拿不准时,解析符号并阅读其所属 Part。forensics Part 记录了这些地址带的推导方式。

数据流

从 XLA HLO module 到执行 TPU bundle 的端到端路径,集合通信结构和 profiler 包围着核心的先编译后执行主干。按从上到下阅读编译路径,然后看底部的运行时循环;collectives 和 profiling 是两侧轨道。

text
                       framework (JAX / TF / PyTorch-XLA)
                                     |
                                     v
        +===========================================================+
        |  PJRT PLUGIN SURFACE          pjrt/overview.md            |
        |  GetPjrtApi@0xe6a83a0 -> GetTpuPjrtApi@0xe6aa440          |
        |          -> CreatePjrtApi@0xf874160 (140 slots)          |
        |  [ singleton pjrt_api @ .lbss 0x227ba840 ]               |
        +===========================================================+
                                     |  Compile(args)        Execute(args)
                                     v                            |
        +===========================================================+   |
        |  TfTpu C-API SHIM             shim/overview.md            |   |
        |  TfTpu_Initialize@0xe6f54a0  -> per-class roster fanout   |   |
        +===========================================================+   |
                                     |                              |
   HLO module --------------------->  v                             |
        +===========================================================+   |
        |  XLA->TPU COMPILER           compiler/overview.md         |   |
        |   HLO  -> [pre-passes, simplifier, sharding, fusion]      |   |
        |        -> MHLO -> Mosaic / `tpu` dialect (xtile)          |   |
        |        -> LLO (low-level op enum)                         |   |
        |        |          ^                  ^                    |   |
        |        |   consults |          consults |                |   |
        |        |   cost/overview.md     sched/overview.md         |   |
        |        |   (latency tables)     (LHS, MSA, bundle pack)   |   |
        |        v                                                  |   |
        +===========================================================+   |
                  | LLO instructions                                    |
                  v                                                      |
        +===========================================================+   |
        |  PER-GEN ISA + ENCODERS      isa/overview.md              |   |
        |  TpuCodec::Create(TpuVersion)@0x1e835fa0                  |   |
        |  TensorCore / SparseCore / BarnaCore emitters            |   |
        |        -> packed instruction BUNDLES (.df/.gf/.jf/...)    |   |
        +===========================================================+   |
                  | executable (bundles + metadata)                     |
                  v                                                      v
        +===========================================================================+
        |  RUNTIME                                       runtime/overview.md        |
        |  load executable -> streams -> infeed/outfeed -> execute -> completion    |
        |  allocators draw from  MEMORY  (memory/overview.md):                      |
        |       HBM | VMEM | SMEM | CMEM | SFLAG                                    |
        +===========================================================================+
             ^                                  |                          |
             | drives                           | emits trace events       |
             v                                  v                          v
   +===========================+   +=========================================+
   | COLLECTIVES + NETWORK     |   | PROFILING                               |
   | collectives|ici|megascale |   | GetTraceCodec@0xf5a2900                  |
   | routing/overview.md       |   | per-core codec -> XPlane/XStat -> XSpace |
   | ICI fabric, route tables, |   | profiling/overview.md                   |
   | Megascale control plane   |   +=========================================+
   +===========================+
```text

> **QUIRK —** 编译器并不通过自己保存的函数指针直接调用 ISA 编码器;它 lowering 到 LLO opcode enum,然后由单独的 codec factory(`TpuCodec::Create`)实例化由 `TpuVersion` 选择的逐代发射器。因此 generation 是一种 *后期* 绑定:同一份 lowering 后的 LLO 可以通过向 factory 传入不同的 `TpuVersion` 而编码为不同 TPU generation。把 lowering 和 encoding 融合到一个 pass 的重实现会丢失这条接缝。参见 [`isa/isa-emitter-registry.md`](isa/isa-emitter-registry.md)。

---

## PJRT 插件表面

框架唯一必需的入口点。`GetPjrtApi` @ `0xe6a83a0` 是一个很薄的 thunk,会 tail-call `pjrt::tpu_plugin::GetTpuPjrtApi` @ `0xe6aa440`;后者是 lazy builder,会构造一次 `PJRT_Api` struct,并把它缓存在 static-local singleton `pjrt_api` @ `0x227ba840`(`.lbss` 中的第一个对象)。struct 本身由 `pjrt::CreatePjrtApi` @ `0xf874160` 组装,它填充一个 **140 槽**、`struct_size = 1120` 的记录(5 个标量 header 字段 + 135 个函数指针),然后遍历由 `PJRT_Extension_Base` next-pointer 串起的一条 **扩展链**,其中包含可选 capability block(layouts、raw-buffer、profiler、Megascale、cross-host-transfers 等)。这是标准 PJRT C ABI:client/device/memory 枚举、buffer 生命周期(`BufferFromHostBuffer` → donate → `Execute` → delete)、async event(带 `Await`/`OnReady`/`IsReady` 的 `PJRT_Event`),以及 executable compile/execute。

> **GOTCHA —** 这个构建中 **没有 FFI extension**。用户 custom-call FFI 不受支持;唯一 custom-op 路径是通过 `tpu_executable` extension 的 compilation-environment hook。为 FFI slot 接线的重实现者会发现没有 consumer。

归属于 **Part `pjrt/`**。从 [`pjrt/overview.md`](pjrt/overview.md) 开始;140 槽重建见 [`pjrt/api-vtable-reconstruction.md`](pjrt/api-vtable-reconstruction.md),可选 block 见 [`pjrt/extension-chain.md`](pjrt/extension-chain.md)。bootstrap 路径(ELF entry → `init_proc` → thunk)位于 [`lifecycle/`](lifecycle/overview.md)。

---

## TfTpu C-API Shim

第二个 C ABI 位于 PJRT 表面 *后面*,处在插件和实现之间。`TfTpu_Initialize` @ `0xe6f54a0` 会 bootstrap 它:启动嵌入式运行时,并填充一组 **按类划分的名册**,也就是函数指针的扁平 struct,每个实现类一个(compiler、executor、transfer manager、topology、program、executable、configuration)。PJRT 插件调用这些名册,而不是直接调用实现方法,这让面向框架的 ABI 可以保持稳定,同时其后的实现可以变化。这是经典 TensorFlow `TfTpu_*` “stream-executor C API” 模式,在这里是静态链接,而不是通过 `dlopen` 加载。

这些名册并不作为扁平的 `TfTpu_*` export 列表暴露(只有少数几个作为命名符号存在);它们是在初始化期间填充的类似 vtable 的 struct。每个名册都映射到该 Part 下的一个详情页。

归属于 **Part `shim/`**。从 [`shim/overview.md`](shim/overview.md) 开始;按类划分的名册包括 [`shim/tpu-compiler-roster.md`](shim/tpu-compiler-roster.md)、[`shim/tpu-executor-roster.md`](shim/tpu-executor-roster.md)、[`shim/tpu-transfer-manager.md`](shim/tpu-transfer-manager.md)、[`shim/tpu-program-roster.md`](shim/tpu-program-roster.md)、[`shim/tpu-executable-roster.md`](shim/tpu-executable-roster.md) 和 [`shim/tpu-configuration-api.md`](shim/tpu-configuration-api.md)。初始化序列在 [`lifecycle/tftpu-initialize-bootstrap.md`](lifecycle/tftpu-initialize-bootstrap.md) 中。

---

## XLA→TPU 编译器

按代码体量看,这是最大的子系统,横跨 `.text` 的宽阔中部。它接收 XLA HLO module,并通过一系列 IR 进行 lowering:HLO pre-pass 和 algebraic simplifier 清理图;sharding propagation 和 auto-sharding (SPMD) 将其分布化;fusion 形成 kernel;然后图被提升为 **MHLO**,再 lowering 到 **Mosaic / `tpu` dialect**(“xtile” tiling 表示),最后降到 ISA 编码器消费的 **LLO** low-level op enum。pipeline 是 HLO pass 的 registry(“walrus”/pass-pipeline driver)加上一套 MLIR conversion stack,其中包含 pattern rewriter 和 dialect-conversion legalizer。SparseCore 程序则走一条并行 lowering 分支进入 SparseCore LLVM。

这是 XLA:TPU 后端。参照系是 LLVM/MLIR dialect conversion:重实现者应按 pass manager、conversion pattern 和 legalization target 来思考,而不是把它看成一个单体 translator。

归属于 **Part `compiler/`**。从 [`compiler/overview.md`](compiler/overview.md) 开始。关键页面包括:[`compiler/compile-phases.md`](compiler/compile-phases.md)、[`compiler/hlo-pass-registry.md`](compiler/hlo-pass-registry.md)、[`compiler/mosaic-overview.md`](compiler/mosaic-overview.md)、[`compiler/tpu-dialect-and-ops.md`](compiler/tpu-dialect-and-ops.md)、[`compiler/tpu-to-llo-ods.md`](compiler/tpu-to-llo-ods.md),以及 MSA 页面 [`compiler/msa-overview.md`](compiler/msa-overview.md)。

---

## 逐代 ISA + 编码器

编译器最后一层 IR 在这里变成字节。factory `tpu::TpuCodec::Create(tpu::TpuVersion)` @ `0x1e835fa0` 按 `TpuVersion` 选择逐代 codec,该 codec 驱动最多三类 engine 的指令发射器:**TensorCore**(矩阵 engine,每一代都有)、**SparseCore**(embedding/gather engine,从 Viperfish 开始),以及 **BarnaCore**(更早的 embedding 协处理器,仅 Jellyfish/Dragonfish/Pufferfish;在 Pufferfish→Viperfish 边界退役并由 SparseCore 取代)。每一代都有自己的 bundle 宽度和 slot 布局:`.df`、`.gf`、`.gl`、`.jf`(41-byte)、`.pf`(51-byte)、`.vf`(64-byte,也用于 Ghostlite 和 6acc60406);编码器把 LLO instruction stream 打包到这些固定宽度的 bundle 中。instruction-bit master DB 和 slot 编码器(MXU、VPU、EUP、sequencer、memory load/store、predicate、immediate)都位于这个地址带。

> **QUIRK —** 逐代 codec 是 *编码器* registry,与 *cost-model* 的逐代表并行但不同。codec 决定 bit 如何布局;cost model 决定一个 bundle 需要多少 cycle。二者都以同一个 `TpuVersion` 为键,但它们是不同地址带中的不同数据表。参见 [`isa/bundle-model-overview.md`](isa/bundle-model-overview.md) 和 [`cost/overview.md`](cost/overview.md)。

归属于 **Part `isa/`**(两个非 TensorCore engine 分别位于 **`sparsecore/`** 和 **`barnacore/`**)。从 [`isa/overview.md`](isa/overview.md) 开始;编码器 registry 是 [`isa/isa-emitter-registry.md`](isa/isa-emitter-registry.md),LLO opcode enum 是 [`isa/llo-opcode-enum.md`](isa/llo-opcode-enum.md)。SparseCore:[`sparsecore/overview.md`](sparsecore/overview.md)。BarnaCore:[`barnacore/overview.md`](barnacore/overview.md)。

---

## 代价模型 + 调度器

编译器在 lowering 时会查询两个协作子系统。**代价模型**是一族逐代延迟表(MXU 延迟、EUP 延迟、逐 opcode cycle 常量、memory bandwidth/latency),再加上估算资源使用的 HLO cost analyzer;`GetHloResources` routing 将每个 HLO op 映射为资源向量。**调度器**消费这些代价:`LatencyHidingScheduler` (LHS) 对 instruction 排序以重叠 compute 与 memory/collective latency,**MSA** (memory-space assignment) 将 tensor 放置到 HBM/VMEM,bundle modulo-scheduler 则打包逐代 slot。诸如 `xla_tpu_memory_space_assignment_while_execution_count` 和逐代 `xla_{vf,gf}_max_vmem_used_by_memory_space_assignment` 的 flag 字符串确认了 MSA knob surface;LHS 有 ILP 变体以及 pre-/post-layout pass。

参照系是标准 XLA `LatencyHidingScheduler` 和 `MemorySpaceAssignment`,再加上用于 VLIW bundle packing 的 modulo scheduling。它们按 generation 区分,因为不同 TPU version 的延迟表不同。

归属于 **Part `cost/` 和 `sched/`**。从 [`cost/overview.md`](cost/overview.md) 和 [`sched/overview.md`](sched/overview.md) 开始。关键页面包括:[`cost/mxu-latency-overview.md`](cost/mxu-latency-overview.md)、[`cost/tpu-hlo-cost-analysis.md`](cost/tpu-hlo-cost-analysis.md)、[`sched/latency-hiding-scheduler-core.md`](sched/latency-hiding-scheduler-core.md)、[`sched/bundle-modulo-scheduling.md`](sched/bundle-modulo-scheduling.md)。

---

## 运行时

插件的执行半边。一旦 executable(bundle 加 metadata)存在,运行时就加载它,设置 **stream**,连接 **infeed/outfeed** queue,运行程序,并驱动一个 **完成循环** 来 signal PJRT event。Buffer 生命周期是异步的:`BufferFromHostBuffer` 产生一个带 `ReadyEvent` 的 buffer;`DonateWithControlDependency` 支持原地复用;外部引用通过 `Increase/DecreaseExternalReferenceCount` 跟踪。多 stream 执行会为每个 device 创建一个 async-tracking event。运行时从内存子系统的 allocator 中抽取所有 device memory。

参照系是 XLA 的 stream-executor 加 PJRT execution model。host 侧 adapter(stream-executor → PJRT)和 host interpreter 各自作为页面记录。

归属于 **Part `runtime/`**。从 [`runtime/overview.md`](runtime/overview.md) 开始。关键页面包括:[`runtime/load-program-enqueue.md`](runtime/load-program-enqueue.md)、[`runtime/execute-async-on-stream.md`](runtime/execute-async-on-stream.md)、[`runtime/infeed-outfeed.md`](runtime/infeed-outfeed.md)、[`runtime/completion-loop.md`](runtime/completion-loop.md)、[`runtime/allocator-integration.md`](runtime/allocator-integration.md)。PJRT 的 executable-execution slot 是 [`pjrt/executable-execution.md`](pjrt/executable-execution.md)。

---

## 集合通信 + 网络

多芯片和多主机程序运行在由运行时驱动的集合通信结构上。这里叠了三层。**ICI** (Inter-Chip Interconnect) 是 pod 内 toroidal fabric:link bring-up、DMA descriptor、topology discovery、virtual-channel balancing,以及一种 fault/resiliency model,只在 resiliency mode 下对 3D Superpod slice 容忍 ICI link fault。**Routing** 生成 route table(randomized toroidal wildfirst,带 dedup/decompress 的 route-cache codec),把逻辑 collective pattern 映射到物理 link。**Megascale** 是位于 ICI 之上的跨主机 control plane:DCN (Data Center Network) topology、per-host control handshake、error aggregator,以及 `tpunetd` gRPC client。**collectives** 层实现算法本身(all-reduce hierarchical pincer、all-gather ND ring、reduce-scatter、all-to-all),包括 FP8 量化变体和 SparseCore offload 路径。

归属于 **Part `collectives/`、`ici/`、`megascale/`、`routing/`**(descriptor 格式位于 **`dma/`**)。从 [`collectives/overview.md`](collectives/overview.md)、[`ici/overview.md`](ici/overview.md)、[`megascale/overview.md`](megascale/overview.md)、[`routing/overview.md`](routing/overview.md) 开始。DMA descriptor:[`dma/intra-chip-descriptor.md`](dma/intra-chip-descriptor.md)。

---

## Profiling

包围所有内容的观察子系统。`xprof::tpu::GetTraceCodec(asic_sw::DeviceIdentifiers, int)` @ `0xf5a2900` 是选择 **按芯片家族划分的 trace codec** 的 factory:五种固定宽度 `TraceEntry` schema(`pxc`、`vfc`、`vlc`、`gfc`、`glc`),再加上传统 `jxc` `PerformanceTraceEntry` 路径,每一种都由自己的 templated codec 解码。解码后的 trace entry 被转换成 Google XProf 的 **XPlane / XStat / XSpace** proto schema,并通过 `TpuProfiler_*` C ABI(`Create`/`Start`/`Stop`/`CollectData`)和 `PJRT_Profiler` extension 暴露。`TraceMe` scope 和 per-core trace control(`0xf34…` 地址带中的 `xprof::tpu::AddObjectsForKind` / `Add*TraceControls` factory)播种 trace limit。

> **NOTE —** codec 是 *按 sub-core 类型* 划分的,不是按 chip 划分的。重实现者必须为 topology 中的每个 core class 实例化正确的 `TraceEntry` codec;一个 codec 不能解码另一个 core 的 trace stream。

归属于 **Part `profiling/`**。从 [`profiling/overview.md`](profiling/overview.md) 开始。关键页面包括:[`profiling/tpu-profiler-abi.md`](profiling/tpu-profiler-abi.md)、[`profiling/trace-entries-coder.md`](profiling/trace-entries-coder.md)、[`profiling/xplane-xstat-traceme.md`](profiling/xplane-xstat-traceme.md)、[`profiling/pjrt-profiler-extension.md`](profiling/pjrt-profiler-extension.md)。

---

## 内存

上面的每一层都从一小组物理上不同的 memory space 分配,每个 space 都有自己的 allocator 和协议。**HBM** 是大型 off-chip 池(带 DMA alignment 规则和 MSA 遵守的 reservation policy 的 HBM allocator);**VMEM** 是 vector-engine scratchpad;**SMEM** 是 scalar memory 加 register window;**CMEM** 是独立的 constant/coefficient 池;**SFLAG** 是用于协调 engine 的 synchronization-flag space。host 侧 allocator 是 **嵌入式 tcmalloc**(它自己的 `google_malloc` ELF section 位于 `0xe6373c0`–`0xe63bab2`,`MallocExtension_Internal_GetExperiments` @ `0xe639600` 是稳定锚点),不同于设备端 pool。

> **GOTCHA —** memory-space enum 由编译器(MSA 将 tensor 放入 space)和 ISA(memory-load/store slot 对 space 编码)共享。同一个整数在两个子系统中表示同一个物理 space;把它们当成独立 namespace 会错误编码每一个 load。参见 [`isa/memory-space-enum.md`](isa/memory-space-enum.md)。

归属于 **Part `memory/`**。从 [`memory/overview.md`](memory/overview.md) 开始。关键页面包括:[`memory/hbm-allocator.md`](memory/hbm-allocator.md)、[`memory/vmem-allocator.md`](memory/vmem-allocator.md)、[`memory/smem-scalar-memory.md`](memory/smem-scalar-memory.md)、[`memory/cmem-pool.md`](memory/cmem-pool.md)、[`memory/sflag-protocol.md`](memory/sflag-protocol.md)、[`memory/embedded-tcmalloc.md`](memory/embedded-tcmalloc.md)。

---

## 组件如何绑定

三种绑定机制把九个子系统连接在一起,每一种都是重实现者必须复现的接缝:

| 接缝 | 机制 | 记录位置 |
|---|---|---|
| 框架 ↔ 插件 | 140 槽 `PJRT_Api` struct + 扩展链,构建一次并缓存在 `.lbss` | [`pjrt/api-vtable-reconstruction.md`](pjrt/api-vtable-reconstruction.md) |
| 插件 ↔ 实现 | `TfTpu` 按类划分的名册,由 `TfTpu_Initialize` 填充 | [`shim/overview.md`](shim/overview.md) |
| 编译器 ↔ ISA | LLO opcode enum + 后期 `TpuCodec::Create(TpuVersion)` 绑定 | [`isa/llo-opcode-to-proto.md`](isa/llo-opcode-to-proto.md) |
| 编译器 ↔ cost/sched | HLO resource model + 逐代延迟表 | [`cost/gethloresources-routing.md`](cost/gethloresources-routing.md) |
| 所有层 ↔ 内存 | 共享 memory-space enum + 逐 pool allocator | [`isa/memory-space-enum.md`](isa/memory-space-enum.md) |
| 进程启动 | `.init_array` (~2,900 ctors) → `init_proc` → plugin discovery | [`lifecycle/elf-entry-and-init-proc.md`](lifecycle/elf-entry-and-init-proc.md) |

最重要的结构事实是 **version (`TpuVersion`) 是主键**([Codename Cheat-Sheet](front/codename-cheatsheet.md) 将它绑定到所有其他命名轴)。ISA 编码器、cost-model 延迟表、调度器资源模型,以及若干 memory 默认值,都沿着这个维度分叉。硬编码某一代的重实现会在其他代上静默地误编码、误计价、误调度;逐代 dispatch 是架构本身,不是事后补充。[forensics](forensics/overview.md) Part 直接记录了逐代 dispatch 机器。

## 交叉引用

- [`pjrt/overview.md`](pjrt/overview.md) — 面向框架的 C ABI 表面;140 槽表和扩展链
- [`shim/overview.md`](shim/overview.md) — 插件和实现之间的内部 `TfTpu` 名册 ABI
- [`compiler/overview.md`](compiler/overview.md) — HLO → MHLO → Mosaic/`tpu` → LLO lowering 和 pass pipeline
- [`isa/overview.md`](isa/overview.md) — 逐代 instruction bundle 和编码器 registry;codec factory
- [`sparsecore/overview.md`](sparsecore/overview.md) — SparseCore engine 及其并行 lowering 分支
- [`barnacore/overview.md`](barnacore/overview.md) — scalar control core ISA
- [`cost/overview.md`](cost/overview.md) — 逐代延迟表和 HLO cost analyzer
- [`sched/overview.md`](sched/overview.md) — LatencyHidingScheduler、MSA、bundle modulo scheduling
- [`runtime/overview.md`](runtime/overview.md) — executable 加载/执行、stream、infeed/outfeed、完成循环
- [`collectives/overview.md`](collectives/overview.md) — collective 算法和 SparseCore offload
- [`ici/overview.md`](ici/overview.md) — pod 内 toroidal interconnect fabric
- [`megascale/overview.md`](megascale/overview.md) — 跨主机 control plane 和 `tpunetd` client
- [`routing/overview.md`](routing/overview.md) — route-table 生成和 route-cache codec
- [`dma/host-device-dma.md`](dma/host-device-dma.md) — runtime 和 fabric 使用的 DMA descriptor 格式
- [`profiling/overview.md`](profiling/overview.md) — per-core trace codec → XPlane/XStat → XSpace
- [`memory/overview.md`](memory/overview.md) — HBM/VMEM/SMEM/CMEM/SFLAG 池和 allocator
- [`config/overview.md`](config/overview.md) — XLA flag、DebugOptions 和 TPU compilation environment
- [`lifecycle/overview.md`](lifecycle/overview.md) — ELF entry、静态初始化、plugin discovery、`TfTpu_Initialize` bootstrap
- [`forensics/overview.md`](forensics/overview.md) — ELF anatomy、地址带推导、逐代 dispatch、嵌入式库 atlas
- [术语表](glossary.md) — 子系统描述中使用的每个 acronym 和 codename 的定义