Skip to content
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

Debug jax > 0.4.32 failures #38

Closed
wants to merge 37 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
66fdc0e
aworkflow to facilitate debugging
mfschubert Oct 9, 2024
2189935
unpin jax for debugging
mfschubert Oct 9, 2024
f6f00ea
break out failing tests
mfschubert Oct 9, 2024
27f7d99
split up failing tests
mfschubert Oct 9, 2024
d1eb1c6
factor out initialize tests
mfschubert Oct 9, 2024
d4badd3
try variants of failing tests
mfschubert Oct 9, 2024
1249c58
try variants of failing tests
mfschubert Oct 9, 2024
3709404
debug tests
mfschubert Oct 9, 2024
b04a331
duplicate failing test
mfschubert Oct 9, 2024
9009e25
no jit for one-at-time optimization
mfschubert Oct 9, 2024
e93042c
no one-at-a-time optimization
mfschubert Oct 9, 2024
4f0eef1
reorganize failing tests
mfschubert Oct 9, 2024
a631212
update debug workflow
mfschubert Oct 9, 2024
fd3e89e
simplify
mfschubert Oct 9, 2024
7734606
simplify
mfschubert Oct 9, 2024
e1335e3
simplify
mfschubert Oct 9, 2024
752fa26
simplify
mfschubert Oct 9, 2024
6e55871
simplify
mfschubert Oct 9, 2024
2b7169c
debug script
mfschubert Oct 9, 2024
15511a6
add debug print statements
mfschubert Oct 9, 2024
f494f86
retry
mfschubert Oct 9, 2024
47cf5b6
test varying step counts
mfschubert Oct 9, 2024
ab89df3
update actiosn
mfschubert Oct 9, 2024
448206f
test more steps
mfschubert Oct 9, 2024
5626bc3
try various step counts
mfschubert Oct 9, 2024
edab51e
remove grad calc
mfschubert Oct 9, 2024
b5f9ea7
simplify
mfschubert Oct 9, 2024
9b2e48b
simplify
mfschubert Oct 9, 2024
adea942
flush print
mfschubert Oct 9, 2024
9972125
simplify debug run
mfschubert Oct 9, 2024
af0282b
additional print statements
mfschubert Oct 9, 2024
0a13478
try fix
mfschubert Oct 10, 2024
0dadb1b
try fix 2
mfschubert Oct 10, 2024
0bc5585
simplify test
mfschubert Oct 10, 2024
6f798e8
try fix
mfschubert Oct 10, 2024
8885b19
try fix
mfschubert Oct 10, 2024
a637e1a
test
mfschubert Oct 10, 2024
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
126 changes: 63 additions & 63 deletions .github/workflows/build-ci.yml
Original file line number Diff line number Diff line change
@@ -1,76 +1,76 @@
name: CI
# name: CI

on:
pull_request:
push:
branches:
- main
schedule:
- cron: "0 13 * * 1" # Every Monday at 9AM EST
# on:
# pull_request:
# push:
# branches:
# - main
# schedule:
# - cron: "0 13 * * 1" # Every Monday at 9AM EST

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
# jobs:
# pre-commit:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout repository
# uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: "pip"
cache-dependency-path: pyproject.toml
# - name: Set up Python
# uses: actions/setup-python@v5
# with:
# python-version: "3.10"
# cache: "pip"
# cache-dependency-path: pyproject.toml

- name: Test pre-commit hooks
run: |
python -m pip install --upgrade pip
pip install pre-commit
pre-commit run -a
# - name: Test pre-commit hooks
# run: |
# python -m pip install --upgrade pip
# pip install pre-commit
# pre-commit run -a

validate-types-and-docstrings:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
# validate-types-and-docstrings:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout repository
# uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: "pip"
cache-dependency-path: pyproject.toml
# - name: Set up Python
# uses: actions/setup-python@v5
# with:
# python-version: "3.10"
# cache: "pip"
# cache-dependency-path: pyproject.toml

