Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove parameters for benchmarks #2706

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ jobs:
- name: Accept all asv questions
run: asv machine --yes

- name: Run benchmarks for last 5 commits if not PR
- name: Run benchmarks for last 4 commits if not PR
if: github.event_name != 'pull_request_target'
run: |
git log -n 5 --pretty=format:"%H" >> tag_commits.txt
asv run HASHFILE:tag_commits.txt | tee asv-output.log
git log -n 4 --pretty=format:"%H" >> tag_commits.txt
asv run -a repeat=1 -a rounds=1 HASHFILE:tag_commits.txt | tee asv-output.log
if grep -q failed asv-output.log; then
echo "Some benchmarks have failed!"
exit 1
Expand Down Expand Up @@ -126,7 +126,7 @@ jobs:
echo $(git rev-parse HEAD) > commit_hashes.txt
echo $(git merge-base HEAD upstream/master) >> commit_hashes.txt
asv run HASHFILE:commit_hashes.txt | tee asv-output-PR.log
asv run -a repeat=1 -a rounds=1 HASHFILE:commit_hashes.txt | tee asv-output-PR.log
if grep -q failed asv-output-PR.log; then
echo "Some benchmarks have failed!"
exit 1
Expand Down
88 changes: 41 additions & 47 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ on:
push:
branches:
- '*'

pull_request:
branches:
- '*'
Expand All @@ -22,24 +21,52 @@ on:
env:
CACHE_NUMBER: 0 # increase to reset cache manually
PYTEST_FLAGS: --tardis-refdata=${{ github.workspace }}/tardis-refdata --tardis-regression-data=${{ github.workspace }}/tardis-regression-data
--cov=tardis --cov-report=xml --cov-report=html
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true

defaults:
run:
shell: bash -l {0}

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true


jobs:
build:
codecov:
if: github.repository_owner == 'tardis-sn'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup LFS
uses: ./.github/actions/setup_lfs
- name: Setup environment
uses: ./.github/actions/setup_env
with:
os-label: linux-64
- name: Generate coverage report
run: |
pytest --cov=tardis --cov-report=xml --cov-report=html
- uses: codecov/codecov-action@v4
if: always()
with:
fail_ci_if_error: true
token: ${{ env.CODECOV_TOKEN }}
verbose: true

tests:
name: ${{ matrix.continuum }} continuum ${{ matrix.rpacket_tracking }} rpacket_tracking ${{ matrix.os }}
if: github.repository_owner == 'tardis-sn'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
pip: [true, false]
label: [osx-arm64, linux-64]
continuum: ['not', '']
rpacket_tracking: ['not', '']
exclude:
- continuum: ''
rpacket_tracking: ''
include:
- label: osx-arm64
os: macos-latest
Expand All @@ -48,9 +75,6 @@ jobs:
- label: linux-64
os: ubuntu-latest
prefix: /usr/share/miniconda3/envs/tardis

