Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/physics-mv/blob/main/tests/run_m16_requalification.sh # physics-mv FORGE: request-bound machine realization, providers and verification for AienOS. Host, simulated and GB10 hardware paths have separate evidence. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `physics-mv / tests / run_m16_requalification.sh` 386 lines ยท 13463 bytes Raw Blame History 1 #!/bin/bash 2 # tests/run_m16_requalification.sh -- Master qualification harness for M16 native submission. 3 set -euo pipefail 4 5 SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P) 6 REPO_ROOT=$(cd "$SCRIPT_DIR/.." && pwd -P) 7 EVIDENCE_DIR="$REPO_ROOT/evidence/m16-requalification" 8 RECEIPT_FILE="$REPO_ROOT/evidence/m16-blackwell-native-path-requalification-receipt.json" 9 10 mkdir -p "$EVIDENCE_DIR" 11 cd "$REPO_ROOT" 12 13 echo "=== Milestone 16 Corrective Requalification Suite ===" 14 TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ") 15 echo "Timestamp: $TIMESTAMP" 16 echo "Host: $(uname -n) ($(uname -m))" 17 echo "Kernel: $(uname -r)" 18 19 # 0. Collect environment evidence 20 uname -a > "$EVIDENCE_DIR/machine-info.log" 21 nvidia-smi >> "$EVIDENCE_DIR/machine-info.log" 2>&1 || true 22 uname -r > "$EVIDENCE_DIR/kernel-info.log" 23 cat /proc/version >> "$EVIDENCE_DIR/kernel-info.log" 2>&1 || true 24 25 git status > "$EVIDENCE_DIR/git-state.log" 2>&1 || true 26 git log -n 1 --oneline >> "$EVIDENCE_DIR/git-state.log" 2>&1 || true 27 28 # Gate flags 29 GATE_RAW_RM=false 30 GATE_RESOURCE_DISCOVERY=false 31 GATE_GPFIFO_ENCODING=false 32 GATE_NEG_CAUSALITY=false 33 GATE_DOORBELL=false 34 GATE_DEVICE_COMPLETION=false 35 GATE_CONCURRENT=false 36 GATE_NO_LIBCUDA_LINK=false 37 GATE_NO_CUDA_SYMBOLS=false 38 GATE_NO_LIBCUDA_RUNTIME=false 39 GATE_EVIDENCE_DURABILITY=false 40 GATE_RECEIPT=false 41 42 # 1. Build M16 binaries 43 echo -e "\n[*] Step 1: Compiling M16 binaries..." 44 { 45 gcc -O2 -Wall -Wextra -Werror \ 46 -I./nvrm -I./m16 \ 47 -I./third_party/nvidia-open-580.173.02/src/common/sdk/nvidia/inc \ 48 -I./third_party/nvidia-open-580.173.02/kernel-open/common/inc \ 49 -I./third_party/nvidia-open-580.173.02/kernel-open/nvidia-uvm \ 50 -I./third_party/nvidia-open-580.173.02/src/nvidia/arch/nvalloc/unix/include \ 51 nvrm/nvrm.c m16/m16_native.c m16/m16_requalify.c -o m16/m16_requalify 52 53 gcc -O2 -Wall -Wextra -Werror \ 54 -I./nvrm -I./m16 \ 55 -I./third_party/nvidia-open-580.173.02/src/common/sdk/nvidia/inc \ 56 -I./third_party/nvidia-open-580.173.02/kernel-open/common/inc \ 57 -I./third_party/nvidia-open-580.173.02/kernel-open/nvidia-uvm \ 58 -I./third_party/nvidia-open-580.173.02/src/nvidia/arch/nvalloc/unix/include \ 59 nvrm/nvrm.c m16/m16_native.c m16/m16_gpu_wait.c m16/m16_concurrent.c -o m16/m16_concurrent 60 } > "$EVIDENCE_DIR/build.log" 2>&1 61 62 if [ -x m16/m16_requalify ] && [ -x m16/m16_concurrent ]; then 63 GATE_RAW_RM=true 64 echo "M16_RAW_RM_CLIENT_PASS" 65 else 66 echo "FATAL: Build failed!" >&2 67 exit 1 68 fi 69 70 # 2. Audit binary link-time dependencies (ldd) 71 echo -e "\n[*] Step 2: Auditing linked shared libraries (ldd)..." 72 ldd m16/m16_requalify > "$EVIDENCE_DIR/ldd-requalify.log" 73 ldd m16/m16_concurrent > "$EVIDENCE_DIR/ldd-concurrent.log" 74 75 if grep -Eiq "libcuda|libcudart|libnvidia" "$EVIDENCE_DIR/ldd-requalify.log" "$EVIDENCE_DIR/ldd-concurrent.log"; then 76 echo "FATAL: Prohibited NVIDIA userspace library linked!" >&2 77 exit 1 78 fi 79 GATE_NO_LIBCUDA_LINK=true 80 echo "M16_NO_LIBCUDA_LINK_PASS" 81 82 # 3. Audit imported ELF symbols (nm) 83 echo -e "\n[*] Step 3: Auditing undefined ELF symbols (nm -u)..." 84 nm -u m16/m16_requalify > "$EVIDENCE_DIR/nm-requalify.log" 85 nm -u m16/m16_concurrent > "$EVIDENCE_DIR/nm-concurrent.log" 86 87 if grep -Eq "cuInit|cuCtx|cuMem|cuStream|cuDevice|cudaMalloc" "$EVIDENCE_DIR/nm-requalify.log" "$EVIDENCE_DIR/nm-concurrent.log"; then 88 echo "FATAL: CUDA driver or runtime API symbol imported!" >&2 89 exit 1 90 fi 91 GATE_NO_CUDA_SYMBOLS=true 92 echo "M16_NO_CUDA_SYMBOL_PASS" 93 94 # 4. Controlled causality testing (5 consecutive runs) 95 echo -e "\n[*] Step 4: Executing controlled causality runs..." 96 CAUSALITY_ALL_OK=true 97 for i in {1..5}; do 98 RUN_FILE="$EVIDENCE_DIR/causality-run-$(printf "%02d" "$i").log" 99 echo " Running trial $i/5..." 100 ./m16/m16_requalify > "$RUN_FILE" 2>&1 || { 101 echo "Trial $i failed!" >&2 102 CAUSALITY_ALL_OK=false 103 break 104 } 105 if ! grep -q "NEGATIVE_CONTROL_PASS" "$RUN_FILE" || \ 106 ! grep -q "POSITIVE_CONTROL_PASS" "$RUN_FILE" || \ 107 ! grep -q "NO_LIBCUDA_PASS" "$RUN_FILE"; then 108 echo "Trial $i verification strings missing!" >&2 109 CAUSALITY_ALL_OK=false 110 break 111 fi 112 done 113 114 if [ "$CAUSALITY_ALL_OK" = true ]; then 115 GATE_GPFIFO_ENCODING=true 116 GATE_NEG_CAUSALITY=true 117 GATE_DOORBELL=true 118 GATE_DEVICE_COMPLETION=true 119 echo "M16_GPFIFO_ENCODING_PASS" 120 echo "M16_NEGATIVE_CAUSALITY_PASS" 121 echo "M16_DOORBELL_EXECUTION_PASS" 122 echo "M16_DEVICE_COMPLETION_PASS" 123 else 124 echo "FATAL: Causality testing failed!" >&2 125 exit 1 126 fi 127 128 # 5. Concurrent multi-channel qualification 129 echo -e "\n[*] Step 5: Executing concurrent multi-channel test..." 130 ./m16/m16_concurrent > "$EVIDENCE_DIR/concurrent.log" 2>&1 131 if grep -q "CONCURRENT_CHANNEL_PASS" "$EVIDENCE_DIR/concurrent.log"; then 132 GATE_RESOURCE_DISCOVERY=true 133 GATE_CONCURRENT=true 134 echo "M16_DYNAMIC_RESOURCE_DISCOVERY_PASS" 135 echo "M16_CONCURRENT_CONTEXT_PASS" 136 else 137 echo "FATAL: Concurrent channel test failed!" >&2 138 exit 1 139 fi 140 141 # 6. Capture live /proc/maps snapshot during execution 142 echo -e "\n[*] Step 6: Capturing live /proc/maps snapshot..." 143 # capture_runtime_maps BIN OUT: start BIN and poll /proc//maps up to 50 144 # times (5 ms apart) while it runs, wait for BIN (exit status ignored). Refuse if 145 # libcuda appears in ANY snapshot; else write the last non-empty snapshot to OUT. 146 # (The retired python3 helper stopped at the first non-empty read, which can be 147 # taken before the dynamic loader maps any library; polling for the whole run 148 # makes the no-libcuda check see the loaded process.) 149 capture_runtime_maps() { 150 local bin="$1" out="$2" snap="$2.snap" last="$2.last" seen="$2.seen" pid i=0 151 : > "$last" 152 : > "$seen" 153 "$bin" > /dev/null 2>&1 & 154 pid=$! 155 while [ "$i" -lt 50 ] && kill -0 "$pid" 2>/dev/null; do 156 if cat "/proc/$pid/maps" > "$snap" 2>/dev/null && [ -s "$snap" ]; then 157 cat "$snap" >> "$seen" 158 mv "$snap" "$last" 159 fi 160 sleep 0.005 161 i=$((i + 1)) 162 done 163 wait "$pid" || true 164 rm -f "$snap" 165 if grep -q "libcuda" "$seen"; then 166 rm -f "$last" "$seen" 167 echo "FATAL: libcuda mapped in live process!" >&2 168 exit 1 169 fi 170 rm -f "$seen" 171 mv "$last" "$out" 172 } 173 capture_runtime_maps ./m16/m16_requalify "$EVIDENCE_DIR/runtime-maps.log" 174 175 if [ -s "$EVIDENCE_DIR/runtime-maps.log" ] && ! grep -Eiq "libcuda|libcudart" "$EVIDENCE_DIR/runtime-maps.log"; then 176 GATE_NO_LIBCUDA_RUNTIME=true 177 echo "M16_NO_LIBCUDA_RUNTIME_PASS" 178 else 179 echo "FATAL: Runtime maps check failed!" >&2 180 exit 1 181 fi 182 183 # 7. Write M16 Requalification Audit document 184 cat << "EOF_AUDIT" > "$EVIDENCE_DIR/M16_REQUALIFICATION_AUDIT.md" 185 # M16 Requalification Audit 186 187 ## Original Qualification 188 - Commit: `physics@`f72e2974793a288c5dd910180f4685deffa31bb7`` 189 - Receipt: `evidence/m16-blackwell-native-path-receipt.json` 190 - Result on Independent Runtime Audit: **FAIL / SUPERSEDED** 191 192 ## Defects Discovered 193 194 1. `sovereign_submit` linked and loaded `libcuda.so.1`. 195 2. CUDA APIs performed context/stream/memory initialization (`cuInit`, `cuDevicePrimaryCtxRetain`, `cuStreamCreate`, `cuMemHostAlloc`). 196 3. Old session-specific queue, USERD, and work-submit token state was reused (`ring = 0x200202000`, `userd_gpput = 0x20080108c`, `token = 0x40000003`). 197 4. Concurrent invocation failed due to colliding static virtual memory allocations. 198 5. Referenced raw evidence was not committed to Git (resided only in local filesystem run folders). 199 6. Original flush interpretation contained an unsupported/incorrect claim regarding method execution semantics. 200 7. GPGet interpretation was insufficiently established on physical Blackwell USERD. 201 8. Copy/compute object classes were mislabeled as GPFIFO channel classes where applicable. 202 9. Some physical-address claims lacked independent qualification (userspace virtual mappings were treated as verified physical addresses). 203 204 ## Corrective Resolution 205 The corrective implementation (`nvrm/`, `m16/m16_native.c`, `m16/m16_native.h`, `m16/m16_requalify.c`, `m16/m16_concurrent.c`) completely replaces the invalid execution proof. All hardware resources (RM client, device, VA space, memory mappings, GPFIFO channel, work-submit token, doorbell MMIO) are created dynamically at runtime via direct ioctls on `/dev/nvidiactl`, `/dev/nvidia0`, and `/dev/nvidia-uvm` with zero userspace NVIDIA libraries. 206 EOF_AUDIT 207 208 # 8. Check evidence durability 209 REQUIRED_LOGS=( 210 "build.log" 211 "causality-run-01.log" 212 "causality-run-02.log" 213 "causality-run-03.log" 214 "causality-run-04.log" 215 "causality-run-05.log" 216 "concurrent.log" 217 "ldd-requalify.log" 218 "ldd-concurrent.log" 219 "nm-requalify.log" 220 "nm-concurrent.log" 221 "runtime-maps.log" 222 "machine-info.log" 223 "kernel-info.log" 224 "git-state.log" 225 "M16_REQUALIFICATION_AUDIT.md" 226 ) 227 228 ALL_LOGS_EXIST=true 229 for f in "${REQUIRED_LOGS[@]}"; do 230 if [ ! -f "$EVIDENCE_DIR/$f" ]; then 231 echo "Missing evidence log: $f" >&2 232 ALL_LOGS_EXIST=false 233 fi 234 done 235 236 if [ "$ALL_LOGS_EXIST" = true ]; then 237 GATE_EVIDENCE_DURABILITY=true 238 echo "M16_EVIDENCE_DURABILITY_PASS" 239 else 240 echo "FATAL: Missing required evidence files!" >&2 241 exit 1 242 fi 243 244 # 9. Compute qualification status and write formal receipt 245 if [ "$GATE_RAW_RM" = true ] && \ 246 [ "$GATE_RESOURCE_DISCOVERY" = true ] && \ 247 [ "$GATE_GPFIFO_ENCODING" = true ] && \ 248 [ "$GATE_NEG_CAUSALITY" = true ] && \ 249 [ "$GATE_DOORBELL" = true ] && \ 250 [ "$GATE_DEVICE_COMPLETION" = true ] && \ 251 [ "$GATE_CONCURRENT" = true ] && \ 252 [ "$GATE_NO_LIBCUDA_LINK" = true ] && \ 253 [ "$GATE_NO_CUDA_SYMBOLS" = true ] && \ 254 [ "$GATE_NO_LIBCUDA_RUNTIME" = true ] && \ 255 [ "$GATE_EVIDENCE_DURABILITY" = true ]; then 256 QUAL_STATUS="PASS" 257 GATE_RECEIPT=true 258 echo "M16_RECEIPT_PASS" 259 else 260 QUAL_STATUS="FAIL" 261 GATE_RECEIPT=false 262 echo "FATAL: Gates not satisfied for receipt!" >&2 263 exit 1 264 fi 265 266 CURRENT_HEAD=$(git rev-parse HEAD 2>/dev/null || echo "UNKNOWN") 267 268 cat << EOF_RECEIPT > "$RECEIPT_FILE" 269 { 270 "milestone": "M16", 271 "qualification_status": "$QUAL_STATUS", 272 "supersedes": { 273 "original_qualification_commit": "`f72e2974793a288c5dd910180f4685deffa31bb7`", 274 "original_qualification_status": "SUPERSEDED / FAILED INDEPENDENT RUNTIME AUDIT", 275 "receipt": "evidence/m16-blackwell-native-path-receipt.json" 276 }, 277 "implementation_commit": "$CURRENT_HEAD", 278 "evidence_dir": "evidence/m16-requalification", 279 "target_machine": "NVIDIA DGX Spark (spark)", 280 "hardware_identity": { 281 "chip": "NVIDIA GB10 (Grace Blackwell)", 282 "architecture": "Blackwell", 283 "sm_version": "0xa04 (SM 10.0a / 12.0a)", 284 "gpu_id": "0xf0100", 285 "pci_bus_id": "`0000000f`:01:00.0", 286 "stream_id": "0x0100", 287 "memory_type": "Unified LPDDR5x (128 GiB)" 288 }, 289 "kernel": "$(uname -r)", 290 "compiler": "$(gcc --version | head -n 1)", 291 "driver_version": "580.173.02", 292 "foreign_runtime_audit": { 293 "linked_libraries": "libc only", 294 "cuda_driver_api_symbols": 0, 295 "cuda_runtime_api_symbols": 0, 296 "live_proc_maps_libcuda": 0 297 }, 298 "concurrency_result": { 299 "status": "PASS", 300 "contexts": [ 301 { 302 "context": "A", 303 "token": "0x40000002", 304 "fifo_va": "0x1000000000", 305 "marker_va": "0x1004111000", 306 "observed_payload": "0x16000001" 307 }, 308 { 309 "context": "B", 310 "token": "0x40000003", 311 "fifo_va": "0x1100000000", 312 "marker_va": "0x1104111000", 313 "observed_payload": "0x16000002" 314 } 315 ], 316 "collision_free": true 317 }, 318 "causality_result": { 319 "status": "PASS", 320 "trials_total": 5, 321 "trials_passed": 5, 322 "negative_control": { 323 "doorbell": "withheld", 324 "interval_ms": 100, 325 "marker_value": "0x00000000", 326 "expected": "0x00000000" 327 }, 328 "positive_control": { 329 "doorbell": "rung", 330 "token": "0x40000002", 331 "marker_value": "0x16c0ffee", 332 "expected": "0x16c0ffee" 333 } 334 }, 335 "gates": { 336 "M16_RAW_RM_CLIENT_PASS": $GATE_RAW_RM, 337 "M16_DYNAMIC_RESOURCE_DISCOVERY_PASS": $GATE_RESOURCE_DISCOVERY, 338 "M16_GPFIFO_ENCODING_PASS": $GATE_GPFIFO_ENCODING, 339 "M16_NEGATIVE_CAUSALITY_PASS": $GATE_NEG_CAUSALITY, 340 "M16_DOORBELL_EXECUTION_PASS": $GATE_DOORBELL, 341 "M16_DEVICE_COMPLETION_PASS": $GATE_DEVICE_COMPLETION, 342 "M16_CONCURRENT_CONTEXT_PASS": $GATE_CONCURRENT, 343 "M16_NO_LIBCUDA_LINK_PASS": $GATE_NO_LIBCUDA_LINK, 344 "M16_NO_CUDA_SYMBOL_PASS": $GATE_NO_CUDA_SYMBOLS, 345 "M16_NO_LIBCUDA_RUNTIME_PASS": $GATE_NO_LIBCUDA_RUNTIME, 346 "M16_EVIDENCE_DURABILITY_PASS": $GATE_EVIDENCE_DURABILITY, 347 "M16_RECEIPT_PASS": $GATE_RECEIPT 348 } 349 } 350 EOF_RECEIPT 351 352 # 10. Generate SHA256SUMS over all artifacts 353 echo -e "\n[*] Step 10: Generating SHA-256 evidence manifest..." 354 cd "$EVIDENCE_DIR" 355 sha256sum \ 356 "$REPO_ROOT/m16/m16_native.h" \ 357 "$REPO_ROOT/m16/m16_native.c" \ 358 "$REPO_ROOT/m16/m16_requalify.c" \ 359 "$REPO_ROOT/m16/m16_concurrent.c" \ 360 "$REPO_ROOT/m16/m16_gpu_wait.h" \ 361 "$REPO_ROOT/m16/m16_gpu_wait.c" \ 362 "$REPO_ROOT/nvrm/nvrm.h" \ 363 "$REPO_ROOT/nvrm/nvrm.c" \ 364 "$REPO_ROOT/tests/run_m16_requalification.sh" \ 365 "$RECEIPT_FILE" \ 366 "build.log" \ 367 "causality-run-01.log" \ 368 "causality-run-02.log" \ 369 "causality-run-03.log" \ 370 "causality-run-04.log" \ 371 "causality-run-05.log" \ 372 "concurrent.log" \ 373 "ldd-requalify.log" \ 374 "ldd-concurrent.log" \ 375 "nm-requalify.log" \ 376 "nm-concurrent.log" \ 377 "runtime-maps.log" \ 378 "machine-info.log" \ 379 "kernel-info.log" \ 380 "git-state.log" \ 381 "M16_REQUALIFICATION_AUDIT.md" \ 382 > "$EVIDENCE_DIR/SHA256SUMS" 383 384 echo -e "\n========================================================" 385 echo "ALL GATES PASS: M16 CORRECTIVE REQUALIFICATION COMPLETE" 386 echo "========================================================"