Datasets:
Formats:
parquet
Size:
1M - 10M
Tags:
gaussian-splatting
fault-tolerance
single-event-upset
reliability
radiance-fields
computer-graphics
License:
File size: 7,929 Bytes
f138992 121e1fb f138992 121e1fb f138992 121e1fb f138992 121e1fb f138992 121e1fb f138992 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | """E15: guard cost, render throughput, and VRAM at scale.
A trained real scene is replicated with spatial offsets to reach tens of millions
of primitives, which is the regime that actually saturates memory bandwidth on a
contemporary accelerator. At each size we measure the VRAM footprint, the
single-frame render time and pixel throughput, and the cost of the support guard,
so that the per-frame guard cost is reported as a function of model size rather
than at a single small operating point. We also confirm that the guard still
removes the catastrophic tail at scale.
"""
import argparse
import json
import os
import time
import numpy as np
import torch
import faultlib as F
import gsmodel
from realscene import load_ply, orbit_cameras
def replicate(params, k):
"""Tile the scene k times on a ground-plane grid; shared appearance, offset means."""
m = params["means"]
ext = (m.max(0).values - m.min(0).values)
side = int(np.ceil(np.sqrt(k)))
offs = []
for i in range(k):
gx, gy = i % side, i // side
offs.append(torch.tensor([gx * ext[0] * 1.1, 0.0, gy * ext[2] * 1.1], device=m.device))
offs = torch.stack(offs, 0) # [k,3]
out = {}
out["means"] = (m[None] + offs[:, None, :]).reshape(-1, 3).contiguous()
for f in ["scales", "quats", "opacities", "sh0", "shN"]:
v = params[f]
rep = [k] + [1] * (v.dim() - 1)
out[f] = v.repeat(*rep).contiguous()
return out
def timed(fn, iters, warmup=3):
for _ in range(warmup):
fn()
torch.cuda.synchronize(); t = time.time()
for _ in range(iters):
fn()
torch.cuda.synchronize()
return (time.time() - t) / iters
def main():
ap = argparse.ArgumentParser()
ap.add_argument("--ply", required=True)
ap.add_argument("--out", default="/root/seu/results/largescene")
ap.add_argument("--W", type=int, default=800)
ap.add_argument("--mults", default="1,8,20,35,50")
ap.add_argument("--vram_budget_gb", type=float, default=29.0)
ap.add_argument("--storm_k", type=int, default=1000)
ap.add_argument("--storm_frames", type=int, default=300)
args = ap.parse_args()
os.makedirs(args.out, exist_ok=True)
base, sh, N0 = load_ply(args.ply)
W = H = args.W
vms, Ks = orbit_cameras(base["means"], 4, W, H)
rows = []
for k in [int(x) for x in args.mults.split(",")]:
torch.cuda.empty_cache(); torch.cuda.reset_peak_memory_stats()
try:
params = base if k == 1 else replicate(base, k)
N = params["means"].shape[0]
bounds = F.compute_bounds(params)
# warm + render time
t_render = timed(lambda: gsmodel.render(params, vms[:1], Ks[:1], W, H, sh), iters=10)
t_guard = timed(lambda: F.apply_guard(params, bounds), iters=10)
vram = torch.cuda.max_memory_allocated() / 1e9
mpix = W * H / 1e6 / t_render
# confirm guard still neutralizes a scale-sign explosion at this scale
stored, work = F.quantize_params(params, "fp32")
clean, _ = F.render_views(work, vms[:1], Ks[:1], W, H, sh)
rng = np.random.default_rng(0); ng, g = [], []
for _ in range(30):
gi = int(rng.integers(0, N)); flat = gi * 3
cv, _ = F.flip_one(stored["scales"], work["scales"], flat, 31, "fp32")
img, _ = F.render_views(work, vms[:1], Ks[:1], W, H, sh)
gimg, _ = F.render_views(F.apply_guard(work, bounds), vms[:1], Ks[:1], W, H, sh)
F.restore_one(work["scales"], flat, cv)
ng.append(((img[0] - clean[0]).abs().amax(-1) > 1 / 255).float().mean().item())
g.append(((gimg[0] - clean[0]).abs().amax(-1) > 1 / 255).float().mean().item())
del stored, work, clean
# effective bandwidth of the guard: it reads+writes only the 14 guarded
# components (means 3, scales 3, quats 4, opacity 1, sh0 3); SH-rest skipped
guard_bytes = N * 14 * 4 * 2 # read + write
guard_bw = guard_bytes / t_guard / 1e9 # GB/s
row = {"k": k, "N": int(N), "vram_gb": float(vram), "render_ms": t_render * 1e3,
"guard_ms": t_guard * 1e3, "mpix_s": float(mpix),
"guard_frac": float(t_guard / t_render),
"guard_bw_gbs": float(guard_bw), "param_bits": int(N * 59 * 32),
"scalesign_foot_noguard": float(np.mean(ng) * 100),
"scalesign_foot_guard": float(np.mean(g) * 100)}
rows.append(row)
print(f"k={k:3d} N={N:11,d} ({N*59*32/1e9:.1f}e9 bits) VRAM={vram:5.1f}GB "
f"render={t_render*1e3:6.2f}ms {mpix:7.1f}Mpix/s guard={t_guard*1e3:.3f}ms "
f"({t_guard/t_render*100:.1f}% render, {guard_bw:.0f}GB/s)", flush=True)
del params, bounds
if vram > args.vram_budget_gb:
print("vram budget reached, stopping", flush=True); break
except torch.cuda.OutOfMemoryError:
print(f"k={k} OOM, stopping", flush=True); break
# ---- real-time fault-storm latency at a memory-safe large scene ----
# the storm needs stored+work copies plus render buffers (~3x params), so cap
# the replication at a size that fits rather than the largest swept point.
storm = None
if rows:
kmax = next((r["k"] for r in reversed(rows) if r["N"] <= 18_000_000), rows[0]["k"])
try:
torch.cuda.empty_cache(); torch.cuda.reset_peak_memory_stats()
params = base if kmax == 1 else replicate(base, kmax)
N = params["means"].shape[0]
bounds = F.compute_bounds(params)
stored, work = F.quantize_params(params, "fp32")
comps = {f: work[f].reshape(N, -1).shape[1] for f in ["means", "scales", "quats", "opacities", "sh0", "shN"]}
FIELDS = ["means", "scales", "quats", "opacities", "sh0", "shN"]
rng = np.random.default_rng(0)
# sustained latency under a continuous storm of storm_k upsets per frame, guarded
import time
lat_ng, lat_g = [], []
for _ in range(args.storm_frames):
sites = []
for _ in range(args.storm_k):
field = FIELDS[int(rng.integers(0, 6))]
flat = int(rng.integers(0, N * comps[field])); bit = int(rng.integers(0, 32))
cv, _ = F.flip_one(stored[field], work[field], flat, bit, "fp32"); sites.append((field, flat, cv))
torch.cuda.synchronize(); t0 = time.time()
gsmodel.render(work, vms[:1], Ks[:1], W, H, sh); torch.cuda.synchronize()
lat_ng.append((time.time() - t0) * 1e3)
torch.cuda.synchronize(); t0 = time.time()
gw = F.apply_guard(work, bounds); gsmodel.render(gw, vms[:1], Ks[:1], W, H, sh); torch.cuda.synchronize()
lat_g.append((time.time() - t0) * 1e3)
for field, flat, cv in sites:
F.restore_one(work[field], flat, cv)
storm = {"N": int(N), "storm_k": args.storm_k, "frames": args.storm_frames,
"lat_noguard_ms_mean": float(np.mean(lat_ng)), "lat_noguard_ms_p99": float(np.percentile(lat_ng, 99)),
"lat_guard_ms_mean": float(np.mean(lat_g)), "lat_guard_ms_p99": float(np.percentile(lat_g, 99))}
print(f"STORM N={N:,} k={args.storm_k}/frame x{args.storm_frames}: "
f"no-guard {storm['lat_noguard_ms_mean']:.2f}ms guard {storm['lat_guard_ms_mean']:.2f}ms", flush=True)
except torch.cuda.OutOfMemoryError:
print("storm OOM", flush=True)
json.dump({"rows": rows, "W": W, "storm": storm}, open(os.path.join(args.out, "largescene.json"), "w"), indent=2)
print("LARGESCENE_DONE", flush=True)
if __name__ == "__main__":
main()
|