Skip to content

build_orchestrator: merge model-card slurm/distributed config in the main build path#152

Open
i-kosarev wants to merge 3 commits into
ROCm:fix/slurm-sglang-disagg-co-located-proxyfrom
i-kosarev:fix/slurm-sglang-disagg-co-located-proxy
Open

build_orchestrator: merge model-card slurm/distributed config in the main build path#152
i-kosarev wants to merge 3 commits into
ROCm:fix/slurm-sglang-disagg-co-located-proxyfrom
i-kosarev:fix/slurm-sglang-disagg-co-located-proxy

Conversation

@i-kosarev

@i-kosarev i-kosarev commented Jul 8, 2026

Copy link
Copy Markdown

Problem

_execute_with_prebuilt_image() already merged the first discovered model's slurm/distributed fields into manifest deployment_config, letting the run phase auto-detect target=slurm from the model card alone. The normal build-from-Dockerfile path (used whenever images are actually built from source, not --use-image) never did this merge -- it only called _save_deployment_config(), which populates deployment_config purely from --additional-context.

A model card with a real "slurm": {...} config but no matching --additional-context override was silently ignored: deployment_config.slurm stayed unset, _infer_deployment_target() fell back to "local", and on GPU-less nodes (e.g. a SLURM login node used only to submit jobs) this caused GPU detection failed: Unable to determine gpu vendor instead of dispatching via sbatch.

Fix

Extract the merge logic into _merge_model_config_into_deployment() and call it from both build paths right after _save_deployment_config().

Copilot AI review requested due to automatic review settings July 8, 2026 16:30

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 aims to prevent runtime GPU auto-detection from failing on SLURM login nodes (where no local GPU is present) by reusing GPU vendor information already recorded in the build manifest, allowing runs to proceed far enough to be dispatched to GPU compute nodes. It also reduces the risk of node-info commands hanging by bounding package-manager queries.

Changes:

  • Pre-load gpu_vendor (and related GPU docker env vars) from the build manifest into additional_context before runtime context initialization.
  • Add a 10-second timeout to host package-manager queries in _show_node_info().

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

Comment thread src/madengine/orchestration/run_orchestrator.py Outdated
Comment thread src/madengine/orchestration/run_orchestrator.py
Comment thread src/madengine/orchestration/run_orchestrator.py Outdated
…main build path too

