Skip to main content

distgfs

Distributed computing framework for the Global Function Search (GFS) hyperparameter optimizer from the Dlib library. Based on gfsopt.

Provides the following features:

  • Parallel optimization: Run distributed hyperparameter searches via mpi4py.
  • Save and restore progress: Save/restore settings, parameters and optimization progress to/from HDF5 file. Parameters are stored in float64 by default; set parameter_dtype: "float32" for smaller files. A resumed checkpoint keeps the precision it was created with.
  • Average over multiple runs: Run a stochastic objective function using the same parameters multiple times and report the average to Dlib's Global Function Search. Useful in highly stochastic domains to avoid biasing the search towards lucky runs.
  • Multi-problem mode: Optimise a set of related problems simultaneously using independent GFS instances, one per problem id. Set problem_ids in gfsopt_params to activate. By default all K problems are bundled into a single worker task per iteration. Set per_problem_tasks: True to dispatch one task per problem instead, enabling up to max(workers, K) concurrent simulations and genuine throughput scaling with the number of MPI ranks.

For theoretical background of GFS, see 'A Global Optimization Algorithm Worth Using' and Malherbe & Vayatis 2017: Global optimization of Lipschitz functions

Example usage

A basic example where we maximize Levi's function with as many parallel processes as there are logical cores, and save progress to file.

import math, distgfs

def levi(x, y):
    """
    Levi's function (see https://en.wikipedia.org/wiki/Test_functions_for_optimization).
    Has a global _minimum_ of 0 at x=1, y=1.
    """
    a = math.sin(3. * math.pi * x)**2
    b = (x - 1)**2 * (1 + math.sin(3. * math.pi * y)**2)
    c = (y - 1)**2 * (1 + math.sin(2. * math.pi * y)**2)
    return a + b + c


def obj_fun(pp, pid):
    """ Objective function to be _maximized_ by GFS. """
    x = pp['x']
    y = pp['y']

    res = levi(0.4*x, y)
    print(f"Iter: {pid}\t x:{x}, y:{y}, result:{res}")
    # Since Dlib maximizes, but we want to find the minimum,
    # we negate the result before passing it to the Dlib optimizer.
    return -res

# For this example, we pretend that we want to keep 'y' fixed at 1.0
# while optimizing 'x' in the range -4.5 to 4.5
space = {'x': [-4.5, 4.5]}
problem_parameters = {'y': 1.}

# Create an optimizer parameter set
distgfs_params = {'opt_id': 'distgfs_levi',
                  'obj_fun_name': 'example_distgfs_levi_file.obj_fun',
                  'problem_parameters': problem_parameters,
                  'space': space,
                  'n_iter': 10,
                  'file_path': 'distgfs.levi.h5',
                  'save': True,
                 }

distgfs.run(distgfs_params, verbose=True)

For additional examples, see examples.

Metadata

Release files for distgfs 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for distgfs 2.0.0
File Size Uploaded Provenance Actions
distgfs-2.0.0.tar.gz 32.2 kB Without provenance Details for distgfs-2.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for distgfs 2.0.0
File Interpreter ABI Platform Actions
distgfs-2.0.0-py3-none-any.whl Python 3 none any Details for distgfs-2.0.0-py3-none-any.whl

Total release size: 64.2 kB

Release files / distgfs-2.0.0.tar.gz

Download URL distgfs-2.0.0.tar.gz
Size 32.2 kB
Tags Source
SHA-256 checksum
How to use checksums
13cc94c9e85e361cf8e8fc69cadbd877119353868073c8478e3fe92c0bb6a93c
BLAKE2b-256 checksum
How to use checksums
080d5bf94f6efe5fe98073a391cc36a4ed7ff725f33761bd93ce172bc9177ea8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / distgfs-2.0.0-py3-none-any.whl

Download URL distgfs-2.0.0-py3-none-any.whl
Size 31.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e59dedaa764ea613438b8a08cb4f1459d943472a121281fff373fcd7f6b723f4
BLAKE2b-256 checksum
How to use checksums
df4802c9c5ba7c2a4ec61472030beeab5ea38788b051727a00696a772c77cd02
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Security for distgfs 2.0.0

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page