Skip to content

Add a performance benchmark pipeline #4375

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

Merged
merged 40 commits into from
Apr 23, 2025
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
30b00c5
add the runbenchmarks
simone-silvestri Apr 9, 2025
f41f048
let's ty it out
simone-silvestri Apr 9, 2025
95bbbfe
Merge branch 'main' into ss/performance-github-action
simone-silvestri Apr 9, 2025
e839d0e
trigger tests
simone-silvestri Apr 9, 2025
7952af8
on everything
simone-silvestri Apr 9, 2025
d13f3c4
Merge branch 'ss/performance-github-action' of github.com:CliMA/Ocean…
simone-silvestri Apr 9, 2025
bd16eae
run the benchmarks
simone-silvestri Apr 9, 2025
299c8e4
maybe this works
simone-silvestri Apr 9, 2025
2155099
above project
simone-silvestri Apr 9, 2025
88ea9e7
adding benchmarktools
simone-silvestri Apr 9, 2025
3bb144d
try pushing on docs build
simone-silvestri Apr 10, 2025
65fc0a4
Merge branch 'main' into ss/performance-github-action
simone-silvestri Apr 22, 2025
ee6fb83
Merge branch 'main' into ss/performance-github-action
simone-silvestri Apr 23, 2025
e38dc9b
try this once
simone-silvestri Apr 23, 2025
1564c5f
correct queue
simone-silvestri Apr 23, 2025
38b6885
try out the pipeline
simone-silvestri Apr 23, 2025
c11b8f3
no need for an architecture
simone-silvestri Apr 23, 2025
4ce978e
use the oceananigans queue
simone-silvestri Apr 23, 2025
65a13b5
add a trace
simone-silvestri Apr 23, 2025
a4b41bf
change output per group
simone-silvestri Apr 23, 2025
a4e021a
use GPU1 for the moment
simone-silvestri Apr 23, 2025
ef8a7f4
instantiate inside the test
simone-silvestri Apr 23, 2025
ed012b9
instantiate first
simone-silvestri Apr 23, 2025
72bdc1e
try uploading an artifact
simone-silvestri Apr 23, 2025
115f466
add an artifact
simone-silvestri Apr 23, 2025
8c68e32
should work all in one pipeline
simone-silvestri Apr 23, 2025
2d423e0
some bugfixes
simone-silvestri Apr 23, 2025
a6b7fba
runb the complete benchmark test suite
simone-silvestri Apr 23, 2025
aba63ef
load cheap advection
simone-silvestri Apr 23, 2025
9c96189
fix cheap advection
simone-silvestri Apr 23, 2025
227766b
Update .buildkite/pipeline-benchmarks.yml
simone-silvestri Apr 23, 2025
78e277a
switch queue
glwagner Apr 23, 2025
cddc36f
add login to the benchmark pipeline
simone-silvestri Apr 23, 2025
6349407
add login to the benchmark pipeline
simone-silvestri Apr 23, 2025
d0c9b02
same the main build name
simone-silvestri Apr 23, 2025
694c417
add a condiitonal block
simone-silvestri Apr 23, 2025
a282496
add a conditional save
simone-silvestri Apr 23, 2025
d4808f7
not working?
simone-silvestri Apr 23, 2025
268c8cc
conditional metadata save once again
simone-silvestri Apr 23, 2025
aaafd2d
add a comment
simone-silvestri Apr 23, 2025
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
97 changes: 97 additions & 0 deletions .buildkite/pipeline-benchmarks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
env:
JULIA_VERSION: "1.10.9"
JULIA_MINOR_VERSION: "1.10"
TARTARUS_HOME: "/storage5/buildkite-agent"
JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER"
JULIA_PKG_SERVER_REGISTRY_PREFERENCE: eager
JULIA_NUM_PRECOMPILE_TASKS: 24
JULIA_NUM_THREADS: 8
NSYS: "/storage6/simone/new_nsight/bin/nsys"
CUDA_VISIBLE_DEVICES: "1" # Tartarus device for GPU Benchmarking
TMPDIR: "$TARTARUS_HOME/tmp"

agents:
queue: "Oceananigans"

steps:
- label: "🏕️ initialize tartarus environment"
key: "init"
env:
JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER"
TEST_GROUP: "init"
JULIA_BINDIR: "$TARTARUS_HOME/julia-$JULIA_VERSION/bin"
command: |
# Download julia binaries
wget -N -P $TARTARUS_HOME https://julialang-s3.julialang.org/bin/linux/x64/$JULIA_MINOR_VERSION/julia-$JULIA_VERSION-linux-x86_64.tar.gz
tar xf $TARTARUS_HOME/julia-$JULIA_VERSION-linux-x86_64.tar.gz -C $TARTARUS_HOME
agents:
queue: "Oceananigans"
retry:
automatic:
- exit_status: 1
limit: 1

- wait

- label: "🚀 Oceananigans GPU benchmarks"
key: "benchmarks"
agents:
queue: "Oceananigans"
command: |
# Instantiate
$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia --color=yes --project --check-bounds=no -e 'using Pkg; Pkg.instantiate()'

# Run Periodic benchmarks
export BENCHMARK_GROUP="periodic"
$NSYS profile --output=periodic_output --trace=cuda $TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia --color=yes --project --check-bounds=no test/benchmark_tests.jl
$NSYS stats periodic_output.nsys-rep > periodic_output.txt

