Hugot Project: Hardware Accelerator Technical Feasibility Assessment
*English adaptation of a Chinese technical evaluation report (originally published on zhichai.net). Charts from the source have been summarized in text.*
Project Overview
Hugot is an ONNX-based pipeline library, written in Go, for running inference and training of Transformer models (including LLMs) originally trained in Python with Hugging Face — without depending on a Python runtime or external services. It is maintained by Knights Analytics and used in production for AI-driven data-cleaning tasks.
Hugot supports many pipeline types through a unified API: text classification, text generation, feature extraction (embeddings), image classification, object detection, question answering, tabular models, zero-shot classification, cross-encoders, and named entity recognition. It also supports fine-tuning of feature-extraction pipelines and aims for prediction parity with the Python Hugging Face ecosystem once models are exported to ONNX.
Technical Architecture
Hugot uses pluggable backends and modular pipelines. Three backends are supported:
- Pure Go backend (SimpleGo) — default, built on GoMLX; fully Go, no C/C++ dependencies, works with CGO disabled, small container images. Optimized for smaller models and batch sizes around 32; larger workloads should use the C backends.
- ONNX Runtime (ORT) backend — enabled with
-tags ORT; requireslibonnxruntime.so(path set viaWithOnnxLibraryPath). Inference only, but the fastest CPU backend and the only one supporting generative pipelines. Exposes ONNX Runtime execution providers (CUDA, TensorRT, DirectML, OpenVINO, CoreML, NNAPI, etc.), e.g., viaWithCuda. - OpenXLA backend — enabled with
-tags XLA; based on Google's XLA compiler and PJRT runtime. Supports training/fine-tuning and is the only backend with TPU support; generative pipeline support is still incomplete. Requires PJRT plugin libraries and thetokenizers.astatic library at build time. - GPU vs CPU: GPUs offer ~an order of magnitude higher inference throughput; CPUs can be competitive for low-latency single requests.
- TPU vs GPU: TPUs win on throughput/energy efficiency at large batch sizes, but have higher deployment friction and a more closed ecosystem.
- NPU: best energy efficiency for edge scenarios; peak performance and accuracy depend on quantization/pruning constraints.
- Text generation is only supported via the ORT backend (ONNX Runtime Generative AI optimizations); a
WithGenerativeEngineoption adds concurrent request handling and smart batching. - Tune batch size: ~32 is a good starting point for the pure Go backend; larger batches can fill GPUs/TPUs but must fit memory.
- On CPU, use
WithInterOpNumThreads/WithIntraOpNumThreads(e.g., setting threads to 1 to reduce contention) and optionallyWithCpuMemArena(false)/WithMemPattern(false). - On GPU/TPU, pin sessions to devices (
WithCudadevice ID), run multiple sessions across GPUs, and keep data resident in device memory. Hugot memory-maps ONNX models to reduce footprint. - Enable graph optimization via
WithGraphOptimizationLevel; 4-bit and other quantization support is planned. - Cloud: Hugot packages with Dockerfiles/compose files; no Python runtime needed. Embedding inference directly in Go services avoids HTTP round-trips and serialization overhead versus calling external Python services. GPU instances for low latency, CPU instances with thread tuning for cost-sensitive workloads.
- Edge: Feasible on higher-end edge devices with GPUs or NPUs via ORT execution providers (CUDA or NNAPI); low-power devices depend on model size and quantization.
- Local servers: The pure Go backend simplifies air-gapped or CGO-free deployments; C backends unlock more performance where libraries can be installed.
Pipelines share a common abstraction (BasePipeline struct and Pipeline interface in pipelines/pipeline.go); new pipeline types are added by embedding BasePipeline, implementing the interface, and registering in NewPipeline. A Session manages multiple pipelines by alias. All models must be converted to ONNX (e.g., via transformers.onnx or Optimum), giving zero-loss migration from Python.
Hardware Accelerator Support and Performance
Officially tested accelerators: CPU, GPU (CUDA), and TPU; other backends (TensorRT, DirectML, CoreML, OpenVINO, NNAPI) are available indirectly through ONNX Runtime execution providers.
GPU (CUDA)
Mature and high-performance. Requirements: NVIDIA driver + CUDA toolkit matching the ORT GPU build (e.g., ORT 1.24.4 needs CUDA 12.x and cuDNN 9.x), the ORT GPU library, and GoMLX's tokenizers.a. Enabled with the WithCuda option. Benchmarks cited: an NVIDIA L4 GPU was ~12.6x faster than a 192-core AMD EPYC CPU for a satellite-image embedding model, retaining ~11x advantage even at full CPU thread utilization. (Source chart: NVIDIA L4 GPU 12.6x vs. CPU baseline 1x.)
TPU
Supported via the OpenXLA backend with the WithTPU option and PJRT plugins. TPUs excel at large-scale matrix computation; Google's internal figures for first-generation TPUs report 83x inference speedup vs. contemporary CPUs and 29x vs. GPUs. (Source chart: CPU 1x baseline, GPU 29x, TPU 83x.) Best suited to large-batch workloads in Google Cloud environments; deployment complexity and operator coverage are considerations.
NPU and Other Accelerators
NPU support depends on ONNX Runtime execution providers: NNAPI (Android NPUs), CoreML (Apple Neural Engine), OpenVINO (Intel VPUs), etc. Compatibility and gains vary by device; operators may be limited. TensorRT EP adds graph-level optimization and kernel fusion on NVIDIA GPUs; DirectML covers DirectX 12 GPUs on Windows.
Performance Analysis
Tuning Best Practices
Deployment Suitability
Conclusion
Hugot is technically viable across CPU, GPU, and TPU, with indirect NPU support via ONNX Runtime execution providers. GPU acceleration through the ORT backend is the most mature and highest-impact option today; TPU is attractive for high-throughput Google Cloud deployments via the XLA backend; and NPUs extend Hugot to edge/mobile use cases subject to per-device operator compatibility testing.