In this article
Array element job IDs can be created out of order; select work through SLURM_ARRAY_TASK_ID and a versioned input map rather than job-ID arithmetic.
A batch worker selects its dataset partition by subtracting the array’s first job ID from its own job ID. Early examples appear consistent, then a placeholder or requeued element processes another input. Slurm’s execution identity is not an ordered dataset index. Use the explicit array element identity instead.
Read the placeholder behavior
The Slurm array guide explains that the first task normally acts as a placeholder and runs last. Consequently, a low job ID can correspond to a high array task ID. The familiar ordering is itself not guaranteed. Record the array specification and inspect actual identities rather than using a successful initial example as proof of a permanent arithmetic relationship between scheduler identifiers and application inputs.
Use the explicit environment contract
The guide defines SLURM_ARRAY_JOB_ID for the array and SLURM_ARRAY_TASK_ID for the element index. The sbatch reference documents the launch environment and submitted index selection. Preserve both fields with the actual job identity and restart evidence. An element’s local task index can select work, while the array identity distinguishes another run with the same index. Neither field alone establishes the immutable dataset revision that the application intended to process.
Map sparse indexes deliberately
Arrays need not represent a convenient continuous range beginning at the first dataset row. Create a versioned mapping from each submitted task index to its intended partition and validate coverage before launch. A task count is not necessarily an upper bound suitable for direct indexing into that map. The logical partition guide explains the adjacent stable-work principle; here the important failure is Slurm-specific identifier ordering being mistaken for that stable application index.
Preserve requeue as another attempt
The array documentation explicitly notes out-of-order creation when elements are requeued or modified before starting. Do not repair a failed subset by assuming the new sequence of job IDs recreates the original partition order. Keep accepted input identities and outputs attached to the explicit task mapping. The attempt identity guide explains why a new execution attempt must not automatically become new logical work or permission to append a duplicate accepted result.
Verify ordering exceptions in a fixture
Use a disposable sparse array with recognizable partition labels. Preserve every element’s job ID, array ID, task ID and selected input. Include a controlled retry or requeue path supported by the site. Compare observed coverage against the submitted mapping, not sorted job IDs or completion order. Acceptance requires no missing or wrongly selected partitions and explicit handling of repeated attempts. It does not claim a completed scheduler experiment or a universal element-creation sequence.
Retain the mapping with outputs
Keep the array specification, mapping revision, actual identities and per-partition acceptance result together. A filename based only on a job ID can remain useful diagnostic evidence but cannot replace the logical input key. The supported conclusion is correct work selection despite scheduler ordering and restarts. It does not establish exactly-once processing, validate every produced artifact or guarantee execution in index order; those properties require their own application contracts rather than an assumption about monotonically assigned identifiers.
Earn rental income from GPUs
Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.