interplane.Get Omega
Read in your language

physics-mv

FORGE: request-bound machine realization, providers and verification for AienOS. Host, simulated and GB10 hardware paths have separate evidence.

Brought by drakestapleton

GitHub aien-dev/physics-mv#28 (code only)

closed derived f77585de21f8a139 #28

Imported from GitHub aien-dev/physics-mv#28 (code only)

GitHub's metadata for this pull request is unavailable: its state is DERIVED from the commits (merged: the head is reachable from this project's main; open: GitHub kept a merge ref; else closed).

Base 1ae3295f3917af510e488f3fc4249d8a545cd8c3 · Head 7c52f426df834aae56b37476de879eba46333d1f

Apply it

git checkout -b patch-f77585de21f8a139 1ae3295f3917af510e488f3fc4249d8a545cd8c3
curl -fsSL https://interplane.io/drakestapleton/physics-mv/patches/f77585de21f8a139.patch | git am

Raw patch (mbox) · Diff

Provenance

This proposal is imported from GitHub; it is not signed by its author. Its import statement and source record:

github-import 1
aien-dev/physics-mv
28
7c52f426df834aae56b37476de879eba46333d1f
{"kind":"github-import","owner":"aien-dev","repo":"physics-mv","number":28,"url":"https://github.com/aien-dev/physics-mv/pull/28","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:39:24Z","metadata":"unavailable","state_derived":true}

Changes

diff --git a/.github/workflows/host-gates.yml b/.github/workflows/host-gates.yml
index 4b099ad..d98be2c 100644
--- a/.github/workflows/host-gates.yml
+++ b/.github/workflows/host-gates.yml
@@ -19,7 +19,8 @@ name: Host gates
 #   SKIP jobs (shown grey, never green): GB10-only runners
 #       tests/run_forge_gates.sh (Gate 3/4 on the GB10), tests/run_m15_gates.sh
 #       (reads the real GPU's sysfs), tests/run_m16_requalification.sh (native
-#       GB10 submission), tests/run_nvrm_lifecycle_gates.sh (NVRM on the GB10).
+#       GB10 submission), tests/run_nvrm_lifecycle_gates.sh (NVRM on the GB10),
+#       tests/run_submission_visibility_gates.sh (GB10 queue/pushbuffer visibility).
 
 on:
   push:
@@ -100,3 +101,9 @@ jobs:
     runs-on: ubuntu-24.04-arm
     steps:
       - run: exit 1
