Run a QDpy seed sweep with Rundra ================================= Each Rundra task in this example runs MAP-Elites with a different seed and writes its own archive. The search minimises normalised Rastrigin fitness and uses the first two genome coordinates as descriptors. Rundra stages the script and configuration, supplies a seed, and retrieves the results. The example uses Rundra 0.1.7 and a QDpy checkout with the JSON run manifest API. See the `Rundra project `__. Run a seed locally ------------------ From the QDpy checkout, create an environment for QDpy and install Rundra as a separate command. The native target runs the Python interpreter on your active ``PATH``. .. code-block:: bash uv venv --python 3.12 source .venv/bin/activate uv pip install . uv tool install --python 3.12 'rundra==0.1.7' cd examples/rundra rundr plan experiment-local.yaml --targets-file targets-local.yaml --seed 0 rundr run experiment-local.yaml --targets-file targets-local.yaml --seed 0 \ --destination ../../build/rundra-local python summarize.py ../../build/rundra-local --runs 1 The native target runs one task at a time with ``rundr run``. The default configuration, ``pilot.yaml``, evaluates 128 candidates with a batch size of 32 in a 32 × 32 grid. The experiment passes the resolved configuration and seed to ``search.py``. The script writes ``run.json`` and a sibling ``archive-.json``. The summary checks that each search exhausted its budget, verifies the archive fingerprints, and reports results by seed. Prepare a Slurm image --------------------- The Shoal examples use a prebuilt ``qdpy-ray.sif`` with Python 3.12, QDpy, Ray 2.60.0 and gRPC. The same image works for sequential sweeps and for Ray evaluation. Build it on a Linux x86-64 Apptainer host or use a cluster build allocation. The commands below run from the QDpy checkout and assume ``python3.12 -m pip`` is available. Keep the checkout, wheelhouse, and image on a filesystem visible to the compute nodes. .. code-block:: bash wheelhouse="$PWD/build/shoal-wheels" image="$PWD/build/qdpy-ray.sif" mkdir -p "$wheelhouse" uv build --wheel --out-dir "$wheelhouse" python3.12 -m pip download --only-binary=:all: --dest "$wheelhouse" \ "$wheelhouse"/qdpy-*.whl 'ray==2.60.0' grpcio (cd "$wheelhouse" && sha256sum -- *.whl > SHA256SUMS) apptainer build --fakeroot --build-arg "WHEELHOUSE=$wheelhouse" \ "$image" examples/rundra/qdpy.def Use an empty wheelhouse for each build so pip takes the intended QDpy wheel. On Shoal, run the Apptainer build on a compute node. The recipe checks the wheel hashes and installs packages from the wheelhouse inside the build. Save the image hash and wheel manifest with your results. See the `Apptainer definition file guide `__. Submit and retrieve the sweep ----------------------------- The ``shoal`` profile in ``rundra.yaml`` selects a target of the same name. Use your existing Rundra target or save this example as ``~/.config/rundra/targets.yaml``, replacing the SSH host and workspace with values for your account. .. code-block:: yaml version: 1 targets: shoal: transport: {type: ssh, host: fishvision} scheduler: {type: slurm} staging: {type: rsync} container: {type: apptainer} workspace: /shoalhome/YOUR_USERNAME/.rundra In ``experiment-shoal.yaml`` and ``experiment-shoal-ray.yaml``, replace ``/shared/qdpy-ray.sif`` with the absolute image path visible to all compute nodes. See the `Rundra Slurm setup guide `__. From ``examples/rundra``, point ``targets`` at your target file. Use the Run ID printed by ``submit`` in the following commands. The seed range ``0:1`` includes both endpoints. .. code-block:: bash targets="$HOME/.config/rundra/targets.yaml" rundr doctor experiment-shoal.yaml --profile shoal --targets-file "$targets" --connect rundr plan experiment-shoal.yaml --profile shoal --targets-file "$targets" --seeds 0:1 rundr submit experiment-shoal.yaml --profile shoal --targets-file "$targets" --seeds 0:1 run_id=RUN_ID rundr wait "$run_id" --progress rundr fetch "$run_id" --mode copy --destination ../../build/rundra-shoal python summarize.py ../../build/rundra-shoal --runs 2 The Shoal pilot with seeds 0 and 1 produced the following results. .. list-table:: :header-rows: 1 * - Seed - Evaluations - Occupied cells - Best fitness * - 0 - 128 - 85 - 0.173643 * - 1 - 128 - 77 - 0.149783 Use ``rundr inspect "$run_id"`` to review the recorded inputs and scheduler jobs, and ``rundr logs "$run_id" --task task_000000`` to investigate a failed search. Once the pilot succeeds, select ``--config sweep.yaml --seeds 0:99`` for 100 independent searches of 50,000 evaluations each. The historical Shoal sweep completed all five million evaluations with four worker allocations and 25 single-CPU task slots per allocation. Worker counts and slot limits depend on your target. On a target that allows this allocation, plan the equivalent sweep with the following command before submitting. See :doc:`parallelism_benchmarks` for timings. .. code-block:: bash rundr plan experiment-shoal.yaml --profile shoal --targets-file "$targets" \ --config sweep.yaml --seeds 0:99 --workers 4 --task-slots-per-worker 25 Run Ray inside a Rundra task ---------------------------- Choose ``ray.yaml`` and the Ray experiment to start a two-CPU Ray runtime on the task's allocated node. The task reserves a third CPU for the driver. One Ray call evaluates up to eight candidates, and QDpy applies results as their calls complete. Use a separate fetch destination for the Ray result. .. code-block:: bash rundr submit experiment-shoal-ray.yaml --profile shoal --targets-file "$targets" \ --config ray.yaml --seed 0 ray_run_id=RUN_ID rundr wait "$ray_run_id" --progress rundr fetch "$ray_run_id" --mode copy --destination ../../build/rundra-ray python summarize.py ../../build/rundra-ray --runs 1 On Shoal, one Ray run evaluated all 128 candidates, filled 80 cells, and reached a best fitness of 0.193843. Completion order can change the archive even with the same seed. To spread one search across several nodes, use the same image with the host-side Slurm launcher in :doc:`tutorial_ray`. The launcher creates the Ray cluster across the nodes, then starts one QDpy driver. Resume individual sweep tasks ----------------------------- For a sweep using polynomial MAP-Elites and :func:`qdpy.checkpoints.run_checkpointed`, give each seed and configuration a distinct output directory on persistent storage visible from the task. A replacement task can use the same checkpoint path and the same evaluator and search settings with ``resume=True, trusted=True``. Wait for the original writer to exit before starting its replacement. The checkpoint example in :doc:`run_results` shows the two driver invocations. Use :doc:`study_report` to verify results across multiple sweep directories and compute paired differences at matching seeds. Retry only unfinished seeds --------------------------- After activating the same QDpy and Rundra environment, run this pilot from the checkout root. Seed 7 finishes, seed 13 stops at evaluation 32 of 128, and seed 23 is missing. .. code-block:: bash config=examples/rundra/pilot.yaml python examples/rundra/search.py --config "$config" --seed 7 \ --checkpointed --output build/pilot/7 python examples/rundra/search.py --config "$config" --seed 13 \ --checkpointed --stop-after 32 --output build/pilot/13 python -m qdpy.reporting --group pilot=build/pilot --seeds 7 13 23 \ --retry-config "pilot=$config" --retry-plan build/retry-plan.json \ --output build/sweep-report.json python examples/rundra/retry_sweep.py build/retry-plan.json build/pilot-retries \ --trust-checkpoints The runner submits two local tasks. It stages copies of the checkpoint and journal for seed 13 and starts seed 23 from scratch. It verifies the fetched archives and puts each attempt under its stable run ID. Running the same command again submits zero tasks after both seeds complete. Use one coordinator per retry output directory. Pass ``--trust-checkpoints`` only for files you trust because a native checkpoint is a pickle. For another target, pass ``--experiment``, ``--profile``, and ``--targets-file``. Start from ``experiment-local-retry.yaml``, keep the staged ``retry-input`` source path and ``results/**`` output, and use the same QDpy, Python, and NumPy versions as the original run. After a killed task, provide the checkpoint and journal alongside its run manifest in the input results directory. Keep the manifest and both recovery files on persistent storage or retrieve them from the task's workspace before creating the retry plan.