"Comparing Network Architectures: InfiniBand vs. RoCEv2 and Language Model Inference Techniques"

Kevin Di

Hatched by Kevin Di

May 22, 2024

5 min read

0

"Comparing Network Architectures: InfiniBand vs. RoCEv2 and Language Model Inference Techniques"

Introduction:
In the world of technology, network architectures and language model inference techniques play a crucial role in optimizing performance and efficiency. In this article, we will explore the key features, advantages, and applications of InfiniBand and RoCEv2 network architectures, as well as delve into the various techniques used in language model inference. By understanding these concepts, we can make informed decisions when it comes to selecting the right network architecture and optimizing language model inference.

Network Architectures: InfiniBand vs. RoCEv2
When it comes to reducing end-to-end communication latency between multiple machines and multiple cards, RDMA (Remote Direct Memory Access) technology is a key player. RDMA allows a host to directly access the memory of another host, bypassing the operating system kernel. There are four main ways to implement RDMA: InfiniBand, RoCEv1, RoCEv2, and iWARP. However, RoCEv1 is already being phased out, and iWARP is less commonly used. Currently, the main solutions for RDMA technology are InfiniBand and RoCEv2. By bypassing the kernel protocol stack, these solutions offer significant improvements in latency performance compared to traditional TCP/IP networks. In laboratory tests, the end-to-end latency at the application layer can be reduced from 50us (TCP/IP) to 5us (RoCE) or 2us (InfiniBand) when bypassing the kernel protocol stack. InfiniBand networks consist of key components such as Subnet Manager (SM), InfiniBand network cards, InfiniBand switches, and InfiniBand cables. In 2021, NVIDIA introduced the Quantum-2 series switch with a speed of 400Gbps (64*400G), featuring 32 800G OSFP (Octal Small Form Factor Pluggable) ports that can be converted into 64 400G QSFP ports using cables. The InfiniBand switch does not run any routing protocols. The entire network's forwarding table is calculated and distributed by the centralized Subnet Manager (SM). In addition to the forwarding table, the SM is responsible for managing the configuration of InfiniBand subnets, partitions, QoS, and more. InfiniBand networks require dedicated cables and optical modules for interconnecting switches and network cards. InfiniBand's Adaptive Routing, based on per-packet dynamic routing, ensures optimal network utilization in ultra-large-scale networking scenarios. InfiniBand networks have been widely adopted in the industry, especially in large GPU clusters such as Baidu Intelligent Cloud and Microsoft Cloud. The leading InfiniBand network solution providers in the market include NVIDIA, Intel Corporation, Cisco Systems, and Hewlett Packard Enterprise. NVIDIA holds the highest market share, accounting for more than 70%.

Language Model Inference Techniques:
In the realm of language models, efficient inference techniques are essential for large-scale models. KV (Key-Value) cache requires 2 * n_layers * n_heads * d_head parameters. Taking GPT-3 as an example, with n_layers = 96, n_heads = 96, and d_head = 128, each token in a context requires 2.4 million parameters. With typical 16-bit precision, each token would require 5MB. If the context window has 2048 tokens, it would require 10GB of HBM (High Bandwidth Memory) for KV cache. While this may seem expensive, the consumption is justified by the value it brings per GB. Inference decoding techniques, such as speculative decoding, are used when computational resources are abundant, typically in local inference settings. They leverage the capabilities of modern accelerators, where the time required for inference on a batch of data is the same as that for inference on a single data point. For example, with the A100 accelerator, up to 160 data points can be inferred in the same time required for a single data point. This has led to the development of various techniques like beam search, Monte Carlo Tree Search (MCTS), and speculative decoding. Speculative decoding involves using two models: a small and fast model, and a large and slow model. Since the inference speed of modern decoders is directly proportional to the number of parameters, using a smaller model allows for multiple inferences within the time required for a single inference using a large model. Recently, a technique called Lookahead Decoding has emerged, aiming to improve speculative decoding. Lookahead Decoding generates n-grams and recursively matches them without relying on the draft model. This technique, known as Jacobi decoding, shows potential improvements over greedy decoding. The Jacobi decoding works by generating n tokens at each point of token generation and "guessing" the entire sequence. It then validates it against previous guesses and accepts the guess if they match. This reduces latency without any side effects, as it can degrade to greedy decoding in the worst-case scenario. One optimization that can be implemented is to skip loading the weights corresponding to an activation if it is zero, avoiding unnecessary computations. While this optimization may not be well supported by mainstream tensor computation programs, it is relatively easy to implement in custom inference implementations like Llama.cpp. However, it is important to note that quantization does not inherently provide an advantage. From first principles, if two models have the same bit precision, they should have the same number of tokens per second and similar performance levels. Significant differences only arise when using higher precision formats. However, the literature's viewpoint on this matter contradicts my intuition. The aforementioned GPTQ paper found that quantizing the model to as low as 4 times the precision resulted in minimal performance degradation. This may be because models with poorer performance are more likely to maintain their performance during the quantization process.

Actionable Advice:

  1. When considering network architecture, carefully evaluate the specific requirements of your application and workload. InfiniBand and RoCEv2 offer different advantages and trade-offs, so choose the one that aligns with your needs.
  2. For language model inference, explore techniques such as speculative decoding and lookahead decoding to optimize performance and reduce latency. Consider the balance between model size and inference speed to achieve efficient results.
  3. Stay updated with the latest advancements and research in network architectures and language model inference techniques. Continuously evaluate and adapt your infrastructure to leverage new innovations and improve overall efficiency.

Conclusion:
InfiniBand and RoCEv2 are prominent network architectures that offer significant improvements in latency performance compared to traditional TCP/IP networks. By bypassing the kernel protocol stack, these architectures enable faster and more efficient communication between multiple machines and multiple cards. Similarly, language model inference techniques like speculative decoding and lookahead decoding provide valuable insights into optimizing performance and reducing latency. Understanding the strengths and applications of these technologies empowers us to make informed decisions and drive innovation in our network infrastructure and language model deployments. As technology continues to evolve, staying updated with the latest advancements will be crucial in harnessing the full potential of these architectures and techniques.

Sources

← Back to Library

Hatch New Ideas with Glasp AI 🐣

Glasp AI allows you to hatch new ideas based on your curated content. Let's curate and create with Glasp AI :)

Start Hatching 🐣