Skip to content

Commit

Permalink
PARSL_MPI_PREFIX moved to the espresso calculator (#2422)
Browse files Browse the repository at this point in the history
## Summary of Changes

As discussed in
(#2419) this is an
attempt to fix the current issue with the

## Expected behavior

Users can redecorate their job, adding the
`parsl_resource_specification`, Parsl take these informations and define
environment variables such as `PARSL_MPI_PREFIX`. If the users
redecorate multiple jobs, different `PARSL_MPI_PREFIX` will be
accessible on a per job basis.

### Example:

``` python
resource_specification_slow = {
    "num_nodes": 1,
    "ranks_per_node": 128,
    "num_ranks": 128,
    "launcher_options": "-vv --cpu-freq=2250000 --hint=nomultithread --distribution=block:block",
}
resource_specification_fast = {
    "num_nodes": 4,
    "ranks_per_node": 128,
    "num_ranks": 128 * 4,
    "launcher_options": "-vv --cpu-freq=2250000 --hint=nomultithread --distribution=block:block",
}

relax_job_slow = redecorate(
    relax_job, job(parsl_resource_specification=resource_specification_slow)
)
relax_job_fast = redecorate(
    relax_job, job(parsl_resource_specification=resource_specification_fast)
)
```
In this case, each job will have access to a different
`PARSL_MPI_PREFIX` environment variable.

## The problem

Right now, the `ESPRESSO_PARALLEL_CMD` is modified in `settings.py`
based on the `PARSL_MPI_PREFIX`, the problem is that this env variable
is only defined within jobs. `ESPRESSO_PARALLEL_CMD` end up being
defined before that, leading to wrong commands.

## The problem

One solution is to modify the command being lunched at the last moment
inside the espresso calculator before the command is lunched.

### Requirements

- [x] My PR is focused on a [single feature addition or
bugfix](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/getting-started/best-practices-for-pull-requests#write-small-prs).
- [ ] My PR has relevant, comprehensive [unit
tests](https://quantum-accelerators.github.io/quacc/dev/contributing.html#unit-tests).
- [x] My PR is on a [custom
branch](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-and-deleting-branches-within-your-repository)
(i.e. is _not_ named `main`).

Note: If you are an external contributor, you will see a comment from
[@buildbot-princeton](https://github.com/buildbot-princeton). This is
solely for the maintainers.
  • Loading branch information
tomdemeyere authored Aug 14, 2024
1 parent 842f28e commit 43fd54d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 6 additions & 2 deletions src/quacc/calculators/espresso/espresso.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,9 +419,13 @@ def __init__(
.get("pseudo_dir", str(self._settings.ESPRESSO_PSEUDO))
)

cmd_prefix = os.environ.get(
"PARSL_MPI_PREFIX", self._settings.ESPRESSO_PARALLEL_CMD[0]
)
cmd_suffix = self._settings.ESPRESSO_PARALLEL_CMD[1]

profile = EspressoProfile(
f"{self._settings.ESPRESSO_PARALLEL_CMD[0]} {self._bin_path} {self._settings.ESPRESSO_PARALLEL_CMD[1]}",
self._pseudo_path,
f"{cmd_prefix} {self._bin_path} {cmd_suffix}", self._pseudo_path
)

super().__init__(
Expand Down
3 changes: 0 additions & 3 deletions src/quacc/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,12 +467,9 @@ def validate_espresso_parallel_cmd(
cls, v: Union[str, tuple[str, str]]
) -> tuple[str, str]:
"""Clean up Espresso parallel command."""
parsl_mpi_prefix = os.environ.get("PARSL_MPI_PREFIX")

if isinstance(v, str):
v = (v, "")
if parsl_mpi_prefix:
v = (parsl_mpi_prefix, v[1])

return v

Expand Down

0 comments on commit 43fd54d

Please sign in to comment.