Skip to main content

Zeroth-order optimization training and experiments

Project description

ZOTitan

A codebase for Zeroth-Order Optimization (ZO) training and experiments.

Supported algorithms:

  • MeZO
  • MeZO with momentum from seed reconstruction
  • MeZO-Adam
  • SPSA
  • Evolutionary Strategies
  • EGGROLL

Plus some other experimental features. You can mix and match pieces of all the above algorithms. See ./train.py --help for more details.

Setup

Requires Python 3.11+ and a CUDA GPU.

python3 -m venv .venv
.venv/bin/pip install .
./train.py --help

Training

./train.py

First-order training requires a differentiable objective. Zeroth-order treats the loss as a black box, so any scalar works. We support both. If the loss your objective returns is differentiable, you can just do:

./train.py --optimizer zo  # MeZO (implied by default)
./train.py --optimizer fo  # Adam (with gradients)

Objectives

The --objective flag takes a +-joined mixture spec. Each component selects a dataset by name, optionally with weights and per-objective keyword config:

# Combine and weight a data mix
./train.py --objective "(scijudge,.5,1)+(c4)"

This trains a model on the c4 and scijudge objectives, where the scijudge loss is weighted half as strongly as the c4 loss.

You can also pass kwargs to the constructor of an objective like so:

./train.py --objective "(c4,z_loss_weight=0.1,fused=True)"

Here is the full grammar for the spec.

spec      := component ("+" component)*
component := NAME | "(" NAME ("," field)* ")"
field     := VALUE | KEY "=" VALUE
KEY       := identifier
VALUE     := "'" CHARS "'" | '"' CHARS '"' | LITERAL
LITERAL   := int | float | True | False | None
CHARS     := ... # Whatever you can put in a python string
  • A bare NAME and any omitted weight default to 1.0, so scijudge == (scijudge,1,1) and (c4,.5) == (c4,.5,1).
  • Keyword fields (KEY=VALUE) come after the positional weights and are forwarded to that objective's constructor.
  • Bare values must be numeric / True / False / None (and keep their type — rank=64 is an int).

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

zotitan-0.1.0.tar.gz (47.9 kB view details)

Uploaded Source

Built Distribution

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

zotitan-0.1.0-py3-none-any.whl (54.1 kB view details)

Uploaded Python 3

File details

Details for the file zotitan-0.1.0.tar.gz.

File metadata

  • Download URL: zotitan-0.1.0.tar.gz
  • Upload date:
  • Size: 47.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for zotitan-0.1.0.tar.gz
Algorithm Hash digest
SHA256 635b3121a080fb5f43b2d025f408bb856396b59579e0382fde39819533e355d7
MD5 51505105b708b45ae6bb1c694791fe95
BLAKE2b-256 a2f8e24bba9443f64cd4c709c7d190edc82da7500bbb4ff90e9c786b7a98d95a

See more details on using hashes here.

Provenance

The following attestation bundles were made for zotitan-0.1.0.tar.gz:

Publisher: publish.yml on apaz-cli/ZOTitan

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file zotitan-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: zotitan-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 54.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for zotitan-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5aa446e93945408b9b28c89b79e0bf5cb77b3a23968622a40f8e003b9b5afaa3
MD5 07df2e7d94e134a501f8316104341507
BLAKE2b-256 8a602adcf88777d6a2293349bb69b4485426c95a9a38dc87eee64bece1af876c

See more details on using hashes here.

Provenance

The following attestation bundles were made for zotitan-0.1.0-py3-none-any.whl:

Publisher: publish.yml on apaz-cli/ZOTitan

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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