LogoLogo
Continuum WebsiteContinuum ApplicationsContinuum KnowledgeAxolotl Platform
Continuum Knowledge
Continuum Knowledge
  • Continuum
  • Data
    • Datasets
      • Pre Training Data
      • Types of Fine Tuning
      • Self Instruct Paper
      • Self-Alignment with Instruction Backtranslation
      • Systematic Evaluation of Instruction-Tuned Large Language Models on Open Datasets
      • Instruction Tuning
      • Instruction Fine Tuning - Alpagasus
      • Less is More For Alignment
      • Enhanced Supervised Fine Tuning
      • Visualising Data using t-SNE
      • UMAP: Uniform Manifold Approximation and Projection for Dimension Reduction
      • Training and Evaluation Datasets
      • What is perplexity?
  • MODELS
    • Foundation Models
      • The leaderboard
      • Foundation Models
      • LLama 2 - Analysis
      • Analysis of Llama 3
      • Llama 3.1 series
      • Google Gemini 1.5
      • Platypus: Quick, Cheap, and Powerful Refinement of LLMs
      • Mixtral of Experts
      • Mixture-of-Agents (MoA)
      • Phi 1.5
        • Refining the Art of AI Training: A Deep Dive into Phi 1.5's Innovative Approach
      • Phi 2.0
      • Phi-3 Technical Report
  • Training
    • The Fine Tuning Process
      • Why fine tune?
        • Does Fine-Tuning LLMs on New Knowledge Encourage Hallucinations?
        • Explanations in Fine Tuning
      • Tokenization
        • Tokenization Is More Than Compression
        • Tokenization - SentencePiece
        • Tokenization explore
        • Tokenizer Choice For LLM Training: Negligible or Crucial?
        • Getting the most out of your tokenizer for pre-training and domain adaptation
        • TokenMonster
      • Parameter Efficient Fine Tuning
        • P-Tuning
          • The Power of Scale for Parameter-Efficient Prompt Tuning
        • Prefix-Tuning: Optimizing Continuous Prompts for Generation
        • Harnessing the Power of PEFT: A Smarter Approach to Fine-tuning Pre-trained Models
        • What is Low-Rank Adaptation (LoRA) - explained by the inventor
        • Low Rank Adaptation (Lora)
        • Practical Tips for Fine-tuning LMs Using LoRA (Low-Rank Adaptation)
        • QLORA: Efficient Finetuning of Quantized LLMs
        • Bits and Bytes
        • The Magic behind Qlora
        • Practical Guide to LoRA: Tips and Tricks for Effective Model Adaptation
        • The quantization constant
        • QLORA: Efficient Finetuning of Quantized Language Models
        • QLORA and Fine-Tuning of Quantized Language Models (LMs)
        • ReLoRA: High-Rank Training Through Low-Rank Updates
        • SLoRA: Federated Parameter Efficient Fine-Tuning of Language Models
        • GaLora: Memory-Efficient LLM Training by Gradient Low-Rank Projection
      • Hyperparameters
        • Batch Size
        • Padding Tokens
        • Mixed precision training
        • FP8 Formats for Deep Learning
        • Floating Point Numbers
        • Batch Size and Model loss
        • Batch Normalisation
        • Rethinking Learning Rate Tuning in the Era of Language Models
        • Sample Packing
        • Gradient accumulation
        • A process for choosing the learning rate
        • Learning Rate Scheduler
        • Checkpoints
        • A Survey on Efficient Training of Transformers
        • Sequence Length Warmup
        • Understanding Training vs. Evaluation Data Splits
        • Cross-entropy loss
        • Weight Decay
        • Optimiser
        • Caching
      • Training Processes
        • Extending the context window
        • PyTorch Fully Sharded Data Parallel (FSDP)
        • Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolation
        • YaRN: Efficient Context Window Extension of Large Language Models
        • Sliding Window Attention
        • LongRoPE
        • Reinforcement Learning
        • An introduction to reinforcement learning
        • Reinforcement Learning from Human Feedback (RLHF)
        • Direct Preference Optimization: Your Language Model is Secretly a Reward Model
  • INFERENCE
    • Why is inference important?
      • Grouped Query Attention
      • Key Value Cache
      • Flash Attention
      • Flash Attention 2
      • StreamingLLM
      • Paged Attention and vLLM
      • TensorRT-LLM
      • Torchscript
      • NVIDIA L40S GPU
      • Triton Inference Server - Introduction
      • Triton Inference Server
      • FiDO: Fusion-in-Decoder optimised for stronger performance and faster inference
      • Is PUE a useful measure of data centre performance?
      • SLORA
  • KNOWLEDGE
    • Vector Databases
      • A Comprehensive Survey on Vector Databases
      • Vector database management systems: Fundamental concepts, use-cases, and current challenges
      • Using the Output Embedding to Improve Language Models
      • Decoding Sentence-BERT
      • ColBERT: Efficient and Effective Passage Search via Contextualized Late Interaction over BERT
      • SimCSE: Simple Contrastive Learning of Sentence Embeddings
      • Questions Are All You Need to Train a Dense Passage Retriever
      • Improving Text Embeddings with Large Language Models
      • Massive Text Embedding Benchmark
      • RocketQAv2: A Joint Training Method for Dense Passage Retrieval and Passage Re-ranking
      • LLM2Vec: Large Language Models Are Secretly Powerful Text Encoders
      • Embedding and Fine-Tuning in Neural Language Models
      • Embedding Model Construction
      • Demystifying Embedding Spaces using Large Language Models
      • Fine-Tuning Llama for Multi-Stage Text Retrieval
      • Large Language Model Based Text Augmentation Enhanced Personality Detection Model
      • One Embedder, Any Task: Instruction-Finetuned Text Embeddings
      • Vector Databases are not the only solution
      • Knowledge Graphs
        • Harnessing Knowledge Graphs to Elevate AI: A Technical Exploration
        • Unifying Large Language Models and Knowledge Graphs: A Roadmap
      • Approximate Nearest Neighbor (ANN)
      • High Dimensional Data
      • Principal Component Analysis (PCA)
      • Vector Similarity Search - HNSW
      • FAISS (Facebook AI Similarity Search)
      • Unsupervised Dense Retrievers
    • Retrieval Augmented Generation
      • Retrieval-Augmented Generation for Large Language Models: A Survey
      • Fine-Tuning or Retrieval?
      • Revolutionising Information Retrieval: The Power of RAG in Language Models
      • A Survey on Retrieval-Augmented Text Generation
      • REALM: Retrieval-Augmented Language Model Pre-Training
      • Retrieve Anything To Augment Large Language Models
      • Generate Rather Than Retrieve: Large Language Models Are Strong Context Generators
      • Active Retrieval Augmented Generation
      • DSPy: LM Assertions: Enhancing Language Model Pipelines with Computational Constraints
      • DSPy: Compiling Declarative Language Model Calls
      • DSPy: In-Context Learning for Extreme Multi-Label Classification
      • Optimizing Instructions and Demonstrations for Multi-Stage Language Model Programs
      • HYDE: Revolutionising Search with Hypothetical Document Embeddings
      • Enhancing Recommender Systems with Large Language Model Reasoning Graphs
      • Retrieval Augmented Generation (RAG) versus fine tuning
      • RAFT: Adapting Language Model to Domain Specific RAG
      • Summarisation Methods and RAG
      • Lessons Learned on LLM RAG Solutions
      • Stanford: Retrieval Augmented Language Models
      • Overview of RAG Approaches with Vector Databases
      • Mastering Chunking in Retrieval-Augmented Generation (RAG) Systems
    • Semantic Routing
    • Resource Description Framework (RDF)
  • AGENTS
    • What is agency?
      • Rephrase and Respond: Let Large Language Models Ask Better Questions for Themselves
      • Types of Agents
      • The risk of AI agency
      • Understanding Personality in Large Language Models: A New Frontier in AI Psychology
      • AI Agents - Reasoning, Planning, and Tool Calling
      • Personality and Brand
      • Agent Interaction via APIs
      • Bridging Minds and Machines: The Legacy of Newell, Shaw, and Simon
      • A Survey on Language Model based Autonomous Agents
      • Large Language Models as Agents
      • AI Reasoning: A Deep Dive into Chain-of-Thought Prompting
      • Enhancing AI Reasoning with Self-Taught Reasoner (STaR)
      • Exploring the Frontier of AI: The "Tree of Thoughts" Framework
      • Toolformer: Revolutionising Language Models with API Integration - An Analysis
      • TaskMatrix.AI: Bridging Foundational AI Models with Specialised Systems for Enhanced Task Completion
      • Unleashing the Power of LLMs in API Integration: The Rise of Gorilla
      • Andrew Ng's presentation on AI agents
      • Making AI accessible with Andrej Karpathy and Stephanie Zhan
  • Regulation and Ethics
    • Regulation and Ethics
      • Privacy
      • Detecting AI Generated content
      • Navigating the IP Maze in AI: The Convergence of Blockchain, Web 3.0, and LLMs
      • Adverse Reactions to generative AI
      • Navigating the Ethical Minefield: The Challenge of Security in Large Language Models
      • Navigating the Uncharted Waters: The Risks of Autonomous AI in Military Decision-Making
  • DISRUPTION
    • Data Architecture
      • What is a data pipeline?
      • What is Reverse ETL?
      • Unstructured Data and Generatve AI
      • Resource Description Framework (RDF)
      • Integrating generative AI with the Semantic Web
    • Search
      • BM25 - Search Engine Ranking Function
      • BERT as a reranking engine
      • BERT and Google
      • Generative Engine Optimisation (GEO)
      • Billion-scale similarity search with GPUs
      • FOLLOWIR: Evaluating and Teaching Information Retrieval Models to Follow Instructions
      • Neural Collaborative Filtering
      • Federated Neural Collaborative Filtering
      • Latent Space versus Embedding Space
      • Improving Text Embeddings with Large Language Models
    • Recommendation Engines
      • On Interpretation and Measurement of Soft Attributes for Recommendation
      • A Survey on Large Language Models for Recommendation
      • Model driven recommendation systems
      • Recommender AI Agent: Integrating Large Language Models for Interactive Recommendations
      • Foundation Models for Recommender Systems
      • Exploring the Impact of Large Language Models on Recommender Systems: An Extensive Review
      • AI driven recommendations - harming autonomy?
    • Logging
      • A Taxonomy of Anomalies in Log Data
      • Deeplog
      • LogBERT: Log Anomaly Detection via BERT
      • Experience Report: Deep Learning-based System Log Analysis for Anomaly Detection
      • Log-based Anomaly Detection with Deep Learning: How Far Are We?
      • Deep Learning for Anomaly Detection in Log Data: A Survey
      • LogGPT
      • Adaptive Semantic Gate Networks (ASGNet) for log-based anomaly diagnosis
  • Infrastructure
    • The modern data centre
      • Enhancing Data Centre Efficiency: Strategies to Improve PUE
      • TCO of NVIDIA GPUs and falling barriers to entry
      • Maximising GPU Utilisation with Kubernetes and NVIDIA GPU Operator
      • Data Centres
      • Liquid Cooling
    • Servers and Chips
      • The NVIDIA H100 GPU
      • NVIDIA H100 NVL
      • Lambda Hyperplane 8-H100
      • NVIDIA DGX Servers
      • NVIDIA DGX-2
      • NVIDIA DGX H-100 System
      • NVLink Switch
      • Tensor Cores
      • NVIDIA Grace Hopper Superchip
      • NVIDIA Grace CPU Superchip
      • NVIDIA GB200 NVL72
      • Hopper versus Blackwell
      • HGX: High-Performance GPU Platforms
      • ARM Chips
      • ARM versus x86
      • RISC versus CISC
      • Introduction to RISC-V
    • Networking and Connectivity
      • Infiniband versus Ethernet
      • NVIDIA Quantum InfiniBand
      • PCIe (Peripheral Component Interconnect Express)
      • NVIDIA ConnectX InfiniBand adapters
      • NVMe (Non-Volatile Memory Express)
      • NVMe over Fabrics (NVMe-oF)
      • NVIDIA Spectrum-X
      • NVIDIA GPUDirect
      • Evaluating Modern GPU Interconnect
      • Scalable Hierarchical Aggregation and Reduction Protocol (SHARP)
      • Next-generation networking in AI environments
      • NVIDIA Collective Communications Library (NCCL)
    • Data and Memory
      • NVIDIA BlueField Data Processing Units (DPUs)
      • Remote Direct Memory Access (RDMA)
      • High Bandwidth Memory (HBM3)
      • Flash Memory
      • Model Requirements
      • Calculating GPU memory for serving LLMs
      • Transformer training costs
      • GPU Performance Optimisation
    • Libraries and Complements
      • NVIDIA Base Command
      • NVIDIA AI Enterprise
      • CUDA - NVIDIA GTC 2024 presentation
      • RAPIDs
      • RAFT
    • Vast Data Platform
      • Vast Datastore
      • Vast Database
      • Vast Data Engine
      • DASE (Disaggregated and Shared Everything)
      • Dremio and VAST Data
    • Storage
      • WEKA: A High-Performance Storage Solution for AI Workloads
      • Introduction to NVIDIA GPUDirect Storage (GDS)
        • GDS cuFile API
      • NVIDIA Magnum IO GPUDirect Storage (GDS)
      • Vectors in Memory
