Skip to content

feat(bare-metal): add conda-based bare-metal execution backend [WIP]#153

Draft
coketaste wants to merge 3 commits into
developfrom
coketaste/bare-metal
Draft

feat(bare-metal): add conda-based bare-metal execution backend [WIP]#153
coketaste wants to merge 3 commits into
developfrom
coketaste/bare-metal

Conversation

@coketaste

Copy link
Copy Markdown
Collaborator

Summary

Adds a non-Docker execution path that runs models directly on the host inside a conda/mamba environment, as an alternative to the existing Docker/K8s/SLURM targets.

  • Target is inferred from a "bare_metal" key in additional_context (highest precedence over slurm/k8s).
  • CondaEnvManager (new conda_env.py) handles env lifecycle: create/update/reuse, conda_run_prefix, and env name resolution (config/model/derived fallback).
  • BareMetalRunner (new bare_metal_runner.py) mirrors ContainerRunner's manifest/run interface: wraps scripts in conda run, handles GPU visibility env vars, pre/post scripts, and perf.csv reporting.
  • New run_reporting.py factors out Docker-independent performance extraction, status determination, and perf.csv/perf_super writing (shared by both container and bare-metal paths).
  • BuildOrchestrator gains _execute_bare_metal_build, which creates conda envs and writes a synthetic manifest (no Docker build involved).
  • RunOrchestrator routes the bare_metal target to BareMetalRunner.
  • discover_models.py carries new model fields: conda_env, environment_file, python_version, setup_script, with path normalization.
  • Env dependency setup can now also:
    • Install ROCm userspace (and torch) pip wheels from TheRock's per-arch index (rocm.index_url=auto resolves to the gfx-arch index via a new gpu_arch param on CondaEnvManager).
    • Install a plain requirements_file.
    • Invalidate env reuse via a dependency-file content hash, so changed deps trigger reinstall instead of silently reusing a stale env.
  • Added a dummy_bare_metal fixture model and a hermetic e2e test. Since CI has no real conda, a checked-in fake_conda.sh shim execs the wrapped command directly; the test asserts the run routes through the bare-metal path (deployment_type=bare_metal, launcher=conda) and extracts performance from the log.

Test plan

  • tests/unit/test_bare_metal.py — conda env manager, ROCm index resolution/wheel install, requirements install, dep-hash reuse invalidation
  • tests/e2e/test_run_workflows.py — bare-metal end-to-end run via dummy_bare_metal fixture
  • tests/integration/test_console_integration.py, tests/unit/test_slurm_multi.py — related coverage
  • pytest full suite

coketaste and others added 3 commits July 7, 2026 15:17
Add a non-Docker execution path that runs models directly on the host
inside a conda/mamba environment. Target is inferred from a "bare_metal"
key in additional_context (highest precedence over slurm/k8s).

- conda_env: CondaEnvManager for env lifecycle (create/update/reuse) and
  conda_run_prefix; resolve_conda_env_name with config/model/derived fallback
- bare_metal_runner: BareMetalRunner mirrors ContainerRunner's manifest/run
  interface, wraps scripts in `conda run`, handles GPU visibility env,
  pre/post scripts, and perf.csv reporting
- run_reporting: shared Docker-independent performance extraction, status
  determination, and perf.csv/perf_super writing
- build_orchestrator: _execute_bare_metal_build creates conda envs and writes
  a synthetic manifest (no Docker build)
