Skip to content

Add Differentiable Physics: Mass-Spring System example #1332

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Resolved merge conflict and integrated differentiable_physics test
  • Loading branch information
AbhiLegend committed May 13, 2025
commit 3d01b48212049a6d263ceb22736cedff609628c8
24 changes: 12 additions & 12 deletions run_python_examples.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,20 @@
# The purpose is just as an integration test, not to actually train models in any meaningful way.
# For that reason, most of these set epochs = 1 and --dry-run.
#
# Optionally specify a comma separated list of examples to run. Can be run as:
# * To run all examples:
# To run all examples:
# ./run_python_examples.sh
# * To run few specific examples:
#
# To run specific examples:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these changes be better moved to separate PR. These are unrelated to the example being added and some are arguable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made it to as it was.

# ./run_python_examples.sh "dcgan,fast_neural_style"
#
# To test examples on CUDA accelerator, run as:
# USE_CUDA=True ./run_python_examples.sh
# USE_CUDA=True ./run_python_examples.sh → for CUDA
# USE_ACCEL=True ./run_python_examples.sh → for any accelerator (CUDA/MPS/XPU)
#
# To test examples on hardware accelerator (CUDA, MPS, XPU, etc.), run as:
# USE_ACCEL=True ./run_python_examples.sh
# To use a custom pip install source:
# PIP_INSTALL_ARGS="--pre -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html" ./run_python_examples.sh
#
# Script requires uv to be installed. It installs requirements from requirements.txt per example.
# To force venv per example:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

venv might be confused with the type of virtual environment. I would prefer to use full naming "virtual environment per example".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed

# VIRTUAL_ENV=".venv" ./run_python_examples.sh

BASE_DIR="$(pwd)/$(dirname $0)"
source $BASE_DIR/utils.sh
Expand All @@ -39,7 +40,7 @@ case $USE_CUDA in
ACCEL_FLAG=""
;;
"")
exit 1;
exit 1
;;
esac

Expand All @@ -53,7 +54,6 @@ function fast_neural_style() {
uv run download_saved_models.py
fi
test -d "saved_models" || { error "saved models not found"; return; }

echo "running fast neural style model"
uv run neural_style/neural_style.py eval --content-image images/content-images/amber.jpg --model saved_models/candy.pth --output-image images/output-images/amber-candy.jpg $ACCEL_FLAG || error "neural_style.py failed"
}
Expand All @@ -80,7 +80,7 @@ function mnist() {
}

function mnist_forward_forward() {
uv run main.py --epochs 1 --no_mps --no_cuda || error "mnist forward forward failed"
uv run main.py --epochs 1 --no_accel || error "mnist forward forward failed"
}

function mnist_hogwild() {
Expand Down Expand Up @@ -205,7 +205,7 @@ function run_all() {
run fx
run gcn
run gat
run differentiable_physics # ✅ Your example now runs in CI!
run differentiable_physics
}

if [ "" == "$EXAMPLES" ]; then
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.