mirror of
https://github.com/NVIDIA/Model-Optimizer.git
synced 2026-10-14 05:00:00 +08:00
## Summary - Removed `PYTHONPATH="" python -I` override in `check_modelopt_local()` so the PYTHONPATH validation uses the actual environment instead of an isolated one - Moved the workdir log line earlier in `server.sh` for better debugging visibility ## Test plan - [x] Start `server.sh` inside a Docker container and verify it correctly detects editable-installed modelopt - [x] Confirm the workdir is logged before the modelopt check runs 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Chores** * Server startup now displays the configured work directory earlier in the initialization process, providing improved visibility of the active directory during server launch. * Simplified the modelopt validation check during server initialization while maintaining the same validation behavior. <!-- end of auto-generated comment: release notes by coderabbit.ai --> Signed-off-by: Chenjie Luo <chenjiel@nvidia.com>
File-Based Command Relay (Debugger)
A lightweight client/server system for running commands inside a Docker container from the host, using only a shared filesystem — no networking required.
Overview
Host (Claude Code) Docker Container
┌─────────────┐ ┌─────────────────┐
│ client.sh │ writes cmd file │ server.sh │
│ run "X" │ ───────────────────► │ detects cmd │
│ │ │ executes X │
│ reads │ writes result file │ writes result │
│ result │ ◄─────────────────── │ │
└─────────────┘ └─────────────────┘
└──── shared filesystem (.relay/) ────┘
Assumptions
- The ModelOpt repo is accessible from both host and container (e.g., bind-mounted)
- HuggingFace models are mounted at
/hf-local - The server auto-detects the repo root from the location of
server.sh
Quick Start
1. Start the server (inside Docker)
# The server auto-detects the repo root (two levels up from tools/debugger/)
bash /path/to/modelopt/tools/debugger/server.sh
The server automatically sets the working directory to the repo root. You can override with --workdir.
2. Connect from the host
bash tools/debugger/client.sh handshake
3. Run commands
# Run a simple command
bash tools/debugger/client.sh run "echo hello"
# Run a test script
bash tools/debugger/client.sh run "bash llm_ptq/scripts/huggingface_example.sh"
# Run with a long timeout (default is 600s)
bash tools/debugger/client.sh --timeout 1800 run "python my_long_test.py"
# Cancel a running command
bash tools/debugger/client.sh cancel
# Check status
bash tools/debugger/client.sh status
Protocol
The relay uses a directory at tools/debugger/.relay/ with this structure:
.relay/
├── server.ready # Written by server on startup
├── client.ready # Written by client during handshake
├── handshake.done # Written by server to confirm handshake
├── running # Written by server while a command is executing (cmd_id:pid)
├── cancel # Written by client to request cancellation of the running command
├── cmd/ # Client writes command .sh files here
│ └── <id>.sh # Command to execute
└── result/ # Server writes results here
├── <id>.log # stdout + stderr
└── <id>.exit # Exit code
Handshake
- Server starts, creates
.relay/server.ready - Client writes
.relay/client.ready - Server detects it, writes
.relay/handshake.done - Both sides are now connected
Command Execution
- Client writes a command to
.relay/cmd/<id>.sh - Server detects the file, reads the command content, and removes the
.shfile - Server runs
bash -c <content>in a new process group, writes.relay/running - Server writes
.relay/result/<id>.exitand.relay/result/<id>.log, then removes.relay/running - Client reads results and cleans up
Cancellation
- Client writes the target
cmd_idto.relay/cancel - Server verifies the
cmd_idmatches, then kills the command's process group - Server writes exit code 130 and removes
.relay/runningand.relay/cancel - Client-side timeout also triggers cancellation automatically
Options
Server
| Flag | Default | Description |
|---|---|---|
--relay-dir |
<script_dir>/.relay |
Relay directory path |
--workdir |
Auto-detected repo root | Working directory for commands |
Client
| Flag | Default | Description |
|---|---|---|
--relay-dir |
<script_dir>/.relay |
Relay directory path |
--timeout |
600 |
Seconds to wait for command result |
Notes
- The
.relay/directory is in.gitignore— it is not checked in. - Only one server should run at a time (startup clears the relay directory).
- Commands run sequentially in the order the server discovers them.
- A running command can be cancelled via
client.sh cancel. Cancelled commands exit with code 130. - Client-side timeouts automatically cancel the running command on the server.