In the context of xargs, the flag
-n 3
means “take at most 3 items from the input per command invocation.”
Put another way:
- You’re piping a (whitespace- or newline-separated) list of tokens into
xargs.
- With
-n 3, xargs will pull 3 tokens at a time and run one instance of your command for each trio.
For example, if your input file ($TMP_FILE) contained:
alpha
beta
gamma
delta
epsilon
zeta
then
cat "$TMP_FILE" | xargs -n 3 echo
would execute:
echo alpha beta gamma
echo delta epsilon zeta
In your real command:
cat "$TMP_FILE" \
| xargs -P $MAX_JOBS -n 3 bash -c \
'uv run train.py --compare --file "$1" -n "$0" --pretokenizer "$2" --parallel ${N_CPUS}'
-P $MAX_JOBS ⇒ run up to $MAX_JOBS processes in parallel.
-n 3 ⇒ feed three tokens into each bash -c call:
$0 becomes the first token (used as the -n arg to uv run),
$1 becomes the second (the filename),
$2 becomes the third (the pretokenizer).
That way you bundle each “name + file + pretokenizer” triple into its own train job. 🚀