How rocm/jax works
This project is the source code for JAX – a high‐performance, accelerator‐oriented Python library that transforms numerical programs using techniques such as automatic differentiation (grad), just-in-time compilation (jit), automatic vectorization (vmap), and SPMD parallelism (pmap). The purpose is to provide a composable system for numerical computations at scale via transformations and integration with XLA; the file structure and README show that it’s a large-scale, full-featured library with extensive test suites, benchmarks, documentation, and CI/CD workflows.
Main Components
• Core API Layer ("jax" package): Represent the core Python API that users interact with. This layer includes the transformation functions (grad, jit, vmap, pmap) and the “pure functions” paradigm.
• Plugins and Backend Extensions (“jax_plugins”): This includes CUDA and ROCM plugins that extend functionality to specific hardware. Mark these as modular components providing enhanced support for different platforms.
• Experimental and Additional Modules: Include “jax.experimental” components such as experimental transformations, array serialization, pallas (for fusion and mosaic kernels), and other features in development.
• Documentation and Examples: Include components such as “docs” (with Sphinx templates, tutorials, and notebooks in docs/notebooks) and “examples” that highlight how users can deploy and experiment with JAX.
• Benchmarks and Performance: Represent the “benchmarks” folder used for performance assessment; these will illustrate how performance testing of the core libraries is integrated.
Relationships and Interactions
• “experimental” modules to the main core, signaling these are advanced or in-the-lab features that augment the primary API.
Architectural Patterns and Design Principles
• Cross-layer transformations: the transformation pipeline where a function goes from a user-written Python function, is transformed (via grad, jit), and then compiled by XLA through jaxlib; you might illustrate this as a flowchart inside the core API.
• Use a layered architecture model: top layer (user APIs and examples/documentation), middle layer (transformation and compilation logic), and bottom layer (hardware-specific drivers and backends).
• Role of design principles like immutability/pure functions – a key constraint that allows the transformations without unintended side effects.
Relevant Technologies and Frameworks
• JAX itself (Python, NumPy-like API) and integration with XLA.
• Bazel: shown by BUILD files and WORKSPACE for managing builds and dependencies.
• CI systems (GitHub Actions, Docker containers from build/rocm/docker etc.) for automating testing and deployment.
• C++ code integration in jaxlib for performance-critical computation.
Instructing the Principal Software Engineer
• Use clear labels for each component: “User API (jax)”, “Compilation Layer (jaxlib + XLA)”, “Hardware Plugins (jax_plugins)”, “Experimental Features”, “CI/Build & Tests”, “Documentation & Examples.”
– API components (perhaps rounded rectangles),