Powered by GitBook
LogoLogo

Continuum - Accelerated Artificial Intelligence

  • Continuum Website
  • Axolotl Platform

Copyright Continuum Labs - 2023

On this page
  • Background and Motivation
  • S-LoRA System
  • Technical Innovations
  • Potential Impact
  • Challenges in Batched Inference
  • S-LoRA's Contributions
  • Performance Evaluation
  • Impact and Potential
  • LM Architecture and Scale
  • Inference Process in LMs
  • Challenges in Online Serving
  • Parallelisation Strategies for Large Models
  • Batching Strategy
  • LoRA Adapter Merging
  • S-LoRA's Approach
  • Memory Management and Adapter Storage
  • Iteration-Level Scheduling Batching Strategy
  • Memory Management Techniques
  • Prefetching and Overlapping
  • Custom Kernels for Heterogeneous LoRA Batching
  • Tensor Parallelism in Batched LoRA Inference
  • Partition Strategy
  • Communication in Partitioning
  • Adaptation to Self-Attention Layer
  • Communication and Memory Cost Analysis

Was this helpful?

  1. Training
  2. The Fine Tuning Process
  3. Parameter Efficient Fine Tuning

SLoRA: Federated Parameter Efficient Fine-Tuning of Language Models

Leveraging Lora

