Compressing VAE-Based Out-of-Distribution Detectors for Embedded Deployment

Aditya Bansal, Michael Yuhas, Arvind EaswaranRtcsa 2024

TL;DR

This paper tackles the challenge of deploying efficient out-of-distribution (OOD) detectors on resource-constrained embedded systems. The authors propose a novel methodology combining quantization, pruning, and knowledge distillation to significantly reduce the memory footprint and inference time of VAE-based OOD detectors, while maintaining high detection accuracy.

What Problem Does This Paper Address?

Machine learning models, especially those used in safety-critical applications like autonomous driving, often operate under a "closed-world assumption" – they are trained on data representative of normal conditions. However, in real-world deployments, these models frequently encounter "out-of-distribution" (OOD) data, which can be drastically different from the training set. This can lead to unpredictable and potentially unsafe behavior. OOD detectors are crucial for identifying these anomalous inputs and triggering safety mechanisms.

The primary challenge lies in deploying these OOD detectors on embedded systems. These systems have strict limitations on memory, processing power, and energy consumption. Deep neural networks, commonly used for OOD detection, are often too computationally expensive and memory-intensive for such environments. Variational Autoencoder (VAE)-based OOD detectors, which learn latent representations of data, are of particular interest due to their ability to learn interpretable features. However, compressing these VAEs without sacrificing their OOD detection performance is a non-trivial task, especially since the relationship between model loss and OOD detection accuracy isn't always straightforward.

Methods

The paper proposes a three-stage design methodology for compressing VAE-based OOD detectors:

  1. Quantization: This technique reduces the precision of model weights and activations (e.g., from 32-bit floating-point to 8-bit integers). This significantly reduces model size and can speed up computation, especially on CPUs. The authors explore dynamic quantization, static quantization, and quantization-aware training (QAT).
  2. Pruning Informed Knowledge Distillation: This stage focuses on training a smaller "student" model from a larger "teacher" model. The novelty here is the "pruning informed" aspect: they first prune the teacher model to identify less important layers, and then use these pruned architectures to train the student. This aims to reduce execution time by removing layers while retaining OOD detection capabilities.
  3. Final Pruning: After the initial compression, a binary search is employed to find the optimal sparsity level for the model, further reducing its size while ensuring it still meets the required accuracy threshold.

Crucially, the methodology generates two models: a 16-bit floating-point (fp16) model optimized for GPU inference and a quantized 8-bit (qint8) model for CPU inference, catering to the diverse hardware capabilities of embedded systems.

Datasets

The experiments were conducted using data collected from a miniature robotic platform called a Duckiebot deployed in a Duckietown environment. This environment simulated autonomous driving scenarios under varying ambient lighting conditions (low, medium, and high brightness).

  • In-distribution (ID) data: Low and medium brightness conditions.
  • Out-of-distribution (OOD) data: High brightness conditions.
  • Calibration set: Generated from ID data with rapidly fluctuating brightness to help the model identify latent variables corresponding to brightness.

For the optical flow OOD detector, the dataset was augmented with simulated rain and snow to create OOD samples.

Key Insights and Ideas

  • Compression techniques are synergistic: Combining quantization, pruning, and knowledge distillation yields greater benefits than applying them individually.
  • VAE loss vs. OOD performance: A low training loss in VAEs doesn't necessarily correlate with high OOD detection accuracy, and vice-versa. This decoupling is key to achieving compression without significant performance degradation.
  • Targeted compression: The methodology's ability to aggressively prune and compress models is attributed to the unique attributes of VAE-based OOD detection, particularly the reliance on latent space representations for OOD detection rather than reconstruction quality.
  • Hardware-specific optimization: Generating separate fp16 (GPU) and qint8 (CPU) models is essential for maximizing efficiency on diverse embedded hardware.
  • Pruning strategy matters: Unstructured pruning can lead to a drastic drop in AUROC, suggesting that structured, layer-wise pruning is more effective for VAE-based OOD detectors.

Key Results

The paper demonstrates significant improvements in memory footprint and execution time on a Jetson Nano embedded platform:

  • B-VAE OOD Detector:
    • Reduced execution time by 38% while AUROC dropped by only 1%.
  • Achieved a model size reduction of approximately 3.7 times due to quantization.
  • Optical Flow OOD Detector:
    • Reduced GPU inference time by 20% and CPU inference time by 28%, while keeping AUROC within 5% of the baseline.
  • Demonstrated that even with significant layer removal (down to a single convolutional layer), OOD detection performance could be maintained as long as the mean KL loss on OOD samples remained above that of ID samples.

Limitations and Future Work

  • OOD Sample Requirement: The proposed methodology requires access to OOD samples at design time for cross-validation. This might not always be feasible in real-world scenarios.
  • Optimality Guarantee: The greedy search approach guides the design process but does not guarantee the absolute optimum result.
  • Generalizability of OOD Distribution: The current approach assumes OOD samples arise from a particular generating distribution, which may not hold true in all general cases.

Future work could explore methods that do not require OOD samples during the design phase and investigate more robust architectural search strategies to guarantee optimality.

Summary updated

BibTeX
@inproceedings{bansal2024compressing,
  author = {Aditya Bansal and Michael Yuhas and Arvind Easwaran},
  title = {{Compressing VAE-Based Out-of-Distribution Detectors for Embedded Deployment}},
  booktitle = {Rtcsa},
  year = {2024},
  doi = {10.1109/rtcsa62462.2024.00015},
}
Figure