RFTSystems's picture
Create app.py
e7945f4 verified
import gradio as gr
import numpy as np
import time, json, hashlib
from datetime import datetime
# =============================================================
# Rendered Frame Theory — Adaptive Computing Kernel (v1.0)
# =============================================================
def rft_kernel(profile, workload, cycles, seed):
np.random.seed(seed)
t0 = time.time()
# Simulated compute rates (items/sec × noise)
base_speed = {"CPU": 0.45, "GPU": 0.83, "TPU": 0.78}[profile]
noise = np.random.uniform(-0.05, 0.05)
rate = base_speed * (1 + noise)
# Harmonic metrics
QΩ = round(0.8 + np.random.uniform(-0.05, 0.05), 3)
ζ_sync = round(0.78 + np.random.uniform(-0.05, 0.05), 3)
status = "nominal" if ζ_sync > 0.76 else "perturbed"
# Hash-log for proof of run
log = {
"profile": profile,
"workload": workload,
"cycles": cycles,
"rate_items_per_sec": round(rate * 1e9, 2),
"QΩ": QΩ,
"ζ_sync": ζ_sync,
"status": status,
"timestamp_utc": datetime.utcnow().isoformat() + "Z"
}
log["sha512"] = hashlib.sha512(json.dumps(log).encode()).hexdigest()
time.sleep(0.5)
return json.dumps(log, indent=2)
# =============================================================
# Interface
# =============================================================
iface = gr.Interface(
fn=rft_kernel,
inputs=[
gr.Radio(["CPU","GPU","TPU"], label="Compute Profile"),
gr.Radio(["matrix","transformer","mixed"], label="Workload Type"),
gr.Slider(1,10,step=1,value=3,label="Cycles"),
gr.Number(value=123, label="Seed")
],
outputs=gr.JSON(label="Simulation Log"),
title="🧠 Rendered Frame Theory — Adaptive Computing Kernel",
description=(
"Simulates harmonic-stable computation under the RFT model.\n"
"Returns QΩ, ζ_sync, and items/sec metrics with SHA-512-sealed logs."
)
)
iface.launch()