Files
VoxelForge/Standalone/Research/WorldAssemblerM3/Linux101/RunL101DensityCompare.py
T
Fr0zkaandClaude Opus 5.5 55e20f4a7e passages: memoized exact MC midpoints + wider conservative sweep bounds (L101, exact vs L100)
Off-grid census by caller (MC midpoints, skirts, far shells); all 63.0M sweep misses accounted
(1.9M exact-route fallbacks, 61.1M counted bound skips). Exact MC midpoint queries memoized by
float bits (Unreal enables it too); feature bounds expanded. L100/L101 whole-view hashes equal in
all four strata (v216 unchanged); 0 added/removed crossings; 15 capture pairs pixel-identical.
Near-ready @W12 L100 -> L101: FI 1.77 -> 1.65, TN 1.66 -> 1.54, SW 0.85 -> 0.84, VS 1.03 -> 1.03 s
(L98 2.28/2.23/1.02/1.11). Fast tier PASS; Linux UE host builds. Unreal arrival traces not obtained
(the runner wrongly applied the 6 GiB address-space cap to Unreal).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016dhxM43dnWvUu2B5Ph1iG1
2026-10-28 18:57:56 +01:00

145 lines
6.7 KiB
Python

#!/usr/bin/env python3
"""Compare the direct passage evaluator with the bounded L101 swept tube."""
from __future__ import annotations
import json
import re
import subprocess
import sys
import time
from pathlib import Path
ROOT = Path(__file__).resolve().parents[4]
OUT = ROOT / "Saved/Linux/l101/density-compare"
DATA = ROOT / "Standalone/data/owner_world.json"
HEADLESS = ROOT / "Saved/Linux/l101/bin/VoxelForgeCoreHeadless-l101-clang"
CAMERAS = {
"SW": (8.0, 16.0, -372.2626953125),
"FI": (25.8369140625, 3.19921875, -737.0),
"TN": (19.166015625, -14.2001953125, -753.3740234375),
"VS": (-20.0625, -5.068359375, -900.353515625),
}
SUMMARY = re.compile(r"^\[L93PassageReachSummary\] reach_m=4\.00 (.*)$", re.M)
COVERAGE = re.compile(r"^\[L93PassageReachCoverage\] (.*)$", re.M)
TILE = re.compile(
r"^\[L93PassageReachTile\] reach_m=4\.00 key=\(([-\d]+),([-\d]+),([-\d]+),lod(\d+)\) "
r"samples=(\d+) changed=(\d+) sign_flips=(\d+) moved_edges=(\d+) "
r"added_crossings=(\d+) removed_crossings=(\d+) "
r"added_surface_triangles=(\d+) removed_surface_triangles=(\d+) "
r"max_displacement_cm=([\deE+.-]+) max_displacement_xyz_vox=\(([^)]*)\) "
r"displacement_region=(\d+) normal_vertices=(\d+) max_normal_degrees=([\deE+.-]+) "
r"max_normal_xyz_vox=\(([^)]*)\) normal_region=(\d+) changed_mesh=(\d+)$", re.M)
VOXEL_SIZE_M = 0.25
def xyz(text: str) -> list[float]:
return [float(part) for part in text.split(",")]
def parse_locations(output: str, strate: str) -> tuple[list[dict], list[dict]]:
rows = []
for match in TILE.finditer(output):
(x, y, z, lod, samples, changed, flips, moved, added, removed,
added_triangles, removed_triangles, displacement, displacement_xyz,
displacement_region, normal_vertices, angle, normal_xyz, normal_region,
changed_mesh) = match.groups()
disp_vox = xyz(displacement_xyz)
normal_vox = xyz(normal_xyz)
rows.append({
"strate": strate, "tile": [int(x), int(y), int(z), int(lod)],
"samples": int(samples), "changed_samples": int(changed),
"sign_flips": int(flips), "moved_edges": int(moved),
"surface_added_crossings": int(added),
"surface_removed_crossings": int(removed),
"surface_added_triangles": int(added_triangles),
"surface_removed_triangles": int(removed_triangles),
"max_displacement_cm": float(displacement),
"displacement_location_voxels": disp_vox,
"displacement_location_metres": [value * VOXEL_SIZE_M for value in disp_vox],
"displacement_region": int(displacement_region),
"normal_vertices": int(normal_vertices), "max_normal_degrees": float(angle),
"normal_location_voxels": normal_vox,
"normal_location_metres": [value * VOXEL_SIZE_M for value in normal_vox],
"normal_region": int(normal_region), "changed_mesh": bool(int(changed_mesh)),
})
top_displacement = sorted(rows, key=lambda row: row["max_displacement_cm"], reverse=True)[:5]
top_normals = sorted(rows, key=lambda row: row["max_normal_degrees"], reverse=True)[:5]
return top_displacement, top_normals
def top_unique(rows: list[dict], value_key: str, location_key: str) -> list[dict]:
chosen, seen = [], set()
for row in sorted(rows, key=lambda item: item[value_key], reverse=True):
if row[value_key] <= 0.0:
continue
location = tuple(round(value, 4) for value in row[location_key])
if location in seen:
continue
seen.add(location)
chosen.append(row)
if len(chosen) == 5:
break
return chosen
def run(strate: str) -> dict:
OUT.mkdir(parents=True, exist_ok=True)
log = OUT / f"reach-{strate.lower()}.log"
camera = ",".join(f"{value:.12f}" for value in CAMERAS[strate]) + ",0,0"
command = [
"taskset", "-c", "0-11", "prlimit", "--as=6442450944", "--",
"timeout", "1740s", str(HEADLESS), str(DATA), "--world-assembler-prototype",
"--stream-benchmark", "--stream-pipeline", "--workers=8", "--clip-radius=3",
"--max-clip-level=8", "--max-level=8", f"--camera={camera}",
"--audit-passage-carve-reach",
]
start = time.monotonic()
with log.open("w", encoding="utf-8") as stream:
result = subprocess.run(command, cwd=ROOT, stdout=stream,
stderr=subprocess.STDOUT, check=False, timeout=1740)
output = log.read_text(encoding="utf-8", errors="replace")
summary_match, coverage_match = SUMMARY.search(output), COVERAGE.search(output)
if summary_match is None or coverage_match is None or result.returncode in (-9, 124):
raise RuntimeError(f"incomplete carve-reach audit: exit={result.returncode} {log}")
reach = dict(re.findall(r"([a-zA-Z0-9_]+)=([^ ]+)", summary_match.group(1)))
coverage = dict(re.findall(r"([a-zA-Z0-9_]+)=([^ ]+)", coverage_match.group(1)))
top_displacement, top_normals = parse_locations(output, strate)
row = {
"strate": strate, "exit_code": result.returncode,
"wall_s": round(time.monotonic() - start, 3), "coverage": coverage,
"bounded_sweep_summary": reach,
"bounded_sweep_tile_rows": len(TILE.findall(output)),
"top_displacement_tiles": top_displacement,
"top_normal_tiles": top_normals,
"log": str(log.relative_to(ROOT)),
}
print("[L101DensityCompareRun] " + json.dumps(row, sort_keys=True), flush=True)
return row
def main() -> int:
if not HEADLESS.is_file() or not DATA.is_file():
raise SystemExit(f"missing input: {HEADLESS if not HEADLESS.is_file() else DATA}")
if "--summarize-only" in sys.argv:
rows = json.loads((OUT / "runs-partial.json").read_text(encoding="utf-8"))
else:
rows = []
for strate in CAMERAS:
rows.append(run(strate))
(OUT / "runs-partial.json").write_text(json.dumps(rows, indent=2) + "\n",
encoding="utf-8")
all_displacements = [row for result in rows for row in result["top_displacement_tiles"]]
all_normals = [row for result in rows for row in result["top_normal_tiles"]]
top_displacement = top_unique(all_displacements, "max_displacement_cm",
"displacement_location_metres")
top_normals = top_unique(all_normals, "max_normal_degrees", "normal_location_metres")
summary = {"runs": rows, "top_displacement_tiles": top_displacement,
"top_normal_tiles": top_normals}
(OUT / "summary.json").write_text(json.dumps(summary, indent=2) + "\n",
encoding="utf-8")
return 0
if __name__ == "__main__":
raise SystemExit(main())