File size: 1,830 Bytes
a66a9c7
 
 
 
 
 
 
 
 
 
 
290f61d
a66a9c7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
# Does interleaved PLACEMENT of the weights help the real engine?
#
# The earlier attempt was invalid: when the GGUF is already in page cache, `numactl --interleave=all` cannot
# re-place pages that were faulted under a different policy, and `--load-mode none` (anonymous copy) costs ~13%
# which cancels the gain. The only honest way is to materialise a NEW file while the interleave policy is in
# force - the page-cache pages of the copy are allocated by the copying process, so they inherit the policy.
#
# Usage: ./interleave-test.sh <model.gguf>
# Leaves <model>-il.gguf behind (same size again on disk).
set -uo pipefail
TARGET=${TARGET:?set TARGET to the ssh alias of the target ISA host}
SRC=${1:?usage: interleave-test.sh <model.gguf>}
IL="${SRC%.gguf}-il.gguf"
RDIR=/home/bob/OldIron/results
THREADS=${THREADS:-24}
NICE="nice -n 19"

echo "=== 1. materialise an interleaved copy (one-off, this is the expensive step) ==="
if ssh -o BatchMode=yes "$TARGET" "[ -f '$IL' ]"; then
  echo "  already exists: $IL"
else
  ssh -o BatchMode=yes "$TARGET" "numactl --interleave=all cp '$SRC' '$IL' && ls -l '$IL'" \
    || { echo "FAILED: copy"; exit 1; }
fi

echo "=== 2. A/B on the engine: default placement vs interleaved copy (same file contents) ==="
for round in 1 2; do
  for tag in default interleaved; do
    [ "$tag" = default ] && M="$SRC" || M="$IL"
    printf '  round %s %-12s ' "$round" "$tag"
    ssh -o BatchMode=yes "$TARGET" "cd /home/bob/OldIron/engine && $NICE ./bin/llama-bench -m '$M' -ngl 0 -nopo 1 -t $THREADS -p 0 -n 48 -r 1" 2>/dev/null \
      | grep tg48 | grep -oE '[0-9]+\.[0-9]+ ± [0-9.]+'
  done
done

echo "=== 3. what the pages actually look like (numastat for the bench's mmap) ==="
ssh -o BatchMode=yes "$TARGET" "numastat -m 2>/dev/null | grep -E 'MemFree|FilePages' | head -4"