
Shifting from Model-First to Module-First architecture to empower both human engineers and autonomous AI agents.
Debugging large distributed ML models often requires re-running entire multi-GPU pipelines just to test a single submodule edit. ModuleLens solves this by capturing runtime weights and tensor I/O into isolated, reproducible modules that can be reloaded locally in seconds. Beyond drastically reducing developer iteration cycles, it serves as an execution substrate for AI agents like Claude Code to autonomously refactor code and generate custom GPU kernels.
Highly recommended for ML Infrastructure teams facing slow iteration loops in multi-GPU distributed training, as well as teams looking to integrate AI agents into automated kernel synthesis and model optimization workflows.
Modern large-scale recommendation systems rely on Distributed Model Parallelism (DMP) across multiple GPUs, making local single-GPU execution impossible. Modifying downstream sub-modules required re-running the entire multi-GPU pipeline to capture realistic input data, resulting in severely slow iteration feedback loops and wasted compute.
Pinterest developed ModuleLens, shifting from a legacy 'Model-First' approach to an isolated 'Module-First' framework. Using non-intrusive PyTorch forward hooks and in-memory init tracking, ModuleLens captures module parameter weights and tensor I/O into a WandB Registry-backed ModuleRepo, enabling human engineers (CLI/Jupyter) and AI agents (Claude Code, Cursor) to reconstruct modules locally in seconds.
Engineers can isolate and profile targeted PyTorch modules locally within seconds, drastically accelerating iteration loops. Furthermore, ModuleLens powers internal tools like Training Analyzer and KernelAgent, providing an execution substrate for AI agents to autonomously synthesize, benchmark, and optimize GPU kernels.
Trade-off
Capturing module traces introduces runtime GPU overhead, which ModuleLens mitigates by running early-stop callbacks after model warmup. For massive tensors, it relies on shape-only logging, requiring synthetic tensor construction during restoration which may not reflect real input distributions.
An engineering approach that isolates individual sub-modules from large neural network architectures to enable independent profiling and execution without initializing the full model. This eliminates multi-GPU dependencies for local testing.
A runtime tracer that non-intrusively captures parameter weights, I/O tensors, and initialization arguments from PyTorch modules using forward hooks and import patching. It minimizes GPU overhead using early-stop callbacks after warmup.
An LLM-driven agent framework designed to synthesize high-performance GPU kernels (e.g., Triton/CUDA). It utilizes captured ModuleLens inputs and baseline outputs to benchmark and validate kernel speed and accuracy.




