e013afb2Add on 26 days agoHistory
README

Environment recipes (scripts/)

Reproducible Python environments for the EvoMO PyTorch rewrite plus a per-backend smoke test.

Verified host: AMD Instinct MI300X VF (gfx942), ROCm 7.1.0, driver/runtime 7.1.25424, single GPU, Python 3.12.3, uv 0.13.1 — uv is not on PATH, it lives at /root/.local/bin/uv (the scripts default to that path and honour UV=/path/to/uv).

file what it is
setup_env.sh (Re)creates both venvs from scratch with the pins below; re-runnable, needs network.
env.sh source-able shim: PATH, PYTHONPATH, PYTHON_A / PYTHON_LEGACY, and the ROCm/XLA variables.
smoke_backends.py One NSGA-II + DTLZ1 loop on one evoxc backend; prints compile s, ms/step and a Pareto-front number.
./scripts/setup_env.sh              # both environments (wipes and recreates them)
source scripts/env.sh               # env A: evox 2.0 / iree / xla
source scripts/env.sh --legacy      # env B: torch / legacy PyTorch evomo

python scripts/smoke_backends.py --backend numpy
python scripts/smoke_backends.py --backend iree
python scripts/smoke_backends.py --backend xla      # leaves via os._exit (see below)

Both scripts are cwd-sensitive: run them from the repository root (env.sh builds PYTHONPATH from $PWD).

Environment A — new stack (/tmp/evomo_env)

evox 2.0 is the evoxc-compiled rewrite; its PyPI installs are shadowed on purpose by the local checkouts /root/evox/src and /root/evoxc (PYTHONPATH="$PWD/src:/root/evox/src:/root/evoxc"), because those heads are newer than the published wheels (evox HEAD b8fcc58f = 2.0.0a1, evoxc HEAD 3481348 = 0.1.0).

package pin why
evox 2.0.0a1 PyPI fallback; the local /root/evox/src head wins via PYTHONPATH.
evoxc 0.1.0 PyPI fallback; the local /root/evoxc head wins via PYTHONPATH.
numpy 2.5.4 as installed on this host.
pytest 9.2.0 as installed on this host.
iree-base-compiler / iree-base-runtime 3.13.0 / 3.13.0 not 3.11.x — 3.11's iree-compile SIGSEGVs on while-heavy (MO/NSGA-II) StableHLO. They must match each other (artifacts are version-specific).
jax-rocm7-pjrt 0.10.2 not 0.11/0.12 — those link the ROCm pip "sysdeps" libraries this host does not ship, so the PJRT plugin fails its ABI gate. Ships jax_plugins/xla_rocm7/xla_rocm_plugin.so.

Install recipe (exactly what setup_env.sh runs):

uv venv --clear --python 3.12 /tmp/evomo_env
uv pip install --python /tmp/evomo_env/bin/python \
    numpy==2.5.4 pytest==9.2.0 evoxc==0.1.0 evox==2.0.0a1 \
    iree-base-compiler==3.13.0 iree-base-runtime==3.13.0 jax-rocm7-pjrt==0.10.2

There is no jax package in env A: only the ROCm PJRT plugin wheel is needed, and evox 2.0 never imports jax.

ROCm / XLA environment variables (and why each one is needed)

variable value why
EVOXC_PJRT_PLUGIN /tmp/evomo_env/lib/python3.12/site-packages/jax_plugins/xla_rocm7/xla_rocm_plugin.so evoxc drives XLA through the PJRT C API and no pip extra ships a plugin: the path is the only way the backend finds one. It is read when the plugin is loaded and re-read on the run path, so compile_options={"plugin_path": ...} alone is not enough.
XLA_FLAGS --xla_gpu_enable_command_buffer= HIP graph command buffers SIGSEGV inside PJRT_Executable_Execute with this plugin; every xla-rocm run must turn them off.
HIP_VISIBLE_DEVICES, ROCR_VISIBLE_DEVICES 0 Remap the MI300X to in-process device id 0, which is what StdWorkflow(device="rocm:0") addresses. Both the HIP runtime and ROCr below it read them at init, so they must be set before any evoxc import.
PYTHONPATH $PWD/src:/root/evox/src:/root/evoxc local evox/evoxc heads shadow the PyPI pins; $PWD/src is this checkout.
(process exit) os._exit() The PJRT plugin aborts during interpreter teardown after all work is done; without this a successful run reports Aborted / non-zero exit. smoke_backends.py flushes and calls os._exit(code).

