This repository contains the Cosmo neural network lift and convolution layers. For a usage example and reproduction of the results of the RECOMB 2026 submission "Gaining mechanistic insight from geometric deep learning on molecule structures through equivariant convolution", see https://github.com/BorgwardtLab/RECOMB2026Cosmo.
Installation: pip install cosmic-torch or pip install git+https://github.com/BorgwardtLab/Cosmo. Make sure to before install torch and torch-scatter according to their instructions.
Cosmo
Cosmo is a neural network architecture based on message passing on geometric graphs of molecule structures. It applies a convolutional filter by translating it to vertices and rotating it towards neighbors. The resulting feature activation (message) is passed to the neighbor that the filter was pointed at. This way, large geometric patterns can be modeled with a template-matching objective by using multiple Cosmo layers. A Cosmo network is equivariant to translation and rotation, and highly interpretable as its weight matrices can be linearly combined and its filter poses can be reconstructed geometrically. For more details, please see the paper.
Example Usage
Cosmo layers operate on lifted geometric graphs. These are computed from an adjacency matrix of the data, either given by e.g. atomic bond connectivity, or constructed by e.g. k-NN:
adj = torch_geometric.nn.knn_graph(coords, k, batch_index)
where coords are the input point coordinates of the data, k is a hyperparameter, and batch_index assigns each node to an instance in the batch (compare the computing principles of PyG, which we highly recommend to use).
Given coordinates, node features (e.g. one-hot encoded atom type), and the adjacency we can lift the input graph:
L = Lift2D()(features, coords, adj, batch_index) # or Lift3D()
The L namespace contains everything that we need to compute in subsequent Cosmo layers:
features = layer(L.source, L.target, L.features, L.hood_coords)
After the Cosmo layers we need to undo the lift operation (lowering) to obtain features on the input graph. This is done by aggregating the edge/triangle features to the nodes, which yields a standard graph object that can be further computed on with PyG layers, for example.
node_features = Lower(agg="max")(features, L.lifted2node, num_nodes)
Or, if features should be aggregated directly to the instance (graph) level:
graph_features = Lower(agg="max")(features, L.lifted2inst, num_instances)
An entire Cosmo network for a node classification task could look like this:
from cosmic import *
import torch.nn as nn
class CosmoModel(nn.Module):
def __init__(self):
self.lift = Lift3D()
self.lower = Lower()
self.cosmo_layers = nn.ModuleList([
NeuralFieldCosmo(in_channels=5, out_channels=128, dim=3),
NeuralFieldCosmo(in_channels=128, out_channels=128, dim=3),
NeuralFieldCosmo(in_channels=128, out_channels=10, dim=3)
])
def forward(self, node_features, coords, adj, batch_index, num_nodes):
L = self.lift(node_features, coords, adj, batch_index)
features = L.features
for layer in self.cosmo_layers:
features = layer(L.source, L.target, features, L.hood_coords)
node_features = self.lower(features, L.lifted2node, num_nodes)
# there could be some classic GNN-layers here, or an MLP head
return node_features
Citation
TBD
License
TBD
Metadata
Release files for cosmic-torch 0.1.11
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cosmic_torch-0.1.11.tar.gz | 529.4 kB | Without provenance | Details for cosmic_torch-0.1.11.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cosmic_torch-0.1.11-py3-none-any.whl | Python 3 | none | any | Details for cosmic_torch-0.1.11-py3-none-any.whl |
Total release size: 537.5 kB
Release files / cosmic_torch-0.1.11.tar.gz
| Download URL | cosmic_torch-0.1.11.tar.gz |
|---|---|
| Size | 529.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
471b861a8ee14ca1c07cd28bbd5238ce21a62eb544b42dc926c851c087126e15
|
|
BLAKE2b-256 checksum How to use checksums |
bad331299aac6e6c9876f483adeae16a567c5144125c32dfb324e1c82d0cf8ec
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / cosmic_torch-0.1.11-py3-none-any.whl
| Download URL | cosmic_torch-0.1.11-py3-none-any.whl |
|---|---|
| Size | 8.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
96ffba6692bc2d456882472f606d4a89418e441a2a24931ceae1dbd5349879f7
|
|
BLAKE2b-256 checksum How to use checksums |
bdf52eb4e6e8ffb17308d63e0dd716129bb4f516ed93169987c62089a5c755a0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Security for cosmic-torch 0.1.11
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.