Contributing to SymTorch
We welcome contributions to SymTorch! This guide will help you get started.
Getting Started
Fork and Clone
Fork the repository and clone it locally:
git clone https://github.com/elizabethsztan/SymTorch.git cd SymTorch
Set Up Development Environment
Create and activate a virtual environment:
python -m venv symtorch_venv source symtorch_venv/bin/activate # On Windows: symtorch_venv\Scripts\activate
Install the package in editable mode:
pip install -e SymTorch/
Development Guidelines
Code Quality
Avoid code duplication: Reuse existing helper methods rather than duplicating patterns
Use class constants: Leverage
DEFAULT_SR_PARAMSand helper methods like_create_sr_params()Follow inheritance patterns: Extend parent functionality rather than duplicating code
Keep methods focused: Each method should have a single, clear responsibility
Testing
Before submitting a pull request, ensure all tests pass:
python -m pytest SymTorch/tests/
Key tests to verify:
Import functionality:
SymbolicMLP,SymbolicModel,SLIMEModel, andPruningMLPimport successfullySymbolic regression pipeline:
distill()�switch_to_equation()�forward()works correctlySave/load functionality: Models save and load with preserved state
You can also run the demo notebooks to verify functionality:
cd SymTorch/docs/demos
jupyter notebook getting_started_demo.ipynb
Making Contributions
Types of Contributions
Bug fixes: Fix issues in existing functionality
New features: Add new capabilities (discuss in an issue first)
Documentation: Improve docs, docstrings, or examples
Tests: Add or improve test coverage
Examples: Create new demo notebooks or case studies
Pull Request Process
Create a branch for your changes:
git checkout -b feature/your-feature-name
Make your changes following the code quality guidelines
Test your changes thoroughly
Commit your changes with clear, descriptive messages:
git commit -m "Add feature: description of your changes"
Push to your fork:
git push origin feature/your-feature-name
Open a pull request on GitHub with:
Clear description of changes
Reference to any related issues
Test results demonstrating functionality
Code Architecture
When to Use Each Component
SymbolicMLP: Layer-level symbolic regression for understanding individual MLP layers
SymbolicModel: Model-level symbolic regression for end-to-end approximation
SLIMEModel: Local interpretability around specific data points (model-agnostic)
PruningMLP: Extension of SymbolicMLP with dimension pruning
Common Patterns to Avoid
Don’t duplicate default parameter blocks (use
_create_sr_params())Don’t manually implement hook registration/removal (use
_capture_layer_output())Don’t copy-paste variable extraction logic (use helper methods)
Don’t override parent methods with full reimplementation
Questions or Issues?
Bug reports: Open an issue on GitHub with a minimal reproducible example
Feature requests: Open an issue to discuss before implementing
Questions: Check existing issues or open a new discussion
Thank you for contributing to SymTorch!