Skip to content

About

No description, website, or topics provided.

Resources

Code of conduct

Contributing

Stars

10 stars

Watchers

1 watching

Forks

Repository files navigation

Welcome to the idea.deploy project!

Thanks for passing by! If you are visiting this repository it is likely because of the four papers making use of it (see below).

Changes are being pushed frequently.

Please, keep on pulling the updates, either with your git manager software of choice or by means of the command

git pull

in order to be able to use the latest paper repository for the works "Higher-order Tuning of Interface Physics in Multiphase Lattice Boltzmann" and "A note on the lattice momentum balance in the lattice Boltzmann interaction-framework"

The repository will keep evolving (hopefully for the best!) as time passes. The main spirit is to make public what has been used to obtain the numerical results published both on the public archive arxiv.org and on peer-reviewed journals. The software and the other contents will be steadily updated, so that the main criteria is not to provide the "definitive" code version but the code version that actually made the published results possible. As the code-base grows and evolves backwards compatibility will be assured.

Statement of Need

Computational physicists who want to use GPUs face a choice between frameworks that hide the computation and frameworks that lock them to one vendor. JAX and PyTorch compile through opaque backends and do not target Metal compute; CuPy and Numba are CUDA-only; Taichi introduces its own language. For a researcher whose contribution is the kernel — a collision operator, a pressure tensor, a spin-network contraction — none of these keep the physics visible, and all of them tie a published result to the hardware that produced it.

idpy takes the opposite position. A kernel is written once in a small metalanguage and lowered to CUDA, OpenCL, Metal or plain C, with the generated source available for inspection at every step. There is no hidden JIT and no graph rewriting: what executes is what you can read. Device memory, kernel dispatch and synchronization are reached through one interface — the Tenet — so the same simulation runs on an NVIDIA cluster, an Apple laptop or a CPU-only machine without editing the physics.

Two consequences motivate the design:

  • Reproducibility as a workflow, not a promise. Each published paper has a repository of notebooks that runs against this framework, so a result can be re-derived rather than described. Cross-backend agreement is a first-class test rather than an aspiration.
  • Access. Unified-memory commodity hardware — Apple Silicon in particular — offers GPU compute at a price and power budget available to researchers without cluster allocations. That only helps if the software runs there, which is why Metal is a first-class backend rather than a port.

The framework is in research use: it produced the numerical results in the peer-reviewed papers listed below, across lattice Boltzmann multiphase flow, lattice pressure tensors, and spin-network evaluation.

Architecture

Three diagrams — the lowering from one kernel source to four backends, the three points at which code enters a build, and the residency layer where the backend differences stop mattering — are in docs/architecture.md.

Installation for use as a library

pip install idpy                 # CPU (CTypes) backend, works anywhere
pip install idpy[cuda]           # + PyCUDA
pip install idpy[opencl]         # + PyOpenCL

GPU bindings are optional by design: each is probed at import and its backend reports itself absent when missing, so a default install runs on any machine. Metal support additionally needs a Swift toolchain — see the Apple Silicon section below. For reproducing a published paper, prefer the full environment built by idpy-init.sh, described next.

For reproducing the papers results please look below in the Installation Section and in Typical usage for reproducing the results reported in a paper Subsection.

Available Peer-Reviewed Papers

Higher-order Tuning of Interface Physics in Multiphase Lattice Boltzmann

A note on the lattice momentum balance in the lattice Boltzmann interaction-framework

The exact evaluation of hexagonal spin-networks and topological quantum neural networks

Metastable and Unstable Dynamics in multi-phase lattice Boltzmann

Mesoscale Modelling of the Tolman Length in Multi-component Systems

Mesoscale Perspective on the Tolman Length

Structure and Isotropy of Lattice Pressure Tensors for Multi-range Potentials

Available Preprints

The exact evaluation of hexagonal spin-networks and topological quantum neural networks

Metastable and Unstable Dynamics in multi-phase lattice Boltzmann

The Jupyter notebook has only been tested in the 'devel' branch of 'idea.deploy'. Make sure you type in the terminal from the root directory of 'idea.deploy' the command git checkout devel before using it.

