SGDF — Signal Processing Meets SGD
SGDF is a PyTorch optimizer providing three update modes in a single torch.optim.Optimizer interface: SGDF, Sign-SGDF, and Muon + SGDF.
Reference: Signal Processing Meets SGD: From Momentum to Filter.
Installation
pip install .
Or install the distributed .whl directly with pip install <wheel-file>.
Python 3.9+ and PyTorch 2.0+ are required. Triton is an optional dependency used only with fused=True:
pip install '.[triton]'
Basic usage
from SGDF import SGDF
optimizer = SGDF(model.parameters(), lr=0.1) # SGDF
optimizer = SGDF(model.parameters(), lr=1e-3, use_sign=True) # Sign-SGDF
optimizer = SGDF(model.parameters(), lr=0.01, use_muon=True) # Muon + SGDF
use_sign and use_muon are mutually exclusive. SGDF works with standard PyTorch parameter groups, learning-rate schedulers, AMP, and optimizer checkpoints (state_dict).
When using Muon, matrix-like parameters are orthogonalized with Newton–Schulz; vectors and scalars receive the standard SGDF update. A common configuration is:
optimizer = SGDF([
{"params": matrix_params, "use_muon": True, "lr": 0.01},
{"params": other_params, "use_muon": False, "lr": 0.001},
])
The two parameter lists must not overlap.
For detailed examples of optimizer modes, parameter groups, AMP, distributed Muon, checkpointing, and options, see USAGE.md.
GPU fused update
Use fused=True with contiguous CUDA FP32 parameters and gradients, after installing the optional Triton dependency:
optimizer = SGDF(model.parameters(), lr=0.1, fused=True)
The fused path supports standard SGDF and Sign-SGDF. Muon uses the non-fused path.
Single-node multi-GPU Muon
For ordinary DDP, the optimizer uses synchronized gradients just like other
PyTorch optimizers. If Muon matrices are large, muon_ddp="shard" balances
Newton–Schulz computations across local DDP replicas and broadcasts directions
in bounded buckets:
optimizer = SGDF(ddp_model.parameters(), lr=0.01, use_muon=True,
muon_ddp="shard")
For FSDP2 / DTensor matrix sharding, muon_distributed="auto" is the default:
optimizer = SGDF(model.parameters(), lr=0.01, use_muon=True,
muon_distributed="auto")
Auto mode chooses between reconstructing the whole matrix (gather) and
computing a global Gram matrix (gram) once, followed by local polynomial
Newton–Schulz iterations. It respects muon_gram_max_dim and
muon_gather_max_bytes. To select a specific strategy, set
muon_distributed="gram" or "gather".
These modes target a single node with multiple GPUs. All ranks must execute collectives in the same order. FSDP1 flattened parameter shards are unsupported for Muon orthogonalization.
Configuration
Main options include lr, betas, eps, gamma, weight_decay, weight_decouple, maximize, use_sign, use_muon, foreach, foreach_max_bytes, fused, capturable, ns_steps, muon_distributed, muon_gram_max_dim, muon_gather_max_bytes, muon_compute_dtype, muon_ddp, muon_ddp_min_numel, and muon_ddp_bucket_bytes.
The default gamma=None selects 0.5 for standard/Muon SGDF and 1.0 for Sign-SGDF. Sparse gradients and differentiable optimizer steps are not supported.
License: MIT.
Metadata
Release files for SGDF 0.5.0
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 |
|---|---|---|---|---|
| sgdf-0.5.0.tar.gz | 19.6 kB | Without provenance | Details for sgdf-0.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sgdf-0.5.0-py3-none-any.whl | Python 3 | none | any | Details for sgdf-0.5.0-py3-none-any.whl |
Total release size: 36.1 kB
Release files / sgdf-0.5.0.tar.gz
| Download URL | sgdf-0.5.0.tar.gz |
|---|---|
| Size | 19.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c20f15595aeff6f21dce6cbdd78064d0063b50dbd09d8f4f36f849d68be7f4eb
|
|
BLAKE2b-256 checksum How to use checksums |
115ec999f4b55f3f16aff9e163821fee1a42dd8677f312c6c1c83d682a2cbbc8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.8
|
Release files / sgdf-0.5.0-py3-none-any.whl
| Download URL | sgdf-0.5.0-py3-none-any.whl |
|---|---|
| Size | 16.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e05f7f721199ef307642c5542768bdb6c9e67d988001356db25e5ccff1bedc83
|
|
BLAKE2b-256 checksum How to use checksums |
d1c87b18ffcc07cbf87b4ee58cd81449bcab50ab7fc26dfc4599240287aed658
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.8
|
Security for SGDF 0.5.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.