PreviousReLoRA: High-Rank Training Through Low-Rank UpdatesNextGaLora: Memory-Efficient LLM Training by Gradient Low-Rank Projection

Last updated 1 year ago

Was this helpful?

The paper on S-LoRA focuses on scalable serving of Low-Rank Adaptation (LoRA) adapters for language models (LMs).

Background and Motivation

  • Pretrain-then-Finetune Paradigm: LMs are commonly fine-tuned for specific tasks, leading to numerous fine-tuned variants of a single base model.

  • LoRA for Fine-Tuning: LoRA is a parameter-efficient fine-tuning method that updates only low-rank additive matrices (adapter weights), achieving performance comparable to full-weight fine-tuning.

  • Challenges in Serving LoRA Adapters: While fine-tuning has been extensively researched, the efficient serving of these fine-tuned variants, especially at scale, remains underexplored.

S-LoRA System

  • Goal: To scalably serve thousands of LoRA adapters on a single machine or across multiple GPUs.

  • Unified Paging: S-LoRA introduces Unified Paging to manage dynamic adapter weights with varying ranks and KV cache tensors with different sequence lengths in a unified memory pool.

  • Tensor Parallelism and CUDA Kernels: It employs a tensor parallelism strategy and custom CUDA kernels for heterogeneous batching of LoRA computation.

  • Efficiency: S-LoRA aims to serve multiple adapters concurrently with high throughput and low latency, significantly improving over traditional methods.