name: ${{ matrix.label }}-pip-${{ matrix.pip }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4

Expand All @@ -59,46 +83,16 @@ jobs:

- name: Setup environment
uses: ./.github/actions/setup_env
with:
with:
os-label: ${{ matrix.label }}

- name: Install package editable
run: |
pip install -e .
echo "TARDIS_PIP_PATH=tardis" >> $GITHUB_ENV
if: matrix.pip == false

- name: Install package git
run: pip install git+https://github.com/tardis-sn/tardis.git@${{ github.ref }}
if: matrix.pip == true

- name: Set pip path
if: matrix.pip == true
run: |
location_line=$(pip show tardis | grep -i -x "Location:.*")
directory_path=$(echo $location_line | awk -F " " '{print $2}')
echo "TARDIS_PIP_PATH=$directory_path" >> $GITHUB_ENV

- name: Set install path
if: matrix.pip == false
- name: Install package editable
run: |
directory_path="."
echo "TARDIS_PIP_PATH=$directory_path" >> $GITHUB_ENV
pip install -e . --user
- name: Run tests
run: pytest tardis ${{ env.PYTEST_FLAGS }} -m "not continuum"
working-directory: ${{ env.TARDIS_PIP_PATH }}
if: always()

- name: Run continuum tests
run: pytest tardis ${{ env.PYTEST_FLAGS }} -m continuum
working-directory: ${{ env.TARDIS_PIP_PATH }}
if: always()

- name: Upload to Codecov
run: bash <(curl -s https://codecov.io/bash)
run: pytest tardis ${{ env.PYTEST_FLAGS }} -m "${{ matrix.continuum }} continuum and ${{ matrix.rpacket_tracking }} rpacket_tracking"

- name: Refdata Generation tests
run: pytest tardis ${{ env.PYTEST_FLAGS }} --generate-reference
working-directory: ${{ env.TARDIS_PIP_PATH }}
if: contains(github.event.pull_request.labels.*.name, 'run-generation-tests') || github.ref == 'refs/heads/master'
run: pytest tardis ${{ env.PYTEST_FLAGS }} --generate-reference -m "${{ matrix.continuum }} continuum and ${{ matrix.rpacket_tracking }} rpacket_tracking"
if: contains(github.event.pull_request.labels.*.name, 'run-generation-tests') || github.ref == 'refs/heads/master'
37 changes: 15 additions & 22 deletions benchmarks/benchmark_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@
from tardis.simulation import Simulation
from tardis.tests.fixtures.atom_data import DEFAULT_ATOM_DATA_UUID
from tardis.tests.fixtures.regression_data import RegressionData
from tardis.transport.montecarlo import RPacket, montecarlo_configuration
from tardis.transport.montecarlo import RPacket
from tardis.transport.montecarlo.configuration import montecarlo_globals
from tardis.transport.montecarlo.configuration.base import (
MonteCarloConfiguration,
)
from tardis.transport.montecarlo.estimators import radfield_mc_estimators
from tardis.transport.montecarlo.numba_interface import opacity_state_initialize
from tardis.transport.montecarlo.packet_collections import (
Expand Down Expand Up @@ -66,7 +70,8 @@ def tardis_ref_path(self):
# /app/tardis-refdata
ref_data_path = Path(
Path(__file__).parent.parent,
"tardis-refdata",
"benchmarks",
"data"
).resolve()
return ref_data_path

Expand All @@ -83,7 +88,7 @@ def atomic_dataset(self) -> AtomData:
@property
def atomic_data_fname(self):
atomic_data_fname = (
f"{self.tardis_ref_path}/atom_data/kurucz_cd23_chianti_H_He.h5"
f"{self.tardis_ref_path}/kurucz_cd23_chianti_H_He.h5"
)

if not Path(atomic_data_fname).exists():
Expand Down Expand Up @@ -235,9 +240,7 @@ def packet(self):

@property
def verysimple_packet_collection(self):
return (
self.nb_simulation_verysimple.transport.transport_state.packet_collection
)
return self.nb_simulation_verysimple.transport.transport_state.packet_collection

@property
def nb_simulation_verysimple(self):
Expand All @@ -259,7 +262,6 @@ def verysimple_opacity_state(self):
self.nb_simulation_verysimple.plasma,
line_interaction_type="macroatom",
disable_line_scattering=self.nb_simulation_verysimple.transport.montecarlo_configuration.DISABLE_LINE_SCATTERING,
continuum_processes_enabled=self.nb_simulation_verysimple.transport.montecarlo_configuration.CONTINUUM_PROCESSES_ENABLED,
)

@property
Expand All @@ -268,27 +270,19 @@ def verysimple_enable_full_relativity(self):

@property
def verysimple_disable_line_scattering(self):
return (
self.nb_simulation_verysimple.transport.montecarlo_configuration.DISABLE_LINE_SCATTERING
)
return self.nb_simulation_verysimple.transport.montecarlo_configuration.DISABLE_LINE_SCATTERING

@property
def verysimple_continuum_processes_enabled(self):
return (
self.nb_simulation_verysimple.transport.montecarlo_configuration.CONTINUUM_PROCESSES_ENABLED
)
return montecarlo_globals.CONTINUUM_PROCESSES_ENABLED

@property
def verysimple_tau_russian(self):
return (
self.nb_simulation_verysimple.transport.montecarlo_configuration.VPACKET_TAU_RUSSIAN
)
return self.nb_simulation_verysimple.transport.montecarlo_configuration.VPACKET_TAU_RUSSIAN

@property
def verysimple_survival_probability(self):
return (
self.nb_simulation_verysimple.transport.montecarlo_configuration.SURVIVAL_PROBABILITY
)
return self.nb_simulation_verysimple.transport.montecarlo_configuration.SURVIVAL_PROBABILITY

@property
def static_packet(self):
Expand Down Expand Up @@ -359,10 +353,10 @@ def verysimple_radfield_mc_estimators(self):

@property
def montecarlo_configuration(self):
return montecarlo_configuration.MonteCarloConfiguration()
return MonteCarloConfiguration()

@property
def rpacket_tracker(self):
def rpacket_tracker(self):
return RPacketTracker(0)

@property
Expand Down Expand Up @@ -396,7 +390,6 @@ def geometry(self):
v_outer=np.array([-1, -1], dtype=np.float64),
)


@property
def estimators(self):
return radfield_mc_estimators.RadiationFieldMCEstimators(
Expand Down
3 changes: 2 additions & 1 deletion benchmarks/transport_geometry_calculate_distances.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from asv_runner.benchmarks.mark import parameterize
from asv_runner.benchmarks.mark import parameterize, skip_benchmark

import tardis.transport.frame_transformations as frame_transformations
import tardis.transport.geometry.calculate_distances as calculate_distances
from benchmarks.benchmark_base import BenchmarkBase


@skip_benchmark
class BenchmarkTransportGeometryCalculateDistances(BenchmarkBase):
"""
Class to benchmark the calculate distances function.
Expand Down
14 changes: 1 addition & 13 deletions benchmarks/transport_montecarlo_interaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from asv_runner.benchmarks.mark import parameterize



class BenchmarkMontecarloMontecarloNumbaInteraction(BenchmarkBase):
"""
Class to benchmark the numba interaction function.
Expand Down Expand Up @@ -52,7 +51,6 @@ def time_line_scatter(self, line_interaction_type):
line_interaction_type,
self.verysimple_opacity_state,
self.verysimple_enable_full_relativity,
self.verysimple_continuum_processes_enabled,
)

@parameterize(
Expand All @@ -63,17 +61,7 @@ def time_line_scatter(self, line_interaction_type):
"emission_line_id": 1000,
"energy": 0.9114437898710559,
},
{
"mu": -0.6975116557422458,
"emission_line_id": 2000,
"energy": 0.8803098648913266,
},
{
"mu": -0.7115661419975774,
"emission_line_id": 0,
"energy": 0.8800385929341252,
},
]
]
}
)
def time_line_emission(self, test_packet):
Expand Down
12 changes: 2 additions & 10 deletions benchmarks/transport_montecarlo_numba_formal_integral_p.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,6 @@ class BenchmarkMontecarloMontecarloNumbaNumbaFormalIntegral(BenchmarkBase):
{
"nu": 1e14,
"temperature": 1e4,
},
{
"nu": 0,
"temperature": 1,
},
{
"nu": 1,
"temperature": 1,
}
]
}
Expand All @@ -41,7 +33,7 @@ def time_intensity_black_body(self, parameters):
temperature = parameters["temperature"]
formal_integral.intensity_black_body(nu, temperature)

