Select complete source LOD explicitly and reject renderer allocation failures
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user