Technical Innovations

  • Adapter and Base Model Separation: S-LoRA separates the batchable base model computation from individual LoRA computations to achieve high-throughput multi-adapter serving.

  • Memory Management: The system stores all adapters in the main memory and fetches the required adapters to the GPU memory as needed, efficiently using GPU memory and reducing fragmentation.

  • Serving Throughput and Latency: Compared to existing libraries (like HuggingFace PEFT and vLLM), S-LoRA can increase throughput by up to 4 times and serve significantly more adapters.

Potential Impact

  • Scalable Serving of Fine-Tuned Models: S-LoRA enables scalable serving of many task-specific fine-tuned models.

  • Large-Scale Customized Fine-Tuning Services: It offers the potential for large-scale customized fine-tuning services, which could be a substantial advancement for deploying personalized AI solutions.

Challenges in Batched Inference

  • Memory Management: Efficiently managing GPU memory is critical due to the simultaneous serving of multiple LoRA adapters. Storing adapter weights outside the GPU and fetching them dynamically presents challenges in memory fragmentation and I/O overhead.

  • Batching Complexity: The separated computation of many adapters, each with distinct ranks and stored in non-contiguous memory, complicates the batching process.

  • Multiple GPU Usage: Utilizing multiple GPUs requires novel parallelism strategies to efficiently handle the added LoRA weights and computations, minimizing communication and memory overheads.

