Repository navigation
fix(executors): keep the inherited launch paths at every prepend site - #1810
Conversation
9b3e0ef to
5bef0d5
Compare
PR #1810 -- fix(profile): keep the inherited PYTHONPATH on profile serversWhat it does: Magpie launches the benchmark server with Blocking issues: none Checked: LGTM |
|
Follow-up request: please fold the remaining launch-
Three of these also hardcode Same defect class, one level up: Scope stays at the two non-test files this PR already touches. Each site wants a test that fails without the change, the way the two fixed sites now have. |
Magpie launches the server with os.environ overlaid by the materialized config's benchmark.envs, so a PYTHONPATH in the config replaces the inherited one. Two profile-flow sites prepended to PYTHONPATH reading only the config: the TraceLens kernel_shape_tool step in materialization and the start-up shim in ProfileExecutor._inject_host_probe. When the config carried no PYTHONPATH they wrote one holding only their own entry, and the profile server lost the operator's private framework trees, the image's PYTHONPATH and the container wrapper paths. In 14 days of sessions, 89 of 93 roofline configs carried such a PYTHONPATH (71 shim-only, 16 shape tool plus shim on SGLang), while baseline/explore/integrate configs never set one, so only the profile server ran on a different import path. Both sites now go through prepend_launch_pythonpath, which builds on the config value when the key is present (the config stays authoritative) and on the inherited value otherwise, puts the new entry first, dedups and drops empty parts. The shim is therefore also moved to the front when it is already present further down, since Python imports only the first sitecustomize on the path. Co-Authored-By: Claude <noreply@anthropic.com>
…rlay The reference recipe's overlay_pythonpath was prepended to the config's PYTHONPATH only. Magpie and the bypass launcher overlay benchmark.envs on os.environ, so a config without PYTHONPATH launched with the overlay as its whole import path and lost the operator's and the image's entries. The join also hardcoded ":" instead of os.pathsep. The PR's prepend_launch_pythonpath already owns this rule for the profile sites (config value when the key is present, inherited value otherwise, new entries first, deduplicated, empty parts dropped). It becomes prepend_launch_path(envs, var, *entries) so the same rule serves PATH and LD_LIBRARY_PATH too; the shape-tool and shim sites move to it and the reference overlay goes through it. Overlay validation is unchanged. Co-Authored-By: Claude <noreply@anthropic.com>
apply_runtime_override (path_prefix, entrypoint_bin_dir, pythonpath_prefix, pythonpath_prefixes, ld_library_path_prefix) and the variant overlay_pythonpath in _build_variant_yaml prepended onto the config value only. When the config carried no such key, the launch got a PATH holding a single directory, an LD_LIBRARY_PATH without /opt/rocm/lib, or a PYTHONPATH without the operator's and the image's import paths, because the launcher lets a config key replace the inherited value. Three of the sites also joined with ":" rather than os.pathsep. Every site now goes through prepend_launch_path, which builds on the inherited value when the config lacks the key and keeps the config authoritative when it has it; _prepend_path_entry is deleted. The per-site validation and warn-and-drop behaviour is unchanged. Behaviour change: an entry already on the path is moved to the front instead of being left where it was, and PYTHONPATH prefixes are now deduplicated. Attempt PATH, LD_LIBRARY_PATH and PYTHONPATH entries are meant to win, so moving them up is the intended order. Co-Authored-By: Claude <noreply@anthropic.com>
5bef0d5 to
af9d909
Compare
|
Thanks, folded in as two commits on top of the reviewed one (rebased onto current main):
Validation and warn-and-drop behaviour at each site are unchanged; only the composition moved. One visible change, stated in the commit body: a prefix entry already present on the path now moves to the front instead of staying in place. Each site has a test that fails without the change (inherited value lost) and passes with it, plus a test that a config value stays authoritative. Cyclomatic complexity of every touched unit is unchanged ( Not touched, as it was not in the list: the xdit PATH guard in |
| """Inject an attempt runtime override into the materialized YAML envs dict.""" | ||
| if not override: | ||
| return | ||
| from ._workload_envs import prepend_launch_path |
| for k, v in variant.extra_envs.items(): | ||
| envs[str(k)] = str(v) | ||
| from ._workload_envs import pin_mlperf_round_concurrency | ||
| from ._workload_envs import pin_mlperf_round_concurrency, prepend_launch_path |
|
Re-review at head What it does: the launch env overlay means a config value for The new code is correct as far as I can check it: the helper's generalisation to Blocking issues: 1
Checked: |
xiaofei-zheng
left a comment
There was a problem hiding this comment.
Approving the code at head af9d9099477043a0a99872f68e601ccbbb2244cd. The description desync raised in my previous comment is being handled separately by the reviewer and is not a reason to hold the code.
Code conclusion: no blocking issues. prepend_launch_path has one definition and seven production call sites; no reference to the deleted _prepend_path_entry or to the earlier prepend_launch_pythonpath survives in the head tree; validate_overlay_pythonpath returns a single directory, so passing it as one entry is correct; the edits to the ten existing runtime-override test lines strengthen rather than weaken them (the multi-entry test now also pins that a config value is not appended to). Helper exercised directly over the seven input shapes the call sites produce, plus the reversed() multi-entry loop and the double-PATH-prepend sequence; output matches the added tests.
Not run: the suite at this head, locally. CI is green at af9d9099 across the full 6-shard x py3.10/3.11 matrix.
Run `python scripts/code_metrics.py --update-baseline` with the pinned tools (ruff 0.16.2, complexipy 8.0.1, vulture 2.16, jscpd 5.4.1 on node 22) after merging main: 1134 -> 1132 entries, 9 lowered. Main had improved these units since the branch's merge base (#1797, #1809, #1810 among them). Co-Authored-By: Claude <noreply@anthropic.com>
Description: Magpie and the bypass launcher start the benchmark server with
os.environoverlaid by the config'sbenchmark.envs, so a config path-list value replaces the inherited one. Every site that prepended toPYTHONPATH,PATHorLD_LIBRARY_PATHbuilt the new value from the config key alone, so a config without the key handed the server only the new entry and dropped the operator's and the image's entries.The profile flow is where this actually happens today: in 1,835 recent session configs only roofline configs set
PYTHONPATH(89 of 93: 71 shim only, 16 shape tool + shim), and a GLM-5.3 profile server imported the shared/sgl-workspacesglang instead of the operator's private sglang/aiter trees used by baseline and candidates. The grid and reference sites have the same defect but are latent (not exercised by current sessions).Fix: one helper,
prepend_launch_path(envs, var, *entries)in_workload_envs.py, owns the rule: build on the config value when the key is present, otherwise on the inherited value; put the new entries first; de-duplicate; drop empty parts; join withos.pathsep. Every prepend site uses it:kernel_shape_tool(SGLang) and the profile start-up shim (ProfileExecutor._inject_host_probe); the shim now moves to the front even when already present, since Python imports only the firstsitecustomize.--reference-script).apply_runtime_override(pythonpath_prefix,pythonpath_prefixes,path_prefix,entrypoint_bin_dir,ld_library_path_prefix) and the variantoverlay_pythonpath._prepend_path_entryis deleted, soPATHno longer collapses to a single directory andLD_LIBRARY_PATHkeeps/opt/rocm/libwhen the config lacks the key. Each site's validation and warn-and-drop behaviour is unchanged; only the composition moved.Linked issue(s): none (reported in an internal AgentX single-node defect note, item D3; grid/reference sites added at review request).
Tests: reproduction tests written first, failing on main and passing here, one per site: the inherited value survives when the config lacks the key (shape tool
<tool>:/a:/b, full profile chain<shim>:<tool>:/a:/b, reference overlay, each runtime-override field, variant overlay); a config value stays authoritative (<shim>:/c); a present entry moves to the front; re-arming is idempotent. Tests that asserted the old replace behaviour carry their contract across with the environment pinned explicitly. Related suites run locally on Windows; the failure set is identical to main (Windows path separator /fcntl). CI is the authoritative Linux run.Size/complexity triggers crossed: none; 3 commits, 4 non-test files. No touched unit's cyclomatic complexity rises (
materialize_config_with_envs111,apply_runtime_override17,_build_variant_yaml19).If this simplifies or refactors: removes
_prepend_path_entryand the hand-written joins at each site; one helper now owns "prepend to a launch path-list env".Observable effect: profile/roofline servers import the same trees as baseline and candidates; attempt runtimes, overlays and reference overlays keep the operator's and the image's
PYTHONPATH,PATHandLD_LIBRARY_PATHentries instead of silently replacing them. A prefix entry already present on the path now moves to the front instead of staying in place.Breaking changes: no
PR addresses single concern: yes
Root cause is upstream: no. Not touched: the xdit PATH guard in
_build_variant_yamluses the same config-only read, but the shipped xdit YAMLs pinPATH, so it is latent.🤖 Generated with Claude Code