LD_LIBRARY_PATH is not needed with jax-rocm7-pjrt==0.10.2: ldd on the plugin resolves every library against the system ROCm 7.1.0 install in /opt/rocm/lib (+ /opt/amdgpu/lib).

Environment B — legacy PyTorch baseline (/tmp/evomo_env_legacy)

package pin why
torch 2.9.1+rocm6.4 from https://download.pytorch.org/whl/rocm6.4. Pin the local segment: a bare torch==2.9.1 also matches PyPI's 2.9.1+cu128, which uv ranks higher and installs instead (~2 GB of nvidia-* wheels).
pytorch-triton-rocm 3.5.1 pulled by the torch wheel above.
evox 1.4.1 the legacy (PyTorch) evox.
numpy / pytest 2.5.4 / 9.2.0 as installed on this host.
uv venv --clear --python 3.12 /tmp/evomo_env_legacy
uv pip install --python /tmp/evomo_env_legacy/bin/python \
    --index-url https://download.pytorch.org/whl/rocm6.4 \
    --extra-index-url https://pypi.org/simple \
    numpy==2.5.4 pytest==9.2.0 evox==1.4.1 torch==2.9.1+rocm6.4

The legacy PyTorch evomo is not installed into env B — it is imported from the frozen snapshot in this checkout, benchmarks/legacy/src/evomo:

source scripts/env.sh --legacy            # PYTHONPATH=$PWD/benchmarks/legacy/src
$PYTHON_LEGACY -c "import torch, evomo.algorithms as a; \
  print(torch.__version__, torch.cuda.is_available(), torch.cuda.get_device_name(0), len(a.__all__))"
# 2.9.1+rocm6.4 True AMD Instinct MI300X VF 61

--legacy selects both the legacy venv and the legacy source path: $PWD/benchmarks/legacy/src, not $PWD/src. The latter is the 1.0 evomo tree, which has no torch code and would import the wrong library. That snapshot evomo is a namespace package (no __init__.py), so evomo.__file__ is None — do not use it as a path check; importing evomo.algorithms and reading len(a.__all__) (61) is the usable smoke test.

--legacy deliberately unsets EVOXC_PJRT_PLUGIN and XLA_FLAGS: inherited values would make a later evox 2.0 process load a plugin from the wrong venv.

Measured numbers

python scripts/smoke_backends.py --backend <id> — NSGA-II, pop_size=100, n_objs=3, d=10, lb=0, ub=1, DTLZ1, opt_direction=["min"]*3, seed 42, init + init_step + 22 steps (23 generations), 3 warmup generations, median of 3 timed runs of 20 generations. compile_s is the wall time of init() + init_step() (all three lazy graph builds; the plain step graph is built inside init).

backend evoxc device compile s ms/step verdict PF (last gen) honest status
numpy cpu 0.083 3.63 OK 17 points, mean f1 = 4.503896 reference implementation
iree (3.13.0) rocm:0 3.78 6.63 OK 1 point, mean f1 = 0.000000 compiles, runs, but numerically wrong (see below)
xla (0.10.2) rocm:0 2.84 0.76 OK 20 points, mean f1 = 1.673728 fastest; matches numpy

Run-to-run spread on this host: numpy 3.3–3.8 ms/step, iree 6.3–6.7 ms/step, xla 0.72–0.77 ms/step; compile times are stable to ±0.05 s.

All three rows were re-reproduced on venvs created by setup_env.sh from scratch (EVOMO_ENV_A=/tmp/evomo_env_check_a ./scripts/setup_env.sh and then EVOMO_ENV_A=/tmp/evomo_env_check_a source scripts/env.sh): identical compile times and identical Pareto numbers (numpy pf_n=17, pf_mean_f1=4.503896; xla pf_n=20, pf_mean_f1=1.673728), i.e. the recipe above — not the pre-existing venv state — is what makes the backends work.

iree on rocm:0 — MO verdict: compiles and runs, results are wrong

