
FPGA là gì? So sánh FPGA vs ASIC vs GPU cho AI inference edge
FPGA (Field-Programmable Gate Array) là vi mạch có thể lập trình lại cấu trúc phần cứng sau khi sản xuất. Khác với ASIC (cố định) và GPU (SIMD cố định), FPGA cho phép tùy chỉnh datapath, memory hierarchy và parallelism chính xác cho workload AI inference cụ thể, đạt hiệu năng/watt vượt trội ở edge.

Kiến trúc bên trong FPGA
FPGA bao gồm ma trận Logic Block (Configurable Logic Block – CLB) chứa LUT (Lookup Table), flip-flop, và multiplexer. Các block kết nối qua routing fabric (interconnect) có thể cấu hình. Hiện đại thêm:
- DSP Block: Đặc biệt cho multiply-accumulate (MAC) – trọng số của convolution, matrix multiply
- Block RAM (BRAM): On-chip memory tốc độ cao, latency thấp, phù hợp weight caching
- Hard IP: PCIe controller, Ethernet MAC, memory controller, SerDes – giảm logic dùng cho I/O
- AI Engine / Tensor Core: (Versal ACAP, Intel Agilex) systolic array cứng cho tensor ops
So sánh FPGA vs GPU vs ASIC cho AI Inference
| Tiêu chí | FPGA | GPU | ASIC (TPU, NPU) |
|---|---|---|---|
| Linh hoạt | Reconfigure bất kỳ lúc nào | Cố định ISA (CUDA, ROCm) | Cố định hoàn toàn |
| Latency (batch=1) | Rất thấp (~µs) | Cao (kernel launch, scheduler) | Thấp (hardware pipeline) |
| Throughput (batch lớn) | Trung bình | Rất cao (SIMT hàng nghìn core) | Rất cao (systolic array) |
| Hiệu năng/Watt (edge) | Tốt nhất cho batch nhỏ | Kém (idle power cao) | Tốt nhất cho workload cố định |
| Time-to-market | Tuần-tháng (HLS, RTL) | Ngày (PyTorch/TensorRT) | Năm (tape-out, mask) |
| Chi phí NRE | Không có (off-the-shelf) | Không có | Cao ($10M+ cho 7nm) |
| Độ chính xác số | Tùy ý (INT4, INT8, FP16, BF16, custom) | Hạn chế bởi ISA | Cố định tại thiết kế |
| Memory bandwidth | Tùy chỉnh (BRAM + HBM) | HBM cao nhưng chia sẻ | Tối ưu hóa chuyên biệt |

Tại sao FPGA thắng ở Edge AI Inference?
- Batch size = 1 thực tế: Edge (camera, robot, gateway) thường inference đơn lẻ, không batch được. GPU bị penalty kernel launch + scheduler overhead; FPGA pipeline streaming data flow-through, latency deterministc.
- Model quantization tùy chỉnh: FPGA hỗ trợ INT4, INT2, binary, ternary weight, mixed precision per-layer – tối ưu accuracy vs size cho từng layer. GPU/ASIC bị giới hạn bởi datatype cứng.
- Sensor fusion pipeline: FPGA có thể gộp preprocessing (ISP, demosaic, resize, normalize) + inference + postprocessing (NMS, tracking) trong một chip, bỏ DDR off-chip, giảm power 10x.
- Deterministic real-time: Không có OS jitter, cache miss, GC pause – quan trọng cho automotive (ISO 26262), industrial control.
Toolchain hiện đại: HLS và AI Compiler
Trước đây lập trình FPGA cần Verilog/VHDL (RTL) – khó, chậm. Nay:
- Vitis AI / Vitis Vision (AMD/Xilinx): Import ONNX/TensorFlow/PyTorch → quantize → compile → deploy. Hỗ trợ DPU (Deep Learning Processor Unit) soft IP trên FPGA.
- Intel OpenVINO + FPGA AI Suite: Graph optimizer → HLS kernel generation → bitstream.
- hls4ml: Chuyển model Keras/PyTorch → HLS C++ → Vivado/Vitis HLS → bitstream. Dùng cho high-energy physics, LHC trigger.
- FINN (Xilinx Research): End-to-end framework cho quantized neural network, generate dataflow architecture tùy chỉnh per-layer.
Ứng dụng thực tế FPGA cho AI Edge
| Lĩnh vực | Usecase | FPGA ví dụ | Lý do chọn FPGA |
|---|---|---|---|
| Automotive | ADAS perception, sensor fusion | Xilinx Zynq UltraScale+, Versal AI Edge | ISO 26262, deterministic latency, multi-sensor |
| Industrial | Defect detection, predictive maintenance | Intel Agilex, Xilinx Kria K26 | Long lifecycle (10+ năm), rugged, real-time |
| 5G/Telecom | RAN acceleration, beamforming | Xilinx RFSoC, Intel Stratix 10 | DSP density, deterministic latency, reconfigurable |
| Smart Camera | Object detection, pose estimation | Kria KV260, i.MX 8M + FPGA | ISP + inference single chip, low power |
| Financial | HFT risk check, fraud detection | Xilinx Alveo, Intel PAC | Sub-µs latency, custom datapath |
Thách thức và xu hướng
- Developer productivity: HLS cải thiện nhưng vẫn kém PyTorch/TensorRT. Cần abstraction level cao hơn (MLIR, TVM FPGA backend).
- Bitstream compile time: Place & route mất giờ. Giải pháp: partial reconfiguration, pre-compiled shell, overlay architecture.
- Chiplet & 3D stacking: Versal ACAP (AI Engine + PL + NoC), Intel Agilex (HBM + FPGA fabric) – memory bandwidth giải phóng bottleneck.
- RISC-V + FPGA: Soft core RISC-V trên FPGA cho control plane, FPGA fabric cho data plane – software-defined accelerator.
FPGA không thay thế GPU trong data center training/inference batch lớn, nhưng là lựa chọn tối ưu cho edge AI inference latency-critical, power-constrained, cần tùy chỉnh pipeline end-to-end. Với HLS/AI compiler hiện đại, rào cản lập trình đang giảm nhanh, mở đường FPGA phổ biến hơn trong AI edge deployment.
Nguồn: AMD Xilinx FPGA | Intel FPGA | hls4ml GitHub | Wikipedia FPGA
