-
Notifications
You must be signed in to change notification settings - Fork 7
add mlipx serve
#87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
add mlipx serve
#87
Conversation
This commit enhances the ZeroMQ-based serve infrastructure with several operational improvements and a new status monitoring command: **Reliability Improvements:** - Fix worker identity collision by adding hostname and random suffix - Add IPC socket cleanup on broker shutdown and startup - Add broker socket existence check before worker connection - Implement worker shutdown detection when broker disconnects **New Features:** - Add `mlipx serve-status` command with rich formatted output - Add `get_broker_status()` function for programmatic status checks **Benefits:** - Prevents "address already in use" errors from stale socket files - Provides clear error messages when broker is not running - Workers gracefully exit when broker stops instead of hanging - Easy troubleshooting with new status command 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a comprehensive ZeroMQ-based model serving infrastructure to mlipx, enabling remote execution of MLIP calculations with automatic dependency management and load balancing. The system provides transparent integration with existing mlipx code through environment variables and API extensions.
Key changes:
- Implements a broker-worker architecture using ZeroMQ for MLIP model serving
- Adds automatic dependency management via UV extras for model isolation
- Integrates serving capabilities directly into GenericASECalculator with fallback behavior
Reviewed Changes
Copilot reviewed 13 out of 14 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| pyproject.toml | Adds pyzmq and msgpack dependencies for ZeroMQ communication |
| mlipx/serve/worker.py | Implements worker processes that serve MLIP calculations via ZeroMQ |
| mlipx/serve/protocol.py | Provides protocol utilities for ZeroMQ communication with msgpack serialization |
| mlipx/serve/client.py | Client interface for connecting to MLIP servers via ZeroMQ broker |
| mlipx/serve/broker.py | Broker process for load balancing MLIP workers using LRU pattern |
| mlipx/serve/autostart_broker.py | Broker with automatic worker starting capabilities |
| mlipx/serve/init.py | Module initialization exposing serve API components |
| mlipx/recipes/models.py.jinja2 | Updates model definitions to include serve integration with extra dependencies |
| mlipx/nodes/generic_ase.py | Extends GenericASECalculator to support remote serving via get_calculator method |
| mlipx/cli/main.py | Adds CLI commands for serve-broker, serve, and serve-status |
| docs/source/concept/serve.rst | Documentation for the serve infrastructure |
| docs/source/concept/models.rst | Documentation updates for serve integration |
| docs/source/concept.rst | Adds serve to documentation index |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
mlipx/serve/worker.py
Outdated
| namespace = {"mlipx": mlipx} | ||
| exec(rendered_code, namespace) |
Copilot
AI
Oct 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using exec() with user-provided models file content poses a security risk. Consider implementing a safer approach using importlib or ast parsing, or at minimum add validation/sanitization of the input.
- Move pyzmq/msgpack to optional [serve] extra dependency - Add import guard with helpful error message for missing deps - Rename name -> serve_name for consistency across model classes (OrbCalc, MatglModel, FairchemModel, GenericASECalculator) - Add username to socket paths for user isolation on shared systems - Add cross-platform broker locking using flufl.lock - Fix race condition in autostart broker by processing frontend messages during worker startup wait loop - Add stderr capture for auto-started workers to log files - Improve CLI error styling with Rich console - Add comprehensive integration tests (14 new tests) - Update documentation with new features and troubleshooting guide 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
mlipx/cli/main.py
Outdated
| # Prevent infinite recursion | ||
| os.environ["_MLIPX_SERVE_UV_WRAPPED"] = "1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is that?
mlipx/cli/main.py
Outdated
| console.print(f"[dim]Command: {' '.join(cmd)}[/dim]") | ||
|
|
||
| os.execvp(cmd[0], cmd) # Replace current process | ||
| return # Never reached |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
??
This PR introduces
mlipx serveCLI tools for automatically serving MLIPs in dedicated environments.uvxsupportmodels.pyin current directory as default!