iree-base-* 3.13.0 does compile the MO NSGA-II/SBX/PM graph (the while-heavy non-dominated-sort class) for --iree-hal-target-backends=rocm on gfx942, device-resident, no while_loop-free rewrite needed — the upstream 3.11 defect really is fixed:

iree-base-* MO compile on ROCm outcome
3.11.0 no iree-compile SIGSEGV (exit -11) on the StableHLO program, 2/2 attempts.
3.13.0 yes (3.8 s) compiles, runs at 6.6 ms/step, 0 crashes in this session.

But the numbers are not trustworthy. Comparing generation 0 (identical RNG draw) against the numpy backend:

  • the 100x10 population tensors at generation 0 are bit-identical (np.array_equal → True); once the wrong objectives feed selection the population stops tracking numpy, as the benchmark records show (benchmarks/evoxc_vs_torch/results/mo_evomo_iree-rocm.json),
  • objective 1 is exact (max abs diff 3e-5, float32 rounding),
  • objectives 2 and 3 are wrong for 99/100 individuals, up to 467 absolute (e.g. numpy [3.886, 11.428, 488.169] vs iree [3.886, 8.584, 21.173]),
  • the consequence is visible in the smoke: the last-generation front collapses to 1 point with f1 = 0 instead of ~17–20 points.

The DTLZ1 objectives that break are the ones built from evox.problems.numerical.dtlz._reverse_axis1, i.e. evoxc.gather(x, arange(k-1, -1, -1), axis=1); objective 1 (0.5*(1+g), no gather) stays exact. So this looks like an iree gather miscompile on ROCm, not an evox/evoxc logic bug. numpy and xla agree (max fitness diff 6e-5 at generation 0, identical populations), which is the cross-check that isolates iree.

For the same reason, the iree PF number in the table (pf_n=1, f1=0) is meaningless — do not read it as "iree converged better".

numpy vs xla parity (informational)

Generation 0 is identical up to float32 rounding (populations bit-equal, max |Δf| = 6.1e-5). After a few generations the two runs diverge (generation 23: mean f1 41.59 numpy vs 39.30 xla) — tournament/crowding tie-breaking amplifies the last-bit differences. This is expected chaos, not a correctness signal; both fronts are equally converged.

Known failure modes (with the exact text) and their fixes

1. librocm_sysdeps_drm.so.2 — PJRT plugin ABI gate (the original blocker)

jax-rocm7-pjrt==0.12.0 (the current release) links ROCm's pip "sysdeps" trio, which exists in ROCm's own pip wheels but not in a system ROCm install (no librocm_sysdeps* anywhere under /opt/rocm*, /usr/lib or the venv):

evoxc.core.errors.BackendError: the PJRT plugin at
'/tmp/evomo_env/lib/python3.12/site-packages/jax_plugins/xla_rocm7/xla_rocm_plugin.so'
failed the ABI gate: failed to load the PJRT plugin library
'.../xla_rocm_plugin.so': librocm_sysdeps_drm.so.2: cannot open shared object file: No such file
or directory — point EVOXC_PJRT_PLUGIN or options['plugin_path'] at a plugin built from the
compatible PJRT C API header

ldd on that plugin reports three unresolved names: librocm_sysdeps_drm.so.2, librocm_sysdeps_drm_amdgpu.so.1, librocm_sysdeps_numa.so.1.

Fix: pin jax-rocm7-pjrt==0.10.2. The 0.9.2 / 0.10.2 / 0.11.2 plugins contain no librocm_sysdeps reference at all (verified by scanning the wheel payloads) and link only against system ROCm 7 libraries — 0.10.2 is the version the evox benchmark used, and it works.

Rejected alternatives (tried, do not work):

  • Symlinking the system libraries under the sysdeps names (librocm_sysdeps_drm.so.2 -> /opt/amdgpu/lib/x86_64-linux-gnu/libdrm.so.2, ..._drm_amdgpu.so.1 -> libdrm_amdgpu.so.1, ..._numa.so.1 -> libnuma.so.1) resolves the file names but not the symbol versions: /tmp/.../librocm_sysdeps_numa.so.1: version 'AMDROCM_SYSDEPS_1.0_libnuma_1.1' not found (required by .../xla_rocm_plugin.so).
  • There is no rocm-sysdeps distribution on PyPI (rocm-sdk-core there is a 0.1.0 stub); the real ROCm pip wheels live on repo.radeon.com and were not installed or tested here.
  • The shim path is also why nothing under /tmp/rocm_shim is part of the recipe.

