Introduction
As foundation models continue to scale, deploying them on resource-constrained hardware becomes a significant engineering challenge. Model compression techniques, such as pruning and quantization, are essential for reducing memory footprints and increasing inference speeds. However, traditional optimization methods often rely on uniform heuristics that fail to account for the specific hardware bottlenecks of different architectures.
ProfilingAgent addresses this by introducing a multi-agent system powered by Large Language Models (LLMs) that automates the optimization process. By analyzing hardware profiling data, the system generates custom strategies that outperform standard heuristics, often maintaining or even improving model accuracy while significantly reducing size and latency.
The Model Compression Challenge
Traditionally, model compression is treated as a "black art." Researchers often use "blind" heuristics, such as L1-norm pruning, which removes weights based on magnitude. These rules ignore the actual hardware reality: a layer might have small weights but be a massive latency bottleneck, or vice versa. Manually tuning these strategies for diverse architectures like ResNets and Vision Transformers (ViTs) requires expert intuition and expensive trial-and-error.
Heuristic methods typically lead to high tuning times and suboptimal accuracy-latency trade-offs. ProfilingAgent shifts this paradigm by making the optimization process "profiling-aware," using real-world performance metrics to guide decision-making.
The ProfilingAgent Framework
The authors introduce a modular pipeline that replaces manual tuning with agentic reasoning. The system is divided into three primary components, each utilizing specialized LLM-based agents to handle specific tasks in the optimization lifecycle.
1. Profiling Component
This stage uses tools like the PyTorch Profiler to capture static metrics (parameter counts, MACs) and dynamic metrics (per-layer latency, memory footprint). The Analysis Agent (powered by GPT-4o) interprets these logs to identify specific performance bottlenecks that are not visible through weight analysis alone.
2. Optimization Component
Based on the profiling analysis, specialized agents generate machine-executable JSON plans for Structured Pruning and Post-Training Quantization (PTQ). Structured pruning removes entire channels or heads to ensure actual hardware speedup, while PTQ reduces numerical precision to save memory.
3. Iterative Pruning Component
To balance the trade-off between accuracy and speed, the system employs a closed-loop iterative process. The Iterative Pruning Agent evaluates the performance of a pruned model and refines the strategy for the next round, allowing the system to "think" through the optimization space dynamically.
Experimental Evaluation
The framework was evaluated on standard computer vision benchmarks, including ImageNet-1K, Imagenette, and CIFAR-10/100. The researchers tested a variety of architectures, including CNNs (ResNet-101) and Vision Transformers (ViT-B/16, Swin-B, and DeiT-B/16), to demonstrate the system's versatility across different model families.
Key Results and Insights
- Superior Efficiency: The system achieved up to 74% memory savings with an accuracy drop of less than 0.5% during quantization. It also delivered inference speedups of up to 1.74x.
- Pruning as a Regularizer: Remarkably, ProfilingAgent increased accuracy by up to +2% on ViT-B/16 after pruning. This suggests the agent effectively identifies and removes redundant features or "noise" that hinders model performance.
- Hardware-Awareness: By focusing on latency rather than just weight magnitude, the agent avoids the diminishing returns common in standard pruning, where parameter reduction does not translate to actual wall-clock time savings.
- LLM Reasoning Quality: The study found that the choice of LLM is critical. While GPT-4-Turbo was often too aggressive, leading to model collapse, GPT-4o provided stable, context-aware reasoning necessary for complex system optimization.
Conclusion
ProfilingAgent demonstrates that LLMs can function as sophisticated systems optimizers, capable of interpreting complex hardware logs to make engineering decisions that surpass human-designed rules. While challenges remain regarding the cost of high-end LLM API calls and the need to extend this logic to Large Language Models and Diffusion models, this work paves the way for a "Universal Optimization Agent" that can autonomously adapt any neural network for any target hardware.
Summary updated