Select complete source LOD explicitly and reject renderer allocation failures
This commit is contained in:
@@ -2,6 +2,7 @@ param(
|
||||
[Parameter(Mandatory=$true)][ValidatePattern('^[a-f0-9]{16}$')][string]$Release,
|
||||
[Parameter(Mandatory=$true)][ValidatePattern('^[a-f0-9]{16}$')][string]$ExpectedCurrentRelease,
|
||||
[string]$EvidenceRoot,
|
||||
[ValidateRange(0,6)][int]$ProjectLod,
|
||||
[switch]$Apply
|
||||
)
|
||||
# Runtime-only update of an already installed service. Installation, firewall,
|
||||
@@ -43,11 +44,17 @@ if($EvidenceRoot) {
|
||||
if($arguments -match '--evidence-root') { throw 'Review existing evidence storage before replacing it' }
|
||||
$arguments+=' --evidence-root "'+$EvidenceRoot+'"'
|
||||
}
|
||||
if($PSBoundParameters.ContainsKey('ProjectLod')) {
|
||||
if($arguments -match '--project-lod\s+\d+') {
|
||||
$arguments=[regex]::Replace($arguments,'--project-lod\s+\d+','--project-lod '+$ProjectLod)
|
||||
} else { $arguments+=' --project-lod '+$ProjectLod }
|
||||
}
|
||||
$action=New-ScheduledTaskAction -Execute $old.Execute -Argument $arguments -WorkingDirectory $old.WorkingDirectory
|
||||
$report=[ordered]@{utc=[DateTime]::UtcNow.ToString('o'); task=$name; previous=$ExpectedCurrentRelease;
|
||||
release=$Release; manifest_sha256=$digest; verified_files=$count; applied=$false;
|
||||
network_changed=$false; credentials_changed=$false; principal_changed=$false}
|
||||
if($EvidenceRoot) { $report['evidence_root']=$EvidenceRoot }
|
||||
if($PSBoundParameters.ContainsKey('ProjectLod')) { $report['project_lod']=$ProjectLod }
|
||||
if($Apply) {
|
||||
if($EvidenceRoot) { New-Item -ItemType Directory -Force -Path $EvidenceRoot | Out-Null }
|
||||
$backup="$root\preparations\worker-activation-$Release"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"""Prepare the complete visual scene from an existing Gaussian Pipeline package.
|
||||
|
||||
Uses the installed SplatTransform, preserves LOD0 and SH, and reuses verified
|
||||
Uses the installed SplatTransform, preserves the selected source LOD and SH, and reuses verified
|
||||
Worker artifacts. The local editor and Isaac share the same collider bytes and
|
||||
saved calibration; this is format adaptation, not another reconstruction.
|
||||
"""
|
||||
@@ -23,7 +23,9 @@ def digest(path):
|
||||
return hashlib.file_digest(stream, "sha256").hexdigest()
|
||||
|
||||
|
||||
def prepare_project(client, run, state, episode, job, pulse, isaac):
|
||||
def prepare_project(client, run, state, episode, job, pulse, isaac, *, lod=0):
|
||||
if type(lod) is not int or not 0 <= lod <= 6:
|
||||
raise ValueError("Invalid source LOD")
|
||||
world = run["world"]
|
||||
package = client.request("/worker/worlds/" + world["world_id"] + "/project-assets")
|
||||
if package["world_sha256"] != world["sha256"]:
|
||||
@@ -87,7 +89,7 @@ def prepare_project(client, run, state, episode, job, pulse, isaac):
|
||||
# Adapt the complete selected source LOD and preserve every SH coefficient.
|
||||
key = hashlib.sha256(
|
||||
json.dumps(
|
||||
{"world": world["sha256"], "coverage": "complete-source-lod0", "adapter": digest(Path(__file__))},
|
||||
{"world": world["sha256"], "coverage": "complete-source", "lod": lod, "adapter": digest(Path(__file__))},
|
||||
sort_keys=True,
|
||||
).encode()
|
||||
).hexdigest()
|
||||
@@ -119,7 +121,7 @@ def prepare_project(client, run, state, episode, job, pulse, isaac):
|
||||
"4",
|
||||
"-w",
|
||||
"--select-lod",
|
||||
"0",
|
||||
str(lod),
|
||||
str(visual),
|
||||
"-r",
|
||||
"0,0,180",
|
||||
@@ -158,8 +160,8 @@ def prepare_project(client, run, state, episode, job, pulse, isaac):
|
||||
{
|
||||
"sha256": digest(output),
|
||||
"gaussian_count": count,
|
||||
"lod": 0,
|
||||
"coverage": "complete-source-lod0",
|
||||
"lod": lod,
|
||||
"coverage": "complete-source",
|
||||
"spatially_cropped": False,
|
||||
"source_sha256": world["sha256"],
|
||||
"converter": "splat-transform-3.4.0",
|
||||
@@ -168,7 +170,8 @@ def prepare_project(client, run, state, episode, job, pulse, isaac):
|
||||
)
|
||||
# Capacity is evidence only, never an admission gate or a count ceiling.
|
||||
count = json.loads(receipt.read_text())["gaussian_count"]
|
||||
write_json(episode / "scene-capacity.json", scene_diagnostics(count, output.stat().st_size))
|
||||
write_json(episode / "scene-capacity.json", {**scene_diagnostics(count, output.stat().st_size),
|
||||
"source_lod": lod, "coverage": "complete-source", "spatially_cropped": False})
|
||||
source_collider_sha256 = digest(collider)
|
||||
decoded = root / (source_collider_sha256 + ".decoded.glb")
|
||||
decoder = Path(__file__).with_name("decode_collision.cjs")
|
||||
|
||||
@@ -143,6 +143,8 @@ def main():
|
||||
help="Optional local volume for complete episode evidence")
|
||||
parser.add_argument("--isaac", type=Path, required=True)
|
||||
parser.add_argument("--stream-address", required=True)
|
||||
parser.add_argument("--project-lod", type=int, choices=range(7), default=0,
|
||||
help="Explicit source LOD; entire project coverage is retained")
|
||||
args = parser.parse_args()
|
||||
args.state.mkdir(parents=True, exist_ok=True)
|
||||
lock = acquire_service_lock(args.state / "realtime-service.lock")
|
||||
@@ -419,7 +421,7 @@ def main():
|
||||
from project_assets import prepare_project
|
||||
|
||||
source, terrain_path = prepare_project(
|
||||
client, run, args.state, episode, job, preparation_pulse, args.isaac
|
||||
client, run, args.state, episode, job, preparation_pulse, args.isaac, lod=args.project_lod
|
||||
)
|
||||
else:
|
||||
terrain_path = prepare_terrain(
|
||||
@@ -491,8 +493,11 @@ def main():
|
||||
preview_sender.start()
|
||||
registered = True
|
||||
readiness_sent = False
|
||||
from scene_capacity import RendererMemoryGuard
|
||||
render_guard = RendererMemoryGuard(episode / "isaac.log")
|
||||
while child.poll() is None:
|
||||
now = time.monotonic()
|
||||
render_guard.check()
|
||||
if stop_deadline and now >= stop_deadline:
|
||||
terminate_episode(child)
|
||||
break
|
||||
|
||||
@@ -37,3 +37,22 @@ def scene_diagnostics(count, source_bytes):
|
||||
except Exception as exc:
|
||||
value["capacity_unavailable"] = type(exc).__name__
|
||||
return value
|
||||
|
||||
|
||||
class RendererMemoryGuard:
|
||||
"""A reported allocation failure invalidates the scene, even if Kit keeps running."""
|
||||
def __init__(self, log):
|
||||
self.log, self.offset, self.tail = log, 0, b""
|
||||
|
||||
def check(self):
|
||||
with self.log.open("rb") as stream:
|
||||
stream.seek(self.offset)
|
||||
while chunk := stream.read(65536):
|
||||
content = self.tail + chunk
|
||||
if (b"ERROR_OUT_OF_DEVICE_MEMORY" in content or
|
||||
b"Out of GPU memory allocating resource" in content):
|
||||
raise ScenePreparationError(
|
||||
"Недостаточно видеопамяти для полной сцены выбранной детализации. "
|
||||
"Прогон остановлен: корректность изображения не подтверждена.")
|
||||
self.tail = content[-128:]
|
||||
self.offset = stream.tell()
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
from pathlib import Path
|
||||
import importlib
|
||||
import pytest
|
||||
|
||||
|
||||
def test_partial_or_late_native_allocation_failure_invalidates_scene(monkeypatch, tmp_path):
|
||||
monkeypatch.syspath_prepend(str(Path(__file__).parents[1] / "simulation/ai-polygon"))
|
||||
module = importlib.import_module("scene_capacity")
|
||||
log = tmp_path / "isaac.log"
|
||||
log.write_bytes(b"startup ready\n" + b"x"*65522 + b"ERROR_OUT_OF_DE")
|
||||
guard = module.RendererMemoryGuard(log)
|
||||
guard.check()
|
||||
guard.check()
|
||||
with log.open("ab") as stream:
|
||||
stream.write(b"VICE_MEMORY\napp still running\n")
|
||||
with pytest.raises(module.ScenePreparationError, match="видеопамяти"):
|
||||
guard.check()
|
||||
Reference in New Issue
Block a user