Introduction
The Transformer architecture has become the standard for high-quality Machine Translation. However, its significant computational requirements pose a major challenge for deployment on resource-constrained embedded devices like the NVIDIA Jetson Nano or smartphones. While static model compression techniques can reduce the footprint of these models, they assume a constant availability of hardware resources. In real-world scenarios, embedded systems are dynamic; available power and compute fluctuate due to battery levels or concurrent background applications.
We present Dynamic-HAT, a framework designed to provide runtime flexibility. It allows a single model to "shrink" or "grow" its computational complexity on the fly to stay within strict latency budgets without the need for retraining or reloading.
Methodology
Dynamic-HAT builds upon the Hardware-Aware Transformer (HAT) framework through a multi-stage optimization process:
- SuperTransformer Training: A single, massive "SuperTransformer" is trained, containing $10^{15}$ possible sub-network configurations (SubTransformers) that share weights.
- Evolutionary Search: An evolutionary algorithm, guided by hardware-specific latency predictors, identifies Pareto-optimal SubTransformers for the target CPU and GPU.
- Weight Inheritance: Sub-networks inherit weights directly from the SuperTransformer. This enables near-instant switching (<1s) between different performance-accuracy trade-offs at runtime.
- Design Space Specialization: To mitigate the performance gap inherent in weight inheritance, the design space is narrowed to a "reduced" space (approx. $10^{11}$ configurations) tailored to the specific architectural preferences of the hardware family.
Experimental Setup
The framework was evaluated using the WMT’14 English-German (En-De) translation task, comprising 4.5 million sentence pairs. Models were validated on newstest2013 and tested on newstest2014. Performance benchmarks were conducted on an NVIDIA Jetson Nano, measuring both CPU and GPU execution times.
Results and Discussion
Dynamic-HAT successfully enables a wide range of operating points on embedded hardware. On the Jetson Nano, the system scales latency from 0.356s to 1.526s on the GPU and 2.9s to 7.31s on the CPU.
Key Insights
- Hardware-Specific Architectures: The search process revealed that GPUs and CPUs have distinct architectural "tastes." GPUs perform most efficiently with wide but shallow models, while CPUs favor deep but thin configurations.
- The Inheritance Penalty: Sampling a sub-network directly from the SuperTransformer results in a BLEU score drop of approximately 1.5% compared to a standalone trained model. However, specializing the design space for the target hardware recovers roughly 1% of this loss.
- Latency Sensitivity: The number of decoder layers was identified as the most critical factor for latency. Adding a single decoder layer increases latency by ~300ms on the GPU and ~1000ms on the CPU.
Conclusion
Dynamic-HAT provides a robust solution for deploying Transformers in unpredictable environments. By allowing models to adapt their complexity in less than a second, it ensures that translation services remain responsive even as hardware resources fluctuate. Future work will focus on incorporating energy-per-translation metrics to further optimize for battery-operated devices.
Summary updated