Skip to content

Latest commit

 

History

History
149 lines (109 loc) · 3.42 KB

DEV_README.md

File metadata and controls

149 lines (109 loc) · 3.42 KB

⚠ Opt-in iteration loop. All PRs must additionally pass make docker-test (see CONTRIBUTING.md). This page describes a faster local edit-test cycle, not a substitute for the canonical Docker test path.

Morphling Development Workflow

This workflow lets you iterate on Morphling with a single Docker image build and incremental rebuilds inside a long-running container. Source code is bind-mounted into the container, and build output is cached in a Docker volume. Before opening a PR, verify your change passes make docker-test against a freshly-built image — the bind-mount loop is for fast iteration only.

Quick Start

1. Build the base image (one-time)

./dev.sh build

2. Start the dev container

./dev.sh start

3. Enter the container

./dev.sh shell

4. Test your changes

# If you changed C++ code, rebuild
./scripts/dev_build.sh

# Or rebuild from the host
./dev.sh rebuild

# Run a test workload
python3 scripts/run_devices.py \
  --num_devices 4 \
  --model_name facebook/opt-125m \
  --backend proxy \
  --seq_length 128 \
  --batch_size 1 \
  --cfg config/proxy/svr.ini

Why this workflow

  • Source code is mounted into the container, so edits apply immediately.
  • Incremental C++ builds use a Docker volume cache.
  • The dev container provides a consistent environment.

Available Commands

Command Description
./dev.sh build Build the Docker image
./dev.sh start Start the dev container
./dev.sh stop Stop the container
./dev.sh restart Restart the container
./dev.sh shell Open a shell in the container
./dev.sh rebuild Rebuild inside the container
./dev.sh run <cmd> Run a command in the container
./dev.sh logs View container logs
./dev.sh clean Remove containers and volumes

Common Development Flows

Edit C++ code

  1. Modify files under csrc/.
  2. Run ./dev.sh rebuild.
  3. Test with ./dev.sh run python3 scripts/run_devices.py ....

Edit Python code

  1. Modify files under morphling/.
  2. Run your tests directly. Python changes take effect immediately after the first ./dev.sh rebuild, which installs the package in editable mode (pip install -e .) against the bind-mounted source.

Debugging

./dev.sh shell

export SPDLOG_LEVEL=debug

SPDLOG_LEVEL=debug python run_devices.py \
  --num_devices 4 \
  --model_name facebook/opt-125m \
  --backend proxy \
  --seq_length 128 \
  --batch_size 1 \
  --cfg ../config/proxy/svr.ini 2>&1 | tee server.log

Bind Mounts

These host directories are mounted into the container:

  • ./csrc -> /app/csrc
  • ./morphling -> /app/morphling
  • ./scripts -> /app/scripts
  • ./config -> /app/config
  • ./logs -> /app/logs
  • morphling_build volume -> /app/build

Environment Variables

  • MORPHLING_DEV_MODE=1: enable dev mode
  • SPDLOG_LEVEL=debug: set log verbosity

Notes

  1. The first build can take a while.
  2. Build output is cached in a Docker volume; deleting the volume clears cache.
  3. If you hit permission errors, ensure Docker can access the repo.
  4. Ensure ports 8080, 443, 39000, and 28516 are available.

Troubleshooting

Build fails

./dev.sh clean
./dev.sh build

Permission errors

ls -la scripts/
chmod +x scripts/*.sh

Port conflicts

lsof -i :28516
# Or update port mappings in dev.sh