- name: Setup environment
run: |
python -m pip install --upgrade pip
pip install ".[tests,dev]"
# - name: Setup environment
# run: |
# python -m pip install --upgrade pip
# pip install ".[tests,dev]"

- name: mypy type validation
run: mypy src
# - name: mypy type validation
# run: mypy src

- name: darglint docstring validation
run: darglint src --strictness=short --ignore-raise=ValueError
# - name: darglint docstring validation
# run: darglint src --strictness=short --ignore-raise=ValueError

tests:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout repository
uses: actions/checkout@v4
# tests:
# runs-on: ubuntu-latest
# timeout-minutes: 5
# steps:
# - name: Checkout repository
# uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: "pip"
cache-dependency-path: pyproject.toml
# - name: Set up Python
# uses: actions/setup-python@v5
# with:
# python-version: "3.10"
# cache: "pip"
# cache-dependency-path: pyproject.toml

- name: Setup environment
run: |
python -m pip install --upgrade pip
pip install ".[tests,dev]"
# - name: Setup environment
# run: |
# python -m pip install --upgrade pip
# pip install ".[tests,dev]"

- name: Run Python tests
run: |
pytest --cov=invrs_opt tests
# - name: Run Python tests
# run: |
# pytest --cov=invrs_opt tests
79 changes: 79 additions & 0 deletions .github/workflows/debug.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: CI

on:
pull_request:
push:
branches:
- main
schedule:
- cron: "0 13 * * 1" # Every Monday at 9AM EST

jobs:
run_debug_0020:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: "pip"
cache-dependency-path: pyproject.toml

- name: Setup environment
run: |
python -m pip install --upgrade pip
pip install ".[tests,dev]"

- name: Run Python tests
run: |
python tests/optimizers/run_debug.py --steps=20

run_debug_0100:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: "pip"
cache-dependency-path: pyproject.toml

- name: Setup environment
run: |
python -m pip install --upgrade pip
pip install ".[tests,dev]"

- name: Run Python tests
run: |
python tests/optimizers/run_debug.py --steps=100

run_debug_1000:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: "pip"
cache-dependency-path: pyproject.toml

- name: Setup environment
run: |
python -m pip install --upgrade pip
pip install ".[tests,dev]"

- name: Run Python tests
run: |
python tests/optimizers/run_debug.py --steps=1000
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ maintainers = [
]

dependencies = [
"jax < 0.4.32",
"jax",
"jaxlib",
"numpy",
"requests",
Expand Down
48 changes: 48 additions & 0 deletions tests/optimizers/run_debug.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
"""Defines tests for the `lbfgsb.lbfgsb` module.

Copyright (c) 2023 The INVRS-IO authors.
"""

import argparse

import jax
import jax.numpy as jnp
from totypes import types

from invrs_opt.optimizers import lbfgsb

jax.config.update("jax_enable_x64", True)


def optimization_with_vmap(steps):
params = types.Density2DArray(array=jnp.ones((2, 3, 3)))
opt = lbfgsb.density_lbfgsb(beta=2)
state = jax.vmap(opt.init)(params)

@jax.jit
@jax.vmap
def step_fn(state):
params = opt.params(state)
dummy_value = jnp.array(1.0, dtype=float)
dummy_grad = jax.tree_util.tree_map(jnp.ones_like, params)
state = opt.update(
grad=dummy_grad, value=dummy_value, params=params, state=state
)
return state, dummy_value

for i in range(steps):
print(f"vmap step {i}", flush=True)
state, value = step_fn(state)


parser = argparse.ArgumentParser(prog="debug", description="opt debugging")
parser.add_argument(
"--steps",
type=int,
default=None,
help="Number of steps.",
)

if __name__ == "__main__":
args = parser.parse_args()
optimization_with_vmap(steps=args.steps)
Loading
Loading