Skip to content

Conversation

@jeremy-myers
Copy link
Contributor

@jeremy-myers jeremy-myers commented Sep 4, 2024

  • Adds a default callback to L-BFGS-B that tracks the times of each iteration.
    • User-defined callbacks are set as a private member callable in a subclass to LBFGSB called Monitor
    • Adds tests to tests/gcp/test_optimizers.py
    • Aligns with MATLAB usage
    • Changes monotonic() to perf_counter() in StochasticSolver
  • Adds timers to gcp_opt in info dictionary

📚 Documentation preview 📚: https://pyttb--314.org.readthedocs.build/en/314/

@jeremy-myers jeremy-myers linked an issue Sep 4, 2024 that may be closed by this pull request
Copy link
Collaborator

@ntjohnson1 ntjohnson1 left a comment

Choose a reason for hiding this comment

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

LGTM. I added a PR into your branch here that is one approach to resolving the typing issues specific to this PR.

The other typing issues for python > 3.8 should be resolved here since they are partially related to numpy 2.0 and newer mypy. I didn't check them exhaustively so its possible that there is still some subtle error remaining but resolving those two PRs first should at least highlight what remains before digging too much deeper.

solver = LBFGSB(maxiter=maxiter)
_, info = solver.solve(model, dense_data, gaussian, gaussian_grad)
assert not "callback" in info["callback"].keys()
assert info["callback"]["time_trace"].shape == (maxiter,)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we update this to ensure the timings are greater than zero? When looking at your typing bug I accidentally turned off the timing portion but the member in the Monitor had the shape set correctly (but always returned zero)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are you asking that the test check that timings > 0? Or something else? I'm having trouble parsing the second sentence.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes. That's the request. Right now if ONLY the constructor for the monitor existed this test would still pass.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah okay, that makes sense.


# Test default callback
maxiter = 2
solver = LBFGSB(maxiter=maxiter)
Copy link
Collaborator

Choose a reason for hiding this comment

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

The code has a comment about re-using the solver but we don't test for it. Can we add a test to make sure that is supported correctly? (My MR to fix the types also changes how we reset things when we are done so a test would confirm our intentions align)

@jeremy-myers
Copy link
Contributor Author

Regression tests fail on other code that was already failing, probably related to numpy & mypy in this PR.

@dmdunla dmdunla merged commit 7b4963b into sandialabs:main Oct 23, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add timings for gcp_opt with L-BFGS.

3 participants