@parameterize({"N": (1e2, 1e3, 1e4, 1e5)})
@parameterize({"N": (1e2, 1e3)})
def time_trapezoid_integration(self, n):
h = 1.0
data = np.random.random(int(n))
Expand Down Expand Up @@ -98,7 +90,7 @@ def time_calculate_z(self, p, test_data):
for r in r_outer:
formal_integral.calculate_z(r, p, inv_t)

@parameterize({"N": [100, 1000, 10000]})
@parameterize({"N": [100, 1000]})
def time_calculate_p_values(self, N):
r = 1.0
formal_integral.calculate_p_values(r, N)
Expand Down
5 changes: 2 additions & 3 deletions benchmarks/transport_montecarlo_numba_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@ class BenchmarkMontecarloMontecarloNumbaNumbaInterface(BenchmarkBase):
Class to benchmark the numba interface function.
"""

@parameterize({"Input params": ["scatter", "macroatom", "downbranch"]})
@parameterize({"Input params": ["scatter", "macroatom"]})
def time_opacity_state_initialize(self, input_params):
line_interaction_type = input_params
plasma = self.nb_simulation_verysimple.plasma
opacity_state_initialize(
plasma,
line_interaction_type,
self.verysimple_disable_line_scattering,
self.verysimple_continuum_processes_enabled,
)
)
Loading
Loading