Skip to content

Installation

griffith-logic manages its dependencies with uv. Don’t invoke .venv directly and don’t use pip install / uv pip install — always go through uv run and uv sync.

ItemRequirement
Python3.11 or newer
uvLatest release recommended
OSmacOS (Apple Silicon) / Linux / Windows

If you don’t have uv yet, install it one of these ways.

ターミナルウィンドウ
curl -LsSf https://astral.sh/uv/install.sh | sh
  1. Clone the repository.

    ターミナルウィンドウ
    git clone https://github.com/tsukushi-gate/Griffith.git
    cd Griffith
  2. Sync with the extras that match your machine.

    ターミナルウィンドウ
    uv sync --extra dev --extra cpu
  3. Verify the install (see “Verifying the install” below).

The extras are declared in [project.optional-dependencies] of pyproject.toml. The first four are the ones you’ll reach for most.

extraWhat it pulls inWhen to use it
cputorch, torchvision, timm (CPU / MPS builds)Everyday development and CI. Always this on Mac
cu128torch, torchvision, timm (CUDA 12.8 builds)GPU machines, training on Modal / RunPod
devpytest, hypothesis, pytest-cov, httpx, mypyTests and type checking (required for development)
editorfastapi, uvicorn, python-multipartBackend of the visual editor
visualizerwebsocketsPer-gate WebGL viewer (tools/visualizer/)
cloudmodal, runpod, wandb-workspacesCloud GPU runs and report generation
figuresmatplotlib, pillowPlotting experiment results
teachers / textonnxruntime, huggingface-hub / transformers, datasetsConverting and distilling pretrained models
satpython-satSAT-based capacity checks (representability proofs)
wmt / sentimentdatasets, sacrebleu / fugashi and friendsTranslation and Japanese sentiment datasets

Extras can be combined freely (except cpu together with cu128).

ターミナルウィンドウ
uv sync --extra dev --extra cpu --extra editor # dev environment including the editor

sys_platform markers under [tool.uv.sources] make the same --extra cpu / --extra cu128 resolve from different indexes depending on the platform. You never have to think about it.

EnvironmentExtra to pickResolved from
MaccpuPyPI (Apple Silicon build with MPS support)
Linux (CPU)cpudedicated pytorch-cpu index (small, used in CI)
Linux (CUDA)cu128dedicated pytorch-cu128 index (CUDA 12.8 build)

You can also consume the package as a plain library without uv, but then you must install torch yourself. As explained above, torch and torchvision resolve from different places per platform, so they are not part of the package’s core dependencies.

ターミナルウィンドウ
# 1. Install torch for your platform first (https://pytorch.org/get-started/locally/)
pip install torch torchvision
# 2. Clone the repository and install it in editable mode
pip install -e .

Copy .env.example to .env and fill in what you need. At the moment only wandb-related variables are used.

ターミナルウィンドウ
cp .env.example .env
ターミナルウィンドウ
uv run python -c "import griffith_logic as gl, torch; print(gl.__name__, torch.__version__)"
uv run python examples/01_xor.py # trains XOR → accuracy 1.00 under hard eval
make test # fast test suite (under 2 minutes, always green)

If examples/01_xor.py prints XOR: soft acc=1.00, hard acc=1.00, you’re done. The XOR appendix tutorial walks through what just happened, one cell at a time. To see it on real data, go to 1. Train on MNIST.

You only need an external simulator if you want to check Verilog / VHDL equivalence. HDL generation itself works without them — the comparison step is simply skipped.

ターミナルウィンドウ
brew install icarus-verilog # Verilog comparison (iverilog)

We do not recommend installing the VHDL side (ghdl) locally on macOS. The Homebrew Cask build of ghdl has been measured to be broken and fails to build, so the supported way to run VHDL equivalence checks is inside CI or a cloud (Modal) container. On machines without ghdl the tests marked hdl_vhdl are simply skipped automatically; nothing else is affected. See HDL export for details.

The tutorials and the scripts under examples/ download the datasets they need at run time (by default into directories such as data-mnist/ at the repository root, overridable with each loader’s root= argument). This repository neither bundles nor redistributes the data itself.

DatasetWhere it is usedDistributed by
MNIST / Fashion-MNISTNearly every tutorial except XORvia torchvision
CIFAR-10 / CIFAR-100CNN, ResNet, and Mixer familiesvia torchvision
Tiny ShakespeareLogic GPT and the RNN family (character LM)the original author’s public text
SST-2TextCNN and sentiment distillationHugging Face Datasets
WRIMEJapanese sentiment analysisHugging Face Datasets
Oxford-IIIT Pet / WIDER FACE, etc.Segmentation and object detectiontheir respective distributors

Use of each dataset is governed by the license and terms of its distributor. Some are restricted to research use, and some forbid redistribution. Downloading them means accepting those terms, so check the dataset’s own primary source before any commercial use. The library’s own license (griffith-logic) does not extend to the datasets.