- run_orchestrator: route "bare_metal" target to BareMetalRunner
- discover_models: carry conda_env/environment_file/python_version/setup_script
  model fields with path normalization

Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
Add a dummy_bare_metal model to the dummy fixture plus a hermetic e2e test
exercising the conda execution backend end-to-end. Since CI has no real
conda, a checked-in fake_conda.sh shim execs the wrapped command directly;
the test points bare_metal.conda_bin at its absolute path (required because
the runner cd's into the model working dir before invoking conda).

The test asserts the run routes to the bare-metal path (deployment_type=
bare_metal, launcher=conda) and that performance is extracted from the log.

Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
…hash reuse invalidation

Extend the conda-based bare-metal backend so a model's dependency setup can
pull ROCm userspace (and torch) pip wheels from TheRock's per-arch index,
install a plain requirements.txt, and invalidate env reuse when dependency
file content changes.

- conda_env.py: add resolve_rocm_index_url ("auto" -> gfx-arch index),
  _install_rocm_wheels, requirements_file support, and content-hash stamp
  reuse-invalidation. create_or_update pipeline is now create/reuse env ->
  [rocm.enabled] rocm+torch -> [requirements_file] pip install -> setup_script,
  each step optional and additive. ROCm wheels stay skip-on-reuse.
- CondaEnvManager gains a gpu_arch param (falls back to bare_metal.gpu_arch)
  to resolve rocm.index_url=auto.
- build_orchestrator.py / bare_metal_runner.py: pass gpu_arch from
  docker_env_vars[MAD_SYSTEM_GPU_ARCHITECTURE]; add rocm/requirements_file to
  the manifest built_models entry.
- tests: cover index resolution, rocm wheel install (default/torch/custom),
  fresh-install vs skip-on-reuse, requirements install + missing-file error,
  and dep-hash reuse invalidation; isolate stamp writes to tmp.

Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
@coketaste coketaste self-assigned this Jul 9, 2026
Copilot AI review requested due to automatic review settings July 9, 2026 14:18
@coketaste coketaste changed the title feat(bare-metal): add conda-based bare-metal execution backend feat(bare-metal): add conda-based bare-metal execution backend [WIP] Jul 9, 2026
@coketaste
coketaste marked this pull request as draft July 9, 2026 14:19

Copilot AI left a comment

Copy link
Copy Markdown

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 new “bare-metal” execution backend that runs model scripts directly on the host inside a conda/mamba environment, as an alternative to the existing Docker/K8s/SLURM paths.

Changes:

  • Adds a conda environment manager and a bare-metal runner, plus routing in build/run orchestrators.
  • Factors out Docker-independent run reporting (performance extraction, status determination, perf.csv/perf_super writing).
  • Adds a dummy bare-metal fixture and unit/e2e coverage (including a fake conda shim for CI).

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
tests/unit/test_bare_metal.py Unit tests for conda env lifecycle, vendor file resolution, ROCm wheel install, dep-hash reuse invalidation, and reporting helpers
tests/fixtures/dummy/scripts/dummy_bare_metal/run.sh Dummy bare-metal model script emitting a performance line
tests/fixtures/dummy/scripts/dummy_bare_metal/fake_conda.sh Fake conda shim used to exercise bare-metal routing in CI without real conda
tests/fixtures/dummy/models.json Adds dummy_bare_metal model fixture with conda fields
tests/e2e/test_run_workflows.py Adds an e2e test validating bare-metal routing and perf extraction
src/madengine/utils/discover_models.py Adds bare-metal model fields and path normalization for new dependency/setup files
src/madengine/orchestration/run_orchestrator.py Routes bare_metal deployments to the new BareMetalRunner path
src/madengine/orchestration/build_orchestrator.py Adds bare-metal “build” phase that creates/updates conda envs and writes a synthetic manifest
src/madengine/execution/run_reporting.py New shared reporting helpers for perf/status + perf.csv/perf_super writing
src/madengine/execution/conda_env.py New conda/mamba/micromamba env manager with dependency hashing and ROCm wheel install support
src/madengine/execution/bare_metal_runner.py New bare-metal runner that wraps script execution in conda run and emits perf records

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

)

try:
script_path, working_dir, interpreter = self._resolve_script(model_info)
Comment on lines +511 to +516
write_perf_records(
run_details,
model_info,
self.perf_csv_path,
run_results.get("status", "FAILURE"),
)
"docker_image": "",
"dockerfile": "N/A (bare-metal mode)",
"build_status": "SUCCESS",
"build_time": 0,
cache_dir = os.path.join(
os.path.expanduser("~"), ".cache", "madengine", "envhash"
)
return os.path.join(cache_dir, env_name)
Comment on lines +240 to +242
if os.path.isfile(configured) or shutil.which(configured):
self._conda_bin = configured
return self._conda_bin


def bootstrap_micromamba() -> str:
"""Download a pinned micromamba static binary when no conda/mamba exists.
Comment on lines +1408 to +1411
from madengine.execution.conda_env import (
CondaEnvManager,
resolve_conda_env_name,
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants