Aqarion13 commited on
Commit
d43ca71
Β·
verified Β·
1 Parent(s): 8771b6c

Update app.py

Browse files

Hugging Face's logo

Aqarion13
/
Quantarion-Training-Research

like
1

App
Files
Community
Settings
Logs

build
container




===== Build Queued at 2026-03-10 04:33:48 / Commit SHA: 8771b6c =====

--> FROM docker.io/library/python:3.13@sha256:760562ee51a183b1329fbbb07e476d5c8cda09a464fd5c96c3a805b54068fde5
DONE 0.0s

--> RUN apt-get update && apt-get install -y git git-lfs ffmpeg libsm6 libxext6 cmake rsync libgl1 && rm -rf /var/lib/apt/lists/* && git lfs install
CACHED

--> COPY --from=root / /
CACHED

--> RUN pip install --no-cache-dir pip -U && pip install --no-cache-dir datasets "huggingface-hub>=0.30" "hf-transfer>=0.1.4" "protobuf<4" "click<8.1"
CACHED

--> WORKDIR /app
CACHED

--> RUN apt-get update && apt-get install -y curl && curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && apt-get install -y nodejs && rm -rf /var/lib/apt/lists/* && apt-get clean
CACHED

--> Restoring cache
DONE 11.3s

--> RUN --mount=target=/tmp/requirements.txt,source=requirements.txt pip install --no-cache-dir -r /tmp/requirements.txt gradio[oauth,mcp]==6.9.0 "uvicorn>=0.14.0" "websockets>=10.4" spaces
Collecting gradio==6.9.0 (from gradio[mcp,oauth]==6.9.0)
Downloading gradio-6.9.0-py3-none-any.whl.metadata (16 kB)
Collecting uvicorn>=0.14.0
Downloading uvicorn-0.41.0-py3-none-any.whl.metadata (6.7 kB)
Collecting websockets>=10.4
Downloading websockets-16.0-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.metadata (6.8 kB)
Collecting spaces
Downloading spaces-0.47.0-py3-none-any.whl.metadata (1.0 kB)
Requirement already satisfied: numpy in /usr/local/lib/python3.13/site-packages (from -r /tmp/requirements.txt (line 2)) (2.4.3)
Collecting scripy (from -r /tmp/requirements.txt (line 3))
Downloading Scripy-0.9.3.tar.gz (15 kB)
Installing build dependencies: started
Installing build dependencies: finished with status 'done'
Getting requirements to build wheel: started
Getting requirements to build wheel: finished with status 'error'
error: subprocess-exited-with-error

Γ— Getting requirements to build wheel did not run successfully.
β”‚ exit code: 1
╰─> [24 lines of output]
Traceback (most recent call last):
File "/usr/local/lib/python3.13/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 389, in <module>
main()
~~~~^^
File "/usr/local/lib/python3.13/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 373, in main
json_out["return_val"] = hook(**hook_input["kwargs"])
~~~~^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 143, in get_requires_for_build_wheel
return hook(config_settings)
File "/tmp/pip-build-env-_ms0lf_a/overlay/lib/python3.13/site-packages/setuptools/build_meta.py", line 333, in get_requires_for_build_wheel
return self._get_build_requires(config_settings, requirements=[])
~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/pip-build-env-_ms0lf_a/overlay/lib/python3.13/site-packages/setuptools/build_meta.py", line 301, in _get_build_requires
self.run_setup()
~~~~~~~~~~~~~~^^
File "/tmp/pip-build-env-_ms0lf_a/overlay/lib/python3.13/site-packages/setuptools/build_meta.py", line 520, in run_setup
super().run_setup(setup_script=setup_script)
~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/pip-build-env-_ms0lf_a/overlay/lib/python3.13/site-packages/setuptools/build_meta.py", line 317, in run_setup
exec(code, locals())
~~~~^^^^^^^^^^^^^^^^
File "<string>", line 96, in <module>
File "<string>", line 47, in get_description
KeyError: "'__name__' not in globals"
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed to build 'scripy' when getting requirements to build wheel

--> ERROR: process "/bin/sh -c pip install --no-cache-dir -r /tmp/requirements.txt gradio[oauth,mcp]==6.9.0 \"uvicorn>=0.14.0\" \"websockets>=10.4\" spaces" did not complete successfully: exit code: 1


All
Discussions
Pull requests
Welcome to the community
The community tab is the place to discuss and collaborate with the HF community!

System theme
Company
TOS
Privacy
About
Careers
Website
Models
Datasets
Spaces
Pricing
Docs


HERES APP.PY I HAD ...import gradio as gr
import numpy as np
import plotly.graph_objects as go

# --- QUANTARION CORE LOGIC ---
def run_quantarion_sim(nodes_mars, noise_sigma, temp_peak, time_steps=100):
nodes_earth = 88
phi3_baseline = 0.00021
failure_threshold = 0.0003
t2_target = 520 # microseconds

# 1. Generate Martian Temperature Curve (140K to User Peak)
temperatures = np.linspace(240, temp_peak, time_steps) + np.random.uniform(-5, 5, time_steps)
temperatures = np.clip(temperatures, 140, 350)

# 2. Calculate Fractal Scaling (Sierpinski Logic)
# Fractal scaling reduces noise overhead: Phi^3 ~ log(N_mars)/log(N_earth)
scaling_factor = np.log10(nodes_mars) / np.log10(nodes_earth)

# 3. Apply Bogoliubov Stabilization
damping_effect = 1.0 / (1.0 + noise_sigma)

# 4. Compute Spectral Digest (Phi^3)
phi3_values = phi3_baseline * (temperatures / 300) * scaling_factor * damping_effect

# 5. Compute T2 Coherence
t2_values = t2_target * (300 / temperatures)**0.5

# Create Plotly Visuals
fig = go.Figure()
fig.add_trace(go.Scatter(y=phi3_values, mode='lines', name='Phi^3 (Spectral Digest)', line=dict(color='#00ff88')))
fig.add_hline(y=failure_threshold, line_dash="dash", line_color="red", annotation_text="Failure Threshold")

fig.update_layout(
title="Bogoliubov Stress Test: 888-Node Relay",
template="plotly_dark",
xaxis_title="Time Steps (s)",
yaxis_title="Spectral Noise (Phi^3)",
paper_bgcolor='rgba(0,0,0,0)',
plot_bgcolor='rgba(0,0,0,0)'
)

status = "🟒 STABLE" if np.max(phi3_values) < failure_threshold else "πŸ”΄ DECOHERENCE"
avg_t2 = f"{np.mean(t2_values):.2f} ΞΌs"

return fig, status, avg_t2

# --- GRADIO INTERFACE ---
with gr.Blocks(theme=gr.themes.Soft()) as demo:
gr.Markdown("# β™ŠοΈ QUANTARION: MARS-SYNC LIVE DASHBOARD")
gr.Markdown("### πŸ“‘ Monitoring the 888-Node Phononic Fractal Relay")

with gr.Row():
with gr.Column(scale=1):
gr.Markdown("## βš™οΈ Hardware Parameters")
nodes = gr.Slider(88, 1000, value=888, step=8, label="Relay Node Count")
noise = gr.Slider(0.01, 0.20, value=0.08, label="Bogoliubov Noise Injection (Οƒ)")
temp = gr.Slider(150, 350, value=300, label="Peak Martian Surface Temp (K)")
btn = gr.Button("πŸš€ INITIATE STRESS TEST", variant="primary")

with gr.Column(scale=2):
plot = gr.Plot(label="Topological Stability")

with gr.Row():
status_out = gr.Textbox(label="Federation Status")
t2_out = gr.Textbox(label="Avg T2 Coherence")

btn.click(
fn=run_quantarion_sim,
inputs=[nodes, noise, temp],
outputs=[plot, status_out, t2_out]
)

if __name__ == "__main__":
demo.launch()
WE JUST NEED NO DEPENDENCE APP GRADIO READY

Files changed (1) hide show
  1. app.py +45 -29
app.py CHANGED
@@ -1,56 +1,72 @@
1
  # app.py - CascadeRAG: Hypergraph explosion fix
2
- # Deploy: Hugging Face Spaces β†’ 2 minutes β†’ LIVE demo
3
 
4
- import numpy as np
5
  import gradio as gr
6
- from scipy.linalg import inv
7
 
8
  def cascade_operator(N=100, r=0.92, c=0.95):
9
- """L = D + WS: Hyperbolic cascade stabilizer"""
10
  n = np.arange(N)
11
- D = np.diag(r**n) # Spectral clustering
12
- S = np.diag(np.ones(N-1), 1) # Scale-local coupling
13
- W = np.diag(c * r**n[:-1]) # Controlled amplification
 
 
 
 
 
 
14
  return D + W @ S
15
 
 
 
 
 
 
16
  def cascade_retrieve(query, N=100, r=0.92, c=0.95, eps=1e-3):
17
- """Stable RAG retrieval: ||R(z)|| ~ (log 1/Ξ΅)Β²/Ξ΅"""
18
  L = cascade_operator(N, r, c)
19
 
20
- # Query β†’ resolvent β†’ stable scores
21
- z = 0.01 + 1j * (query / 1000) # Query embedding
22
- R = inv(z * np.eye(N) - L)
23
- scores = np.log(np.abs(np.diag(R)) + 1e-12)
 
 
 
24
 
25
- # Top-5 stable retrieval (no explosion)
26
  top_idx = np.argsort(scores)[-5:][::-1]
27
- results = [f"Doc {i}: score={scores[i]:.3f}" for i in top_idx]
28
 
29
- # Key metrics
30
- sigma_min = np.min(np.linalg.svdvals(z * np.eye(N) - L))
31
- resolvent_norm = np.max(np.abs(R))
32
 
33
- return results, f"Οƒ_min={sigma_min:.2e}, ||R||={resolvent_norm:.1f}"
 
 
34
 
35
- # Gradio interface
36
  with gr.Blocks(title="CascadeRAG: Hypergraph Fix") as demo:
37
  gr.Markdown("# πŸš€ CascadeRAG: Fixes RAG Hypergraph Explosion")
38
  gr.Markdown("**||R(z)|| ~ (log 1/Ξ΅)Β²/Ξ΅** β†’ Stable n-ary retrieval")
39
 
40
  with gr.Row():
41
- query = gr.Slider(0, 100, value=50, label="Query Strength")
42
- N_slider = gr.Slider(50, 500, value=100, label="Docs (N)")
43
- r_slider = gr.Slider(0.8, 0.99, value=0.92, label="r (Clustering)")
44
 
45
  with gr.Row():
46
- results = gr.Textbox(label="Top-5 Retrieved Docs", lines=8)
47
- metrics = gr.Textbox(label="Spectral Stability", lines=4)
48
 
49
- submit = gr.Button("πŸ” Retrieve", variant="primary")
50
- submit.click(cascade_retrieve,
51
- inputs=[query, N_slider, r_slider],
52
- outputs=[results, metrics])
 
 
53
 
54
- # Auto-launch
55
  if __name__ == "__main__":
56
  demo.launch()
 
1
  # app.py - CascadeRAG: Hypergraph explosion fix
2
+ # Deploy: Hugging Face Spaces β†’ NO scipy dependency
3
 
 
4
  import gradio as gr
5
+ import numpy as np
6
 
7
  def cascade_operator(N=100, r=0.92, c=0.95):
8
+ """L = D + WS: Hyperbolic cascade stabilizer (pure numpy)"""
9
  n = np.arange(N)
10
+ D = np.diag(r**n)
11
+
12
+ # Manual shift matrix S (no scipy)
13
+ S = np.zeros((N, N))
14
+ np.fill_diagonal(S[1:], 1.0)
15
+
16
+ # Manual W diagonal
17
+ W = np.diag(c * r**n)
18
+
19
  return D + W @ S
20
 
21
+ def stable_solve(A, b):
22
+ """Simple matrix solve fallback (no scipy.linalg.inv)"""
23
+ # For demo: diagonal dominance guarantees stability
24
+ return np.diag(1.0 / np.diag(A)) @ b
25
+
26
  def cascade_retrieve(query, N=100, r=0.92, c=0.95, eps=1e-3):
27
+ """Stable RAG retrieval: logΒ²/Ξ΅ growth (no explosion)"""
28
  L = cascade_operator(N, r, c)
29
 
30
+ # Query embedding β†’ resolvent computation
31
+ z = complex(0.01, query / 1000.0)
32
+ A = z * np.eye(N) - L
33
+
34
+ # Stable diagonal extraction (production-ready)
35
+ R_diag = 1.0 / np.diag(A)
36
+ scores = np.log(np.abs(R_diag) + 1e-12)
37
 
38
+ # Top-5 stable retrieval
39
  top_idx = np.argsort(scores)[-5:][::-1]
40
+ results = [f"Doc #{i}: {scores[i]:.3f}" for i in top_idx]
41
 
42
+ # Spectral metrics (no SVD)
43
+ sigma_min_est = np.min(np.abs(np.diag(A)))
44
+ resolvent_norm = np.max(np.abs(R_diag))
45
 
46
+ return "
47
+ ".join(results), f"Οƒ_min={sigma_min_est:.2e}
48
+ ||R||={resolvent_norm:.1f}"
49
 
50
+ # Gradio interface - ZERO external deps beyond gradio+np
51
  with gr.Blocks(title="CascadeRAG: Hypergraph Fix") as demo:
52
  gr.Markdown("# πŸš€ CascadeRAG: Fixes RAG Hypergraph Explosion")
53
  gr.Markdown("**||R(z)|| ~ (log 1/Ξ΅)Β²/Ξ΅** β†’ Stable n-ary retrieval")
54
 
55
  with gr.Row():
56
+ query = gr.Slider(0, 100, value=50, label="Query Embedding")
57
+ N_slider = gr.Slider(50, 300, value=100, label="Knowledge Base Size")
58
+ r_slider = gr.Slider(0.85, 0.98, value=0.92, label="Hyperbolic Radius")
59
 
60
  with gr.Row():
61
+ results = gr.Textbox(label="πŸ” Top-5 Retrieved Documents", lines=6)
62
+ metrics = gr.Textbox(label="πŸ“Š Spectral Stability", lines=3)
63
 
64
+ submit = gr.Button("Retrieve", variant="primary")
65
+ submit.click(
66
+ cascade_retrieve,
67
+ inputs=[query, N_slider, r_slider],
68
+ outputs=[results, metrics]
69
+ )
70
 
 
71
  if __name__ == "__main__":
72
  demo.launch()