GotThatData commited on
Commit
3459700
·
1 Parent(s): 6c4abbd

Enhanced Space with Ising model, educational tabs, hardware comparisons

Browse files
Files changed (2) hide show
  1. README.md +59 -23
  2. app.py +395 -189
README.md CHANGED
@@ -1,5 +1,5 @@
1
  ---
2
- title: Daugherty Engine SAT Solver
3
  emoji: 🧮
4
  colorFrom: green
5
  colorTo: blue
@@ -9,43 +9,79 @@ python_version: "3.10"
9
  app_file: app.py
10
  pinned: false
11
  license: apache-2.0
12
- short_description: GPU-accelerated constraint satisfaction solver demo
 
 
 
 
 
 
 
 
13
  ---
14
 
15
- # Daugherty Engine - SAT Solver Demo
16
 
17
- Test our GPU-accelerated constraint satisfaction solver through a simple API interface.
18
 
19
- ## What This Does
20
 
21
- 1. **Generates** random 3-SAT problems at the phase transition ratio (α=4.27)
22
- 2. **Solves** using our proprietary GPU-accelerated algorithm
23
- 3. **Verifies** results and reports satisfaction percentage
24
- 4. **Anchors** proofs to BSV blockchain (optional)
25
 
26
- ## Key Metrics
27
 
28
- - **Hardware:** NVIDIA RTX 6000 Ada (48GB VRAM)
29
- - **Cost:** $1.57/hour (vs $13.20/hour for D-Wave)
30
- - **Power:** 195W typical (vs 25kW for quantum systems)
31
 
32
  ## How It Works
33
 
34
- This Space calls the public API at `https://1millionspins.originneural.ai/api` - no proprietary code is exposed. You're interacting with the same verification endpoint available on the main demo site.
35
 
36
- ## Problem Difficulty
37
 
38
- The phase transition ratio of 4.27 clauses per variable represents the hardest region for 3-SAT problems. At this ratio:
39
- - Below 4.27: Problems are almost always satisfiable (easy)
40
- - Above 4.27: Problems are almost always unsatisfiable (easy to prove)
41
- - At 4.27: Maximum uncertainty, hardest to solve
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
 
43
  ## Links
44
 
