Inspiration
Memory-constrained environments and the need for automatic optimization which is what we faced in our own jobs as ML Engineers pushing agents to production
What it does
Meridian is an AI-powered code optimization system that automatically adds compression/decompression statements to Python code, enabling it to run within tight memory limits while preserving exact computational results. The AI agent analyzes code and automatically inserts compression_manager.compress_variable() and decompress_variable() calls at optimal points, compressing variables immediately after transformation and decompressing only when needed. Our Streamlit app visualizes compression operations, memory bank state, and efficiency metrics in real-time, showing before/after comparisons where the first run fails and the second succeeds with compression.
How we built it
We built Meridian using Python 3.12+ with the uv package manager, integrating Anthropic Claude API (Haiku model) for AI-powered code optimization and Daytona SDK for secure sandbox execution. The core architecture consists of six main components: a compression manager using Zstandard (levels 1-22), an AI code optimizer agent with few-shot learning, a memory-constrained environment that automatically compresses variables
Challenges we ran into
The AI agent was initially too slow (7-10 seconds) due to verbose prompts, so we simplified prompts by 80%, reduced max_tokens from 4096 to 2048, added caching, and implemented skip logic for simple cases. When code failed even after compression with tight memory limits, we improved the strategy to compress ALL variables, try recompression with higher levels, and provide better error messages with actionable suggestions.
Accomplishments that we're proud of
We built a complete end-to-end system from compression engine to AI agent to visualization, creating an intelligent memory management agent that automatically optimizes code for memory constraints while preserving computational equivalence.
What we learned
We learned that compression preserves exact values and maintains computational equivalence, while deletion + recomputation breaks equivalence with random state, making compression superior for memory-constrained execution. Simplified prompts with clear examples are faster and more effective than verbose instructions - we reduced tokens by 80% while improving results. When memory is tight, we discovered that compressing ALL variables immediately works better than compressing just until there's enough space.
What's next for Meridian
e plan to implement advanced compression strategies including variable lifetime analysis and predictive compression based on usage patterns, while supporting different compression algorithms (LZ4, Brotli) for different data types. The AI agent will be enhanced with fine-tuning on optimization examples, cost-benefit analysis (compression time vs memory saved), and support for more optimization patterns like in-place operations and generators. We'll extend language support to Rust, Go, and Swift with language-specific optimization patterns, and add production features like API deployment, authentication, and CI/CD pipeline integration.
Built With
- anthropic
- daytona
- langchain
- python
- streamlit
Log in or sign up for Devpost to join the conversation.