# Remove generated output files
rm periodic_output.nsys-rep
rm periodic_output.sqlite

# Run Bounded benchmarks
export BENCHMARK_GROUP="bounded"
$NSYS profile --output=bounded_output --trace=cuda $TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia --color=yes --project --check-bounds=no test/benchmark_tests.jl
$NSYS stats bounded_output.nsys-rep > bounded_output.txt

# Remove generated output files
rm bounded_output.nsys-rep
rm bounded_output.sqlite

# Run Periodic cheap advection benchmarks
export BENCHMARK_GROUP="periodic_cheap_advection"
$NSYS profile --output=periodic_cheap_advection_output --trace=cuda $TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia --color=yes --project --check-bounds=no test/benchmark_tests.jl
$NSYS stats periodic_cheap_advection_output.nsys-rep > periodic_cheap_advection_output.txt

# Remove generated output files
rm periodic_cheap_advection_output.nsys-rep
rm periodic_cheap_advection_output.sqlite

# Run Bounded cheap advection benchmarks
export BENCHMARK_GROUP="bounded_cheap_advection"
$NSYS profile --output=bounded_cheap_advection_output --trace=cuda $TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia --color=yes --project --check-bounds=no test/benchmark_tests.jl
$NSYS stats bounded_cheap_advection_output.nsys-rep > bounded_cheap_advection_output.txt

# Remove generated output files
rm bounded_cheap_advection_output.nsys-rep
rm bounded_cheap_advection_output.sqlite

# Run Immersed benchmarks
export BENCHMARK_GROUP="immersed"
$NSYS profile --output=immersed_output --trace=cuda $TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia --color=yes --project --check-bounds=no test/benchmark_tests.jl
$NSYS stats immersed_output.nsys-rep > immersed_output.txt

# Remove generated output files
rm immersed_output.nsys-rep
rm immersed_output.sqlite

artifact_paths:
- "periodic_output.txt"
- "bounded_output.txt"
- "periodic_cheap_advection_output.txt"
- "bounded_cheap_advection_output.txt"
- "immersed_output.txt"
soft_fail:
- exit_status: 3

95 changes: 95 additions & 0 deletions test/benchmark_tests.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
using Oceananigans
using Oceananigans.Units
using Oceananigans.Architectures: on_architecture
using Oceananigans.TurbulenceClosures.TKEBasedVerticalDiffusivities: CATKEVerticalDiffusivity
using SeawaterPolynomials.TEOS10
using Random

function ocean_benchmark(arch, Nx, Ny, Nz, topology, immersed, tracer_advection=WENO(order=7))

z_faces = collect(range(-6000, 0, length=Nz+1))

grid = RectilinearGrid(arch; size=(Nx, Ny, Nz),
halo=(7, 7, 7),
z=z_faces,
x=(-1000kilometers, 1000kilometers),
y=(-1000kilometers, 1000kilometers),
topology)

grid = if immersed
Random.seed!(1234)
bottom = Oceananigans.Architectures.on_architecture(arch, - 5000 .* rand(Nx, Ny) .- 1000)
ImmersedBoundaryGrid(grid, GridFittedBottom(bottom); active_cells_map=true)
else
grid
end

@info "Grid is built"
momentum_advection = WENOVectorInvariant()
buoyancy = SeawaterBuoyancy(equation_of_state=TEOS10EquationOfState())
free_surface = SplitExplicitFreeSurface(grid; substeps=70)
closure = CATKEVerticalDiffusivity()

model = HydrostaticFreeSurfaceModel(; grid,
momentum_advection,
tracer_advection,
buoyancy,
closure,
free_surface,
tracers = (:T, :S, :e))

@info "Model is built"

R = rand(size(model.grid))

# initialize variables with randomish values
Tᵢ = 0.0001 .* R .+ 20
Sᵢ = 0.0001 .* R .+ 35
uᵢ = 0.0001 .* R
vᵢ = 0.0001 .* R

set!(model, T=Tᵢ, S=Sᵢ, e=1e-6, u=uᵢ, v=vᵢ)

return model
end

function run_benchmark(model)
for _ in 1:15
time_step!(model, 1.0)
end
end

group = get(ENV, "BENCHMARK_GROUP", "all") |> Symbol

const Nx = 500
const Ny = 200
const Nz = 60

arch = GPU()

cheap_advection = FluxFormAdvection(WENO(order=7), WENO(order=7), Centered())

if group == :periodic
model = ocean_benchmark(arch, Nx, Ny, Nz, (Periodic, Periodic, Bounded), false)
run_benchmark(model)
end

if group == :bounded
model = ocean_benchmark(arch, Nx, Ny, Nz, (Bounded, Bounded, Bounded), false)
run_benchmark(model)
end

if group == :periodic_cheap_advection
model = ocean_benchmark(arch, Nx, Ny, Nz, (Periodic, Periodic, Bounded), false, cheap_advection)
run_benchmark(model)
end

if group == :bounded_cheap_advection
model = ocean_benchmark(arch, Nx, Ny, Nz, (Bounded, Bounded, Bounded), false, cheap_advection)
run_benchmark(model)
end

if group == :immersed
model = ocean_benchmark(arch, Nx, Ny, Nz, (Periodic, Periodic, Bounded), true)
run_benchmark(model)
end