Instructor Notes
This is a placeholder file. Please add content here.
Introduction
Connecting to Falcon - SSH keys
Instructor Note
Instructor notes
Timing. About 25 minutes of live coding and 15 of exercises. Do the “before” demo first (type the password three times) so the gain is visible.
Mixed audience. Demonstrate on your own system, but say aloud what is different on Windows (paths, no ssh-copy-id, agent service) and have a Windows machine or screenshots ready for PuTTY and MobaXterm. Ask PuTTY and MobaXterm users to follow the documentation page while you demonstrate the concepts.
Common problems.
- Nothing is shown while typing a passphrase, and people think the terminal is frozen.
- Confusing the Falcon password with the key passphrase.
- Windows: Notepad saves the config file as config.txt; the .ssh folder does not exist yet; paths use backslashes.
- PuTTYgen: the Save public key button produces a format Falcon cannot read.
- MobaXterm: its local terminal has a different home directory from Windows.
- Someone sends or pastes the private key. Treat it as a teaching moment and have them regenerate the key.
Fallback. The rest of the lesson does not depend on keys. If someone cannot get them working in the time, they can keep using their password and fix it afterwards with the documentation page or by contacting support.
Fallback. The rest of the lesson does not depend on keys. If someone cannot get them working in the time, they can keep using their password and fix it afterwards with the documentation page or by contacting support.
Finding the software and libraries you need
Instructor notes
Timing. About 20 minutes of live coding and 15 of exercises. Let learners predict the result of each command before you run it. If time is short, drop the optional CPU-count challenge, which also fits the interactive sessions episode.
Do not run sweep.py on the login node in the
session. The os.cpu_count() check makes the point
without loading the node. The actual effect is shown later on a compute
node, with htop open next to the job.
Check before the session.
- Run every command on the node type used for the course and replace the illustrative outputs with the real ones. The Python and NumPy session at the start is from the login node.
- Make sure there is something to find: a NumPy version from at least two toolchain generations, so the choosing challenge works. Adjust the matplotlib example to match what is installed.
- Confirm that
os.sched_getaffinity(0)inside a Slurm job shows the allocated CPUs on Falcon, because it depends on how Slurm’s CPU binding is configured. - If Falcon uses a spider cache, very recently installed software may not show up until it is refreshed, which can confuse a live demo.
Software differs by architecture. The software trees
on Falcon differ by CPU type, which you can see in the install paths
(for example .../amd/zen4/... versus
.../intel/cascadelake/...). The modules listed can
therefore depend on the node you are on. This links to the architectures
episode, and an optional extension is to run
module spider numpy in an interactive session on a
different node type and compare. Confirm that this matches how Falcon is
configured before presenting it.
Common problems.
- Typing
module load numpyand concluding that NumPy is missing. - Mixing toolchain generations, which produces errors that do not mention modules.
- Piping
module availintogrepwithout2>&1. - Forgetting
--loginin a job script, somodule: command not found. - Running a “quick test” of the real script on the login node.
Estimating resources
Instructor notes
Timing. About 25 minutes of live coding and 15 of exercises. Have learners type the script rather than paste it, and submit it all at about the same time. The training partition should keep the wait short, but check it beforehand.
The resource values are deliberately generous. 16 GB
is far more than this script needs, and 8 CPUs are far more than it can
use. This sets up the efficiency episode, where seff shows
the waste. Do not fix it now; say that we will come back to it.
Check before the session.
- Replace the illustrative outputs with the real ones, and the project and partition placeholders.
- Run the script on a few different laptops, or have your own timings, so you know what to expect. A recent laptop with fast cores may beat a cluster core, which is good for the message but should not come as a surprise.
- Confirm that the
time,sysctland PowerShell commands work on the machines learners will use. - The tab group syntax (
tab) depends on your Workbench version. If it does not render, use three separate headings.
Common problems.
-
Invalid account or account/partition combination specified: the project or partition is wrong or the learner does not belong to the project. - A script written or pasted in a Windows editor can contain Windows
line breaks. Slurm then complains about DOS line breaks, or Bash reports
a bad interpreter. Create or edit the file on Falcon, or convert it with
dos2unix. -
#SBATCHlines placed after a command are silently ignored. -
module: command not foundwhen--loginis missing from the first line. - The job ends with
TIMEOUTorOUT_OF_MEMORYwhen learners reduce the limits too far. Use it as a teaching moment. - Learners look in the
.ofile for errors instead of the.efile. - Someone runs
python sweep.py 42directly on the login node instead of submitting it. Remind them of the previous episode.
Making the job script safe
Instructor notes
Timing. About 25 minutes of live coding and 15 of
exercises. The small echo and cd
demonstrations run in a terminal on the login node and need no job, so
they are safe and quick. Do them live and let learners predict each
result first.
Check before the session.
- Replace the illustrative outputs,
SCWFXXXXX, and the project and partition placeholders. Make sure each learner can create a directory under their scratch path. - Fill in the scratch policy and the quota command, and run the commands yourself first.
- Check that
module loadworks underset -uon Falcon. If a module prints an “unbound variable” error, use theset +uworkaround from the callout. - Run the final script once and check that the scratch directory is removed.
A useful extra demonstration. Introduce a deliberate
typo (pyton sweep.py "${SEED}") and submit. Use
sacct to show FAILED with exit code 127, and
ls on scratch to show that the directory was kept. Then
remove set -e and show the same job ending as
COMPLETED even though no result exists. This is the best
demonstration of why -e matters.
This episode prepares later ones.
OMP_NUM_THREADS=${SLURM_CPUS_PER_TASK} is used in the
scaling episode, where the CPU count is changed from the command line
(sbatch -c 4 sweep-test.sh). The seed argument and unique
names lead to array jobs, where SLURM_ARRAY_TASK_ID
provides the seed.
Common problems.
- Windows line endings in a script written elsewhere (see the previous episode).
-
set -eu -pipefailcopied from somewhere: it does not enablepipefail. -
SLURM_CPUS_PER_TASK: unbound variablebecause the script has no--cpus-per-task, which isset -udoing its job. -
rm -rfguards: stress${WORKDIR:?}and never deleting with wildcards. - Learners clean up scratch by hand before the job has finished.
Can more cores make it faster?
Instructor notes
Timing. About 25 minutes plus 15 of exercises. Submit the scaling jobs at the start of the episode, then explain the vocabulary and Amdahl’s law while they run, and come back to collect and plot the results.
Capacity. If the whole class submits 64 or 128 CPU jobs at once, the training partition will fill up. The text limits learners to 32. Show the larger counts from your own measurements.
Investigate the 128-CPU result before the session. The text deliberately lists possible causes rather than naming one, because the data does not settle it. Before teaching, it is worth running these:
- Repeat 128 three times. Is it reproducible?
- Record the node:
sacct -j <jobid> -o JobID,NodeList,Elapsed, and comparelscpu(model, sockets, threads per core) between the 64 and 128 CPU jobs. - Try 96, 112 and 127 CPUs. If 96 is fine and larger counts are slow, a processor boundary is likely. If 127 recovers, the cause is probably system activity on a fully allocated node.
- Try
-c 128withOMP_NUM_THREADS=64, to separate “allocated 128” from “used 128 threads”. - Look at
sefffor the 128 CPU job. Threads that spin while waiting count as busy time, so the CPU efficiency may look high for a job that was very slow. This makes a good lead into the efficiency episode.
Once you know the cause, update the “What happened at 128 CPUs?” section to say so.
Check before the session.
- Confirm that
sbatch -c Noverrides the#SBATCHline on Falcon and thatSLURM_CPUS_PER_TASKis set accordingly. - Make sure learners can run the plot: either matplotlib on their laptop, or have them paste the numbers into a spreadsheet.
- Confirm the one-CPU run finishes comfortably inside the time limit (5 minutes in the script).
Common problems.
- Using
-ninstead of-c. The jobs run, but nothing changes. - Forgetting to change the result file name, so results overwrite each other or cannot be told apart.
- Mixing up the script’s own time with Slurm’s
Elapsed. Both are useful, but they differ by the start-up cost. - Reading the flattening curve as a “sweet spot”.
- Windows line endings in the loop commands pasted from a document.
Measuring efficiency with sacct and seff
Instructor notes
Timing. About 25 minutes of teaching and 20 of
exercises. The best use of time is the three seff reports
side by side (1, 8 and 128 CPUs), then the “which job would you rather
run?” challenge.
Check before the session.
- Run
seffon your own 1, 8, 32, 64 and 128 CPU jobs and replace the illustrative numbers. The point of the section on high efficiency depends on the 128-CPU job really showing a high CPU efficiency and a much largerCPU Utilizedthan the single-CPU job. Confirm that on your data, and adjust the wording if it does not. - If you find the cause of the 128-CPU slowdown (see the previous episode), say so in that section and here.
- Confirm that
seffis available to learners, that theCluster:line reads sensibly, and which memory values it reports for very short jobs. Run one of the small jobs and checkMaxRSS. - Make sure the account and partition let learners see their own jobs
with
sacctwithout extra options.
A useful comparison. If users can see their jobs in a web tool such as XDMoD, show the same jobs there as a “looking at many jobs” view. It makes the same point at the scale of a whole project.
Common problems.
-
seffprints nothing or zeros for a job that has not finished. It reports only completed jobs. - Reading
saccttimes with a different format:ElapsedisHH:MM:SS, whileTotalCPUcan show fractions of a second or days (1-02:03:04). - Forgetting that
MaxRSSis on the.batchline, so it does not appear with-X. - Treating a high CPU efficiency as proof that a job is healthy.
- Right-sizing too aggressively: setting limits equal to the measurement, so the next run is killed.
Watching a job run: interactive sessions, tmux, htop and ps
Instructor notes
Timing. About 30 minutes of live coding and 15 of exercises. Do the setup together, step by step, because it is the part most likely to go wrong. The disconnection demonstration (close the window, reconnect, reattach) is the one learners remember.
Check before the session.
- Run the whole sequence on the node type learners will get. Confirm
the exact
sruncommand, thatmoduleworks in the interactive shell (if it does not, start the shell withbash -l), and thathtop,watchandpgrepare installed on the compute nodes. - Confirm that
srun --jobid=<id> --overlap --pty bashworks, and what happens without--overlap. In recent Slurm versions a second step may wait for the first to release the CPUs. - Check how long a run takes on the interactive CPUs, so that the
burst is long enough to see in
htop. With a few more CPUs the burst is shorter, and with fewer the serial part is a smaller share of the total. - Confirm that the number of
Rthreads really jumps between1and the CPU count in thewatchoutput. Spinning threads also show asR, so the picture can be less clean than the text suggests, and the discrepancy is itself worth showing. - Replace the illustrative outputs and add a real
htopscreenshot. - Ask learners to use at most 8 CPUs, and a short time limit, so that the interactive sessions leave room on the partition.
Mixed audience. Windows users on PuTTY and MobaXterm
need the terminal type set to xterm-256color for
tmux and htop to display well. Selecting text
with the mouse may need the Shift key while
tmux mouse mode is on. The Ctrl+b prefix is
the same on all systems. On a Mac, use the Control key, not
Command.
Common problems.
- Starting
srunbeforetmux, so that a lost connection ends the session. - Using
tmuxonfalconlogin.cf.ac.uk, then not finding the session after reconnecting to the other login node. - Running
htopin the second pane without attaching to the allocation, so it shows the login node. - Forgetting
export OMP_NUM_THREADS=${SLURM_CPUS_PER_TASK}in the interactive shell, which changes the thread count. - Forgetting to
exitthe interactive session, so the allocation stays reserved until its time limit. - Reading the
%CPUcolumn ofpsas a live figure.
Finding the bottleneck with a profiler
Instructor notes
Timing. About 15 minutes plus 10 for the exercise.
Have the .map file ready for everyone in a shared location
in case a learner cannot install the client, or the licence or version
gets in the way. Show the client on the projector.
The profile can change the story. Earlier episodes
assumed that the long serial part of sweep.py is the
pair-distance loop. That was inferred from the shape of the scaling
curve and not measured. Look at the profile before the session, and if
the time is split differently (for example if part of the serial time is
in the eigenvalue calculation, which many linear algebra libraries do
not parallelise well), update the earlier wording and the challenge
solution above.
Check before the session.
- Run the job on the node type learners will use, and replace the summary and file name.
- Check that
--no-mpiis accepted by the installed version, and what the summary looks like without it. - Check the licence for the profiler on the compute nodes, and for the client on learners’ computers.
- Make sure the
.mapfile is copied out and not deleted by the cleanup.
The matmul warning. Under MAP we saw
RuntimeWarning: invalid value encountered in matmul for the
covariance line, which we have not explained. Run the same job without
map and check whether the warning is still there, and
whether the results agree. Decide what to say if learners see it.
Common problems.
- Forgetting to load the profiler module, so
map: command not found. - No
.mapfile after the job, because the scratch directory was cleaned up. - A client older than the profiler cannot open the file.
- The name of the file, with its date and time, makes it harder to find when many are in one directory.
- Opening the profile on the cluster over X forwarding, which is slow. Use the client on your own computer.
Improving the code
Instructor notes
Timing. About 20 minutes plus 15 of exercises. Learners can submit the variants at the start and discuss while they run.
Check before the session.
- Fill in the table with your own numbers, and say which software versions differ between the two stacks.
- Make sure the new stack exists for the node type learners will use, and that the script runs without changes there.
- Confirm that the results match to the precision you expect, and decide what you will say if a learner’s differ.
- Find out why the new stack is faster, if you can, by comparing the numpy and OpenBLAS versions, the kernel OpenBLAS chooses on the node, and the profiles. The text deliberately does not claim a reason.
- If
pdistgave no gain on your runs, look at the profile of that variant to see where the time went. It is a useful part of the story.
Common problems.
- Changing two things at once (the module and the code), so the effect cannot be attributed.
- Comparing single runs. Timings vary from run to run, so repeat them.
- Mixing modules from different toolchain generations after editing the module line.
- Not saving the results with distinct names, so the old and new results overwrite each other (use the CPU count and job number as before).
Running many analyses: array jobs and GNU Parallel
Instructor notes
Timing. About 35 minutes of teaching and 25 of exercises. The array part and the QOS discussion take about half of it. The overhead and “which approach” discussions are the most valuable, so protect that time.
Do not let the whole class hit the limit. If 20 learners each submit 100 tasks of 20 seconds, the class does to the scheduler exactly what this episode warns against. Options: demonstrate the 100-task submission once, from the instructor account; ask learners to submit it once, together, at a set time; or use a training QOS with a low limit so the effect is visible without the load. Warn the people who run the cluster before the session.
Check before the session.
- Find out what really happens on Falcon when 100 tasks are submitted
with the training account: is the submission refused, or do tasks wait?
Note the exact message or reason, and update the section on scaling up.
Also check how the
%throttle looks, and the value ofMaxArraySize(scontrol show config | grep MaxArraySize). - Fill in the real limits and the contact address for limit requests.
- Check the
sacctmgrcolumn names on your Slurm version. - Run both scripts end to end, and confirm the module name for GNU Parallel, and whether it prints a citation notice on first use (if so, mention that GNU Parallel asks to be cited in publications).
- Confirm the memory figure: peak memory per task, from
sefforMaxRSS, times the number of tasks at once. - Check how long 100 seeds take with 16 at a time, so the time limit in the script is realistic. Memory bandwidth shared between 16 tasks can make each one slower than a single run.
- Confirm the job numbers of array tasks on Falcon and update the example outputs.
A good demonstration of overhead. Submit 100 tasks as an array and the same 100 with GNU Parallel on the same number of CPUs, and compare the total time from submission to the last result. The array has to be scheduled task by task, and the difference is usually striking. The queue state of the cluster at that moment affects it, so try it first.
Common problems.
- The
logsdirectory does not exist, so the log files are not written. -
--memset for one task in the Parallel script, and the job killed withOUT_OF_MEMORY. - Forgetting
-j, so parallel starts more tasks than CPUs. - Forgetting the thread setting, and oversubscribing.
-
%10mistaken for a limit on the number of tasks submitted. It limits only how many run at the same time. - Windows line endings in the scripts (see the earlier episodes).
- Learners put
--arrayin the script and also on the command line and wonder which wins. The command line does.
Using GPUs
Instructor notes
Timing. About 20 minutes of teaching and 15 of exercises. This is the part that can be shortened if you are running late.
What has and has not been tested. The kernel logic and the host code were checked in Numba’s CUDA simulator on a small case (the result agreed with SciPy), not on a real GPU. Run the whole sequence on a GPU node before the session.
Check before the session.
- Fill in the partition,
--gressyntax and GPU types. Check whether the GPU partition ties CPUs or memory to GPUs, and adjust--cpus-per-taskand--mem. - GPU nodes are scarce. Learners may queue for a long time. Consider a reservation for the session, or have a recorded run and its output ready so the lesson can continue.
- Confirm
module spider numba-cudashows nothing on the login node, and the full name on the GPU node. Confirm the plainnumbamodule does give the confusing error on your system if you plan to demonstrate it. - Confirm the driver on the GPU nodes supports the CUDA version in the module name.
- Replace the illustrative outputs, and check the time for a larger
m. - Make sure
sweep-numba.pyuses the same sizes assweep.py(seemake_data).
Common problems.
- Searching for the module on the login node and concluding it does not exist.
- Loading
numbainstead ofnumba-cuda. - Forgetting
--gres=gpu:1, so the job runs on a GPU node with no GPU visible, or in a CPU partition. - Leaving an interactive GPU session open, which holds a scarce resource.
- Timing the first GPU call and reading the compilation time as the speed of the GPU.
- A large
mfor the kernel with the naive access pattern can be slow. This is a demonstration of access, not of tuning.