Installation

Automatic installation of idea.deploy

In order to install the idea.deploy environment one can copy and paste the line below

bash -c "$(curl -fsSL https://raw.githubusercontent.com/lullimat/idea.deploy/refs/heads/master/idpy-bootstrap.sh)"

Manual installation of idea.deploy python virtual environment: idpy-env

For the time being the project has been tested only on some Linux platforms (ubuntu) and on MacOS for both Intel and M1 machines.

At the moment the main code base for the project is written in python and it heavily relies, among other modules, on PyCUDA (https://documen.tician.de/pycuda/), PyOpenCL (https://documen.tician.de/pyopencl/) and numpy (https://numpy.org). In order to keep the user computer as clean as possible a python virtual environment is created through the script idpy-init.sh and the necessary dependencies downloaded and installed. PyCUDA and PyOpenCL are both compiled from source when possible. On macOS (Apple Silicon / Metal), idpy can also use the METAL_T backend via pymetallic: if swiftc is available, idpy-init.sh runs scripts/install-pymetallic.sh, which clones a pinned pymetallic revision, applies the idpy FFI patch under patches/pymetallic/, builds the Swift bridge, and editable-installs into idpy-env (optional; not a hard dependency). Re-running init after idpy-clean.sh --purge-sources restores Metal the same way. The python environment and the other optional system modifications (like new aliases in the .bashrc) can be cleaned by using the script idpy-clean.sh. Since erasing files must be taken with care, each "rm" command is executed only after the user reviews the files/directories that will be removed (please check the terms of the license). The purpose is to fully clean the changes performed by the use of idpy-init.sh

Apple Silicon / Metal backend

Metal is available as a first-class Idpy backend on Darwin (lang=METAL_T), using the same meta-language / IdpyCode path as CUDA and OpenCL. Device arrays use persistent shared Metal buffers with a NumPy view (.host); prefer writing into .host and rare sync over treating every H2D from a separate host array as free (that path is still a memcpy into shared storage).

Caveats: very small 1D problems may be slower on GPU than a tight CPU implementation; ultra-low-noise fp32 work can be precision-limited; Apple OpenCL remains usable, but Metal is the longer-term path on macOS. For an OpenCL vs Metal timing sketch on Mac, see tutorials/OCL_vs_Metal_Bench.ipynb.

Typical usage for reproducing the results reported in a paper

  1. Open a terminal session and go to the directory you want to clone the repository to

  2. Clone the repository

git clone https://github.com/lullimat/idea.deploy.git
  1. Enter the repository
cd idea.deploy
  1. Install the virtual environment
bash idpy-init.sh

If you opted for installing the aliases either execute

source ~/.bashrc

or open a new terminal session and type idpy-go to reach the idea.deploy directory

idpy-go
  1. Type idpy-load to load the python virtual environment
idpy-load
  1. Go to the papers directory and execute python idpy-papers.py to list the available papers and select the one you wish to clone from its own git repository
cd papers
python idpy-papers.py
  1. cd into the cloned directory and launch the Jupyter or Jupyter Lab server
cd [cloned-git-paper-repository]
idpy-jupyter

or

idpy-jupyter-lab
  1. Copy and paste the url from the terminal in your browser to access and execute the notebook

Cleaning the Virtual Environment (and .bashrc)

  1. Go to the idea.deploy repository directory. If you installed the aliases sourced from your .bashrc you can type
idpy-go
  1. Run the cleaning script
bash idpy-clean.sh

By default this removes the virtual environment and runs make clean in py-env/sources/pymetallic (Metal build artifacts only; source trees are kept). Optional flags:

bash idpy-clean.sh --preserve-sources   # remove the venv only; keep sources and Metal build artifacts
bash idpy-clean.sh --purge-sources      # remove the venv and delete py-env/sources entirely

Details

  • The alias "idpy-jupyter" launches a Jupyter notebook server (preferably) on the port 4379 with the "--no-browser" option
  • The alias "idpy-jupyter-forward remotehost" forwards to your computer the port 4379 (supposedly) used on the "remotehost" computer by the jupyter session opened within the idea.deploy python virtual environment

Purpose of the project

The purpose of the idea.deploy project can be described in three points

  • To provide a unified open-source environment for scientific code for physics simulations
  • To assure the reproducibility of published numerical results (one of the fundamental features of the scientific method)
  • Acknowledgement of contributions

Git model

This project will consist of this one repository with two branches, 'master' and 'devel'. All the papers and work in progress will be developed in separated git repositories so that important updates from the software side will be pushed into the master branch much faster while the original scientific work will be available only when ready. The folder ./collabs will serve as a docking point for ongoing research and will be kept empty while the folder ./papers will contain the most updated version of the preprints in ./papers/arxiv:* and the related symlink ./papers/doi:* -> ./papers/arxiv:* when the work is published on a peer-reviewed journal.

This scheme should allow for the parallel improvement of the code (all research private repositories in ./collabs would be served by the most updated version) while keeping a clean separation of the ongoing projects that will be publicly available once, at least, posted on the arxiv.

Meta-Language

idea.deploy is growing as a response to my personal (and probably common) need of wasting as little code as possible while keeping a code base that is as general as possible. One of the ideas is that code development and computational/physics output should happen side by side, in order to implement a faster feedback loop leading to a wider scientific output. This is achieved by trying to spend less and less time in the development of the core coding part (GPU programming, multi-threading, mpi, disk I/O etc.) while focusing more on the new and original parts of the code, i.e. mainly the kernels for simulations and data analysis. Given the heterogeneity of the available architectures and programming languages for parallel implementations (OpenCL, CUDA, and Metal on Apple Silicon via pymetallic) pushed me to use Python for a high level implementation heavily based on PyCUDA (https://documen.tician.de/pycuda/)(GPUs only), PyOpenCL (https://documen.tician.de/pyopencl/) (GPUs and CPUs), and Metal (via pymetallic), but with a twist: merging these approaches into one that automatically resolves the specific features of the language that is eventually used. Hence, all the code development can be carried out either making specific use of each language features, or by using the Idpy "meta-language" allowing to write kernels only once, which are then automatically compiled according to one of the three standards, or assigning and manipulating the device memory through a common interface that, once the language has been set at the beginning, does not make any distinction between the backends. This elements can all be examined at work in the Lattice Boltzmann Method (LBM) module in idpy/LBM for having an idea of what it means to develop in the idea.deploy framework.

A very important consequence of this approach is that simulations belonging to physics areas with a weak mutual interaction (say Lattice Boltzmann and Ising models) will coexist in the same framework allowing for the opening of new shared directions.

This is a growing computational project based on my work as a theoretical/computational physicist, hence, with much room for improvement from the computational point of view. I will look for ways to publish this project on its own right in order to make citation easier. However, as described in the next section, the hope is to provide a framework fostering collaborations between different people.

Underlying Philosophy: a hopeful deal

idea.deploy allows whoever is interested to pick up the work that is published through this platform exactly from the (edge) state at which it has been published, either on the arxiv, or after peer review in a journal. The main idea is that of serving the scientific community with reliable results which can be improved minimizing the cost of reproducing the results already obtained. Doing this implies much supplementary work on the side of those who publish their work through this platform (so far only myself) which is meant to be only for the sake of sparing people's time and give a possible way to implement reproducibility (a pillar of the scientific method) in computational physics. This is done as a "generous" act.

Clearly, I am willing to collaborate with those researchers who would like to port their code/work in this framework and use the idea.deploy project as a gateway for their own research. At the same time, researchers might be perfectly able to adapt the code themselves in which case the only thing to do would be to interact for merging the code in the master branch and make it available. Moreover, the code could just be used, as it is, for other research outlets in which case citing the proper reference paper is highly recommended and appreciated.

Matteo Lulli, July 16th 2026 www.ideadeploylabs.com www.lullimat.org matteo.lulli@ideadeploylabs.com

About

No description, website, or topics provided.

Resources

Code of conduct

Contributing

Stars

10 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages