Skip to content

Conversation

@michaelmckinsey1
Copy link
Collaborator

@michaelmckinsey1 michaelmckinsey1 commented Jul 29, 2025

Description

  • Refactor programming models to be defined like scaling options are. I noticed while testing that the scaling variants were not affected from the same bug as the programming models. I.e. this is an issue with importing the programming class multiple times, which results in weird behavior with directives. This change avoids this.
  • Depends on Automatically Enumerate Dryruns and MpiOnlyExperiment #904
  • Issue described in Cannot initialize second experiment from library #932
  • This can be worked around by running the pytests individually, but this complicates the code coverage.
    • Example of error code checking on command line tests here Require --system During Experiment Init #982
      files#diff-a3ddd7238fc6e36daeb0ef76e93fe15cc87824bd3299888075210c5ca6a474d3
    • See removed tests in .github/workflows/run.yml -> moved to pytest now with this fix. Much cleaner tests in pytests.
  • Refactor all experiments
  • rename models.py to experiment_models.py

@github-actions github-actions bot added feature New feature or request ci CI, unit tests, GitHub actions labels Jul 29, 2025
@michaelmckinsey1 michaelmckinsey1 linked an issue Jul 29, 2025 that may be closed by this pull request
1 task
@slabasan slabasan added the WIP A work-in-progress not yet ready to commit label Aug 1, 2025
@github-actions github-actions bot added the experiment New or modified experiment label Oct 1, 2025
Comment on lines -24 to -44
# 1) Non-MPIOnlyExperiment Test
set +e
# babelstream is not an MPIOnlyExperiment
stderr_output="$({ ./bin/benchpark experiment init --dest babelstream --system dane babelstream; } 2>&1)"
status=$?
set -e
[[ $status -ne 0 ]] || fail "Expected non-zero exit status, got $status"
# Check for the specific BenchparkError message
expected="cannot run with MPI only"
grep -Fq "$expected" <<< "$stderr_output" && echo "failed as expected: $expected" || fail "Expected error message not found in stderr. Got: $stderr_output"
# 2) Multiple scaling options
set +e
# Cannot use both +strong and +weak
stderr_output="$({ ./bin/benchpark experiment init --dest kripke --system dane kripke+strong+weak; } 2>&1)"
status=$?
set -e
[[ $status -ne 0 ]] || fail "Expected non-zero exit status, got $status"
# Check for the specific BenchparkError message
expected="spec cannot specify multiple scaling options"
grep -Fq "$expected" <<<"$stderr_output" && echo "failed as expected: $expected" || fail "Expected error message not found in stderr. Got: $stderr_output"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests can now be moved to lib/benchpark/test/experiment_errors.py, which shows how much more concise the pytest format is

@michaelmckinsey1 michaelmckinsey1 changed the title [WIP] Enable Initializing Second Experiment From Library Enable Initializing Second Experiment From Library Oct 1, 2025
@michaelmckinsey1 michaelmckinsey1 added ready for review Ready for review and removed WIP A work-in-progress not yet ready to commit labels Oct 1, 2025
@michaelmckinsey1
Copy link
Collaborator Author

Ready for a review, but definitely not merging because only 2 of the experiments are updated for this change

@michaelmckinsey1 michaelmckinsey1 added the bug Something isn't working label Oct 1, 2025
Copy link
Collaborator

@scheibelp scheibelp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a question and a request

@@ -0,0 +1,85 @@
# Copyright 2023 Lawrence Livermore National Security, LLC and other
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this module should be called experiment_models, or live in an an experiments subdir

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I will rename this to experiment_models

variant("mpi", default=True, description="Run with MPI")
variant("rocm", default=False, description="Build and run with ROCm")
variant("cuda", default=False, description="Build and run with CUDA")
variant("openmp", default=False, description="Build and run with OpenMP")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like these variants are always defined on every experiment, regardless of whether it inherits the associated model types.

It should be allowed to split these variants into separate modules and imported classes (as they were originally); at the same time, customizing it all from one file is ok too, I wonder if it's possible to address the above concern though (it might not be possible to conditionally define the variants).

Copy link
Collaborator Author

@michaelmckinsey1 michaelmckinsey1 Oct 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is true, regardless of which models are defined, if the experiment inherits from Models(...) all programming models will show in the spec +mpi~rocm~cuda~openmp. I would like to note that this is the same behavior for the Scaling, e.g. even if the experiment does not define Throughput scaling it will show ~throughput in the spec. Not that this is correct either, but if we can find a solution for this it should be applied to both the programming models and scaling.

I don't know of a solution to the underlying bug that would enable separate classes. Perhaps something like

# mpi.py
def Mpi():
  class BaseMPI:
       variant("mpi")
# rocm.py
def Rocm():
  class BaseRocm:
       variant("rocm")

would provide the correct behavior, but the design seems maybe a bit convoluted.

It seems like the relevant piece for the behavior we desire is making sure the variant is not applied when the class is imported.

@michaelmckinsey1 michaelmckinsey1 added changes requested Changes requested and removed ready for review Ready for review labels Oct 2, 2025
@michaelmckinsey1 michaelmckinsey1 mentioned this pull request Oct 3, 2025
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working changes requested Changes requested ci CI, unit tests, GitHub actions experiment New or modified experiment feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot initialize second experiment from library

4 participants