Julia on HPC

CounterfactualExplanations.jl meets Supercomputing

Delft University of Technology

May 14, 2024

Agenda

  • Introduction to Parallel Computing (15 min).
    1. What is parallel computing?
    2. Parallel computing in Julia.
    3. Different forms of parallelization offered by CounterfactualExplanations.jl.
  • First interactive session: local parallelization (15 min).
  • Julia on DelftBlue (25 min).
    1. What is DelftBlue?
    2. How to use Julia on DelftBlue?
    3. Challenges and solutions.
  • Second interactive session: remote parallelization (25 min).

Introduction to Parallel Computing

What is Parallel Computing?

Parallel computing is a type of computation in which many calculations or processes are carried out simultaneously. — Wikipedia

Image by Kay Jan Wong.

Parallel Computing in Julia

Julia has strong native and external support for parallel computing.

Multi-Threading

Command line:

julia --threads 4

Julia:

Threads.@threads for i = 1:10
    a[i] = Threads.threadid()
end

Multi-Processing

Parallelization in CounterfactualExplanations.jl

  • Motivation: often required to generate many explanations.
  • Goal: native support for both forms of parallelization.
  • Desiteratum: minimize the burden on users.

Usage example.

First Interactive Session: Local Parallelization

Tasks (15 min)

  1. If not already done, either fork or clone the repo.
  2. Open the notebook docs/src/tutorials/parallelization.qmd.
  3. Using the @time macro, check if multi-threading speeds up computations.

Julia on DelftBlue

What is DelftBlue?

DelftBlue is [one of two] supercomputer[s] at TU Delft [that] will offer 20,000 CPU cores in over 400 compute nodes. — DelftBlue

  • Rich documentation including a small section on Julia.
  • Should be accessible to all of you.
  • You will be among the first to use Julia on DelftBlue.
  • Alternative: DAIC.

How to Use Julia on DelftBlue?

  • Use Julia from the software stack (see docs).
  • Recommended: install your own Julia version.
  • Get help on Mattermost.

Self-install

See julia-hpc-for-dummies for additional details.

  1. Sym-link the Julia installation to your home directory.
mkdir -p /scratch/${USER}/.julia
ln -s /scratch/${USER}/.julia $HOME/.julia
  1. Sym-link juliaup to your home directory.
mkdir -p /scratch/${USER}/.juliaup
ln -s /scratch/${USER}/.juliaup $HOME/.juliaup
  1. Install juliaup as follows: curl -fsSL https://install.julialang.org | sh. Customize location to /scratch/${USER}/.juliaup.

Challenges and Solutions

  1. Julia version shipped with software stack is outdated. Solution: install your own Julia version.
  2. Login nodes are not meant for computations. Compiling Julia takes a long time. Solution: do as much as possible on your local machine. For anything else, rely mostly on the compute nodes.
  3. Self-installed Julia uses “all the resources!” 🧐 Solution: use this header for your scripts.

Whoopsie!

Second Interactive Session: Remote Parallelization

Tasks (25 min)

  1. Install your own Julia version on DelftBlue.
  2. Fork and/or clone the julia-hpc-for-dummies repo.
  3. Send a job to DelftBlue.