Posts Tagged ‘PaulSandoz’
[DevoxxBE2025] Java for AI
Lecturer
Paul Sandoz is a Distinguished Engineer at Oracle, leading efforts in Java platform features for AI and machine learning. With contributions to projects like Valhalla and Babylon, he focuses on performance enhancements and interoperability. Paul has a history in RESTful web services, co-authoring JAX-RS specifications.
Abstract
This article surveys Java platform capabilities supporting AI, encompassing current tools like Foreign Function & Memory API and Vector API, alongside prospective ones from Valhalla and Babylon. It clarifies mechanisms for native interoperation and vectorized computations, placed amid demands for competitive AI libraries. Via examples of array manipulations and kernel generations, the narrative spotlights tactics for efficiency and portability. The exploration gauges situational elements in AI workloads, ramifications for library construction and app performance, and furnishes views on Java’s trajectory in empowering AI solutions.
Current Platform Tools for AI Efficiency
Java’s existing arsenal includes the Foreign Function & Memory API (FFM) for native code access and the Vector API for SIMD operations. FFM enables safe, efficient calls to C libraries, crucial for AI frameworks like TensorFlow.
Examples: Loading libraries, invoking functions via MethodHandles. Vector API vectorizes loops:
VectorSpecies<Float> SPECIES = FloatVector.SPECIES_PREFERRED;
FloatVector a = FloatVector.fromArray(SPECIES, arrayA, 0);
FloatVector b = FloatVector.fromArray(SPECIES, arrayB, 0);
FloatVector c = a.add(b);
c.intoArray(result, 0);
This accelerates computations on hardware like AVX.
Context: These address Java’s gaps in low-level access, enabling NumPy-like libraries. Implications: Better performance in ML without external dependencies.
Valhalla’s Value Types for Data Optimization
Project Valhalla introduces value types—immutable, identity-free—for efficient data structures. Arrays of values flatten, reducing overheads.
Code: Defining value classes, using in arrays for contiguous memory. Implications: Dense layouts boost cache efficiency, vital for AI tensors.
Babylon’s Code Reflection for Kernel Generation
Project Babylon enables runtime code generation via reflection, targeting GPUs/CPUs. It translates Java methods to IR for compilation.
Examples: Reflecting methods, generating OpenCL kernels for Game of Life. Implications: Portable acceleration without manual native code.
Synergies and AI Library Building
Combined, these enable competitive libraries: FFM for interop, Vector for math, Valhalla for structures, Babylon for kernels.
Analysis: Supports dialects for GPU code, like OpenAI’s Triton. Ramifications: Empowers Java AI ecosystems rivaling Python’s.
Future: Stabilizing features in Java 24+.
In summary, Java’s enhancements position it strongly for AI, providing building blocks for high-performance solutions.
Links:
- Lecture video: https://www.youtube.com/watch?v=CjPPJFcUCl8
- Paul Sandoz on LinkedIn: https://www.linkedin.com/in/paul-sandoz-697a711/
- Paul Sandoz on Twitter/X: https://twitter.com/paulsandoz
- Oracle website: https://www.oracle.com/