Abstract
FluidML is a novel optimization framework designed to enhance machine learning inference on resource-constrained edge devices. By integrating holistic graph-operator optimization with a "greedy-by-size" static memory allocator, FluidML achieves significant reductions in both inference latency and peak memory usage. Experimental results demonstrate up to a 25% reduction in latency and over 40% reduction in memory footprint compared to state-of-the-art tools across various language and vision models.
Introduction
Deploying massive AI models, such as Transformers and Foundation Models, on edge devices like AR glasses, robots, or smartphones presents a significant challenge due to limited hardware resources. While techniques like pruning and quantization are commonly used to shrink models, the underlying software execution often remains inefficient.
Current optimization tools typically focus on individual kernels (single operations like matrix multiplication) in isolation. However, modern models feature complex, interwoven graphs where a local optimization for one operation may force the next to rearrange its data, creating a bottleneck. Furthermore, standard operating system memory allocators are often "blind" to a model's future needs, leading to fragmented and bloated memory usage. FluidML addresses these issues by treating the model graph and memory management as a single, holistic optimization problem.
Methodology
FluidML introduces a multi-layered approach to optimization, leveraging the predictable nature of AI model execution graphs.
Holistic Graph and Layout Optimization
Instead of optimizing kernels in isolation, FluidML decomposes the model graph into independent sequences using a modified Dijkstra algorithm to identify the longest paths. For each sequence, the system employs Dynamic Programming (DP) to determine the optimal memory layout (e.g., row-major vs. column-major) for every edge. This ensures that data flows through the graph in a way that minimizes expensive reformatting costs. Additionally, FluidML performs loop reordering for heavy operations like matrix multiplication (GEMM) to find the most cache-friendly execution order for a given layout.
Static Memory Allocation
Because an AI model's memory requirements are entirely predictable once the graph is defined, FluidML bypasses general-purpose OS allocators. It uses a custom "greedy-by-size" static allocator that sorts tensors by size and packs them into the smallest possible memory footprint, reusing space for tensors that do not coexist in time.
Evaluation and Results
The researchers evaluated FluidML using prominent model architectures, including BERT, ConvBERT, GPT-NEOX, I-BERT, and VGG, all processed via the ONNX format. Testing was conducted across Intel i7, AMD Threadripper, and Apple M1 Pro platforms.
Performance Gains
FluidML consistently outperformed existing tools like ONNX-MLIR and Apache TVM:
- Latency: Reduced end-to-end inference time by up to 25.38% for language models.
- Memory Efficiency: Reduced peak memory usage by up to 41.47%. For example, on the GPT-NEOX model, FluidML required only 3.1 MB of memory overhead compared to 59.1 MB for ONNXRuntime.
- Operator Speed: Specific operations like Matrix Multiplication saw speedups of up to 17.87% due to optimized loop reordering.
Conclusion
FluidML demonstrates that global graph awareness and static memory management can significantly outperform local kernel optimizers and general-purpose memory managers. By resolving layout conflicts across the entire model chain and exploiting the predictability of tensor lifetimes, it enables more efficient deployment of complex models on edge hardware. Future work will focus on expanding operator support and extending these holistic optimizations to GPUs and specialized AI accelerators.
Summary updated