_execute_with_prebuilt_image() already merged the first discovered model's
"slurm"/"distributed" fields into manifest deployment_config, letting the
run phase auto-detect target=slurm from the model card alone. The normal
build-from-Dockerfile path (the one actually used when building images
from source, e.g. any CI run that isn't --use-image) never did this merge
-- it only called _save_deployment_config(), which populates
deployment_config purely from --additional-context. A model card with a
real "slurm" config but no matching --additional-context override was
silently ignored: deployment_config.slurm stayed unset,
_infer_deployment_target() fell back to "local", and on GPU-less nodes
(e.g. a SLURM login node used only to submit jobs) this caused
"GPU detection failed: Unable to determine gpu vendor" instead of
dispatching via sbatch.

Extract the merge logic into _merge_model_config_into_deployment() and
call it from both build paths right after _save_deployment_config().
@i-kosarev
i-kosarev force-pushed the fix/slurm-sglang-disagg-co-located-proxy branch from 32142bf to 183b679 Compare July 22, 2026 13:47
Copilot AI review requested due to automatic review settings July 22, 2026 13:47
@i-kosarev i-kosarev changed the title run_orchestrator: pre-load gpu_vendor from manifest to fix SLURM login node runs build_orchestrator: merge model-card slurm/distributed config in the main build path Jul 22, 2026

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@i-kosarev
i-kosarev marked this pull request as draft July 22, 2026 15:42
@i-kosarev
i-kosarev requested a review from Copilot July 23, 2026 12:32

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

src/madengine/orchestration/run_orchestrator.py:774

  • _show_node_info() now relies on the external timeout binary being present. On minimal images/nodes where timeout (coreutils) isn’t installed, these commands will fail immediately and the node info output becomes less useful. Since Console.sh() already supports a timeout= parameter, consider using that and catching the timeout exception so this debug/info path remains best-effort without adding a runtime dependency on timeout.
        host_os = self.context.ctx.get("host_os", "")
        if "HOST_UBUNTU" in host_os:
            print(self.console.sh("timeout 10 apt show rocm-libs -a", canFail=True))
        elif "HOST_CENTOS" in host_os:
            print(self.console.sh("timeout 10 yum info rocm-libs", canFail=True))
        elif "HOST_SLES" in host_os:
            print(self.console.sh("timeout 10 zypper info rocm-libs", canFail=True))
        elif "HOST_AZURE" in host_os:
            print(self.console.sh("timeout 10 tdnf info rocm-libs", canFail=True))

Comment thread src/madengine/orchestration/build_orchestrator.py
@i-kosarev
i-kosarev marked this pull request as ready for review July 23, 2026 13:27
…m merge

Copilot review on PR ROCm#152 pointed out that _execute_with_prebuilt_image and
_execute_build_on_compute both have coverage locking in the
deployment_config.slurm/distributed merge, but the normal build-from-
Dockerfile path (BuildOrchestrator.execute(), used by any CI run that isn't
--use-image/--build-on-compute) had none -- which is exactly the path where
the original bug shipped undetected.

Add TestMainBuildPathDeploymentConfigMerge, mirroring the existing
TestPrebuiltImageManifestShape / TestBuildOnComputeManifestShape pattern:
stub a BuildOrchestrator, patch DiscoverModels to return a model card with a
real "slurm"/"distributed" config and no matching --additional-context, and
assert manifest deployment_config picks both up after execute() runs.
build_all_models is patched to a no-op summary since the merge only depends
on the discovered models list, not on build success/failure.

Verified this test fails with KeyError: 'deployment_config' against the
pre-fix code (38bb9dd) and passes after the _merge_model_config_into_deployment
fix.
Copilot AI review requested due to automatic review settings July 23, 2026 14:11

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

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (6)

src/madengine/orchestration/build_orchestrator.py:1264

  • deployment_config["distributed"] may already exist but not be a dict (or may be None). In that case, key not in saved_manifest["deployment_config"]["distributed"] will raise a TypeError. Ensure it's a dict before merging model_distributed.
            if "distributed" not in saved_manifest["deployment_config"]:
                saved_manifest["deployment_config"]["distributed"] = {}

src/madengine/orchestration/build_orchestrator.py:1288

  • deployment_config["slurm"] may already exist but not be a dict (or may be None). In that case, assigning keys into it will raise a TypeError. Ensure it's a dict before merging model_slurm.
            if "slurm" not in saved_manifest["deployment_config"]:
                saved_manifest["deployment_config"]["slurm"] = {}

src/madengine/orchestration/run_orchestrator.py:768

  • Prefer using Console.sh's built-in timeout parameter instead of shelling out to the external timeout utility (which may not exist on all distros/containers). This also keeps the printed command clearer.
            print(self.console.sh("timeout 10 apt show rocm-libs -a", canFail=True))

src/madengine/orchestration/run_orchestrator.py:770

  • Same as above: use Console.sh(timeout=10) rather than prefixing the command with timeout 10.
            print(self.console.sh("timeout 10 yum info rocm-libs", canFail=True))

src/madengine/orchestration/run_orchestrator.py:772

  • Same as above: use Console.sh(timeout=10) rather than prefixing the command with timeout 10.
            print(self.console.sh("timeout 10 zypper info rocm-libs", canFail=True))

src/madengine/orchestration/run_orchestrator.py:774

  • Same as above: use Console.sh(timeout=10) rather than prefixing the command with timeout 10.
            print(self.console.sh("timeout 10 tdnf info rocm-libs", canFail=True))

Comment thread src/madengine/orchestration/build_orchestrator.py Outdated
Comment thread tests/unit/test_slurm_multi.py
…lues

Copilot review: _merge_model_config_into_deployment assumed
manifest["deployment_config"] (and its "distributed"/"slurm" sub-keys) were
always dicts. If a manifest came from a less-trusted source (e.g. a
hand-edited --manifest-file passed to `madengine run`) and one of those
fields was some other JSON type, the subsequent `[...][key] = value` writes
would raise TypeError instead of failing gracefully. Reset to {} whenever
the existing value isn't a dict, at all three levels (deployment_config
itself, deployment_config.distributed, deployment_config.slurm).

Also hardens the new regression test's BuildOrchestrator stub: execute()
reads args.target_archs/args.live_output via getattr(), and a bare
MagicMock attribute is truthy and non-list, which could silently change
control flow (multi-arch build loop) in future refactors. Set explicit
values so the test deterministically exercises the single-arch path.
Copilot AI review requested due to automatic review settings July 23, 2026 14:48

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

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

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