S-LoRA's Contributions

  • Unified Paging: S-LoRA introduces a unified memory pool to manage dynamic adapter weights and KV cache tensors. This approach reduces memory fragmentation and increases batch size.

  • Heterogeneous Batching: Custom CUDA kernels are employed for efficiently batching different adapters of varying ranks. These kernels operate on non-contiguous memory, aligning with the memory pool design for efficient batched inference.

  • S-LoRA TP (Tensor Parallelism): A novel tensor parallelism strategy ensures effective parallelization across multiple GPUs. It achieves minimal communication cost by scheduling communications on small intermediate tensors and fusing large tensors with the communications of the base model.

Performance Evaluation

  • Model Testing: S-LoRA was evaluated on models ranging from Llama-7B to Llama-70B.

  • Throughput Enhancement: Compared to HuggingFace PEFT, a leading parameter-efficient fine-tuning library, S-LoRA can enhance throughput by up to 30 times.

  • Comparison with vLLM: Against the vLLM system, which naively supports LoRA serving, S-LoRA improves throughput by up to 4 times and significantly increases the number of served adapters.

Impact and Potential

  • Scalability: S-LoRA's ability to serve thousands of adapters on a single GPU or across multiple GPUs with minimal overhead represents a significant advancement in scalable serving of fine-tuned models.

  • Efficiency in Serving Multiple Tasks: By overcoming the challenges of memory management, batching complexity, and effective use of multiple GPUs, S-LoRA enables the efficient and scalable serving of a wide range of task-specific fine-tuned models.

In conclusion, the S-LoRA paper presents a comprehensive solution for the scalable serving of LoRA adapters in large language models. By addressing key challenges in memory management, batching, and parallelism, S-LoRA notably enhances throughput and scalability, paving the way for the efficient deployment of highly personalized and diverse AI services.

LM Architecture and Scale

  • Architecture: Most LMs are based on the transformer architecture.

  • Size: LMs can have several billion to trillion parameters, resulting in disk sizes from gigabytes to terabytes.

  • Computational and Memory Demands: The sheer scale of LMs leads to significant computational and memory requirements during serving.

Inference Process in LMs

  • Autoregressive Decoding: Inference requires iterative autoregressive decoding, where the model encodes the prompt in a forward pass and then decodes the output one token at a time.

  • Sequential Nature: The sequential nature of decoding each token, attending to the hidden states of all preceding tokens, makes the process slow.

  • KV Cache: There's a need to store the hidden states of all previous tokens, referred to as the KV cache, which adds substantial memory overhead.

