Datasets:
Formats:
parquet
Size:
1M - 10M
Tags:
gaussian-splatting
fault-tolerance
single-event-upset
reliability
radiance-fields
computer-graphics
License:
Upload folder using huggingface_hub
Browse files- code/campaign_batched.py +115 -0
- code/distributed_multigpu.py +130 -0
- code/hf_release.py +68 -5
- code/largescene.py +52 -6
- code/make_figs.py +106 -5
- code/realscene_fig.py +53 -0
- code/survival.py +5 -1
code/campaign_batched.py
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Batched parallel fault injection: render B independently-corrupted variants of
|
| 2 |
+
the scene in a single rasterizer call, so the device is saturated rather than
|
| 3 |
+
latency-bound. The batch buffer is allocated once; each step flips one bit in one
|
| 4 |
+
parameter of each batch element (vectorized, no Python loop), renders all B at
|
| 5 |
+
once, scores them against the clean image, then restores. Reports sustained
|
| 6 |
+
injection throughput and GPU utilisation.
|
| 7 |
+
"""
|
| 8 |
+
import argparse
|
| 9 |
+
import json
|
| 10 |
+
import os
|
| 11 |
+
import subprocess
|
| 12 |
+
import threading
|
| 13 |
+
import time
|
| 14 |
+
|
| 15 |
+
import numpy as np
|
| 16 |
+
import torch
|
| 17 |
+
from gsplat import rasterization
|
| 18 |
+
|
| 19 |
+
FIELDS = ["means", "scales", "quats", "opacities", "sh0", "shN"]
|
| 20 |
+
FIELD_ID = {f: i for i, f in enumerate(FIELDS)}
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
def util_sampler(stop, out):
|
| 24 |
+
while not stop.is_set():
|
| 25 |
+
try:
|
| 26 |
+
r = subprocess.run(["nvidia-smi", "--query-gpu=utilization.gpu,power.draw",
|
| 27 |
+
"--format=csv,noheader,nounits"], capture_output=True, text=True, timeout=5)
|
| 28 |
+
u, p = r.stdout.strip().split("\n")[0].split(",")
|
| 29 |
+
out.append((float(u), float(p)))
|
| 30 |
+
except Exception:
|
| 31 |
+
pass
|
| 32 |
+
stop.wait(1.0)
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
def render_batch(wb, sh, vm, K, W, H):
|
| 36 |
+
colors = torch.cat([wb["sh0"], wb["shN"]], dim=2)
|
| 37 |
+
renders, alphas, _ = rasterization(
|
| 38 |
+
wb["means"], wb["quats"], torch.exp(wb["scales"]), torch.sigmoid(wb["opacities"]),
|
| 39 |
+
colors, vm, K, W, H, sh_degree=sh, packed=True, rasterize_mode="classic")
|
| 40 |
+
return (renders + (1.0 - alphas)).clamp(0, 1)
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
def main():
|
| 44 |
+
ap = argparse.ArgumentParser()
|
| 45 |
+
ap.add_argument("--model", default="/root/seu/results/chair/model.pt")
|
| 46 |
+
ap.add_argument("--out", default="/root/seu/results/batched")
|
| 47 |
+
ap.add_argument("--B", type=int, default=32)
|
| 48 |
+
ap.add_argument("--minutes", type=float, default=8.0)
|
| 49 |
+
ap.add_argument("--seed", type=int, default=0)
|
| 50 |
+
args = ap.parse_args()
|
| 51 |
+
os.makedirs(args.out, exist_ok=True)
|
| 52 |
+
dev = "cuda"
|
| 53 |
+
ck = torch.load(args.model, map_location=dev, weights_only=False)
|
| 54 |
+
params = {k: v.to(dev).float() for k, v in ck["params"].items()}
|
| 55 |
+
sh, W, H = ck["sh_degree"], ck["W"], ck["H"]
|
| 56 |
+
N = params["means"].shape[0]
|
| 57 |
+
B = args.B
|
| 58 |
+
vmb = ck["test_viewmats"][:1].to(dev)[None].repeat(B, 1, 1, 1).contiguous()
|
| 59 |
+
Kb = ck["test_Ks"][:1].to(dev)[None].repeat(B, 1, 1, 1).contiguous()
|
| 60 |
+
comps = {f: params[f].reshape(N, -1).shape[1] for f in FIELDS}
|
| 61 |
+
|
| 62 |
+
# allocate the batch buffer once: B identical clean copies
|
| 63 |
+
wb = {k: params[k][None].repeat(B, *([1] * params[k].dim())).contiguous() for k in FIELDS}
|
| 64 |
+
clean = render_batch({k: params[k][None] for k in FIELDS}, sh, vmb[:1], Kb[:1], W, H)[0, 0]
|
| 65 |
+
rows_b = torch.arange(B, device=dev)
|
| 66 |
+
g = torch.Generator(device=dev); g.manual_seed(args.seed)
|
| 67 |
+
|
| 68 |
+
def step():
|
| 69 |
+
fi = int(torch.randint(0, 6, (1,), generator=g, device=dev).item())
|
| 70 |
+
field = FIELDS[fi]; Cf = comps[field]
|
| 71 |
+
fb = wb[field].reshape(B, N * Cf) # view of the batch buffer
|
| 72 |
+
iv = fb.view(torch.int32)
|
| 73 |
+
idx = torch.randint(0, N * Cf, (B,), generator=g, device=dev) # int64 index
|
| 74 |
+
bit = torch.randint(0, 32, (B,), generator=g, device=dev, dtype=torch.int32)
|
| 75 |
+
clean_int = iv[rows_b, idx].clone()
|
| 76 |
+
mask = (torch.ones(B, dtype=torch.int32, device=dev) << bit)
|
| 77 |
+
iv[rows_b, idx] = clean_int ^ mask # vectorized flip
|
| 78 |
+
img = render_batch(wb, sh, vmb, Kb, W, H) # [B,1,H,W,3]
|
| 79 |
+
d = (img[:, 0] - clean).abs()
|
| 80 |
+
fr = (d.amax(-1) > 1 / 255).float().mean(dim=(1, 2))
|
| 81 |
+
finite = torch.isfinite(img).all(dim=(1, 2, 3, 4))
|
| 82 |
+
iv[rows_b, idx] = clean_int # vectorized restore
|
| 83 |
+
bitc = torch.where(bit == 31, 0, torch.where(bit >= 23, 1, 2))
|
| 84 |
+
out = torch.stack([torch.full((B,), fi, device=dev), bit.float(), bitc.float(),
|
| 85 |
+
fr, ((~finite) | (fr > 0.01)).float()], dim=1)
|
| 86 |
+
return out.cpu().numpy()
|
| 87 |
+
|
| 88 |
+
for _ in range(3):
|
| 89 |
+
step()
|
| 90 |
+
torch.cuda.synchronize()
|
| 91 |
+
|
| 92 |
+
stop = threading.Event(); samples = []
|
| 93 |
+
th = threading.Thread(target=util_sampler, args=(stop, samples)); th.start()
|
| 94 |
+
t0 = time.time(); n_inj = 0; allrows = []
|
| 95 |
+
while time.time() - t0 < args.minutes * 60:
|
| 96 |
+
allrows.append(step()); n_inj += B
|
| 97 |
+
torch.cuda.synchronize(); dt = time.time() - t0
|
| 98 |
+
stop.set(); th.join()
|
| 99 |
+
util = np.array([s[0] for s in samples]) if samples else np.array([0.0])
|
| 100 |
+
powr = np.array([s[1] for s in samples]) if samples else np.array([0.0])
|
| 101 |
+
|
| 102 |
+
arr = np.concatenate(allrows, 0)
|
| 103 |
+
np.savez_compressed(os.path.join(args.out, "batched_rows.npz"), data=arr,
|
| 104 |
+
cols=np.array(["field_id", "bit", "bitclass", "fracchg", "cat"]))
|
| 105 |
+
res = {"N": int(N), "B": B, "W": W, "H": H, "minutes": args.minutes,
|
| 106 |
+
"injections": int(n_inj), "seconds": dt, "inj_per_s": n_inj / dt,
|
| 107 |
+
"batches_per_s": (n_inj / B) / dt, "gaussian_instances_per_render": int(B * N),
|
| 108 |
+
"mean_util": float(util.mean()), "p50_util": float(np.median(util)),
|
| 109 |
+
"max_util": float(util.max()), "mean_power_w": float(powr.mean())}
|
| 110 |
+
json.dump(res, open(os.path.join(args.out, "batched.json"), "w"), indent=2)
|
| 111 |
+
print("BATCHED_RESULT", json.dumps(res), flush=True)
|
| 112 |
+
|
| 113 |
+
|
| 114 |
+
if __name__ == "__main__":
|
| 115 |
+
main()
|
code/distributed_multigpu.py
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Real two-GPU distributed sort-first rendering with the node-local support guard.
|
| 2 |
+
|
| 3 |
+
Each of the two physical GPUs is a rendering node (rank) that renders one screen
|
| 4 |
+
half of the same model and contributes it to the composite over the real PCIe
|
| 5 |
+
interconnect (NCCL all-gather). We measure, on actual hardware rather than by
|
| 6 |
+
emulation: per-rank render time and load imbalance, the inter-GPU transfer time and
|
| 7 |
+
bandwidth for compositing, how many nodes a single scale-sign upset contaminates,
|
| 8 |
+
and how the node-local guard (applied independently on each GPU's replica before it
|
| 9 |
+
renders) contains that contamination. This validates the distributed claims against
|
| 10 |
+
a genuine multi-GPU interconnect.
|
| 11 |
+
"""
|
| 12 |
+
import argparse
|
| 13 |
+
import json
|
| 14 |
+
import os
|
| 15 |
+
import time
|
| 16 |
+
|
| 17 |
+
import numpy as np
|
| 18 |
+
import torch
|
| 19 |
+
import torch.distributed as dist
|
| 20 |
+
import torch.multiprocessing as mp
|
| 21 |
+
|
| 22 |
+
import faultlib as F
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
def render_half(params, rank, world, vm, Kfull, W, H, sh):
|
| 26 |
+
Wh = W // world
|
| 27 |
+
K = Kfull.clone()
|
| 28 |
+
K[0, 0, 2] = K[0, 0, 2] - rank * Wh # shift principal point to this node's column band
|
| 29 |
+
img, _ = F.render_views(params, vm, K, Wh, H, sh)
|
| 30 |
+
return img[0].contiguous() # [H, Wh, 3]
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
def worker(rank, world, args):
|
| 34 |
+
os.environ.setdefault("MASTER_ADDR", "127.0.0.1")
|
| 35 |
+
os.environ.setdefault("MASTER_PORT", "29517")
|
| 36 |
+
dist.init_process_group("nccl", rank=rank, world_size=world)
|
| 37 |
+
torch.cuda.set_device(rank)
|
| 38 |
+
dev = f"cuda:{rank}"
|
| 39 |
+
ck = torch.load(args.model, map_location=dev, weights_only=False)
|
| 40 |
+
params = {k: v.to(dev).float() for k, v in ck["params"].items()}
|
| 41 |
+
sh, W0, H0 = ck["sh_degree"], ck["W"], ck["H"]
|
| 42 |
+
vm = ck["test_viewmats"][:1].to(dev)
|
| 43 |
+
K = ck["test_Ks"][:1].to(dev).clone()
|
| 44 |
+
# render at a larger frame (supersample) so the inter-GPU transfer is bandwidth-
|
| 45 |
+
# rather than latency-bound; scale the intrinsics accordingly
|
| 46 |
+
W = H = args.render_W
|
| 47 |
+
s = W / W0
|
| 48 |
+
K[0, :2, :] = K[0, :2, :] * s
|
| 49 |
+
Wh = W // world
|
| 50 |
+
bounds = F.compute_bounds(params)
|
| 51 |
+
stored, work = F.quantize_params(params, "fp32")
|
| 52 |
+
N = params["means"].shape[0]
|
| 53 |
+
|
| 54 |
+
# rank 0 finds a frame-spanning scale-sign upset and broadcasts the site
|
| 55 |
+
site = torch.zeros(1, dtype=torch.long, device=dev)
|
| 56 |
+
if rank == 0:
|
| 57 |
+
cfull, _ = F.render_views(work, vm, K, W, H, sh)
|
| 58 |
+
rng = np.random.default_rng(0); best = (-1.0, 0)
|
| 59 |
+
for _ in range(80):
|
| 60 |
+
gi = int(rng.integers(0, N)); flat = gi * 3
|
| 61 |
+
cv, _ = F.flip_one(stored["scales"], work["scales"], flat, 31, "fp32")
|
| 62 |
+
img, _ = F.render_views(work, vm, K, W, H, sh)
|
| 63 |
+
F.restore_one(work["scales"], flat, cv)
|
| 64 |
+
fp = ((img[0] - cfull[0]).abs().amax(-1) > 1 / 255).float().mean().item()
|
| 65 |
+
if fp > best[0]:
|
| 66 |
+
best = (fp, flat)
|
| 67 |
+
site[0] = best[1]
|
| 68 |
+
dist.broadcast(site, src=0)
|
| 69 |
+
flat = int(site[0].item())
|
| 70 |
+
|
| 71 |
+
def render_gather(p, reps=25):
|
| 72 |
+
render_half(p, rank, world, vm, K, W, H, sh) # warmup (untimed)
|
| 73 |
+
dist.barrier()
|
| 74 |
+
rts, gts = [], []
|
| 75 |
+
full = None
|
| 76 |
+
for _ in range(reps):
|
| 77 |
+
torch.cuda.synchronize(); t = time.time()
|
| 78 |
+
half = render_half(p, rank, world, vm, K, W, H, sh)
|
| 79 |
+
torch.cuda.synchronize(); rts.append(time.time() - t)
|
| 80 |
+
halves = [torch.zeros_like(half) for _ in range(world)]
|
| 81 |
+
torch.cuda.synchronize(); t2 = time.time()
|
| 82 |
+
dist.all_gather(halves, half) # real inter-GPU transfer
|
| 83 |
+
torch.cuda.synchronize(); gts.append(time.time() - t2)
|
| 84 |
+
full = torch.cat(halves, dim=1)
|
| 85 |
+
rt = float(np.median(rts)); gt = float(np.median(gts))
|
| 86 |
+
rtimes = [torch.zeros(1, device=dev) for _ in range(world)]
|
| 87 |
+
dist.all_gather(rtimes, torch.tensor([rt], device=dev))
|
| 88 |
+
return full, [float(x.item()) for x in rtimes], gt, half.numel() * 4 * (world - 1)
|
| 89 |
+
|
| 90 |
+
clean_full, ct, cg, _ = render_gather(work)
|
| 91 |
+
cv, _ = F.flip_one(stored["scales"], work["scales"], flat, 31, "fp32")
|
| 92 |
+
corr_full, xt, xg, xb = render_gather(work)
|
| 93 |
+
gw = F.apply_guard(work, bounds)
|
| 94 |
+
guard_full, gt, gg, _ = render_gather(gw)
|
| 95 |
+
F.restore_one(work["scales"], flat, cv)
|
| 96 |
+
|
| 97 |
+
if rank == 0:
|
| 98 |
+
def nodes_changed(full):
|
| 99 |
+
d = (full - clean_full).abs().amax(-1) > (1 / 255)
|
| 100 |
+
return sum(int(bool(d[:, r * Wh:(r + 1) * Wh].any())) for r in range(world))
|
| 101 |
+
res = {"world": world, "W": W, "H": H, "Wh": Wh, "N": int(N),
|
| 102 |
+
"clean_rank_ms": [t * 1e3 for t in ct],
|
| 103 |
+
"corrupt_rank_ms": [t * 1e3 for t in xt],
|
| 104 |
+
"guard_rank_ms": [t * 1e3 for t in gt],
|
| 105 |
+
"transfer_ms": xg * 1e3, "transfer_bytes": int(xb),
|
| 106 |
+
"transfer_gbps": (xb / 1e9) / xg if xg > 0 else 0,
|
| 107 |
+
"imbalance_corrupt": max(xt) / (sum(xt) / world),
|
| 108 |
+
"imbalance_guard": max(gt) / (sum(gt) / world),
|
| 109 |
+
"contam_corrupt_nodes": nodes_changed(corr_full),
|
| 110 |
+
"contam_guard_nodes": nodes_changed(guard_full),
|
| 111 |
+
"frame_ms_clean": max(ct) * 1e3 + cg * 1e3,
|
| 112 |
+
"frame_ms_corrupt": max(xt) * 1e3 + xg * 1e3,
|
| 113 |
+
"frame_ms_guard": max(gt) * 1e3 + gg * 1e3}
|
| 114 |
+
json.dump(res, open(args.out, "w"), indent=2)
|
| 115 |
+
print("MULTIGPU_RESULT", json.dumps(res), flush=True)
|
| 116 |
+
dist.barrier(); dist.destroy_process_group()
|
| 117 |
+
|
| 118 |
+
|
| 119 |
+
def main():
|
| 120 |
+
ap = argparse.ArgumentParser()
|
| 121 |
+
ap.add_argument("--model", default="/root/seu/results/chair/model.pt")
|
| 122 |
+
ap.add_argument("--out", default="/root/seu/results/multigpu.json")
|
| 123 |
+
ap.add_argument("--world", type=int, default=2)
|
| 124 |
+
ap.add_argument("--render_W", type=int, default=1600)
|
| 125 |
+
args = ap.parse_args()
|
| 126 |
+
mp.spawn(worker, args=(args.world, args), nprocs=args.world, join=True)
|
| 127 |
+
|
| 128 |
+
|
| 129 |
+
if __name__ == "__main__":
|
| 130 |
+
main()
|
code/hf_release.py
CHANGED
|
@@ -4,6 +4,7 @@ Uploads whatever currently exists (idempotent), so it can be run once for the
|
|
| 4 |
code and trained models and again after the campaign for the results, logs,
|
| 5 |
figures, and dataset card. Token is read from the HF_TOKEN environment variable.
|
| 6 |
"""
|
|
|
|
| 7 |
import json
|
| 8 |
import os
|
| 9 |
|
|
@@ -22,6 +23,7 @@ def card():
|
|
| 22 |
p = os.path.join(ROOT, "results", s, "train_summary.json")
|
| 23 |
if os.path.exists(p):
|
| 24 |
summ[s] = json.load(open(p))
|
|
|
|
| 25 |
lines = []
|
| 26 |
lines.append("---")
|
| 27 |
lines.append("license: mit")
|
|
@@ -30,10 +32,20 @@ def card():
|
|
| 30 |
"reliability", "radiance-fields", "computer-graphics"]:
|
| 31 |
lines.append(f" - {t}")
|
| 32 |
lines.append("pretty_name: Single-Event Upsets in 3D Gaussian Splatting")
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
lines.append("---\n")
|
| 38 |
lines.append("# Single-Event Upsets in 3D Gaussian Splatting Rendering\n")
|
| 39 |
lines.append("Artifacts for the paper *Single-Event Upsets in 3D Gaussian Splatting "
|
|
@@ -59,7 +71,8 @@ def card():
|
|
| 59 |
lines.append("```")
|
| 60 |
lines.append("code/ training, fault-injection engine, campaign, analysis, figures")
|
| 61 |
lines.append("models/ trained gsplat checkpoints per scene (model.pt)")
|
| 62 |
-
lines.append("
|
|
|
|
| 63 |
lines.append("logs/ campaign / driver / GPU-utilisation logs")
|
| 64 |
lines.append("figures/ regenerated figures, tables, and numbers.tex")
|
| 65 |
lines.append("```\n")
|
|
@@ -67,13 +80,63 @@ def card():
|
|
| 67 |
"header comments; the GPU run used an RTX 5090 (sm_120), PyTorch 2.12 / "
|
| 68 |
"CUDA 13, gsplat 1.5.3.\n")
|
| 69 |
lines.append("PAPER_URL: __ARXIV_LINK_PLACEHOLDER__\n")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
return "\n".join(lines)
|
| 71 |
|
| 72 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
def main():
|
| 74 |
create_repo(REPO, repo_type="dataset", token=TOK, exist_ok=True, private=False)
|
| 75 |
print("repo ready:", REPO)
|
| 76 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
# dataset card
|
| 78 |
cpath = "/tmp/README_hf.md"
|
| 79 |
open(cpath, "w").write(card())
|
|
|
|
| 4 |
code and trained models and again after the campaign for the results, logs,
|
| 5 |
figures, and dataset card. Token is read from the HF_TOKEN environment variable.
|
| 6 |
"""
|
| 7 |
+
import glob
|
| 8 |
import json
|
| 9 |
import os
|
| 10 |
|
|
|
|
| 23 |
p = os.path.join(ROOT, "results", s, "train_summary.json")
|
| 24 |
if os.path.exists(p):
|
| 25 |
summ[s] = json.load(open(p))
|
| 26 |
+
has_parquet = os.path.isdir(os.path.join(ROOT, "results", "parquet", "single_bit_upsets"))
|
| 27 |
lines = []
|
| 28 |
lines.append("---")
|
| 29 |
lines.append("license: mit")
|
|
|
|
| 32 |
"reliability", "radiance-fields", "computer-graphics"]:
|
| 33 |
lines.append(f" - {t}")
|
| 34 |
lines.append("pretty_name: Single-Event Upsets in 3D Gaussian Splatting")
|
| 35 |
+
if has_parquet:
|
| 36 |
+
# Point the dataset viewer at the per-injection Parquet records so it
|
| 37 |
+
# browses the millions of single-bit upset rows (not the summary JSONs).
|
| 38 |
+
lines.append("configs:")
|
| 39 |
+
lines.append(" - config_name: single_bit_upsets")
|
| 40 |
+
lines.append(" data_files:")
|
| 41 |
+
lines.append(" - split: train")
|
| 42 |
+
lines.append(" path: data/single_bit_upsets/*.parquet")
|
| 43 |
+
lines.append(" - config_name: multi_upset")
|
| 44 |
+
lines.append(" data_files:")
|
| 45 |
+
lines.append(" - split: train")
|
| 46 |
+
lines.append(" path: data/multi_upset/*.parquet")
|
| 47 |
+
else:
|
| 48 |
+
lines.append("viewer: false")
|
| 49 |
lines.append("---\n")
|
| 50 |
lines.append("# Single-Event Upsets in 3D Gaussian Splatting Rendering\n")
|
| 51 |
lines.append("Artifacts for the paper *Single-Event Upsets in 3D Gaussian Splatting "
|
|
|
|
| 71 |
lines.append("```")
|
| 72 |
lines.append("code/ training, fault-injection engine, campaign, analysis, figures")
|
| 73 |
lines.append("models/ trained gsplat checkpoints per scene (model.pt)")
|
| 74 |
+
lines.append("data/ per-injection records as Parquet (browsable in the viewer)")
|
| 75 |
+
lines.append("results/ aggregate.json, bench.json, multiupset/largescene records, summaries")
|
| 76 |
lines.append("logs/ campaign / driver / GPU-utilisation logs")
|
| 77 |
lines.append("figures/ regenerated figures, tables, and numbers.tex")
|
| 78 |
lines.append("```\n")
|
|
|
|
| 80 |
"header comments; the GPU run used an RTX 5090 (sm_120), PyTorch 2.12 / "
|
| 81 |
"CUDA 13, gsplat 1.5.3.\n")
|
| 82 |
lines.append("PAPER_URL: __ARXIV_LINK_PLACEHOLDER__\n")
|
| 83 |
+
if has_parquet:
|
| 84 |
+
lines.append("The per-injection records are browsable in the dataset viewer "
|
| 85 |
+
"(`single_bit_upsets`: one row per single-bit upset, several million "
|
| 86 |
+
"rows; `multi_upset`: accumulated-dose records), stored as Parquet under "
|
| 87 |
+
"`data/`.\n")
|
| 88 |
return "\n".join(lines)
|
| 89 |
|
| 90 |
|
| 91 |
+
FIELD_NAMES = ["means", "scales", "quats", "opacities", "sh0", "shN"]
|
| 92 |
+
BCLASS = {0: "sign", 1: "exp", 2: "mantissa"}
|
| 93 |
+
|
| 94 |
+
|
| 95 |
+
def write_parquet(root):
|
| 96 |
+
"""Convert the per-injection .npz shards into viewer-friendly Parquet, one
|
| 97 |
+
file per (scene, precision), with readable field/bit-class names."""
|
| 98 |
+
import glob
|
| 99 |
+
import numpy as np
|
| 100 |
+
import pandas as pd
|
| 101 |
+
sb_dir = os.path.join(root, "results", "parquet", "single_bit_upsets")
|
| 102 |
+
mu_dir = os.path.join(root, "results", "parquet", "multi_upset")
|
| 103 |
+
os.makedirs(sb_dir, exist_ok=True); os.makedirs(mu_dir, exist_ok=True)
|
| 104 |
+
n = 0
|
| 105 |
+
for fp in sorted(glob.glob(os.path.join(root, "results", "campaign", "shard_*.npz"))):
|
| 106 |
+
d = np.load(fp, allow_pickle=True); a = d["data"]; cols = list(d["cols"]); meta = list(d["meta"])
|
| 107 |
+
df = pd.DataFrame(a, columns=cols)
|
| 108 |
+
df["scene"] = meta[0]; df["precision"] = meta[1]
|
| 109 |
+
df["field"] = df["field_id"].astype(int).map(lambda i: FIELD_NAMES[i])
|
| 110 |
+
df["bitclass"] = df["bitclass"].astype(int).map(BCLASS)
|
| 111 |
+
df["guarded"] = fp.endswith("_guard.npz")
|
| 112 |
+
df = df.drop(columns=["field_id"])
|
| 113 |
+
df.to_parquet(os.path.join(sb_dir, os.path.basename(fp).replace(".npz", ".parquet")), index=False)
|
| 114 |
+
n += len(df)
|
| 115 |
+
for fp in sorted(glob.glob(os.path.join(root, "results", "multiupset", "multiupset_*.npz"))):
|
| 116 |
+
d = np.load(fp, allow_pickle=True); a = d["data"]; cols = list(d["cols"]); meta = list(d["meta"])
|
| 117 |
+
df = pd.DataFrame(a, columns=cols)
|
| 118 |
+
df["scene"] = meta[0]; df["precision"] = meta[1]; df["guarded"] = fp.endswith("_guard.npz")
|
| 119 |
+
df.to_parquet(os.path.join(mu_dir, os.path.basename(fp).replace(".npz", ".parquet")), index=False)
|
| 120 |
+
print(f"wrote parquet: {n} single-bit-upset rows")
|
| 121 |
+
return n
|
| 122 |
+
|
| 123 |
+
|
| 124 |
def main():
|
| 125 |
create_repo(REPO, repo_type="dataset", token=TOK, exist_ok=True, private=False)
|
| 126 |
print("repo ready:", REPO)
|
| 127 |
|
| 128 |
+
# convert per-injection records to Parquet so the dataset viewer can browse
|
| 129 |
+
# the millions of rows (skips gracefully if the campaign has not produced shards)
|
| 130 |
+
try:
|
| 131 |
+
if glob.glob(os.path.join(ROOT, "results", "campaign", "shard_*.npz")):
|
| 132 |
+
write_parquet(ROOT)
|
| 133 |
+
api.upload_folder(folder_path=os.path.join(ROOT, "results", "parquet"),
|
| 134 |
+
path_in_repo="data", repo_id=REPO, repo_type="dataset",
|
| 135 |
+
token=TOK, allow_patterns=["*.parquet"])
|
| 136 |
+
print("uploaded data/ (parquet)")
|
| 137 |
+
except Exception as e:
|
| 138 |
+
print("parquet step skipped:", e)
|
| 139 |
+
|
| 140 |
# dataset card
|
| 141 |
cpath = "/tmp/README_hf.md"
|
| 142 |
open(cpath, "w").write(card())
|
code/largescene.py
CHANGED
|
@@ -55,8 +55,10 @@ def main():
|
|
| 55 |
ap.add_argument("--ply", required=True)
|
| 56 |
ap.add_argument("--out", default="/root/seu/results/largescene")
|
| 57 |
ap.add_argument("--W", type=int, default=800)
|
| 58 |
-
ap.add_argument("--mults", default="1,
|
| 59 |
-
ap.add_argument("--vram_budget_gb", type=float, default=
|
|
|
|
|
|
|
| 60 |
args = ap.parse_args()
|
| 61 |
os.makedirs(args.out, exist_ok=True)
|
| 62 |
base, sh, N0 = load_ply(args.ply)
|
|
@@ -87,21 +89,65 @@ def main():
|
|
| 87 |
ng.append(((img[0] - clean[0]).abs().amax(-1) > 1 / 255).float().mean().item())
|
| 88 |
g.append(((gimg[0] - clean[0]).abs().amax(-1) > 1 / 255).float().mean().item())
|
| 89 |
del stored, work, clean
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
row = {"k": k, "N": int(N), "vram_gb": float(vram), "render_ms": t_render * 1e3,
|
| 91 |
"guard_ms": t_guard * 1e3, "mpix_s": float(mpix),
|
| 92 |
"guard_frac": float(t_guard / t_render),
|
|
|
|
| 93 |
"scalesign_foot_noguard": float(np.mean(ng) * 100),
|
| 94 |
"scalesign_foot_guard": float(np.mean(g) * 100)}
|
| 95 |
rows.append(row)
|
| 96 |
-
print(f"k={k:3d} N={N:
|
| 97 |
-
f"{mpix:7.1f}Mpix/s guard={t_guard*1e3:.3f}ms
|
| 98 |
-
flush=True)
|
| 99 |
del params, bounds
|
| 100 |
if vram > args.vram_budget_gb:
|
| 101 |
print("vram budget reached, stopping", flush=True); break
|
| 102 |
except torch.cuda.OutOfMemoryError:
|
| 103 |
print(f"k={k} OOM, stopping", flush=True); break
|
| 104 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
print("LARGESCENE_DONE", flush=True)
|
| 106 |
|
| 107 |
|
|
|
|
| 55 |
ap.add_argument("--ply", required=True)
|
| 56 |
ap.add_argument("--out", default="/root/seu/results/largescene")
|
| 57 |
ap.add_argument("--W", type=int, default=800)
|
| 58 |
+
ap.add_argument("--mults", default="1,8,20,35,50")
|
| 59 |
+
ap.add_argument("--vram_budget_gb", type=float, default=29.0)
|
| 60 |
+
ap.add_argument("--storm_k", type=int, default=1000)
|
| 61 |
+
ap.add_argument("--storm_frames", type=int, default=300)
|
| 62 |
args = ap.parse_args()
|
| 63 |
os.makedirs(args.out, exist_ok=True)
|
| 64 |
base, sh, N0 = load_ply(args.ply)
|
|
|
|
| 89 |
ng.append(((img[0] - clean[0]).abs().amax(-1) > 1 / 255).float().mean().item())
|
| 90 |
g.append(((gimg[0] - clean[0]).abs().amax(-1) > 1 / 255).float().mean().item())
|
| 91 |
del stored, work, clean
|
| 92 |
+
# effective bandwidth of the guard: it reads+writes only the 14 guarded
|
| 93 |
+
# components (means 3, scales 3, quats 4, opacity 1, sh0 3); SH-rest skipped
|
| 94 |
+
guard_bytes = N * 14 * 4 * 2 # read + write
|
| 95 |
+
guard_bw = guard_bytes / t_guard / 1e9 # GB/s
|
| 96 |
row = {"k": k, "N": int(N), "vram_gb": float(vram), "render_ms": t_render * 1e3,
|
| 97 |
"guard_ms": t_guard * 1e3, "mpix_s": float(mpix),
|
| 98 |
"guard_frac": float(t_guard / t_render),
|
| 99 |
+
"guard_bw_gbs": float(guard_bw), "param_bits": int(N * 59 * 32),
|
| 100 |
"scalesign_foot_noguard": float(np.mean(ng) * 100),
|
| 101 |
"scalesign_foot_guard": float(np.mean(g) * 100)}
|
| 102 |
rows.append(row)
|
| 103 |
+
print(f"k={k:3d} N={N:11,d} ({N*59*32/1e9:.1f}e9 bits) VRAM={vram:5.1f}GB "
|
| 104 |
+
f"render={t_render*1e3:6.2f}ms {mpix:7.1f}Mpix/s guard={t_guard*1e3:.3f}ms "
|
| 105 |
+
f"({t_guard/t_render*100:.1f}% render, {guard_bw:.0f}GB/s)", flush=True)
|
| 106 |
del params, bounds
|
| 107 |
if vram > args.vram_budget_gb:
|
| 108 |
print("vram budget reached, stopping", flush=True); break
|
| 109 |
except torch.cuda.OutOfMemoryError:
|
| 110 |
print(f"k={k} OOM, stopping", flush=True); break
|
| 111 |
+
# ---- real-time fault-storm latency at a memory-safe large scene ----
|
| 112 |
+
# the storm needs stored+work copies plus render buffers (~3x params), so cap
|
| 113 |
+
# the replication at a size that fits rather than the largest swept point.
|
| 114 |
+
storm = None
|
| 115 |
+
if rows:
|
| 116 |
+
kmax = next((r["k"] for r in reversed(rows) if r["N"] <= 18_000_000), rows[0]["k"])
|
| 117 |
+
try:
|
| 118 |
+
torch.cuda.empty_cache(); torch.cuda.reset_peak_memory_stats()
|
| 119 |
+
params = base if kmax == 1 else replicate(base, kmax)
|
| 120 |
+
N = params["means"].shape[0]
|
| 121 |
+
bounds = F.compute_bounds(params)
|
| 122 |
+
stored, work = F.quantize_params(params, "fp32")
|
| 123 |
+
comps = {f: work[f].reshape(N, -1).shape[1] for f in ["means", "scales", "quats", "opacities", "sh0", "shN"]}
|
| 124 |
+
FIELDS = ["means", "scales", "quats", "opacities", "sh0", "shN"]
|
| 125 |
+
rng = np.random.default_rng(0)
|
| 126 |
+
# sustained latency under a continuous storm of storm_k upsets per frame, guarded
|
| 127 |
+
import time
|
| 128 |
+
lat_ng, lat_g = [], []
|
| 129 |
+
for _ in range(args.storm_frames):
|
| 130 |
+
sites = []
|
| 131 |
+
for _ in range(args.storm_k):
|
| 132 |
+
field = FIELDS[int(rng.integers(0, 6))]
|
| 133 |
+
flat = int(rng.integers(0, N * comps[field])); bit = int(rng.integers(0, 32))
|
| 134 |
+
cv, _ = F.flip_one(stored[field], work[field], flat, bit, "fp32"); sites.append((field, flat, cv))
|
| 135 |
+
torch.cuda.synchronize(); t0 = time.time()
|
| 136 |
+
gsmodel.render(work, vms[:1], Ks[:1], W, H, sh); torch.cuda.synchronize()
|
| 137 |
+
lat_ng.append((time.time() - t0) * 1e3)
|
| 138 |
+
torch.cuda.synchronize(); t0 = time.time()
|
| 139 |
+
gw = F.apply_guard(work, bounds); gsmodel.render(gw, vms[:1], Ks[:1], W, H, sh); torch.cuda.synchronize()
|
| 140 |
+
lat_g.append((time.time() - t0) * 1e3)
|
| 141 |
+
for field, flat, cv in sites:
|
| 142 |
+
F.restore_one(work[field], flat, cv)
|
| 143 |
+
storm = {"N": int(N), "storm_k": args.storm_k, "frames": args.storm_frames,
|
| 144 |
+
"lat_noguard_ms_mean": float(np.mean(lat_ng)), "lat_noguard_ms_p99": float(np.percentile(lat_ng, 99)),
|
| 145 |
+
"lat_guard_ms_mean": float(np.mean(lat_g)), "lat_guard_ms_p99": float(np.percentile(lat_g, 99))}
|
| 146 |
+
print(f"STORM N={N:,} k={args.storm_k}/frame x{args.storm_frames}: "
|
| 147 |
+
f"no-guard {storm['lat_noguard_ms_mean']:.2f}ms guard {storm['lat_guard_ms_mean']:.2f}ms", flush=True)
|
| 148 |
+
except torch.cuda.OutOfMemoryError:
|
| 149 |
+
print("storm OOM", flush=True)
|
| 150 |
+
json.dump({"rows": rows, "W": W, "storm": storm}, open(os.path.join(args.out, "largescene.json"), "w"), indent=2)
|
| 151 |
print("LARGESCENE_DONE", flush=True)
|
| 152 |
|
| 153 |
|
code/make_figs.py
CHANGED
|
@@ -23,7 +23,17 @@ BC = {0: "sign", 1: "exp", 2: "mantissa"}
|
|
| 23 |
CAT_FOOT = 0.01 # footprint > 1% of frame => catastrophic (matches paper)
|
| 24 |
SCENES = ["chair", "lego", "ficus", "hotdog"]
|
| 25 |
PRECS = ["fp32", "fp16", "bf16"]
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
|
| 29 |
def load_shards(campaign_dir, guard=False):
|
|
@@ -280,7 +290,7 @@ def main():
|
|
| 280 |
s = json.load(open(sp))
|
| 281 |
rows.append((sc, s["n_gaussians"], s["test_psnr"], s["test_ssim"]))
|
| 282 |
with open(os.path.join(args.out, "tab_scenes.tex"), "w") as f:
|
| 283 |
-
f.write("\\begin{table}[
|
| 284 |
f.write("\\caption{Trained scenes used in the campaign: primitive count and "
|
| 285 |
"clean held-out fidelity.}\n\\label{tab:scenes}\n")
|
| 286 |
f.write("\\begin{tabular}{lrrr}\n\\toprule\nScene & Primitives & PSNR (dB) & SSIM \\\\\n\\midrule\n")
|
|
@@ -295,7 +305,7 @@ def main():
|
|
| 295 |
if (fp32 & (rec["field_id"] == fid) & (rec["bit"] == b)).sum() > 0] or [0]))
|
| 296 |
macros["samplesPerCell"] = f"{persite:,}".replace(",", "{,}")
|
| 297 |
with open(os.path.join(args.out, "tab_criticality.tex"), "w") as f:
|
| 298 |
-
f.write("\\begin{table}[
|
| 299 |
f.write("\\caption{Per-field single-bit upset severity at \\texttt{fp32}, pooled over "
|
| 300 |
"scenes and bits. Footprint is the percent of pixels changed; quantiles expose "
|
| 301 |
"the tail. The catastrophe rate (Definition~\\ref{def:catastrophe}) is reported "
|
|
@@ -315,7 +325,7 @@ def main():
|
|
| 315 |
|
| 316 |
# guard table
|
| 317 |
with open(os.path.join(args.out, "tab_guard.tex"), "w") as f:
|
| 318 |
-
f.write("\\begin{table}[
|
| 319 |
f.write("\\caption{Support guard on the same fault grid (\\texttt{fp32}). The guard "
|
| 320 |
"removes the catastrophic tail at negligible cost and is the identity on clean "
|
| 321 |
"models.}\n\\label{tab:guard}\n")
|
|
@@ -397,7 +407,7 @@ def main():
|
|
| 397 |
agg.setdefault(mode, {"cat": [], "foot": []})
|
| 398 |
agg[mode]["cat"].append(a[m, ci["cat"]]); agg[mode]["foot"].append(a[m, ci["footprint"]])
|
| 399 |
with open(os.path.join(args.out, "tab_mitigation.tex"), "w") as f:
|
| 400 |
-
f.write("\\begin{table}[
|
| 401 |
f.write("\\caption{Mitigations on a shared \\texttt{fp32} fault grid pooled over "
|
| 402 |
"scenes. The support guard matches the protection of far more expensive "
|
| 403 |
"duplication at a fraction of the cost.}\n\\label{tab:mitigation}\n")
|
|
@@ -488,6 +498,76 @@ def main():
|
|
| 488 |
plt.legend(); plt.grid(alpha=0.3)
|
| 489 |
plt.savefig(os.path.join(args.out, "fig_foot_hist.pdf"), bbox_inches="tight"); plt.close()
|
| 490 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 491 |
# ---------- real-scene generalization macros (E12) ----------
|
| 492 |
rs = sorted(glob.glob(os.path.join(args.root, "realscene", "realscene_*.json")))
|
| 493 |
if rs:
|
|
@@ -522,6 +602,15 @@ def main():
|
|
| 522 |
macros["guardFracBig"] = fmt(big["guard_frac"] * 100, 1)
|
| 523 |
macros["bigScaleFootNg"] = fmt(big["scalesign_foot_noguard"], 1)
|
| 524 |
macros["bigScaleFootG"] = fmt(big["scalesign_foot_guard"], 2)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 525 |
|
| 526 |
# ---------- distributed rank timing (E16) ----------
|
| 527 |
if dfs:
|
|
@@ -556,6 +645,18 @@ def main():
|
|
| 556 |
"mpixBig": "0", "guardFracBig": "0.0", "bigScaleFootNg": "0.0",
|
| 557 |
"bigScaleFootG": "0.0", "rankBarrierClean": "0.0", "rankBarrierCorrupt": "0.0",
|
| 558 |
"rankBarrierGuard": "0.0", "rankImbalCorrupt": "0.0", "rankImbalGuard": "0.0",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 559 |
}
|
| 560 |
for k, v in defaults.items():
|
| 561 |
macros.setdefault(k, v)
|
|
|
|
| 23 |
CAT_FOOT = 0.01 # footprint > 1% of frame => catastrophic (matches paper)
|
| 24 |
SCENES = ["chair", "lego", "ficus", "hotdog"]
|
| 25 |
PRECS = ["fp32", "fp16", "bf16"]
|
| 26 |
+
PUBSTYLE = {
|
| 27 |
+
"font.family": "serif", "mathtext.fontset": "cm",
|
| 28 |
+
"font.size": 12, "axes.titlesize": 12, "axes.labelsize": 12,
|
| 29 |
+
"legend.fontsize": 9.5, "xtick.labelsize": 10, "ytick.labelsize": 10,
|
| 30 |
+
"axes.linewidth": 0.8, "lines.linewidth": 1.9, "lines.markersize": 5.5,
|
| 31 |
+
"axes.grid": True, "grid.alpha": 0.25, "grid.linewidth": 0.5,
|
| 32 |
+
"legend.frameon": True, "legend.framealpha": 0.9, "legend.edgecolor": "0.8",
|
| 33 |
+
"figure.dpi": 150, "savefig.dpi": 220, "savefig.bbox": "tight",
|
| 34 |
+
"axes.prop_cycle": plt.cycler(color=["#2c3e9e", "#c0392b", "#27ae60", "#e67e22", "#7f3fbf", "#16a085"]),
|
| 35 |
+
}
|
| 36 |
+
plt.rcParams.update(PUBSTYLE)
|
| 37 |
|
| 38 |
|
| 39 |
def load_shards(campaign_dir, guard=False):
|
|
|
|
| 290 |
s = json.load(open(sp))
|
| 291 |
rows.append((sc, s["n_gaussians"], s["test_psnr"], s["test_ssim"]))
|
| 292 |
with open(os.path.join(args.out, "tab_scenes.tex"), "w") as f:
|
| 293 |
+
f.write("\\begin{table}[tbp]\n\\centering\n")
|
| 294 |
f.write("\\caption{Trained scenes used in the campaign: primitive count and "
|
| 295 |
"clean held-out fidelity.}\n\\label{tab:scenes}\n")
|
| 296 |
f.write("\\begin{tabular}{lrrr}\n\\toprule\nScene & Primitives & PSNR (dB) & SSIM \\\\\n\\midrule\n")
|
|
|
|
| 305 |
if (fp32 & (rec["field_id"] == fid) & (rec["bit"] == b)).sum() > 0] or [0]))
|
| 306 |
macros["samplesPerCell"] = f"{persite:,}".replace(",", "{,}")
|
| 307 |
with open(os.path.join(args.out, "tab_criticality.tex"), "w") as f:
|
| 308 |
+
f.write("\\begin{table}[tbp]\n\\centering\n\\small\n")
|
| 309 |
f.write("\\caption{Per-field single-bit upset severity at \\texttt{fp32}, pooled over "
|
| 310 |
"scenes and bits. Footprint is the percent of pixels changed; quantiles expose "
|
| 311 |
"the tail. The catastrophe rate (Definition~\\ref{def:catastrophe}) is reported "
|
|
|
|
| 325 |
|
| 326 |
# guard table
|
| 327 |
with open(os.path.join(args.out, "tab_guard.tex"), "w") as f:
|
| 328 |
+
f.write("\\begin{table}[tbp]\n\\centering\n")
|
| 329 |
f.write("\\caption{Support guard on the same fault grid (\\texttt{fp32}). The guard "
|
| 330 |
"removes the catastrophic tail at negligible cost and is the identity on clean "
|
| 331 |
"models.}\n\\label{tab:guard}\n")
|
|
|
|
| 407 |
agg.setdefault(mode, {"cat": [], "foot": []})
|
| 408 |
agg[mode]["cat"].append(a[m, ci["cat"]]); agg[mode]["foot"].append(a[m, ci["footprint"]])
|
| 409 |
with open(os.path.join(args.out, "tab_mitigation.tex"), "w") as f:
|
| 410 |
+
f.write("\\begin{table}[tbp]\n\\centering\n\\small\n")
|
| 411 |
f.write("\\caption{Mitigations on a shared \\texttt{fp32} fault grid pooled over "
|
| 412 |
"scenes. The support guard matches the protection of far more expensive "
|
| 413 |
"duplication at a fraction of the cost.}\n\\label{tab:mitigation}\n")
|
|
|
|
| 498 |
plt.legend(); plt.grid(alpha=0.3)
|
| 499 |
plt.savefig(os.path.join(args.out, "fig_foot_hist.pdf"), bbox_inches="tight"); plt.close()
|
| 500 |
|
| 501 |
+
# ---------- multi-GPU scaling of the engine + cross-architecture (4x L40S) ----------
|
| 502 |
+
sc4 = os.path.join(args.root, "scaling4.json")
|
| 503 |
+
if os.path.exists(sc4):
|
| 504 |
+
o = json.load(open(sc4))
|
| 505 |
+
if o.get("single_inj_per_s"):
|
| 506 |
+
macros["lFortySingleInj"] = f"{o['single_inj_per_s']:,.0f}".replace(",", "{,}")
|
| 507 |
+
macros["scaleFourAgg"] = f"{o['aggregate_inj_per_s']:,.0f}".replace(",", "{,}")
|
| 508 |
+
macros["scaleFourSpeedup"] = fmt(o.get("scaling", 0) or 0, 2)
|
| 509 |
+
macros["scaleFourEff"] = fmt((o.get("efficiency", 0) or 0) * 100, 0)
|
| 510 |
+
macros["scaleFourNodes"] = str(o.get("n_gpus", 4))
|
| 511 |
+
macros["scaleFourUtil"] = fmt(o.get("mean_util", 0), 0)
|
| 512 |
+
mg4 = os.path.join(args.root, "multigpu4.json")
|
| 513 |
+
if os.path.exists(mg4):
|
| 514 |
+
o = json.load(open(mg4))
|
| 515 |
+
macros["mgpuFourWorld"] = str(o["world"])
|
| 516 |
+
macros["mgpuFourContamNg"] = str(o["contam_corrupt_nodes"])
|
| 517 |
+
macros["mgpuFourContamG"] = str(o["contam_guard_nodes"])
|
| 518 |
+
|
| 519 |
+
# ---------- real two-GPU distributed validation ----------
|
| 520 |
+
mg = os.path.join(args.root, "multigpu.json")
|
| 521 |
+
if os.path.exists(mg):
|
| 522 |
+
o = json.load(open(mg))
|
| 523 |
+
macros["mgpuWorld"] = str(o["world"])
|
| 524 |
+
macros["mgpuContamNg"] = str(o["contam_corrupt_nodes"])
|
| 525 |
+
macros["mgpuContamG"] = str(o["contam_guard_nodes"])
|
| 526 |
+
macros["mgpuTransferGbps"] = fmt(o.get("transfer_gbps", 0), 1)
|
| 527 |
+
macros["mgpuRankMs"] = fmt(float(np.median(o["corrupt_rank_ms"])), 2)
|
| 528 |
+
macros["mgpuFrameMs"] = fmt(o.get("frame_ms_corrupt", 0), 1)
|
| 529 |
+
macros["mgpuRenderW"] = str(o["W"])
|
| 530 |
+
|
| 531 |
+
# ---------- accumulation / redundancy scaling law (theorem support) ----------
|
| 532 |
+
accj = os.path.join(args.root, "accumulation", "accumulation.json")
|
| 533 |
+
if os.path.exists(accj):
|
| 534 |
+
o = json.load(open(accj))
|
| 535 |
+
ng = o.get("noguard", []); gd = o.get("guard", [])
|
| 536 |
+
|
| 537 |
+
def powfit(rows, key):
|
| 538 |
+
N = np.array([r["N"] for r in rows], float); y = np.array([r[key] for r in rows], float)
|
| 539 |
+
ok = y > 0
|
| 540 |
+
a, b = np.polyfit(np.log(N[ok]), np.log(y[ok]), 1)
|
| 541 |
+
pred = a * np.log(N[ok]) + b
|
| 542 |
+
r2 = 1 - np.sum((np.log(y[ok]) - pred) ** 2) / max(np.sum((np.log(y[ok]) - np.log(y[ok]).mean()) ** 2), 1e-12)
|
| 543 |
+
return -a, r2
|
| 544 |
+
if ng and gd:
|
| 545 |
+
a_med, r2_med = powfit(ng, "median_mse") # redundancy law: typical upset shrinks
|
| 546 |
+
a_mean, _ = powfit(ng, "mean_mse") # mean is tail-dominated (~flat)
|
| 547 |
+
a_gmed, _ = powfit(gd, "median_mse")
|
| 548 |
+
macros["accAlpha"] = fmt(a_med, 2) # redundancy exponent (median)
|
| 549 |
+
macros["accRsq"] = fmt(r2_med, 3)
|
| 550 |
+
macros["accMeanExp"] = fmt(a_mean, 2) # ~0 without the guard
|
| 551 |
+
macros["accAlphaGuard"] = fmt(a_gmed, 2)
|
| 552 |
+
macros["accScrubExp"] = fmt(a_med - 1.0, 2)
|
| 553 |
+
macros["accGuardFactor"] = fmt(ng[-1]["mean_mse"] / max(gd[-1]["mean_mse"], 1e-30), 0)
|
| 554 |
+
spc = ng[0].get("samples", 0)
|
| 555 |
+
macros["accSamplesPerCell"] = fmt(spc / 1e6, 1)
|
| 556 |
+
tot = sum(r.get("samples", 0) for r in ng + gd)
|
| 557 |
+
macros["accTotalSamples"] = fmt(tot / 1e6, 0)
|
| 558 |
+
macros["accNlo"] = f"{ng[0]['N']:,}".replace(",", "{,}")
|
| 559 |
+
macros["accNhi"] = f"{ng[-1]['N']:,}".replace(",", "{,}")
|
| 560 |
+
|
| 561 |
+
# ---------- batched-injection throughput (GPU-saturating engine) ----------
|
| 562 |
+
bj2 = os.path.join(args.root, "batched", "batched.json")
|
| 563 |
+
if os.path.exists(bj2):
|
| 564 |
+
o = json.load(open(bj2))
|
| 565 |
+
macros["batchInjPerSec"] = f"{o['inj_per_s']:,.0f}".replace(",", "{,}")
|
| 566 |
+
macros["batchUtil"] = str(int(round(o["mean_util"])))
|
| 567 |
+
macros["batchPower"] = str(int(round(o["mean_power_w"])))
|
| 568 |
+
macros["batchB"] = str(o["B"])
|
| 569 |
+
macros["batchGaussInst"] = fmt(o["gaussian_instances_per_render"] / 1e6, 1)
|
| 570 |
+
|
| 571 |
# ---------- real-scene generalization macros (E12) ----------
|
| 572 |
rs = sorted(glob.glob(os.path.join(args.root, "realscene", "realscene_*.json")))
|
| 573 |
if rs:
|
|
|
|
| 602 |
macros["guardFracBig"] = fmt(big["guard_frac"] * 100, 1)
|
| 603 |
macros["bigScaleFootNg"] = fmt(big["scalesign_foot_noguard"], 1)
|
| 604 |
macros["bigScaleFootG"] = fmt(big["scalesign_foot_guard"], 2)
|
| 605 |
+
macros["bigParamBits"] = fmt(big.get("param_bits", 0) / 1e9, 0)
|
| 606 |
+
macros["guardBwBig"] = str(int(round(big.get("guard_bw_gbs", 0))))
|
| 607 |
+
st = o.get("storm")
|
| 608 |
+
if st:
|
| 609 |
+
macros["stormK"] = f"{st['storm_k']:,}".replace(",", "{,}")
|
| 610 |
+
macros["stormN"] = f"{st['N']/1e6:.0f}\\,million"
|
| 611 |
+
macros["stormFrames"] = str(st["frames"])
|
| 612 |
+
macros["stormLatNg"] = fmt(st["lat_noguard_ms_mean"], 1)
|
| 613 |
+
macros["stormLatG"] = fmt(st["lat_guard_ms_mean"], 1)
|
| 614 |
|
| 615 |
# ---------- distributed rank timing (E16) ----------
|
| 616 |
if dfs:
|
|
|
|
| 645 |
"mpixBig": "0", "guardFracBig": "0.0", "bigScaleFootNg": "0.0",
|
| 646 |
"bigScaleFootG": "0.0", "rankBarrierClean": "0.0", "rankBarrierCorrupt": "0.0",
|
| 647 |
"rankBarrierGuard": "0.0", "rankImbalCorrupt": "0.0", "rankImbalGuard": "0.0",
|
| 648 |
+
"bigParamBits": "0", "guardBwBig": "0", "stormK": "0", "stormN": "0",
|
| 649 |
+
"stormFrames": "0", "stormLatNg": "0.0", "stormLatG": "0.0",
|
| 650 |
+
"batchInjPerSec": "0", "batchUtil": "0", "batchPower": "0", "batchB": "0",
|
| 651 |
+
"batchGaussInst": "0.0",
|
| 652 |
+
"accAlpha": "0.0", "accRsq": "0.0", "accAlphaGuard": "0.0", "accScrubExp": "0.0",
|
| 653 |
+
"accGuardFactor": "0", "accSamplesPerCell": "0.0", "accTotalSamples": "0",
|
| 654 |
+
"accNlo": "0", "accNhi": "0", "accMeanExp": "0.0",
|
| 655 |
+
"mgpuWorld": "2", "mgpuContamNg": "2", "mgpuContamG": "1", "mgpuTransferGbps": "0.0",
|
| 656 |
+
"mgpuRankMs": "0.0", "mgpuFrameMs": "0.0", "mgpuRenderW": "1600",
|
| 657 |
+
"lFortySingleInj": "0", "scaleFourAgg": "0", "scaleFourSpeedup": "0.0", "scaleFourEff": "0",
|
| 658 |
+
"scaleFourNodes": "4", "scaleFourUtil": "0", "mgpuFourWorld": "4", "mgpuFourContamNg": "4",
|
| 659 |
+
"mgpuFourContamG": "1",
|
| 660 |
}
|
| 661 |
for k, v in defaults.items():
|
| 662 |
macros.setdefault(k, v)
|
code/realscene_fig.py
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Publication panel for the real-world (truck) scene: clean | faulted | guarded
|
| 2 |
+
| |error|. We search several orbit views and many candidate sites for the most
|
| 3 |
+
visible scale sign-bit upset, then show the absolute-error map so the corruption
|
| 4 |
+
footprint is legible regardless of the (off-distribution) viewpoint sharpness."""
|
| 5 |
+
import os, numpy as np, torch
|
| 6 |
+
import matplotlib; matplotlib.use("Agg")
|
| 7 |
+
import matplotlib.pyplot as plt
|
| 8 |
+
plt.rcParams.update({"font.family": "serif", "mathtext.fontset": "cm", "font.size": 11,
|
| 9 |
+
"savefig.dpi": 220, "savefig.bbox": "tight"})
|
| 10 |
+
import faultlib as F
|
| 11 |
+
from realscene import load_ply, orbit_cameras
|
| 12 |
+
|
| 13 |
+
PLY = "/root/seu/data/truck.ply"; GEN = "/root/seu/results/generated"
|
| 14 |
+
dev = "cuda"
|
| 15 |
+
params, sh, N = load_ply(PLY)
|
| 16 |
+
W = H = 900
|
| 17 |
+
vms, Ks = orbit_cameras(params["means"], 8, W, H)
|
| 18 |
+
bounds = F.compute_bounds(params)
|
| 19 |
+
stored, work = F.quantize_params(params, "fp32")
|
| 20 |
+
clean, _ = F.render_views(work, vms, Ks, W, H, sh)
|
| 21 |
+
|
| 22 |
+
rng = np.random.default_rng(7)
|
| 23 |
+
best = (-1.0, 0, 0) # footprint, view, gaussian
|
| 24 |
+
sc = work["scales"]
|
| 25 |
+
for _ in range(450):
|
| 26 |
+
v = int(rng.integers(0, 8)); g = int(rng.integers(0, N)); flat = g * 3
|
| 27 |
+
cv, _ = F.flip_one(stored["scales"], sc, flat, 31, "fp32")
|
| 28 |
+
img, _ = F.render_views(work, vms[v:v+1], Ks[v:v+1], W, H, sh)
|
| 29 |
+
F.restore_one(sc, flat, cv)
|
| 30 |
+
fp = ((img[0] - clean[v]).abs().amax(-1) > 1/255).float().mean().item()
|
| 31 |
+
if fp > best[0]:
|
| 32 |
+
best = (fp, v, g)
|
| 33 |
+
fp, v, g = best; flat = g * 3
|
| 34 |
+
print(f"chosen view={v} gaussian={g} footprint={fp*100:.1f}%", flush=True)
|
| 35 |
+
cv, _ = F.flip_one(stored["scales"], sc, flat, 31, "fp32")
|
| 36 |
+
faulted, _ = F.render_views(work, vms[v:v+1], Ks[v:v+1], W, H, sh)
|
| 37 |
+
gw = F.apply_guard(work, bounds)
|
| 38 |
+
guarded, _ = F.render_views(gw, vms[v:v+1], Ks[v:v+1], W, H, sh)
|
| 39 |
+
F.restore_one(sc, flat, cv)
|
| 40 |
+
|
| 41 |
+
cl = clean[v].clamp(0,1).cpu().numpy(); fa = faulted[0].clamp(0,1).cpu().numpy(); gu = guarded[0].clamp(0,1).cpu().numpy()
|
| 42 |
+
err = np.abs(fa - cl).max(-1)
|
| 43 |
+
|
| 44 |
+
fig, ax = plt.subplots(1, 4, figsize=(13, 3.5))
|
| 45 |
+
for a in ax: a.set_xticks([]); a.set_yticks([])
|
| 46 |
+
ax[0].imshow(cl); ax[0].set_title("clean")
|
| 47 |
+
ax[1].imshow(fa); ax[1].set_title(f"faulted (footprint {fp*100:.0f}\\%)")
|
| 48 |
+
ax[2].imshow(gu); ax[2].set_title("support guard")
|
| 49 |
+
vmx=float(np.percentile(err,99.5)); im = ax[3].imshow(err, cmap="inferno", vmin=0, vmax=max(vmx,0.02)); ax[3].set_title("$|\\Delta I|_\\infty$ (faulted)")
|
| 50 |
+
cb = fig.colorbar(im, ax=ax[3], fraction=0.046, pad=0.04); cb.set_label("abs. error")
|
| 51 |
+
plt.tight_layout()
|
| 52 |
+
plt.savefig(os.path.join(GEN, "fig_realscene.pdf"), bbox_inches="tight")
|
| 53 |
+
print("WROTE fig_realscene.pdf", flush=True)
|
code/survival.py
CHANGED
|
@@ -17,6 +17,10 @@ import numpy as np
|
|
| 17 |
import matplotlib
|
| 18 |
matplotlib.use("Agg")
|
| 19 |
import matplotlib.pyplot as plt
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
# representative SEU rates (upsets per stored bit per hour), order-of-magnitude,
|
| 22 |
# from terrestrial/avionic/space soft-error literature.
|
|
@@ -127,7 +131,7 @@ def main():
|
|
| 127 |
|
| 128 |
# emit a small table and macro file
|
| 129 |
with open(os.path.join(args.out, "tab_survival.tex"), "w") as f:
|
| 130 |
-
f.write("\\begin{table}[
|
| 131 |
f.write("\\caption{Estimated mean time between catastrophic frames for a "
|
| 132 |
"model of $\\modelBits$ stored bits under representative single-event-upset "
|
| 133 |
"rates, without and with the support guard. Rates are order-of-magnitude "
|
|
|
|
| 17 |
import matplotlib
|
| 18 |
matplotlib.use("Agg")
|
| 19 |
import matplotlib.pyplot as plt
|
| 20 |
+
plt.rcParams.update({"font.family": "serif", "mathtext.fontset": "cm", "font.size": 12,
|
| 21 |
+
"axes.labelsize": 12, "legend.fontsize": 10, "lines.linewidth": 1.9,
|
| 22 |
+
"lines.markersize": 5.5, "axes.grid": True, "grid.alpha": 0.25,
|
| 23 |
+
"savefig.dpi": 220, "savefig.bbox": "tight"})
|
| 24 |
|
| 25 |
# representative SEU rates (upsets per stored bit per hour), order-of-magnitude,
|
| 26 |
# from terrestrial/avionic/space soft-error literature.
|
|
|
|
| 131 |
|
| 132 |
# emit a small table and macro file
|
| 133 |
with open(os.path.join(args.out, "tab_survival.tex"), "w") as f:
|
| 134 |
+
f.write("\\begin{table}[tbp]\n\\centering\n")
|
| 135 |
f.write("\\caption{Estimated mean time between catastrophic frames for a "
|
| 136 |
"model of $\\modelBits$ stored bits under representative single-event-upset "
|
| 137 |
"rates, without and with the support guard. Rates are order-of-magnitude "
|