A job whose memory doesn’t sit still

A job whose memory doesn’t sit still#

Recording multiple jobs fitted a model to perfectScaler, which tries to use exactly the memory you ask it for. Real jobs aren’t that obliging. This lesson runs a 39-run loop against complexMemScaler, whose memory moves from run to run, and looks at what slurmise does when the fit isn’t good enough to trust.

On a cluster this lesson takes a few minutes, mostly SLURM starting 39 job steps. To follow along, cd into 03_noisy_job/.

The noisy job#

../bin/complexMemScaler takes the same --intensity as perfectScaler, and the sbatch walks lesson 02’s 13 intensities, 3 replicates each. What differs is inside the script: it allocates the intensity you asked for, jitters it by ±20%, and adds a flat 1000 MB on top.

run_complexMemScaler_loop.sbatch#
#!/bin/bash
#SBATCH --nodes=1
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=1
#SBATCH --mem=10G
#SBATCH --time=00:10:00
#SBATCH --job-name=complexMemScaler_loop
#SBATCH --output=out_slurm_logs/slurm-%x-%j.out

# Specify 13 run parameters on the complex scaler.
#
#       Runs:  1   2     3    4    5    6    7    8    9   10   11   12   13
intensities=(500 1000 1500 2000 2500 3000 3500 4000 4500 5000 5500 6000 6500)

replicates=3

# Launch complexMemScaler srun jobs in a loop. First job will get intensity=500
step=0
for i in "${!intensities[@]}"; do
    intensity=${intensities[$i]}

    # Run multiple replicates of the same --intensity job
    for (( j=0; j<replicates; j++ )); do
        # srun the command
        srun ../bin/complexMemScaler --intensity "$intensity"

        # record the results keeping track of the --step-id
        slurmise record \
            --step-id "$step" \
            "complexMemScaler --intensity $intensity"

        # increment the step
        step=$((step + 1))
    done

done

So two things are true at once, and it’s worth keeping them apart. The flat 1000 MB is a real, learnable offset — this job simply needs more memory than perfectScaler at the same arguments, and a model can pick that up. The ±20% jitter is noise, and no model can predict it; the best it can do is fit through the middle and be wrong by up to a fifth either way.

The toml is lesson 02’s with the job name changed:

slurmise.toml#
[slurmise]
base_dir = "."

[slurmise.job.complexMemScaler]
job_spec = "--intensity {intensity}"

[slurmise.job.complexMemScaler.runtime]
default = 30

[slurmise.job.complexMemScaler.memory]
default = 5000

[slurmise.job.complexMemScaler.variables]
intensity = {type = "numeric"}

Submit it#

mkdir -p out_slurm_logs
sbatch --wait run_complexMemScaler_loop.sbatch
bash mock_complexMemScaler_loop.sh

Inspect#

slurmise --toml slurmise.toml print | head -30
complexMemScaler
|--- 23456.0
|    |--- intensity: () int64 500
|    |--- memory: () int64 1570
|    |--- runtime: () int64 0
|--- 23456.1
|    |--- intensity: () int64 500
|    |--- memory: () int64 1510
|    |--- runtime: () int64 0
|--- 23456.10
|    |--- intensity: () int64 2000
|    |--- memory: () int64 2980
|    |--- runtime: () int64 0
|--- 23456.11
|    |--- intensity: () int64 2000
|    |--- memory: () int64 2660
|    |--- runtime: () int64 0
|--- 23456.12
|    |--- intensity: () int64 2500
|    |--- memory: () int64 3675
|    |--- runtime: () int64 0
|--- 23456.13
|    |--- intensity: () int64 2500
|    |--- memory: () int64 3250
|    |--- runtime: () int64 0
|--- 23456.14
|    |--- intensity: () int64 2500
|    |--- memory: () int64 3300
|    |--- runtime: () int64 0
|--- 23456.15

39 records, sharing one job id and separated by --step-id. Look down the memory values for the replicates of a single intensity — perfectScaler would have used the same memory each time; here they scatter.

Train, and predict#

slurmise update-all
slurmise predict "complexMemScaler --intensity 2750"
Predicted runtime: 30
Predicted memory: 3851
Warnings:
  Predicted runtime for job complexMemScaler is zero or negative (0).
  Run: slurmise update-model --job-name complexMemScaler

You’ll get one of two things here, and which one depends on how the noise fell in the 39 runs. Either a model-based number, noticeably larger than lesson 02’s answer to the same question, which is the flat 1000 MB showing up. Or this:

Predicted memory: 5000

Warnings:
  Memory prediction for job complexMemScaler is not within 20% of actual value.
  Returning default memory value.

5000 is default_mem from the toml. slurmise scored the fitted model against the runs it held back, found it missed by more than 20%, and declined to use it. Across several passes while writing this lesson the error came out at 15.6%, 17.7% and 22.4% — the same command, genuinely falling on both sides of that line, because the ±20% jitter lands differently every time.

That is the guard rail worth taking away. slurmise would rather hand back a default it has warned you about than a model estimate it can’t stand behind. perfectScaler never trips it; a job with real-world variance sometimes will, and when it does the honest answer is the one you got.

If your own job behaves like this, more runs are what help — not a better model. The jitter doesn’t shrink, but a larger sample makes the fit’s estimate of the middle steadier, and the held-out error less of a lottery.