Challenges in Online Serving

  • Dynamic Requests: In online settings, handling requests of varying sequence lengths that arrive dynamically is a challenge.

  • Fine-Grained Scheduling: Orca introduces iteration-level scheduling, batching at the token level instead of the request level, allowing for the addition of new requests to the current batch, thus enhancing throughput.

  • vLLM's Memory Optimization: vLLM optimizes memory efficiency through PagedAttention, which uses concepts from virtual memory and paging to manage KV cache tensors, reducing fragmentation and enabling larger batch sizes.

Parallelisation Strategies for Large Models

  • Necessity for Parallelisation: Serving models exceeding a single GPU's memory capacity, or meeting strict latency requirements, necessitates parallelization across multiple GPUs.

  • Parallelism Methods:

    • Tensor Parallelism: Distributes the computational load of tensor operations across GPUs.

    • Sequence Parallelism: Focuses on distributing different sequence parts across GPUs.

    • Pipeline Parallelism: Involves dividing the model into stages, each processed on different GPUs, often in combination with other parallelism methods.

Integration of Methods

Combining various parallelism techniques (tensor, sequence, pipeline) has been proposed to effectively handle the demands of very large models, ensuring efficient utilization of computational resources and minimizing latency.

In summary, the paper's focus on batching and scheduling highlights S-LoRA's innovative approach to efficiently manage memory and computational resources.

This is achieved by separating batched computations for the base model and LoRA adapters, using custom CUDA kernels, and implementing a dynamic iteration-level scheduling strategy.

These strategies enable S-LoRA to serve a large number of LoRA adapters concurrently, addressing the challenges of high-throughput and online serving in large language models.

Batching Strategy

  • Goal: To support online and high-throughput serving of many LoRA adapters simultaneously.

  • Separate Batched Computation: The base model computation and the LoRA adapters are batched separately. The base computation is batched using General Matrix Multiply (GEMM), while LoRA adapters are handled by custom CUDA kernels.

  • Efficiency: This separation allows for efficient computation without the need for padding, as would be required by traditional batch GEMM kernels due to heterogeneity in sequence lengths and adapter ranks.

LoRA Adapter Merging

  • Original LoRA Method: In the original LoRA approach, adapter weights were merged into the base model, creating a new model without additional overhead during inference.

  • Limitation in Multiple Adapter Context: Merging weights for multiple adapters leads to multiple weight copies and misses batching opportunities. Additionally, the original method of adding and subtracting LoRA weights on the fly doesn’t support concurrent inference on separate adapters.

S-LoRA's Approach

  • On-the-fly LoRA Computation: S-LoRA computes the LoRA computation (xAB) on-the-fly, avoiding weight duplication and enabling batching of the more costly xW operation. This results in considerable savings despite increased computation overhead.

  • Custom CUDA Kernels: Custom CUDA kernels are used for the LoRA computation, optimizing for efficiency and avoiding the limitations of padding required by batch GEMM kernels.

Memory Management and Adapter Storage

  • Main Memory Storage: All LoRA adapters are stored in the main memory. Only the adapters needed for the current batch are fetched to the GPU RAM during inference, which manages the GPU memory more effectively.

  • Maximizing Adapter Service: The maximum number of adapters that can be served is bounded by the main memory size. This approach allows for a higher throughput of adapter serving.

Iteration-Level Scheduling Batching Strategy

  • Adopted from Orca: The iteration-level scheduling batching strategy from Orca is employed, where requests are scheduled at the token level.

  • Dynamic Request Incorporation: New requests are immediately incorporated into the running batch if space is available. Requests exit the batch once they reach the maximum number of generated tokens or other stopping criteria.

  • Memory Management Challenges: This strategy reduces GPU memory usage but introduces new challenges in memory management.

Memory Management Techniques

  • Efficient Handling of Memory: Techniques for managing memory efficiently in this dynamic and high-throughput context are discussed in Section 5 of the paper.

