[Paper Review] In-network Neural Networks
This paper proposes N2Net, a system that enables in-network inference using binary neural networks (BNNs) on programmable switching chips by leveraging existing hardware primitives like XNOR, POPCNT, and bitwise operations. It demonstrates that BNNs can be efficiently executed at line rate (up to 960 million neurons/sec) using only 14 pipeline elements, reducing memory usage compared to traditional lookup tables while requiring minimal chip area additions.
We present N2Net, a system that implements binary neural networks using commodity switching chips deployed in network switches and routers. Our system shows that these devices can run simple neural network models, whose input is encoded in the network packets' header, at packet processing speeds (billions of packets per second). Furthermore, our experience highlights that switching chips could support even more complex models, provided that some minor and cheap modifications to the chip's design are applied. We believe N2Net provides an interesting building block for future end-to-end networked systems.
Motivation & Objective
- To explore the feasibility of deploying neural networks directly within network switching chips for high-throughput packet classification.
- To reduce reliance on large, memory-intensive lookup tables by replacing them with compact, computation-heavy BNN models.
- To leverage existing programmable switching chip primitives—such as bitwise logic and POPCNT—to implement BNN inference at line rate.
- To develop a compiler that automatically generates P4 code for deploying BNNs on RMT-based switching chips.
- To demonstrate that adding minimal, low-cost circuitry (e.g., native POPCNT) can significantly improve BNN efficiency and scalability.
Proposed method
- N2Net implements the forward pass of binary neural networks (BNNs) using only bitwise operations (XNOR, AND, shifts) and POPCNT for Hamming weight computation.
- It uses a five-step pipeline: replication of activations, XNOR and duplication, parallel POPCNT computation via a tree-based algorithm, sign activation, and folding of results into output vectors.
- The system maps BNN layers to P4-defined actions on the packet header vector (PHV), using RMT chip’s 32 pipeline elements and 512B PHV capacity.
- A custom compiler generates P4 code from a BNN model description (layers, neurons), automatically configuring the pipeline for inference.
- The design exploits parallelism by replicating activation vectors to process multiple neurons simultaneously across RISC processors.
- It assumes pre-configured BNN weights stored in SRAM, similar to BrainWave’s approach, to avoid runtime memory access overhead.
Experimental results
Research questions
- RQ1Can binary neural networks be efficiently executed on commodity programmable switching chips using only existing hardware primitives?
- RQ2To what extent can BNNs reduce memory usage compared to traditional lookup tables in packet classification?
- RQ3How many pipeline elements and PHV resources are required to support BNN inference at line rate?
- RQ4What performance gains can be achieved by adding minimal, low-area hardware extensions (e.g., native POPCNT)?
- RQ5Can N2Net enable scalable, high-throughput in-network inference for real-world workloads like DoS protection or load balancing?
Key findings
- N2Net can process up to 960 million neurons per second using 2048-bit activation vectors, achieving line-rate performance on an RMT switching chip.
- With 32-bit activation vectors, up to 64 neurons can be processed in parallel using only 14 pipeline elements, enabling 960 million two-layer BNNs per second.
- The system requires 3+2log₂(N) pipeline elements per neuron, where N is the activation vector size, with a maximum of 25 elements for 2048-bit vectors.
- Adding a native POPCNT primitive could reduce element count from 12–25 to 5–10, cutting hardware cost and doubling parallel neuron capacity.
- The computational circuitry for BNNs would consume less than 3–5% of the chip’s total area, making it a cost-effective enhancement.
- The approach enables deployment of compact, memory-efficient classifiers for use cases like large-scale packet filtering or application-aware load balancing.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.