Skip to content

Flux support inside MPIExecutor, plus FluxExecutor#1735

Draft
jlnav wants to merge 1 commit into
developfrom
feature/flux_executor
Draft

Flux support inside MPIExecutor, plus FluxExecutor#1735
jlnav wants to merge 1 commit into
developfrom
feature/flux_executor

Conversation

@jlnav
Copy link
Copy Markdown
Member

@jlnav jlnav commented May 22, 2026

Addresses #1647

Credit to Claude, as usual

Flux Usage Examples

Option 1: MPIExecutor with flux run wrapper

This wraps flux run as a subprocess, similar to how srun or mpirun work:

from libensemble.executors.mpi_executor import MPIExecutor

# Auto-detect Flux (works when FLUX_URI is set in environment)
exctr = MPIExecutor()

# Or explicit configuration
exctr = MPIExecutor(custom_info={"mpi_runner": "flux"})
exctr.register_app(full_path="/path/to/app.x", app_name="my_app")

# In sim function:
task = exctr.submit(app_name="my_app", num_procs=4, num_nodes=2)
task.wait()

Option 2: Native FluxExecutor

Uses Flux Python API directly — no subprocess spawning of flux run:

from libensemble.executors.flux_executor import FluxExecutor

exctr = FluxExecutor()  # Requires FLUX_URI to be set
exctr.register_app(full_path="/path/to/app.x", app_name="my_app")

# In sim function - submits via flux.job.submit() Python API
task = exctr.submit(app_name="my_app", num_procs=4, num_nodes=2)
task.wait()

Option 3: Container Workflow (FluxExecutor recommended)

This is the key use case mentioned in the issue — running libEnsemble inside a container where srun/mpiexec aren't available but Flux manages the resources from outside:

# Inside container (e.g., podman-hpc, Singularity, or Docker)
# Flux instance runs on the host and FLUX_URI is passed into the container

from libensemble.executors.flux_executor import FluxExecutor
from libensemble import Ensemble
from libensemble.specs import LibeSpecs, SimSpecs, GenSpecs

# FluxExecutor uses the Flux Python API to submit jobs
# No need for mpiexec/srun inside the container!
exctr = FluxExecutor()
exctr.register_app(full_path="/app/simulation.x", app_name="sim")

def sim_f(H, persis_info, sim_specs, libE_info):
    """Simulation function running inside container"""
    x = H["x"][0]

    # Submit work to Flux - Flux handles launching on compute nodes
    # even though we're inside a container
    task = exctr.submit(
        app_name="sim",
        app_args=f"--input {x[0]} {x[1]}",
        num_procs=4,
        num_nodes=1,
        num_gpus=2# Flux handles GPU assignment
    )
    task.wait()

    # Parse output...
    result = parse_output(task.read_stdout())

    H_out = np.zeros(1, dtype=sim_specs["out"])
    H_out["f"] = result
    return H_out, persis_info

# Configure libEnsemble for container environment
libE_specs = LibeSpecs(
    nworkers=4,
    comms="local",
    platform="flux"# Use Flux platform configuration
)

# ... rest of ensemble setup
  • Flux's Python bindings communicate directly with the Flux instance via FLUX_URI
  • Flux running on the host handles all resource allocation and job launching
  • Works with podman-hpc, Singularity, Docker, or any container runtime that can pass through the Flux socket

…ecutor for inside container. Basically, if Flux is found and FLUX_URI is set, this is sufficient to submit jobs that that scheduler.
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.

1 participant