45
- - [Full Demo Site](https://1millionspins.originneural.ai)
46
- - [Origin Neural](https://originneural.ai)
47
- - [SmartLedger Solutions](https://smartledger.solutions)
48
 
49
  ## Contact
50
 
51
- Questions? Email: Shawn@smartledger.solutions
 
 
 
 
 
1
  ---
2
+ title: Daugherty Engine
3
  emoji: 🧮
4
  colorFrom: green
5
  colorTo: blue
 
9
  app_file: app.py
10
  pinned: false
11
  license: apache-2.0
12
+ short_description: GPU-accelerated SAT & Ising solver - quantum-competitive
13
+ tags:
14
+ - optimization
15
+ - sat-solver
16
+ - ising-model
17
+ - constraint-satisfaction
18
+ - quantum-computing
19
+ - gpu
20
+ - nvidia
21
  ---
22
 
23
+ # Daugherty Engine
24
 
25
+ **GPU-accelerated constraint satisfaction and combinatorial optimization achieving quantum-competitive results on classical hardware.**
26
 
27
+ ## What You Can Test
28
 
29
+ | Problem Type | Description | Quantum Equivalent |
30
+ |-------------|-------------|-------------------|
31
+ | **3-SAT** | Boolean satisfiability at phase transition (α=4.27) | Gate-based quantum computing |
32
+ | **Ising Model** | Spin glass energy minimization | Quantum annealing (D-Wave) |
33
 
34
+ ## Key Results
35
 
36
+ - **128x more power efficient** than D-Wave Advantage
37
+ - **8x cheaper** per solve than quantum cloud services
38
+ - Runs on a single NVIDIA RTX 6000 Ada ($1.57/hour)
39
 
40
  ## How It Works
41
 
42
+ This Space provides **API-only access** to the Daugherty Engine. No proprietary algorithms or source code are exposed. You interact with the same verification endpoints available at [1millionspins.originneural.ai](https://1millionspins.originneural.ai).
43
 
44
+ ### API Endpoints Used
45
 
46
+ - `POST /api/verify/sat` - 3-SAT verification
47
+ - `POST /api/verify/ising` - Ising model optimization
48
+ - `GET /api/health` - System status
49
+
50
+ ## The Science
51
+
52
+ ### 3-SAT at Phase Transition
53
+
54
+ At the clause-to-variable ratio α = 4.27:
55
+ - Problems are maximally hard (neither clearly SAT nor UNSAT)
56
+ - This is the "computational phase transition"
57
+ - First proven NP-complete problem (Cook-Levin, 1971)
58
+
59
+ ### Ising Model
60
+
61
+ The Ising Hamiltonian: `H(s) = -Σᵢⱼ Jᵢⱼ sᵢ sⱼ - Σᵢ hᵢ sᵢ`
62
+
63
+ - Native problem type for quantum annealers
64
+ - Maps to QUBO (Quadratic Unconstrained Binary Optimization)
65
+ - Applications: portfolio optimization, logistics, ML
66
+
67
+ ## Hardware
68
+
69
+ | System | Power | Cost/Hour | Qubits/Cores |
70
+ |--------|-------|-----------|--------------|
71
+ | **Daugherty Engine** | 195W | $1.57 | 18,176 CUDA |
72
+ | D-Wave Advantage | 25kW | $13.20 | 5,000 qubits |
73
+ | IBM Quantum | 15kW | $1.60 | 127 qubits |
74
 
75
  ## Links
76
 
77
+ - [Full Demo](https://1millionspins.originneural.ai) - Interactive visualizations
78
+ - [Origin Neural](https://originneural.ai) - Company website
79
+ - [SmartLedger Solutions](https://smartledger.solutions) - Blockchain partner
80
 
81
  ## Contact
82
 
83
+ **Shawn@smartledger.solutions**
84
+
85
+ ---
86
+
87
+ *Built with [Gradio](https://gradio.app) on [Hugging Face Spaces](https://huggingface.co/spaces)*
app.py CHANGED
@@ -1,6 +1,6 @@
1
  """
2
- Daugherty Engine - SAT Solver Demo
3
- API-only interface for testing constraint satisfaction solving.
4
 
5
  This demo calls the public API at https://1millionspins.originneural.ai
6
  No proprietary code is exposed - only API interactions.
@@ -9,22 +9,39 @@ No proprietary code is exposed - only API interactions.
9
  import gradio as gr
10
  import requests
11
  import time
12
- import json
13
 
14
  # Public API endpoint
15
  API_BASE = "https://1millionspins.originneural.ai/api"
16
 
17
  # Hardware specs (public information from DigitalOcean pricing)
18
  HARDWARE_INFO = {
19
- "accelerator": "NVIDIA RTX 6000 Ada (48GB VRAM)",
20
- "cost_per_hour": 1.57,
21
- "typical_power": 195, # Watts
 
 
 
 
 
 
22
  }
23
 
24
- # Competitor reference data (public sources)
25
  COMPETITORS = {
26
- "D-Wave Advantage": {"power": 25000, "cost_per_hour": 13.20},
27
- "IBM Quantum": {"power": 15000, "cost_per_hour": 1.60},
 
 
 
 
 
 
 
 
 
 
 
 
28
  }
29
 
30
 
@@ -34,40 +51,91 @@ def check_api_health():
34
  response = requests.get(f"{API_BASE}/health", timeout=10)
35
  if response.status_code == 200:
36
  data = response.json()
37
- return f"Online - GPU: {data.get('gpu', 'Unknown')}"
 
38
  return "Offline"
39
  except Exception as e:
40
  return f"Error: {str(e)}"
41
 
42
 
43
- def run_verification(num_variables: int, num_trials: int):
44
- """
45
- Run SAT verification through the public API.
 
 
 
 
 
 
46
 
47
- Args:
48
- num_variables: Number of variables (20-500)
49
- num_trials: Number of verification trials (1-20)
50
 
51
- Returns:
52
- Results dictionary with metrics and comparisons
53
- """
54
- # Validate inputs
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  num_variables = max(20, min(500, int(num_variables)))
56
  num_trials = max(1, min(20, int(num_trials)))
57
 
58
- # Calculate problem parameters
59
- alpha = 4.27 # Phase transition ratio
60
- num_clauses = int(num_variables * alpha)
61
-
62
  start_time = time.time()
63
 
64
  try:
65
  response = requests.post(
66
  f"{API_BASE}/verify/sat",
67
- json={
68
- "size": num_variables,
69
- "trials": num_trials
70
- },
71
  timeout=120,
72
  headers={"Content-Type": "application/json"}
73
  )
@@ -75,216 +143,354 @@ def run_verification(num_variables: int, num_trials: int):
75
  elapsed_time = time.time() - start_time
76
 
77
  if response.status_code != 200:
78
- return format_error(f"API Error: {response.status_code} - {response.text[:200]}")
79
 
80
  data = response.json()
81
-
82
  if not data.get("success"):
83
- return format_error(f"API returned error: {data}")
84
 
85
  results = data.get("data", {}).get("results", {})
86
-
87
- # Calculate metrics
88
- mean_satisfaction = results.get("mean_satisfaction", 0)
89
- std_satisfaction = results.get("std_satisfaction", 0)
90
-
91
- # Derive quality tier from satisfaction percentage
92
- if mean_satisfaction >= 95:
93
- quality_tier = "EXCELLENT"
94
- elif mean_satisfaction >= 85:
95
- quality_tier = "GOOD"
96
- elif mean_satisfaction >= 70:
97
- quality_tier = "ACCEPTABLE"
98
  else:
99
- quality_tier = "LOW"
100
 
101
- # Energy calculation
102
- energy_joules = HARDWARE_INFO["typical_power"] * elapsed_time
103
  cost_usd = (HARDWARE_INFO["cost_per_hour"] / 3600) * elapsed_time
 
 
 
104
 
105
- # Competitor comparisons
106
- dwave_energy = COMPETITORS["D-Wave Advantage"]["power"] * elapsed_time
107
- power_ratio = round(dwave_energy / energy_joules) if energy_joules > 0 else 0
108
- cost_ratio = round(COMPETITORS["D-Wave Advantage"]["cost_per_hour"] / HARDWARE_INFO["cost_per_hour"])
109
-
110
- return format_results(
111
- num_variables=num_variables,
112
- num_clauses=num_clauses,
113
- num_trials=num_trials,
114
- mean_satisfaction=mean_satisfaction,
115
- std_satisfaction=std_satisfaction,
116
- quality_tier=quality_tier,
117
- elapsed_time=elapsed_time,
118
- energy_joules=energy_joules,
119
- cost_usd=cost_usd,
120
- power_ratio=power_ratio,
121
- cost_ratio=cost_ratio,
122
- blockchain=data.get("data", {}).get("blockchain", {})
123
- )
 
 
 
 
 
 
124
 
125
  except requests.exceptions.Timeout:
126
- return format_error("Request timed out. Try a smaller problem size.")
127
- except requests.exceptions.ConnectionError as e:
128
- return format_error(f"Could not connect to API: {str(e)}")
129
  except Exception as e:
130
- import traceback
131
- return format_error(f"Error: {str(e)}\n\nTraceback:\n```\n{traceback.format_exc()}\n```")
132
 
133
 
134
- def format_results(**kwargs):
135
- """Format results as markdown."""
136
- blockchain = kwargs.get("blockchain", {})
137
- txid = blockchain.get("txid", "")
138
 
139
- bsv_link = ""
140
- if txid:
141
- bsv_link = f"\n\n**Blockchain Proof:** [{txid[:16]}...](https://whatsonchain.com/tx/{txid})"
142
 
143
- return f"""
144
- ## Verification Results
 
 
 
 
 
145
 
146
- ### Problem Configuration
147
- - **Variables:** {kwargs['num_variables']}
148
- - **Clauses:** {kwargs['num_clauses']} (ratio: 4.27)
149
- - **Trials:** {kwargs['num_trials']}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
150
 
151
- ### Performance
152
  | Metric | Value |
153
  |--------|-------|
154
- | Satisfaction | **{kwargs['mean_satisfaction']:.1f}%** (std: {kwargs['std_satisfaction']:.2f}) |
155
- | Quality Tier | **{kwargs['quality_tier']}** |
156
- | Solve Time | {kwargs['elapsed_time']:.3f}s |
157
- | Energy | {kwargs['energy_joules']:.1f}J |
158
- | Cost | ${kwargs['cost_usd']:.6f} |
159
-
160
- ### Efficiency vs Quantum Computers
161
- | Comparison | Ratio |
162
- |------------|-------|
163
- | Power Efficiency vs D-Wave | **{kwargs['power_ratio']}x** less power |
164
- | Cost Efficiency vs D-Wave | **{kwargs['cost_ratio']}x** cheaper |
165
- {bsv_link}
 
 
166
 
167
  ---
168
- *Computed on {HARDWARE_INFO['accelerator']}*
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
169
  """
170
 
 
 
171
 
172
- def format_error(message: str):
173
- """Format error message."""
174
- return f"""
175
- ## Error
 
 
 
 
 
 
 
 
 
 
 
 
176
 
177
- {message}
 
 
 
178
 
179
- Please try again or reduce the problem size.
180
  """
181
 
 
 
182
 
183
- def get_problem_info(num_variables: int):
184
- """Get information about the problem that will be generated."""
185
- num_variables = max(20, min(500, int(num_variables)))
186
- num_clauses = int(num_variables * 4.27)
187
- search_space = 2 ** num_variables
188
 
189
- return f"""
190
- **Problem Preview:**
191
- - Variables: {num_variables}
192
- - Clauses: {num_clauses}
193
- - Search Space: 2^{num_variables} = {search_space:.2e} possibilities
194
- - Difficulty: {"Easy" if num_variables < 100 else "Medium" if num_variables < 300 else "Hard"}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
195
  """
196
 
 
 
197
 
198
- # Build Gradio Interface
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
199
  with gr.Blocks(
200
- title="Daugherty Engine - SAT Solver Demo",
201
- theme=gr.themes.Base(
202
- primary_hue="green",
203
- secondary_hue="gray",
204
- neutral_hue="gray",
205
- ),
206
- css="""
207
- .gradio-container { max-width: 900px !important; }
208
- .result-box { font-family: monospace; }
209
- """
210
  ) as demo:
211
 
212
- gr.Markdown("""
213
- # Daugherty Engine - Constraint Satisfaction Solver
 
 
 
 
 
 
 
 
 
214
 
215
- Test our GPU-accelerated SAT solver through the public API.
216
- No code is exposed - this interface simply calls the verification endpoint.
 
 
 
 
 
 
 
 
217
 
218
- **What it does:** Generates random 3-SAT problems at the phase transition (hardest region)
219
- and attempts to find satisfying assignments using our proprietary solver.
220
- """)
221
 
222
- with gr.Row():
223
- with gr.Column(scale=1):
224
- api_status = gr.Textbox(
225
- label="API Status",
226
- value=check_api_health(),
227
- interactive=False
228
- )
229
 
230
- refresh_btn = gr.Button("Refresh Status", size="sm")
231
- refresh_btn.click(fn=check_api_health, outputs=api_status)
 
 
 
 
 
 
 
232
 
233
- gr.Markdown("---")
 
234
 
235
- with gr.Row():
236
- with gr.Column(scale=1):
237
- num_vars = gr.Slider(
238
- minimum=20,
239
- maximum=500,
240
- value=100,
241
- step=10,
242
- label="Number of Variables",
243
- info="More variables = harder problem"
244
- )
245
-
246
- num_trials = gr.Slider(
247
- minimum=1,
248
- maximum=20,
249
- value=5,
250
- step=1,
251
- label="Verification Trials",
252
- info="More trials = higher confidence"
253
- )
254
-
255
- problem_info = gr.Markdown(get_problem_info(100))
256
- num_vars.change(fn=get_problem_info, inputs=num_vars, outputs=problem_info)
257
-
258
- run_btn = gr.Button("Run Verification", variant="primary", size="lg")
259
-
260
- with gr.Column(scale=2):
261
- results = gr.Markdown(
262
- value="*Click 'Run Verification' to test the solver*",
263
- elem_classes=["result-box"]
264
- )
265
-
266
- run_btn.click(
267
- fn=run_verification,
268
- inputs=[num_vars, num_trials],
269
- outputs=results
270
- )
271
 
272
- gr.Markdown("""
273
- ---
 
274
 
275
- ### About
 
276
 
277
- The Daugherty Engine is a novel approach to constraint satisfaction that achieves
278
- quantum-competitive results on classical GPU hardware. This demo provides API access
279
- only - no proprietary algorithms or source code are exposed.
280
 
281
- **Links:**
282
- - [Full Demo Site](https://1millionspins.originneural.ai)
283
- - [Origin Neural](https://originneural.ai)
284
 
285
- **Hardware:** NVIDIA RTX 6000 Ada (48GB VRAM) @ $1.57/hour
286
- """)
287
 
 
 
 
 
 
288
 
289
  if __name__ == "__main__":
290
  demo.launch()
 
1
  """
2
+ Daugherty Engine - SAT & Ising Solver Demo
3
+ API-only interface for testing constraint satisfaction and optimization.
4
 
5
  This demo calls the public API at https://1millionspins.originneural.ai
6
  No proprietary code is exposed - only API interactions.
 
9
  import gradio as gr
10
  import requests
11
  import time
 
12
 
13
  # Public API endpoint
14
  API_BASE = "https://1millionspins.originneural.ai/api"
15
 
16
  # Hardware specs (public information from DigitalOcean pricing)
17
  HARDWARE_INFO = {
18
+ "name": "NVIDIA RTX 6000 Ada",
19
+ "vram": 48, # GB
20
+ "architecture": "Ada Lovelace",
21
+ "cuda_cores": 18176,
22
+ "tensor_cores": 568,
23
+ "tdp": 300, # Watts
24
+ "typical_power": 195, # Watts at ~65% utilization
25
+ "cost_per_hour": 1.57, # USD (DigitalOcean GPU Droplet)
26
+ "source": "DigitalOcean GPU Droplet pricing, January 2026"
27
  }
28
 
29
+ # Competitor reference data (all from public sources)
30
  COMPETITORS = {
31
+ "D-Wave Advantage": {
32
+ "qubits": 5000,
33
+ "power": 25000, # Watts (system + cooling)
34
+ "cost_per_hour": 13.20, # AWS Braket pricing
35
+ "type": "Quantum Annealer",
36
+ "source": "AWS Braket pricing, D-Wave documentation"
37
+ },
38
+ "IBM Quantum (127Q)": {
39
+ "qubits": 127,
40
+ "power": 15000, # Watts (dilution refrigerator)
41
+ "cost_per_hour": 1.60, # IBM Quantum Network
42
+ "type": "Gate-based Quantum",
43
+ "source": "IBM Quantum pricing documentation"
44
+ }
45
  }
46
 
47
 
 
51
  response = requests.get(f"{API_BASE}/health", timeout=10)
52
  if response.status_code == 200:
53
  data = response.json()
54
+ gpu = data.get('gpu', 'Unknown')
55
+ return f"Online ({gpu})"
56
  return "Offline"
57
  except Exception as e:
58
  return f"Error: {str(e)}"
59
 
60
 
61
+ def calculate_search_space(n):
62
+ """Calculate and format the search space size."""
63
+ space = 2 ** n
64
+ if space > 1e100:
65
+ return f"2^{n} (astronomical)"
66
+ elif space > 1e30:
67
+ return f"2^{n} ({space:.2e})"
68
+ else:
69
+ return f"2^{n} = {space:,.0f}"
70
 
 
 
 
71
 
72
+ def get_sat_difficulty(num_vars):
73
+ """Analyze SAT problem difficulty."""
74
+ clauses = int(num_vars * 4.27)
75
+
76
+ if num_vars <= 50:
77
+ difficulty, desc = "Easy", "Solvable in milliseconds"
78
+ elif num_vars <= 150:
79
+ difficulty, desc = "Medium", "Requires seconds"
80
+ elif num_vars <= 300:
81
+ difficulty, desc = "Hard", "May require minutes"
82
+ else:
83
+ difficulty, desc = "Very Hard", "Exponential blowup region"
84
+
85
+ return f"""
86
+ ### Problem Preview
87
+
88
+ | Parameter | Value |
89
+ |-----------|-------|
90
+ | Variables | {num_vars} |
91
+ | Clauses | {clauses} |
92
+ | Ratio (α) | 4.27 |
93
+ | Search Space | {calculate_search_space(num_vars)} |
94
+ | Difficulty | **{difficulty}** |
95
+
96
+ *{desc}*
97
+ """
98
+
99
+
100
+ def get_ising_difficulty(size):
101
+ """Analyze Ising problem difficulty."""
102
+ interactions = size * (size - 1) // 2
103
+
104
+ if size <= 30:
105
+ difficulty, desc = "Easy", "Small spin glass"
106
+ elif size <= 100:
107
+ difficulty, desc = "Medium", "Moderate complexity"
108
+ elif size <= 300:
109
+ difficulty, desc = "Hard", "Large spin system"
110
+ else:
111
+ difficulty, desc = "Very Hard", "Massive optimization landscape"
112
+
113
+ return f"""
114
+ ### Problem Preview
115
+
116
+ | Parameter | Value |
117
+ |-----------|-------|
118
+ | Spins | {size} |
119
+ | Interactions | ~{interactions:,} |
120
+ | Configuration Space | {calculate_search_space(size)} |
121
+ | Difficulty | **{difficulty}** |
122
+
123
+ *{desc}*
124
+ """
125
+
126
+
127
+ def run_sat_verification(num_variables: int, num_trials: int):
128
+ """Run SAT verification through the public API."""
129
  num_variables = max(20, min(500, int(num_variables)))
130
  num_trials = max(1, min(20, int(num_trials)))
131
 
132
+ num_clauses = int(num_variables * 4.27)
 
 
 
133
  start_time = time.time()
134
 
135
  try:
136
  response = requests.post(
137
  f"{API_BASE}/verify/sat",
138
+ json={"size": num_variables, "trials": num_trials},
 
 
 
139
  timeout=120,
140
  headers={"Content-Type": "application/json"}
141
  )
 
143
  elapsed_time = time.time() - start_time
144
 
145
  if response.status_code != 200:
146
+ return f"## Error\n\nAPI Error: {response.status_code}"
147
 
148
  data = response.json()
 
149
  if not data.get("success"):
150
+ return f"## Error\n\n{data.get('error', 'Unknown error')}"
151
 
152
  results = data.get("data", {}).get("results", {})
153
+ mean_sat = results.get("mean_satisfaction", 0)
154
+ std_sat = results.get("std_satisfaction", 0)
155
+ max_sat = results.get("max_satisfaction", 0)
156
+ min_sat = results.get("min_satisfaction", 0)
157
+
158
+ # Quality tier
159
+ if mean_sat >= 95:
160
+ tier = "EXCELLENT"
161
+ elif mean_sat >= 85:
162
+ tier = "GOOD"
163
+ elif mean_sat >= 70:
164
+ tier = "ACCEPTABLE"
165
  else:
166
+ tier = "LOW"
167
 
168
+ # Resource calculations
169
+ energy_j = HARDWARE_INFO["typical_power"] * elapsed_time
170
  cost_usd = (HARDWARE_INFO["cost_per_hour"] / 3600) * elapsed_time
171
+ dwave = COMPETITORS["D-Wave Advantage"]
172
+ dwave_energy = dwave["power"] * elapsed_time
173
+ power_ratio = round(dwave_energy / energy_j) if energy_j > 0 else 0
174
 
175
+ return f"""
176
+ ## SAT Verification Results
177
+
178
+ ### Performance
179
+
180
+ | Metric | Value |
181
+ |--------|-------|
182
+ | Mean Satisfaction | **{mean_sat:.2f}%** |
183
+ | Std Deviation | ±{std_sat:.2f}% |
184
+ | Best/Worst Trial | {max_sat:.2f}% / {min_sat:.2f}% |
185
+ | Quality Tier | **{tier}** |
186
+
187
+ ### Resources
188
+
189
+ | Metric | Daugherty | D-Wave Equivalent |
190
+ |--------|-----------|-------------------|
191
+ | Time | {elapsed_time:.3f}s | {elapsed_time:.3f}s |
192
+ | Energy | {energy_j:.1f} J | {dwave_energy:.1f} J |
193
+ | Cost | ${cost_usd:.6f} | ${(dwave["cost_per_hour"]/3600)*elapsed_time:.6f} |
194
+
195
+ **Efficiency: {power_ratio}x less power than D-Wave**
196
+
197
+ ---
198
+ *{num_variables} variables, {num_clauses} clauses, {num_trials} trials*
199
+ """
200
 
201
  except requests.exceptions.Timeout:
202
+ return "## Error\n\nRequest timed out. Try smaller problem."
 
 
203
  except Exception as e:
204
+ return f"## Error\n\n{str(e)}"
 
205
 
206
 
207
+ def run_ising_verification(size: int, trials: int):
208
+ """Run Ising model verification through the public API."""
209
+ size = max(10, min(500, int(size)))
210
+ trials = max(1, min(20, int(trials)))
211
 
212
+ start_time = time.time()
 
 
213
 
214
+ try:
215
+ response = requests.post(
216
+ f"{API_BASE}/verify/ising",
217
+ json={"size": size, "trials": trials},
218
+ timeout=120,
219
+ headers={"Content-Type": "application/json"}
220
+ )
221
 
222
+ elapsed_time = time.time() - start_time
223
+
224
+ if response.status_code != 200:
225
+ return f"## Error\n\nAPI Error: {response.status_code}"
226
+
227
+ data = response.json()
228
+ if not data.get("success"):
229
+ return f"## Error\n\n{data.get('error', 'Unknown error')}"
230
+
231
+ results = data.get("data", {}).get("results", {})
232
+ quality_score = results.get("quality_score", 0)
233
+ quality_tier = results.get("quality_tier", "UNKNOWN")
234
+ solution_hash = results.get("solution_hash", "N/A")
235
+ accelerator = data.get("data", {}).get("accelerator", "Unknown")
236
+
237
+ # Resource calculations
238
+ energy_j = HARDWARE_INFO["typical_power"] * elapsed_time
239
+ cost_usd = (HARDWARE_INFO["cost_per_hour"] / 3600) * elapsed_time
240
+ dwave = COMPETITORS["D-Wave Advantage"]
241
+ dwave_energy = dwave["power"] * elapsed_time
242
+ power_ratio = round(dwave_energy / energy_j) if energy_j > 0 else 0
243
+
244
+ return f"""
245
+ ## Ising Model Results
246
+
247
+ ### Optimization Performance
248
 
 
249
  | Metric | Value |
250
  |--------|-------|
251
+ | Quality Score | **{quality_score:.1f}** |
252
+ | Quality Tier | **{quality_tier}** |
253
+ | Solution Hash | `{solution_hash}` |
254
+ | Accelerator | {accelerator} |
255
+
256
+ ### Resources
257
+
258
+ | Metric | Daugherty | D-Wave Equivalent |
259
+ |--------|-----------|-------------------|
260
+ | Time | {elapsed_time:.3f}s | {elapsed_time:.3f}s |
261
+ | Energy | {energy_j:.1f} J | {dwave_energy:.1f} J |
262
+ | Cost | ${cost_usd:.6f} | ${(dwave["cost_per_hour"]/3600)*elapsed_time:.6f} |
263
+
264
+ **Efficiency: {power_ratio}x less power than D-Wave**
265
 
266
  ---
267
+ *{size} spins, {trials} trials*
268
+ """
269
+
270
+ except requests.exceptions.Timeout:
271
+ return "## Error\n\nRequest timed out. Try smaller problem."
272
+ except Exception as e:
273
+ return f"## Error\n\n{str(e)}"
274
+
275
+
276
+ # Educational content
277
+ INTRO_MD = """
278
+ # Daugherty Engine
279
+
280
+ GPU-accelerated constraint satisfaction and combinatorial optimization.
281
+ Achieving quantum-competitive results on classical hardware.
282
+
283
+ ## Available Tests
284
+
285
+ | Problem | Description | Quantum Equivalent |
286
+ |---------|-------------|-------------------|
287
+ | **3-SAT** | Boolean satisfiability at phase transition | Gate-based QC |
288
+ | **Ising** | Spin glass energy minimization | Quantum Annealing |
289
  """
290
 
291
+ ABOUT_SAT_MD = """
292
+ ## Boolean Satisfiability (SAT)
293
 
294
+ ### The Problem
295
+
296
+ Given a boolean formula in CNF (Conjunctive Normal Form):
297
+ ```
298
+ (x₁ OR ¬x₂ OR x₃) AND (¬x₁ OR x₂ OR ¬x₄) AND ...
299
+ ```
300
+
301
+ Find an assignment of TRUE/FALSE to each variable that satisfies ALL clauses.
302
+
303
+ ### Why It Matters
304
+
305
+ - **First NP-Complete problem** (Cook-Levin theorem, 1971)
306
+ - **Universal reducer**: Most combinatorial problems can be encoded as SAT
307
+ - **Applications**: Circuit verification, AI planning, cryptanalysis, scheduling
308
+
309
+ ### The Phase Transition
310
 
311
+ At α = 4.27 (clauses/variables ratio):
312
+ - **Below 4.27**: Almost always satisfiable
313
+ - **Above 4.27**: Almost always unsatisfiable
314
+ - **At 4.27**: Maximum uncertainty — **hardest instances**
315
 
316
+ We test at this critical threshold.
317
  """
318
 
319
+ ABOUT_ISING_MD = """
320
+ ## Ising Model Optimization
321
 
322
+ ### The Problem
 
 
 
 
323
 
324
+ The Ising model represents a system of interacting spins (±1):
325
+
326
+ ```
327
+ H(s) = -Σᵢⱼ Jᵢⱼ sᵢ sⱼ - Σᵢ hᵢ sᵢ
328
+ ```
329
+
330
+ Goal: Find spin configuration that minimizes total energy H.
331
+
332
+ ### Why It Matters
333
+
334
+ - **Native to quantum annealers**: D-Wave's fundamental problem type
335
+ - **QUBO mapping**: Most optimization problems encode to Ising/QUBO
336
+ - **Applications**: Portfolio optimization, logistics, machine learning
337
+
338
+ ### Connection to Quantum Computing
339
+
340
+ Quantum annealers (D-Wave) physically simulate the Ising model using superconducting qubits. Our approach achieves competitive results using GPU parallelism instead of quantum effects.
341
+ """
342
+
343
+ HARDWARE_MD = f"""
344
+ ## Hardware Comparison
345
+
346
+ ### Daugherty Engine
347
+
348
+ | Spec | Value |
349
+ |------|-------|
350
+ | GPU | {HARDWARE_INFO["name"]} |
351
+ | VRAM | {HARDWARE_INFO["vram"]} GB |
352
+ | Architecture | {HARDWARE_INFO["architecture"]} |
353
+ | CUDA Cores | {HARDWARE_INFO["cuda_cores"]:,} |
354
+ | Power | {HARDWARE_INFO["typical_power"]}W typical |
355
+ | Cost | ${HARDWARE_INFO["cost_per_hour"]}/hour |
356
+
357
+ ### Quantum Systems
358
+
359
+ | System | Qubits | Power | Cost/Hour |
360
+ |--------|--------|-------|-----------|
361
+ | D-Wave Advantage | 5,000 | ~25 kW | $13.20 |
362
+ | IBM Quantum | 127 | ~15 kW | $1.60 |
363
+ | Google Sycamore | 70 | ~25 kW | N/A |
364
+
365
+ ### Key Insight
366
+
367
+ Quantum computers require:
368
+ - **Dilution refrigerators** (10-15 millikelvin)
369
+ - **Electromagnetic shielding**
370
+ - **Error correction overhead**
371
+
372
+ Our GPU approach avoids these requirements entirely.
373
+ """
374
+
375
+ METHODOLOGY_MD = """
376
+ ## Methodology
377
+
378
+ ### SAT Verification
379
+
380
+ We measure **satisfaction rate** — percentage of clauses satisfied.
381
+
382
+ | Tier | Satisfaction | Meaning |
383
+ |------|-------------|---------|
384
+ | EXCELLENT | ≥95% | Near-optimal |
385
+ | GOOD | ≥85% | High quality |
386
+ | ACCEPTABLE | ≥70% | Reasonable |
387
+ | LOW | <70% | Very hard instance |
388
+
389
+ ### Ising Verification
390
+
391
+ We measure **quality score** — normalized energy minimization quality.
392
+
393
+ | Tier | Meaning |
394
+ |------|---------|
395
+ | EXCELLENT | Ground state or near |
396
+ | GOOD | Low energy solution |
397
+ | ACCEPTABLE | Local minimum |
398
+ | POOR | High energy state |
399
+
400
+ ### Why These Metrics?
401
+
402
+ At the phase transition, problems may be unsatisfiable. Satisfaction percentage captures solution quality even for UNSAT instances (MAX-SAT interpretation).
403
  """
404
 
405
+ LINKS_MD = """
406
+ ## Resources
407
 
408
+ ### Live Demos
409
+ - [Full Interactive Demo](https://1millionspins.originneural.ai) — Animated visualizations
410
+ - [Origin Neural](https://originneural.ai) — Company site
411
+
412
+ ### Academic References
413
+ - Cook (1971) — "The Complexity of Theorem-Proving Procedures"
414
+ - Mézard et al. (2002) — "Random Satisfiability Problems"
415
+ - Kirkpatrick & Selman (1994) — "Critical Behavior in SAT"
416
+ - Barahona (1982) — "On the computational complexity of Ising spin glass models"
417
+
418
+ ### Contact
419
+ **Shawn@smartledger.solutions**
420
+ """
421
+
422
+
423
+ # Build Interface
424
  with gr.Blocks(
425
+ title="Daugherty Engine",
426
+ theme=gr.themes.Soft(primary_hue="emerald"),
427
+ css=".gradio-container { max-width: 1100px !important; }"
 
 
 
 
 
 
 
428
  ) as demo:
429
 
430
+ gr.Markdown(INTRO_MD)
431
+
432
+ with gr.Row():
433
+ api_status = gr.Textbox(
434
+ label="API Status",
435
+ value=check_api_health(),
436
+ interactive=False,
437
+ scale=3
438
+ )
439
+ refresh_btn = gr.Button("Refresh", size="sm", scale=1)
440
+ refresh_btn.click(fn=check_api_health, outputs=api_status)
441
 
442
+ with gr.Tabs():
443
+ # SAT Tab
444
+ with gr.TabItem("3-SAT Solver"):
445
+ with gr.Row():
446
+ with gr.Column(scale=1):
447
+ sat_vars = gr.Slider(20, 500, 100, step=10, label="Variables")
448
+ sat_trials = gr.Slider(1, 20, 5, step=1, label="Trials")
449
+ sat_info = gr.Markdown(get_sat_difficulty(100))
450
+ sat_vars.change(get_sat_difficulty, sat_vars, sat_info)
451
+ sat_btn = gr.Button("Run SAT Verification", variant="primary")
452
 
453
+ with gr.Column(scale=2):
454
+ sat_results = gr.Markdown("*Click 'Run SAT Verification' to test*")
 
455
 
456
+ sat_btn.click(run_sat_verification, [sat_vars, sat_trials], sat_results)
 
 
 
 
 
 
457
 
458
+ # Ising Tab
459
+ with gr.TabItem("Ising Model"):
460
+ with gr.Row():
461
+ with gr.Column(scale=1):
462
+ ising_size = gr.Slider(10, 500, 50, step=10, label="Spins")
463
+ ising_trials = gr.Slider(1, 20, 5, step=1, label="Trials")
464
+ ising_info = gr.Markdown(get_ising_difficulty(50))
465
+ ising_size.change(get_ising_difficulty, ising_size, ising_info)
466
+ ising_btn = gr.Button("Run Ising Verification", variant="primary")
467
 
468
+ with gr.Column(scale=2):
469
+ ising_results = gr.Markdown("*Click 'Run Ising Verification' to test*")
470
 
471
+ ising_btn.click(run_ising_verification, [ising_size, ising_trials], ising_results)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
472
 
473
+ # Info Tabs
474
+ with gr.TabItem("About SAT"):
475
+ gr.Markdown(ABOUT_SAT_MD)
476
 
477
+ with gr.TabItem("About Ising"):
478
+ gr.Markdown(ABOUT_ISING_MD)
479
 
480
+ with gr.TabItem("Hardware"):
481
+ gr.Markdown(HARDWARE_MD)
 
482
 
483
+ with gr.TabItem("Methodology"):
484
+ gr.Markdown(METHODOLOGY_MD)
 
485
 
486
+ with gr.TabItem("Links"):
487
+ gr.Markdown(LINKS_MD)
488
 
489
+ gr.Markdown("---")
490
+ gr.Markdown(
491
+ "*API-only demo — no proprietary code exposed. "
492
+ "Built with [Gradio](https://gradio.app).*"
493
+ )
494
 
495
  if __name__ == "__main__":
496
  demo.launch()