Skip to content

bangyen/zsharp

Repository files navigation

ZSharp

Open in Colab Tests License

Sharpness-Aware Minimization with Z-Score Gradient Filtering: +5.26% accuracy over SGD, Apple Silicon optimized, fully reproducible

Training curves comparison

Quickstart

Clone the repo and run the demo:

git clone https://github.com/bangyen/zsharp.git
cd zsharp
pip install -e .
pytest   # optional: run tests
python -m scripts.train --config configs/zsharp_baseline.yaml

Or open in Colab: Colab Notebook.

Results

Scenario / Dataset Baseline This Project Δ Improvement
CIFAR-10 ResNet-18 74.89% 80.15%* +5.26%

*Benchmark results from full training runs. Local results may vary based on configuration.

Features

  • Z-Score Gradient Filtering — Intelligent gradient filtering with a default 70th percentile threshold (configurable) for improved training stability.
  • Apple Silicon Optimization — Up to 4.39x speedup using MPS (Metal Performance Shaders) for faster training on Mac.
  • Comprehensive Testing — 98% test coverage with 51 unit tests ensuring reliability and reproducibility.

Repo Structure

zsharp/
├── zsharp_demo.ipynb  # Colab notebook demo
├── scripts/           # Training and experiment scripts
├── tests/             # Unit/integration tests (51 tests)
├── docs/              # Documentation and training curves
├── configs/           # Configuration files
├── results/           # Experimental results
└── src/               # Core implementation

Validation

  • ✅ 98% test coverage (pytest)
  • ✅ Reproducible seeds for experiments
  • ✅ Benchmark scripts included

References

License

This project is licensed under the MIT License.

About

Sharpness-Aware Minimization with Z-Score gradient filtering achieving +5.26% accuracy, Apple Silicon optimized (4.39x speedup), and fully reproducible.

Topics

Resources

License

Stars

Watchers

Forks

Contributors