+  gb10-submission-visibility:
+    name: "submission visibility gates (SKIP: needs GB10 + NVRM)"
+    if: ${{ false }}
+    runs-on: ubuntu-24.04-arm
+    steps:
+      - run: exit 1
diff --git a/README.md b/README.md
index f9de9bc..8413a7e 100644
--- a/README.md
+++ b/README.md
@@ -35,7 +35,7 @@ tests/run_forge_analog_sim_gates.sh  # simulated analog provider vs digital orac
 m3/tests/run_m3_gates.sh             # M3 PHYSICS_EFFECTS, 19 gates in QEMU
 ```
 
-`./run_m2_gates.sh` leaves the committed receipt untouched unless `--write-receipt` is passed, which is only for a recorded requalification decision. Gates that need the real GB10 (`tests/run_forge_gates.sh`, `tests/run_m15_gates.sh`, `tests/run_m16_requalification.sh`, `tests/run_nvrm_lifecycle_gates.sh`) run on the DGX Spark one at a time and are never killed mid-run; CI declares them SKIP, never PASS.
+`./run_m2_gates.sh` leaves the committed receipt untouched unless `--write-receipt` is passed, which is only for a recorded requalification decision. Gates that need the real GB10 (`tests/run_forge_gates.sh`, `tests/run_m15_gates.sh`, `tests/run_m16_requalification.sh`, `tests/run_nvrm_lifecycle_gates.sh`, `tests/run_submission_visibility_gates.sh`) run on the DGX Spark one at a time and are never killed mid-run; CI declares them SKIP, never PASS.
 
 ## Contributing
 
diff --git a/m16/m16_native.c b/m16/m16_native.c
index c97b42f..a964f3a 100644
--- a/m16/m16_native.c
+++ b/m16/m16_native.c
@@ -44,8 +44,9 @@ int m16_native_free_memory(M16NativeContext *ctx, void *cpu_addr) {
 int m16_native_create_channel(M16NativeContext *ctx) {
     if (!ctx) return -1;
     if (nvrm_channel(&ctx->rm) != 0) return -1;
-    /* Preallocate pushbuffer memory (4 KiB) */
-    if (nvrm_alloc(&ctx->rm, 0x1000, &ctx->pb_mem) != 0) return -1;
+    /* The CPU rewrites this command buffer between retired submissions.
+     * Bypass the GPU cache so the next submission reads the new commands. */
+    if (nvrm_alloc_gpu_uncached(&ctx->rm, 0x1000, &ctx->pb_mem) != 0) return -1;
     return 0;
 }
 
diff --git a/nvrm/nvrm.c b/nvrm/nvrm.c
index abab24f..a7cea38 100644
--- a/nvrm/nvrm.c
+++ b/nvrm/nvrm.c
@@ -625,7 +625,10 @@ int nvrm_channel(Nvrm *rm) {
     if (rm_alloc(rm, rm->chgroup, FERMI_CONTEXT_SHARE_A, &cs, sizeof cs, &rm->ctxshare)) return -1;
 
     rm->entries = 1024;
-    if (nvrm_alloc(rm, 0x10000, &rm->fifo)) return -1;
+    /* CPU publishes new queue entries and USERD GPPut after each completion.
+     * A GPU-cached allocation can retain their previous contents on GB10;
+     * CPU store barriers alone do not invalidate that cached copy. */
+    if (nvrm_alloc_gpu_uncached(rm, 0x10000, &rm->fifo)) return -1;
     if (nvrm_alloc(rm, 0x100000, &rm->notifier)) return -1;
 
     NV_CHANNEL_ALLOC_PARAMS gp;
diff --git a/nvrm/submission_visibility_gates.c b/nvrm/submission_visibility_gates.c
new file mode 100644
index 0000000..44e18a9
--- /dev/null
+++ b/nvrm/submission_visibility_gates.c
@@ -0,0 +1,77 @@
+/* Real-device regression for CPU-published queue entries and rewritten
+ * command buffers. No CUDA runtime; run under the shared chip queue.
+ * The unfixed allocator stalls on the second submission on GB10.
+ */
+#include "m16_native.h"
+
+#include <inttypes.h>
+#include <stdio.h>
+#include <string.h>
+
+static int run_sequence(int reuse) {
+    M16NativeContext ctx;
+    if (m16_native_open(&ctx) != 0) {
+        fprintf(stderr, "visibility: open failed\n");
+        return 0;
+    }
+    int ok = 0;
+    NvrmMem completion;
+    if (m16_native_create_channel(&ctx) != 0 ||
+        nvrm_alloc_gpu_uncached(&ctx.rm, 4096, &completion) != 0)
+        goto finish;
+    volatile uint32_t *marker = completion.cpu;
+    *marker = 0;
+    __asm__ volatile("dsb sy" ::: "memory");
+    uint32_t count = reuse ? ctx.rm.entries * 2 + 3 : 2;
+    for (uint32_t payload = 1; payload <= count; ++payload) {
+        uint32_t methods[32];
+        int words = m16_native_build_release(methods, completion.va,
+                                             payload, ctx.rm.compute_class);
+        if (words <= 0) goto finish;
+        if (reuse) {
+            /* Previous use is retired before the next call overwrites slot 0. */
+            if (ctx.rm.put != ctx.rm.retired ||
+                m16_native_enqueue_methods(&ctx, methods, (size_t)words) != 0)
+                goto finish;
+        } else {
+            uint32_t offset = (payload - 1) * 128;
+            memcpy((unsigned char *)ctx.pb_mem.cpu + offset, methods,
+                   (size_t)words * sizeof(uint32_t));
+            __asm__ volatile("dsb sy" ::: "memory");
+            if (nvrm_enqueue(&ctx.rm, &ctx.pb_mem, offset, (uint32_t)words) != 0)
+                goto finish;
+        }
+        if (payload == 1) {
+            /* Negative control: no notification, no completed work. */
+            if (m16_native_wait_marker_ge(marker, payload, 5) == 0 || *marker != 0) {
+                fprintf(stderr, "visibility: pre-notification control failed\n");
+                goto finish;
+            }
+        }
+        m16_native_ring_doorbell(&ctx);
+        if (m16_native_wait_marker_ge(marker, payload, 5000) != 0 ||
+            *marker != payload) {
+            fprintf(stderr, "VISIBILITY_FAIL reuse=%d expected=%" PRIu32
+                    " observed=%" PRIu32 " put=%" PRIu32 " retired=%" PRIu32 "\n",
+                    reuse, payload, *marker, ctx.rm.put, ctx.rm.retired);
+            goto finish;
+        }
+        nvrm_retire(&ctx.rm, ctx.rm.put);
+    }
+    printf("visibility: reuse=%d submissions=%" PRIu32
+           " ring_capacity=%" PRIu32 " final_marker=%" PRIu32 "\n",
+           reuse, count, ctx.rm.entries, *marker);
+    ok = 1;
+finish:
+    /* Tear down the channel before freeing memory, including failure paths. */
+    if (m16_native_close(&ctx) != 0) ok = 0;
+    return ok;
+}
+
+int main(void) {
+    int distinct = run_sequence(0);
+    printf("[%s] SUBMISSION_VISIBILITY_DISTINCT_COMMANDS\n", distinct ? "PASS" : "FAIL");
+    int reuse = run_sequence(1);
+    printf("[%s] SUBMISSION_VISIBILITY_REUSE_AND_RING_WRAP\n", reuse ? "PASS" : "FAIL");
+    return distinct && reuse ? 0 : 1;
+}
diff --git a/tests/run_submission_visibility_gates.sh b/tests/run_submission_visibility_gates.sh
new file mode 100755
index 0000000..6a0b8b4
--- /dev/null
+++ b/tests/run_submission_visibility_gates.sh
@@ -0,0 +1,34 @@
+#!/bin/bash
+# tests/run_submission_visibility_gates.sh -- GB10 CPU-published queue entries and rewritten command buffers.
+set -euo pipefail
+
+SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)
+REPO_ROOT=$(cd "$SCRIPT_DIR/.." && pwd -P)
+LOCK_FILE=/tmp/aien-gb10.lock
+
+cd "$REPO_ROOT"
+
+echo "=== GB10 Submission Visibility Gates ==="
+echo "Timestamp: $(date -u +"%Y-%m-%dT%H:%M:%SZ")"
+echo "Host: $(uname -n) ($(uname -m))"
+
+echo -e "\n[*] Building submission_visibility_gates..."
+gcc -O2 -Wall -Wextra -Werror \
+  -I./nvrm -I./m16 \
+  -I./third_party/nvidia-open-580.173.02/src/common/sdk/nvidia/inc \
+  -I./third_party/nvidia-open-580.173.02/kernel-open/common/inc \
+  -I./third_party/nvidia-open-580.173.02/kernel-open/nvidia-uvm \
+  -I./third_party/nvidia-open-580.173.02/src/nvidia/arch/nvalloc/unix/include \
+  nvrm/nvrm.c m16/m16_native.c nvrm/submission_visibility_gates.c -o nvrm/submission_visibility_gates
+
+echo "    submission_visibility_gates built cleanly."
+
+if [ ! -e /dev/nvidia0 ]; then
+  echo "SKIP: /dev/nvidia0 not present; submission visibility gates need the GB10 (build above succeeded)."
+  exit 0
+fi
+
+echo -e "\n[*] Running submission_visibility_gates under GPU lock ($LOCK_FILE)..."
+flock "$LOCK_FILE" ./nvrm/submission_visibility_gates
+
+echo -e "\n=== GB10 Submission Visibility Gates: done ==="