Spaces:
Running
Running
Commit
·
886f2cc
0
Parent(s):
Daugherty Engine SAT Solver - API Demo
Browse files- README.md +50 -0
- app.py +287 -0
- requirements.txt +2 -0
README.md
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: Daugherty Engine SAT Solver
|
| 3 |
+
emoji: 🧮
|
| 4 |
+
colorFrom: green
|
| 5 |
+
colorTo: blue
|
| 6 |
+
sdk: gradio
|
| 7 |
+
sdk_version: 4.44.0
|
| 8 |
+
app_file: app.py
|
| 9 |
+
pinned: false
|
| 10 |
+
license: apache-2.0
|
| 11 |
+
short_description: GPU-accelerated constraint satisfaction solver demo
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
+
# Daugherty Engine - SAT Solver Demo
|
| 15 |
+
|
| 16 |
+
Test our GPU-accelerated constraint satisfaction solver through a simple API interface.
|
| 17 |
+
|
| 18 |
+
## What This Does
|
| 19 |
+
|
| 20 |
+
1. **Generates** random 3-SAT problems at the phase transition ratio (α=4.27)
|
| 21 |
+
2. **Solves** using our proprietary GPU-accelerated algorithm
|
| 22 |
+
3. **Verifies** results and reports satisfaction percentage
|
| 23 |
+
4. **Anchors** proofs to BSV blockchain (optional)
|
| 24 |
+
|
| 25 |
+
## Key Metrics
|
| 26 |
+
|
| 27 |
+
- **Hardware:** NVIDIA RTX 6000 Ada (48GB VRAM)
|
| 28 |
+
- **Cost:** $1.57/hour (vs $13.20/hour for D-Wave)
|
| 29 |
+
- **Power:** 195W typical (vs 25kW for quantum systems)
|
| 30 |
+
|
| 31 |
+
## How It Works
|
| 32 |
+
|
| 33 |
+
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.
|
| 34 |
+
|
| 35 |
+
## Problem Difficulty
|
| 36 |
+
|
| 37 |
+
The phase transition ratio of 4.27 clauses per variable represents the hardest region for 3-SAT problems. At this ratio:
|
| 38 |
+
- Below 4.27: Problems are almost always satisfiable (easy)
|
| 39 |
+
- Above 4.27: Problems are almost always unsatisfiable (easy to prove)
|
| 40 |
+
- At 4.27: Maximum uncertainty, hardest to solve
|
| 41 |
+
|
| 42 |
+
## Links
|
| 43 |
+
|
| 44 |
+
- [Full Demo Site](https://1millionspins.originneural.ai)
|
| 45 |
+
- [Origin Neural](https://originneural.ai)
|
| 46 |
+
- [SmartLedger Solutions](https://smartledger.solutions)
|
| 47 |
+
|
| 48 |
+
## Contact
|
| 49 |
+
|
| 50 |
+
Questions? Email: Shawn@smartledger.solutions
|
app.py
ADDED
|
@@ -0,0 +1,287 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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.
|
| 7 |
+
"""
|
| 8 |
+
|
| 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 |
+
|
| 31 |
+
def check_api_health():
|
| 32 |
+
"""Check if the API is online."""
|
| 33 |
+
try:
|
| 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, progress=gr.Progress()):
|
| 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 |
+
progress(0.1, desc="Generating SAT problem...")
|
| 59 |
+
|
| 60 |
+
# Calculate problem parameters
|
| 61 |
+
alpha = 4.27 # Phase transition ratio
|
| 62 |
+
num_clauses = int(num_variables * alpha)
|
| 63 |
+
|
| 64 |
+
start_time = time.time()
|
| 65 |
+
|
| 66 |
+
try:
|
| 67 |
+
progress(0.3, desc="Sending to Daugherty Engine API...")
|
| 68 |
+
|
| 69 |
+
response = requests.post(
|
| 70 |
+
f"{API_BASE}/verify",
|
| 71 |
+
json={
|
| 72 |
+
"size": num_variables,
|
| 73 |
+
"trials": num_trials
|
| 74 |
+
},
|
| 75 |
+
timeout=120
|
| 76 |
+
)
|
| 77 |
+
|
| 78 |
+
elapsed_time = time.time() - start_time
|
| 79 |
+
|
| 80 |
+
if response.status_code != 200:
|
| 81 |
+
return format_error(f"API Error: {response.status_code}")
|
| 82 |
+
|
| 83 |
+
data = response.json()
|
| 84 |
+
|
| 85 |
+
if data.get("status") != "success":
|
| 86 |
+
return format_error(data.get("error", "Unknown error"))
|
| 87 |
+
|
| 88 |
+
progress(0.8, desc="Processing results...")
|
| 89 |
+
|
| 90 |
+
results = data.get("data", {}).get("results", {})
|
| 91 |
+
|
| 92 |
+
# Calculate metrics
|
| 93 |
+
mean_satisfaction = results.get("mean_satisfaction", 0)
|
| 94 |
+
std_satisfaction = results.get("std_satisfaction", 0)
|
| 95 |
+
quality_tier = results.get("quality_tier", "UNKNOWN")
|
| 96 |
+
|
| 97 |
+
# Energy calculation
|
| 98 |
+
energy_joules = HARDWARE_INFO["typical_power"] * elapsed_time
|
| 99 |
+
cost_usd = (HARDWARE_INFO["cost_per_hour"] / 3600) * elapsed_time
|
| 100 |
+
|
| 101 |
+
# Competitor comparisons
|
| 102 |
+
dwave_energy = COMPETITORS["D-Wave Advantage"]["power"] * elapsed_time
|
| 103 |
+
power_ratio = round(dwave_energy / energy_joules) if energy_joules > 0 else 0
|
| 104 |
+
cost_ratio = round(COMPETITORS["D-Wave Advantage"]["cost_per_hour"] / HARDWARE_INFO["cost_per_hour"])
|
| 105 |
+
|
| 106 |
+
progress(1.0, desc="Complete!")
|
| 107 |
+
|
| 108 |
+
return format_results(
|
| 109 |
+
num_variables=num_variables,
|
| 110 |
+
num_clauses=num_clauses,
|
| 111 |
+
num_trials=num_trials,
|
| 112 |
+
mean_satisfaction=mean_satisfaction,
|
| 113 |
+
std_satisfaction=std_satisfaction,
|
| 114 |
+
quality_tier=quality_tier,
|
| 115 |
+
elapsed_time=elapsed_time,
|
| 116 |
+
energy_joules=energy_joules,
|
| 117 |
+
cost_usd=cost_usd,
|
| 118 |
+
power_ratio=power_ratio,
|
| 119 |
+
cost_ratio=cost_ratio,
|
| 120 |
+
blockchain=data.get("data", {}).get("blockchain", {})
|
| 121 |
+
)
|
| 122 |
+
|
| 123 |
+
except requests.exceptions.Timeout:
|
| 124 |
+
return format_error("Request timed out. Try a smaller problem size.")
|
| 125 |
+
except requests.exceptions.ConnectionError:
|
| 126 |
+
return format_error("Could not connect to API. Check your internet connection.")
|
| 127 |
+
except Exception as e:
|
| 128 |
+
return format_error(f"Unexpected error: {str(e)}")
|
| 129 |
+
|
| 130 |
+
|
| 131 |
+
def format_results(**kwargs):
|
| 132 |
+
"""Format results as markdown."""
|
| 133 |
+
blockchain = kwargs.get("blockchain", {})
|
| 134 |
+
txid = blockchain.get("txid", "")
|
| 135 |
+
|
| 136 |
+
bsv_link = ""
|
| 137 |
+
if txid:
|
| 138 |
+
bsv_link = f"\n\n**Blockchain Proof:** [{txid[:16]}...](https://whatsonchain.com/tx/{txid})"
|
| 139 |
+
|
| 140 |
+
return f"""
|
| 141 |
+
## Verification Results
|
| 142 |
+
|
| 143 |
+
### Problem Configuration
|
| 144 |
+
- **Variables:** {kwargs['num_variables']}
|
| 145 |
+
- **Clauses:** {kwargs['num_clauses']} (ratio: 4.27)
|
| 146 |
+
- **Trials:** {kwargs['num_trials']}
|
| 147 |
+
|
| 148 |
+
### Performance
|
| 149 |
+
| Metric | Value |
|
| 150 |
+
|--------|-------|
|
| 151 |
+
| Satisfaction | **{kwargs['mean_satisfaction']:.1f}%** (std: {kwargs['std_satisfaction']:.2f}) |
|
| 152 |
+
| Quality Tier | **{kwargs['quality_tier']}** |
|
| 153 |
+
| Solve Time | {kwargs['elapsed_time']:.3f}s |
|
| 154 |
+
| Energy | {kwargs['energy_joules']:.1f}J |
|
| 155 |
+
| Cost | ${kwargs['cost_usd']:.6f} |
|
| 156 |
+
|
| 157 |
+
### Efficiency vs Quantum Computers
|
| 158 |
+
| Comparison | Ratio |
|
| 159 |
+
|------------|-------|
|
| 160 |
+
| Power Efficiency vs D-Wave | **{kwargs['power_ratio']}x** less power |
|
| 161 |
+
| Cost Efficiency vs D-Wave | **{kwargs['cost_ratio']}x** cheaper |
|
| 162 |
+
{bsv_link}
|
| 163 |
+
|
| 164 |
+
---
|
| 165 |
+
*Computed on {HARDWARE_INFO['accelerator']}*
|
| 166 |
+
"""
|
| 167 |
+
|
| 168 |
+
|
| 169 |
+
def format_error(message: str):
|
| 170 |
+
"""Format error message."""
|
| 171 |
+
return f"""
|
| 172 |
+
## Error
|
| 173 |
+
|
| 174 |
+
{message}
|
| 175 |
+
|
| 176 |
+
Please try again or reduce the problem size.
|
| 177 |
+
"""
|
| 178 |
+
|
| 179 |
+
|
| 180 |
+
def get_problem_info(num_variables: int):
|
| 181 |
+
"""Get information about the problem that will be generated."""
|
| 182 |
+
num_variables = max(20, min(500, int(num_variables)))
|
| 183 |
+
num_clauses = int(num_variables * 4.27)
|
| 184 |
+
search_space = 2 ** num_variables
|
| 185 |
+
|
| 186 |
+
return f"""
|
| 187 |
+
**Problem Preview:**
|
| 188 |
+
- Variables: {num_variables}
|
| 189 |
+
- Clauses: {num_clauses}
|
| 190 |
+
- Search Space: 2^{num_variables} = {search_space:.2e} possibilities
|
| 191 |
+
- Difficulty: {"Easy" if num_variables < 100 else "Medium" if num_variables < 300 else "Hard"}
|
| 192 |
+
"""
|
| 193 |
+
|
| 194 |
+
|
| 195 |
+
# Build Gradio Interface
|
| 196 |
+
with gr.Blocks(
|
| 197 |
+
title="Daugherty Engine - SAT Solver Demo",
|
| 198 |
+
theme=gr.themes.Base(
|
| 199 |
+
primary_hue="green",
|
| 200 |
+
secondary_hue="gray",
|
| 201 |
+
neutral_hue="gray",
|
| 202 |
+
),
|
| 203 |
+
css="""
|
| 204 |
+
.gradio-container { max-width: 900px !important; }
|
| 205 |
+
.result-box { font-family: monospace; }
|
| 206 |
+
"""
|
| 207 |
+
) as demo:
|
| 208 |
+
|
| 209 |
+
gr.Markdown("""
|
| 210 |
+
# Daugherty Engine - Constraint Satisfaction Solver
|
| 211 |
+
|
| 212 |
+
Test our GPU-accelerated SAT solver through the public API.
|
| 213 |
+
No code is exposed - this interface simply calls the verification endpoint.
|
| 214 |
+
|
| 215 |
+
**What it does:** Generates random 3-SAT problems at the phase transition (hardest region)
|
| 216 |
+
and attempts to find satisfying assignments using our proprietary solver.
|
| 217 |
+
""")
|
| 218 |
+
|
| 219 |
+
with gr.Row():
|
| 220 |
+
with gr.Column(scale=1):
|
| 221 |
+
api_status = gr.Textbox(
|
| 222 |
+
label="API Status",
|
| 223 |
+
value=check_api_health(),
|
| 224 |
+
interactive=False
|
| 225 |
+
)
|
| 226 |
+
|
| 227 |
+
refresh_btn = gr.Button("Refresh Status", size="sm")
|
| 228 |
+
refresh_btn.click(fn=check_api_health, outputs=api_status)
|
| 229 |
+
|
| 230 |
+
gr.Markdown("---")
|
| 231 |
+
|
| 232 |
+
with gr.Row():
|
| 233 |
+
with gr.Column(scale=1):
|
| 234 |
+
num_vars = gr.Slider(
|
| 235 |
+
minimum=20,
|
| 236 |
+
maximum=500,
|
| 237 |
+
value=100,
|
| 238 |
+
step=10,
|
| 239 |
+
label="Number of Variables",
|
| 240 |
+
info="More variables = harder problem"
|
| 241 |
+
)
|
| 242 |
+
|
| 243 |
+
num_trials = gr.Slider(
|
| 244 |
+
minimum=1,
|
| 245 |
+
maximum=20,
|
| 246 |
+
value=5,
|
| 247 |
+
step=1,
|
| 248 |
+
label="Verification Trials",
|
| 249 |
+
info="More trials = higher confidence"
|
| 250 |
+
)
|
| 251 |
+
|
| 252 |
+
problem_info = gr.Markdown(get_problem_info(100))
|
| 253 |
+
num_vars.change(fn=get_problem_info, inputs=num_vars, outputs=problem_info)
|
| 254 |
+
|
| 255 |
+
run_btn = gr.Button("Run Verification", variant="primary", size="lg")
|
| 256 |
+
|
| 257 |
+
with gr.Column(scale=2):
|
| 258 |
+
results = gr.Markdown(
|
| 259 |
+
value="*Click 'Run Verification' to test the solver*",
|
| 260 |
+
elem_classes=["result-box"]
|
| 261 |
+
)
|
| 262 |
+
|
| 263 |
+
run_btn.click(
|
| 264 |
+
fn=run_verification,
|
| 265 |
+
inputs=[num_vars, num_trials],
|
| 266 |
+
outputs=results
|
| 267 |
+
)
|
| 268 |
+
|
| 269 |
+
gr.Markdown("""
|
| 270 |
+
---
|
| 271 |
+
|
| 272 |
+
### About
|
| 273 |
+
|
| 274 |
+
The Daugherty Engine is a novel approach to constraint satisfaction that achieves
|
| 275 |
+
quantum-competitive results on classical GPU hardware. This demo provides API access
|
| 276 |
+
only - no proprietary algorithms or source code are exposed.
|
| 277 |
+
|
| 278 |
+
**Links:**
|
| 279 |
+
- [Full Demo Site](https://1millionspins.originneural.ai)
|
| 280 |
+
- [Origin Neural](https://originneural.ai)
|
| 281 |
+
|
| 282 |
+
**Hardware:** NVIDIA RTX 6000 Ada (48GB VRAM) @ $1.57/hour
|
| 283 |
+
""")
|
| 284 |
+
|
| 285 |
+
|
| 286 |
+
if __name__ == "__main__":
|
| 287 |
+
demo.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio>=4.0.0
|
| 2 |
+
requests>=2.28.0
|