TL;DR
On-device LLM fine-tuning is severely bottlenecked by data layout transformations and conflicting memory access patterns between forward and backward passes on mobile GPUs. This paper introduces FBLayout, a framework that co-designs tensor organization with mobile GPU texture memory using a unified "R-Tile" layout and virtual index transformations. By eliminating physical data movement, FBLayout delivers up to a 5.7× training speedup over existing mobile frameworks.
What Problem Does This Paper Address?
While mobile GPUs excel at running AI inference, attempting to fine-tune a Large Language Model (LLM) on a smartphone reveals a massive performance gap: GPU training latency can actually be worse than CPU training.
The root cause is the Forward-Backward Layout (FB-Layout) Conflict. AI inference is a one-way street, but training is bidirectional. The backward pass reuses forward activations and weights but accesses them via different mathematical operations, such as transpositions and reductions along entirely different dimensions.
Mobile GPUs rely heavily on a 2.5D texture memory system optimized for 2D spatial locality. Existing mobile frameworks either reuse the forward pass layout during backpropagation (forcing the GPU into strided, non-contiguous memory accesses that cause severe cache thrashing) or perform explicit, expensive layout conversions that can consume up to 50% of total runtime.
Methods
FBLayout introduces a layout-aware framework that eliminates layout transformation overhead through three core components:
- R-Tile (Reduction-aware Tiling) Layout: Instead of switching layouts between passes, R-Tile keeps tile elements physically contiguous in 2D texture memory. Because reduction operations load the same underlying elements regardless of direction (only the aggregation order changes), a single tile layout can optimally serve both forward and backward passes.
- Tile-based Index Transformation: Many transposes and reshapes in attention blocks only reorder tiles without altering their internal structures. FBLayout replaces these physical data movements with lightweight, compile-time coordinate remappings at the tile granularity, bypassing physical GPU memory writes entirely.
- Activation-guided Global Layout Selection: To resolve layout preferences across consecutive operations (like successive matrix multiplications in attention blocks), the framework uses a size-aware greedy search to propagate optimal layout decisions globally across the entire computation graph.
Datasets
The paper evaluates FBLayout using a representative suite of 7 pretrained foundation models spanning different architectures and modalities, rather than training on a specific new dataset:
- Decoder-only LLMs: Llama3.2-1B, Qwen2.5-1.5B, Gemma2-2B
- Encoder-only models: BERT-Large, ViT-Large
- Encoder-Decoder models: Whisper-Large, Stable Diffusion v1.5 (UNet)
All models (except ViT) were fine-tuned using Low-Rank Adaptation (LoRA) configurations on hardware platforms including Qualcomm Adreno and ARM Mali GPUs.
Key Insights and Ideas
- The Tile-Invariance Principle: The authors realized that while matrix multiplication reduces along different dimensions in forward vs. backward passes, the data tiles themselves remain identical. Designing for tile-level invariance unlocks a unified layout that satisfies both passes.
- Exploiting Asymmetric Cache Geometry: Mobile GPU texture caches are rectangular and favor horizontal over vertical strides. FBLayout cleverly maps the primary reduction dimensions to the horizontal axis to maximize cache line reuse.
- Virtualizing Transformations: By treating structural operations (
reshape,transpose) as virtual coordinate translations, the framework removes data reorganization barriers, allowing aggressive kernel fusion and drastically reducing global memory traffic.
Key Results
- Substantial Speedups: Compared against state-of-the-art mobile deep learning frameworks, FBLayout consistently achieves 3.9×–4.1× speedup over MNN, 4.3×–4.9× over TFLite, and 5.4×–5.7× over TVM on decoder-only LLMs.
- Cache and Memory Efficiency: FBLayout issues 3.5× fewer global memory accesses and cuts cache misses by more than 4× on decoder-only LLMs.
- Energy Savings: Minimized DRAM polling and shorter training times translate directly to a 3.5×–6.3× reduction in total energy consumption, mitigating thermal throttling on mobile devices.
- Minimal Compilation Overhead: Thanks to architecture-aware pruning of the tile search space, FBLayout reduces layout optimization/compilation time from hours down to just 6.1 seconds.
Limitations and Future Work
- Element-Size Mismatches: The tile-based index remapping technique relies on structural consistency. It falls back to explicit layout conversions when element counts change drastically before and after a transformation (such as during the expansion phase in Grouped-Query Attention), though this accounts for less than 6% of total runtime.
- Future Work: The authors plan to combine their memory layout optimizations with complementary efficiency techniques, such as low-bit quantization (e.g., QLoRA) and sparse training, to further lower the barrier for on-device foundation model adaptation.
Summary updated