2. iree-base-*==3.11.0 SIGSEGVs on the MO graph

evoxc.core.errors.BackendError: iree-compile failed to compile the StableHLO program for the iree
backend (targets: rocm): Error invoking IREE compiler tool iree-compile
Error code: -11
...
iree.compiler.tools.binaries.CompilerToolError: Error invoking IREE compiler tool iree-compile
Error code: -11
Diagnostics:
Please report issues to https://github.com/iree-org/iree/issues and include the crash backtrace.
Stack dump:
0.  Program arguments: .../iree-compile - --iree-input-type=stablehlo ...
    --iree-hal-target-backends=rocm ... --iree-rocm-target=gfx942
...
32  libIREECompiler.so ... ireeCompilerInvocationPipeline + 4247

Fix: iree-base-compiler==3.13.0 + iree-base-runtime==3.13.0 (both, in lockstep). This is also what the local evoxc head pins (>=3.13.0,<3.14); 3.11 is the version that shipped the nondeterministic IREE::Stream::AffinityAnalysis crash on stablehlo.while-heavy programs. Note the runtime side of 3.11 also aborted loop-carried int32 while/scan graphs on the ROCm HAL. Remember that the rest of the iree numerics are still broken (previous section).

3. torch==2.9.1 silently installs the CUDA build (and a mixed index list cannot pin ROCm)

torch==2.9.1 matches both 2.9.1+rocm6.4 (pytorch index) and 2.9.1+cu128 (PyPI); uv prefers the higher local version, so env B came up with torch 2.9.1+cu128 and 17 nvidia-* wheels. Pinning the local segment (torch==2.9.1+rocm6.4) inside a single command that also lists --extra-index-url https://pypi.org/simple fails too:

error: No solution found when resolving dependencies
  cause: Because there is no version of torch==2.9.1+rocm6.4 and you require torch==2.9.1+rocm6.4,
         we can conclude that your requirements are unsatisfiable.
hint: `torch` was found on https://pypi.org/simple, but not at the requested version
      (torch==2.9.1+rocm6.4). ... uv will only consider versions that are published on the first
      index that contains a given package ... use `--index-strategy unsafe-best-match`

Fix: two separate installs — torch from the ROCm index alone, then the rest from PyPI (evox only requires torch>=2.6.0, so the second step leaves the installed ROCm torch alone). setup_env.sh verifies torch.__version__.endswith("+rocm6.4") and pytorch-triton-rocm is present, and fails loudly otherwise.

4. Do not try to pip install the local evox / evoxc heads

pip install /root/evox (or /root/evoxc) fails in this sandbox: both build with setuptools / uv_build and write *.egg-info into the source tree, which is read-only here. Use PYTHONPATH=/root/evox/src:/root/evoxc instead (already in env.sh).

Notes and gotchas

  • Nothing in scripts/ writes outside /tmp and the repository; the venvs are the only artifacts.
  • smoke_backends.py re-executes itself once (EVOMO_SMOKE_ENV=<backend>) so the device/plugin variables are in the environment before any evoxc import; it is safe under timeout.
  • Smoke verdicts are machine-readable: the last line is BACKEND <id>: OK compile_s=... ms_per_step=... pf_n=... pf_mean_f1=... or BACKEND <id>: FAIL(<reason>), and the exit code is 0 only for OK.
  • full_fit_history=False means the Pareto check can only use the last generation, which is what smoke_backends.py reports; EvalMonitor.get_pf_fitness(latest=True) ranks that generation from a cache, while latest=False re-ranks the whole recorded history (O(n²) domination matrix, memory blow-up at larger populations).
  • EvalMonitorConfig is completed by the workflow (pop_size/dim/n_obj/multi_obj), so the multi_obj=True flag is redundant but explicit.
  • XLA prints TF_XLA_HSACO_CACHE_DIR is not set: HSACO file cache is disabled! on every run; it is a performance hint, not an error. Setting it to a /tmp directory would speed up recompiles.
  • CUDA is out of scope here (no NVIDIA GPU on this host).