In summary, the paper's focus on batching and scheduling highlights S-LoRA's innovative approach to efficiently manage memory and computational resources. This is achieved by separating batched computations for the base model and LoRA adapters, utilizing custom CUDA kernels, and implementing a dynamic iteration-level scheduling strategy.

These strategies enable S-LoRA to serve a large number of LoRA adapters concurrently, addressing the challenges of high-throughput and online serving in large language models.

The section on "Prefetching and Overlapping" and "Custom Kernels" in the S-LoRA paper focuses on optimizing the system's efficiency in handling multiple LoRA adapters. Here's a brief summary:

Prefetching and Overlapping

  • Challenge: I/O overhead from loading and offloading adapter weights, especially with numerous or large adapters, introduces latency.

  • Dynamic Prediction Mechanism: While decoding the current batch, the system predicts which adapters will be needed for the next batch based on the current queue.

  • Prefetching Strategy: Adapters predicted to be needed are prefetched and stored in memory, reducing I/O time and latency for adapter swapping.

Custom Kernels for Heterogeneous LoRA Batching

  • Non-Contiguous Memory Handling: Due to the unified memory pool's design, adapter weights are stored in non-contiguous memory.

  • Custom CUDA Kernels: These kernels are implemented to efficiently handle LoRA computations with varying ranks and sequence lengths in a non-contiguous memory layout.

  • Multi-size Batched Gather Matrix-Matrix Multiplication (MBGMM): This kernel, implemented in Triton with tiling, is used in the prefill stage to handle a sequence of tokens and gather adapter weights of different ranks.

  • Multi-size Batched Gather Matrix-Vector Multiplication (MBGMV): Used in the decode stage, this kernel is adapted from Punica to support multiple ranks in a batch and more fine-grained memory gathering for a single token.

Tensor Parallelism in Batched LoRA Inference

  • Objective: To support multi-GPU inference of large transformer models using batched LoRA inference.

  • Why Tensor Parallelism?: It's widely used because of its simplicity and compatibility with existing systems. It helps reduce memory usage and latency per GPU when serving large models.

Partition Strategy

  • Alignment with Base Model: The strategy aligns the partitioning of inputs and outputs of the added LoRA computation with those of the base model. This minimizes communication costs by reducing unnecessary communications and fusing some communications.

  • Illustration with Feed-Forward Module: The partition strategy is demonstrated using a 2-layer MLP (feed-forward module). The base model's first weight matrix (W1) is column-partitioned, and the second (W2) is row-partitioned.

  • Added LoRA Computation: The LoRA computation involves additional matrices (A1, B1, A2, B2). A1 and B1 (for the first weight matrix W1) are column-partitioned, while A2 and B2 (for the second weight W2) are row-partitioned and column-partitioned, respectively.

Communication in Partitioning

  • Base Model: An all-reduce operation accumulates the partial sum from distributed devices.

  • LoRA Computation: Involves all-gather operations to collect intermediate results and all-reduce operations to sum up these results.

  • Fusion of Operations: The strategy includes fusing an all-gather operation with the final all-reduce operation, a novel approach in parallelization.

Adaptation to Self-Attention Layer

  • Head Dimension Partitioning: Similar to the Megatron-LM strategy, the head dimension of the self-attention layer is partitioned.

  • Projection Weight Matrices: The query-key-value projection weight matrix is treated like W1, and the output projection weight matrix is like W2 in the feed-forward module example.

Communication and Memory Cost Analysis

  • Costs for Base Model and Added LoRA Computation: The communication cost for the base model involves one all-reduce operation. For the added LoRA computation, it involves three all-gathers and one all-reduce.

  • Negligible Additional Cost: The extra communication cost introduced by LoRA is small compared to the base model's cost, mainly because the rank of the adapter (r) is much smaller than the hidden size (h).

  • Optimal Memory Usage: The strategy is memory-efficient as it partitions all weight matrices across devices without replication.

LogoSLoRA: Federated Parameter Efficient Fine-Tuning of Language ModelsarXiv.org
SLoRA: Federated Parameter Efficient Fine-Tuning of Language Models
Page cover image