SDK + CLI (mrg) for local synth/PnR feedback, sandboxed agents, and running FPGA designs on real silicon.
Project description
Manhattan Reasoning Gym
Python SDK and CLI (mrg) for hardware design: iterate locally with fast
synthesis / place-and-route feedback, run untrusted agents in a sandbox, and
program real cloud FPGAs — all from one package.
| Surface | What it does | Needs |
|---|---|---|
mrg.build |
local synth / place-and-route reports (no board) | Docker |
mrg.Sandbox |
run an agent in a locked container that promotes to silicon | Docker |
mrg.cloud |
program + drive a real ECP5 over the cloud | API key |
Cloud FPGA access requires an allowlisted API key (
mrg login). Local synth/PnR and sandboxing need only Docker — no toolchain to install.
Install
pip install manhattan-reasoning-gym
For local synth/PnR and sandboxing, pull the pinned toolchain image once (the SDK runs it for you — you never install yosys/nextpnr/LiteX):
docker pull ghcr.io/manhattanreasoning/mrg-sandbox:latest
Local feedback — mrg.build
import manhattan_reasoning_gym as mrg
rep = mrg.build.synth("examples/design.py") # fast: resource utilization
rep = mrg.build.pnr("examples/design.py") # full SoC: real Fmax + timing
print(rep.fmax_mhz, rep.timing_met, rep.util.dsp.used)
CLI: mrg synth design.py · mrg pnr design.py [--target-mhz N].
synth is the cheap "is it getting bigger?" signal (core-only util); pnr
places & routes the full SoC for the truthful system-clock Fmax and timing.
Sandboxed agents — mrg.Sandbox
Run untrusted agent code in a locked container (--network none, no key) that
iterates locally and promotes vetted candidates to silicon:
import manhattan_reasoning_gym as mrg
result = mrg.Sandbox(files=["examples/design.py", "examples/agent.py"]).run("agent.py")
for promo in result.promotions:
print(promo)
The container never holds a key or touches the network; the promote is a file
handoff the trusted host brokers to silicon. No promote gating by default —
the agent gates itself; pass guard= for an opt-in host-side check. With no API
key, silicon resolves to a no-op backend; set one (and silicon="cloud") for
real hardware.
Real silicon — mrg.cloud
import manhattan_reasoning_gym as mrg
app = mrg.cloud.App("my_design", design="examples/design.py")
with app: # programs the FPGA on first use, releases on exit
app.write(0x0, 3)
print("read:", app.read(0x8))
Or drive it from the CLI: mrg run my_design.py.
Authentication (cloud only)
API requests authenticate with an opaque API key sent as X-API-Key. You obtain
one by exchanging a GitHub identity — the orchestrator verifies you against its
allowlist and mints a key.
mrg login # GitHub device flow (or paste a no-scope PAT), then you're set
The key is saved to ~/.config/mrg/credentials.json (mode 0600, keyed by
orchestrator URL). Every command resolves the key in this order:
--api-keyflag$MRG_API_KEY- the stored login (
mrg login)
mrg logout revokes the key on the server and clears it locally.
Tutorials
Two runnable notebooks in examples/notebooks/:
01_build_and_run— local synth/pnr feedback → program a real FPGA.02_sandboxing— run an agent in a locked sandbox that promotes to silicon.
The shared examples/design.py is a tiny tunable multiply-accumulate; tweak its
WIDTH and watch DSP/Fmax move. examples/agent.py is the sandboxed agent.
CLI reference
mrg login | logout
mrg synth <design.py> [--target-mhz N] # local synthesis report
mrg pnr <design.py> [--target-mhz N] # local full-SoC place & route
mrg run <file.py> [--fpga-id N] [--no-program]
mrg status [fpga_id]
mrg job | logs | cancel <fpga_id> <job_id>
mrg reset <fpga_id>
mrg read <fpga_id> <addr> [--count N]
mrg write <fpga_id> <addr> <value>
Development
pip install -e ".[dev]"
ruff check . && pytest -q
License
MIT — see LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file manhattan_reasoning_gym-0.1.1.tar.gz.
File metadata
- Download URL: manhattan_reasoning_gym-0.1.1.tar.gz
- Upload date:
- Size: 37.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1c5bdc603dff0186a598b4591c87cffc1e7fef8de8bd4b00ff26cb4f2c05505d
|
|
| MD5 |
13dc03387cb38872951c8016a78946a0
|
|
| BLAKE2b-256 |
b171b66d1d621494fb411cee253fc6c4cea06072005d1499b9f133be9f38adb8
|
Provenance
The following attestation bundles were made for manhattan_reasoning_gym-0.1.1.tar.gz:
Publisher:
publish.yml on ManhattanReasoning/manhattan-reasoning-gym
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
manhattan_reasoning_gym-0.1.1.tar.gz -
Subject digest:
1c5bdc603dff0186a598b4591c87cffc1e7fef8de8bd4b00ff26cb4f2c05505d - Sigstore transparency entry: 2042698273
- Sigstore integration time:
-
Permalink:
ManhattanReasoning/manhattan-reasoning-gym@4379e628c7a904eecd56d5ee86f2ad2fcf6f01ac -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/ManhattanReasoning
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@4379e628c7a904eecd56d5ee86f2ad2fcf6f01ac -
Trigger Event:
push
-
Statement type:
File details
Details for the file manhattan_reasoning_gym-0.1.1-py3-none-any.whl.
File metadata
- Download URL: manhattan_reasoning_gym-0.1.1-py3-none-any.whl
- Upload date:
- Size: 35.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
838a1b02be5d03010218471cfdfb0f4248282c35339cb2d74c87a69ec62a6434
|
|
| MD5 |
f3af0551b29ac9abd84b70c3968614b8
|
|
| BLAKE2b-256 |
5896627dffb6efc6c666c5fdb4149e8ccd7003f99e2c56d47ddd5b9043c6fd07
|
Provenance
The following attestation bundles were made for manhattan_reasoning_gym-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on ManhattanReasoning/manhattan-reasoning-gym
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
manhattan_reasoning_gym-0.1.1-py3-none-any.whl -
Subject digest:
838a1b02be5d03010218471cfdfb0f4248282c35339cb2d74c87a69ec62a6434 - Sigstore transparency entry: 2042699072
- Sigstore integration time:
-
Permalink:
ManhattanReasoning/manhattan-reasoning-gym@4379e628c7a904eecd56d5ee86f2ad2fcf6f01ac -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/ManhattanReasoning
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@4379e628c7a904eecd56d5ee86f2ad2fcf6f01ac -
Trigger Event:
push
-
Statement type: