Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/contrib/dgx-spark.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ BLOOMERY_BOX_LOCAL=1 BLOOMERY_BOX_ENV='BLOOMERY_TIER=fixture BLOOMERY_GATE_BOUND
reference set's identity is the first shard's full path (`AGENTS.md`; a set's `# model` line,
`crates/refset/src/fixture.rs:19-20`). `/models/fixtures` stays the one legal root, so on a Spark it is a symlink
(answer 2).
- **Container drive counters.** The depth, nvtier-read and engram-rate runners resolve a model's mount through
`tools/ref/drive-read.sh`: `findmnt --nofsroot` removes a bind mount's bracketed root, then `lsblk` resolves the
whole-disk parent or kernel name. The container must expose readable `/sys/block/<disk>/stat` counters.
A mount or counter that cannot be read is a named exit 2 before timing, not a guessed device or a weaker witness.
- **Card names.** A Spark's card is named neither 3090 nor A6000, and local mode takes the one local card without a name
match. `--place gate` plans the 3090's bytes on the smallest visible card with the room for them, the GB10 here, and local mode refuses the
two-card recipes (rc 64) ([#13](https://github.com/midagedev/bloomery/issues/13#issuecomment-6124298082)). Which
Expand Down
40 changes: 40 additions & 0 deletions tools/ref/card-tests/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,46 @@ has() {
if grep -Eq -- "$2" "$tmp/out"; then pass "$1"; else fail "$1" "no line matches /$2/" "$tmp/out"; fi
}

# The drive reader against a bind-root source, a whole-disk alias and absent counters. Only the
# mount/block-device commands and /sys readability stand in; no disk or Linux /sys is needed.
drive_case() (
mode=$1
source "$ROOT/tools/ref/drive-read.sh"
findmnt() {
[ "$mode" != unmounted ] || return 1
case "$mode" in
alias) echo /dev/disk/by-id/test-alias ;;
fallback) echo /dev/testdisk ;;
*)
case " $* " in
*" --nofsroot "*) echo /dev/testp1 ;;
*) echo '/dev/testp1[/models]' ;;
esac
;;
esac
}
lsblk() {
case "$3:$4" in
PKNAME:/dev/testp1) echo testdisk ;;
KNAME:/dev/disk/by-id/test-alias) echo testdisk ;;
*) return 1 ;;
esac
}
function [ {
if builtin [ "${1:-}" = -r ] && [[ "${2:-}" = /sys/block/*/stat ]]; then
builtin [ "$mode" != nocounters ] && builtin [ "$2" = /sys/block/testdisk/stat ]
else
builtin [ "$@"
fi
}
drive_dev '/models with space/model.gguf'
)
run 'drive: a bind root resolves to the whole disk' 0 '^testdisk$' drive_case bind
run 'drive: a whole-disk alias resolves through KNAME' 0 '^testdisk$' drive_case alias
run 'drive: a canonical disk with no lsblk row retains its counters' 0 '^testdisk$' drive_case fallback
run 'drive: absent counters are a named refusal' 2 'no counters at /sys/block/testdisk/stat' drive_case nocounters
run 'drive: an unreadable mount is a named refusal' 2 'findmnt cannot name the mount of /models with space' drive_case unmounted

# card <fixture> <rc> <pattern> [args…]: card.py check on a fixture of this directory.
card() {
local f=$1 want=$2 pat=$3
Expand Down
15 changes: 11 additions & 4 deletions tools/ref/drive-read.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
# shellcheck shell=bash
# The drive a model file is read from, and what the drive was asked to read (nvtier-read.sh,
# depth-qwen3moe.sh): the device is read from the file's mount, never guessed, and its counters are the
# depth-qwen3moe.sh, engram-rate.sh): the device is read from the file's mount, never guessed, and its counters are the
# kernel's own (/sys/block/<dev>/stat, field 3: sectors read, 512 B each — the number /proc/diskstats
# prints as its sixth column). Sourced; it defines functions and runs nothing.

# drive_source <file>: the mount's device, without a bind mount's bracketed filesystem root.
drive_source() {
local dir
dir=$(dirname "$1")
findmnt --nofsroot -n -o SOURCE --target "$dir" || { echo "drive-read.sh: findmnt cannot name the mount of $dir" >&2; return 2; }
}

# drive_dev <file>: the whole-disk device of the mount <file>'s directory sits on, on stdout; rc 2 with the
# reason on stderr when the mount or its counters cannot be read (a drive whose counters cannot be read is
# no instrument).
drive_dev() {
local dir src dev
dir=$(dirname "$1")
src=$(findmnt -n -o SOURCE --target "$dir") || { echo "drive-read.sh: findmnt cannot name the mount of $dir" >&2; return 2; }
local src dev
src=$(drive_source "$1") || return 2
dev=$(lsblk -n -o PKNAME "$src" 2> /dev/null | head -n1 || true)
[ -n "$dev" ] || dev=$(lsblk -n -o KNAME "$src" 2> /dev/null | head -n1 || true)
[ -n "$dev" ] || dev=$(basename "$src")
[ -r "/sys/block/$dev/stat" ] || { echo "drive-read.sh: no counters at /sys/block/$dev/stat (mount source $src, device $dev)" >&2; return 2; }
echo "$dev"
Expand Down
11 changes: 5 additions & 6 deletions tools/ref/engram-rate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,17 @@ export BLOOMERY_DATA
# The lease and the witness fields.
# shellcheck source=tools/ref/lease.sh
source "${BASH_SOURCE[0]%/*}/lease.sh"
# shellcheck source=tools/ref/drive-read.sh
source "${BASH_SOURCE[0]%/*}/drive-read.sh"

BIN=${BLOOMERY_ENGRAM_BIN:-target/release/engram-rate}
[ -x "$BIN" ] || { echo "no engram-rate at $BIN — run: just build-engram" >&2; exit 2; }

# The V4.1 file set: the deepseek41 profile's choice, exported by tools/box.sh.
DIR=${BLOOMERY_V41_DIR:?BLOOMERY_V41_DIR unset — run through tools/box.sh, which exports it from the deepseek41 profile}
# 테이블이 어느 블록 디바이스에 있는지는 추측하지 않는다 — 마운트에서 읽는다.
SRC=$(findmnt -n -o SOURCE --target "$DIR")
# `|| true` 안에서 받는다: set -e 아래에서는 대입 안의 파이프라인이 실패하면 그 줄에서 죽어,
# 다음 줄의 폴백이 영영 안 돈다. 발견이 실패해도 러너는 증인만 약해진 채 계속 가야 한다.
DEV=$(lsblk -n -o PKNAME "$SRC" 2>/dev/null | head -n1 || true)
[ -n "$DEV" ] || DEV=$(basename "$SRC")
# The shared reader resolves bind roots and refuses a drive with no readable counters.
SRC=$(drive_source "$DIR/.") || exit 2
DEV=$(drive_dev "$DIR/.") || exit 2
STAT=/sys/block/$DEV/stat

WITNESS=(head table loadavg pressure-io blockstat meminfo lock-holder model)
Expand Down
2 changes: 1 addition & 1 deletion tools/ref/nvtier-read.sh
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ echo "[binary] $BIN sha256=$BIN_SHA mtime=$BIN_MTIME (newer than every file in i
DIR=$(dirname "$MODEL")
DEV=$(drive_dev "$MODEL") || exit 2
# The witness's table and blockstat fields read the mount source and the device's counters.
SRC=$(findmnt -n -o SOURCE --target "$DIR")
SRC=$(drive_source "$MODEL") || exit 2
STAT=/sys/block/$DEV/stat

WITNESS=(head loadavg pressure-cpu pressure-io table blockstat meminfo pgmajfault cpu cpu-mhz-range lock-holder binary model)
Expand Down
Loading