Skip to main content

A torch implementation of GFlowNets

Project description

Python Documentation Status

Documentation ~ Code ~ Paper

torchgfn

A Python Package for GFlowNets. Please cite this paper if you are using the library for your research!

Installing the package

The codebase requires python >= 3.10. To install the latest stable version with the core dependencies:

pip install torchgfn

torchgfn supports installation with multiple sets of dependencies, under the following tags:

  • dev: dependencies required for development of the core library.
  • scripts: dependencies needed to run examples in tutorials/examples/.
  • all: everything.

and can be called by running

pip install torchgfn[scripts]

Or to install the latest release (from the master branch) with all dependencies in a Conda environment:

git clone https://github.com/GFNOrg/torchgfn.git
conda create -n gfn python=3.10
conda activate gfn
cd torchgfn
pip install -e ".[all]"

About this repo

This repo serves the purpose of fast prototyping GFlowNet (GFN) related algorithms. It decouples the environment definition, the sampling process, and the parametrization of the function approximators used to calculate the GFN loss. It aims to accompany researchers and engineers in learning about GFlowNets, and in developing new algorithms.

The library is shipped with many environments under the gym, including discrete environments (e.g., Discrete Energy Based Model, Hyper Grid, Graph Generation), and continuous environments (e.g., Box). The library is designed to allow users to define their own environments relatively easily. See here for more details.

Getting Started with Example Scripts & Notebooks

Contributing

Please see the Contributing Guidelines.

Components of the Library

  • States, Actions, & Containers: The two core elements of torchgfn are the concepts of states, which are emitted by stateless environments, and actions, which transform states through the environment logic. These are encapsulated with metadata in containers.
  • Modules, Estimators, & Samplers: The components of a GFlowNet policy (those which select actions given a state), are encapsulated in Estimators. If the policy is a neural network, that logic is captured in a Module. This estimator can then be used with a Sampler to produce states (in the form of trajectories or transitions).
  • Losses: Each type of GFlowNet has a specific parameterization related to a specific loss.
  • Defining Environments: For most applications of torchgfn, the main challenge will be to define a stateless environment which will produce a valid sampler.
  • Advanced Usage: Extending torchgfn with Custom GFlowNets: While torchgfn aims to support major usages of GFlowNets, we hope this will also serve as a platform for the community to extend the possible use cases of the technology. This guide details how one can extend the library for new research and applications.
  • Full API Reference: A breakdown of all major components of both the core GFN library, the associated gym, and the included tutorials.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

torchgfn-2.3.1.tar.gz (158.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

torchgfn-2.3.1-py3-none-any.whl (187.3 kB view details)

Uploaded Python 3

File details

Details for the file torchgfn-2.3.1.tar.gz.

File metadata

  • Download URL: torchgfn-2.3.1.tar.gz
  • Upload date:
  • Size: 158.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for torchgfn-2.3.1.tar.gz
Algorithm Hash digest
SHA256 8d7bc7b43e188467e29a037c57dc57f7c51a101ea6f1470cf6f8704d0f599e80
MD5 28f9ba597f582053cae438d4083e657b
BLAKE2b-256 5ebdbf64ac0fc4b7dbfe37a03df90a9171ee758b8d4d31e5a7d3613ae9ed5ca8

See more details on using hashes here.

File details

Details for the file torchgfn-2.3.1-py3-none-any.whl.

File metadata

  • Download URL: torchgfn-2.3.1-py3-none-any.whl
  • Upload date:
  • Size: 187.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for torchgfn-2.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fc9764672b0b656b73c814937151ff86df120e56979b2f307165f4a72ab760ae
MD5 9059e5f2995ec43e59ea65efd4e02ac0
BLAKE2b-256 52b378a2571d34d2f6bf5fd486319b5d5db2da53522549149ab5a00c90fb332f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page