Skip to main content

ironaccelerator_tpu/
lib.rs

1//! # `ironaccelerator-tpu`
2//!
3//! Google TPU backend via the **PJRT** (Pretty Just Runtime) C plugin
4//! interface. PJRT is the stable cross-framework TPU entry point — the
5//! same ABI JAX and PyTorch/XLA use. The backend dynamically loads
6//! `pjrt_c_api_tpu_plugin.so` (or `libtpu.so` on older images), calls
7//! `GetPjrtApi`, creates a `PJRT_Client`, and enumerates the attached
8//! TPU chips as devices.
9//!
10//! Enumeration is all we need at the backend-trait level; compilation and
11//! execution sit on top of a `StableHLO` graph that the higher layers
12//! build and hand back through PJRT. That machinery lives in a follow-on
13//! crate and is not part of 1.1.
14//!
15//! Hosts without the PJRT plugin — i.e. every machine that is not a
16//! Cloud TPU VM or a `libtpu`-provisioned GKE pod — get an unavailable
17//! backend and an empty device list.
18
19#![warn(missing_docs)]
20#![allow(clippy::missing_safety_doc)]
21
22pub mod backend;
23pub mod drv;
24
25pub use backend::{TpuBackend, TPU_BACKEND};
26
27/// Registers the TPU backend with `reg`.
28pub fn register(reg: &mut ironaccelerator_core::BackendRegistry) {
29    reg.register(&TPU_BACKEND);
30}