question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Saving metrics during solve

See original GitHub issue

Hi, thanks again for the library.

we have a numerical integration we perform using lax.scan. We’d like to port it over to diffrax. I wanted to get your thoughts on the shortest path to this implementation.

From https://jax.readthedocs.io/en/latest/_autosummary/jax.lax.scan.html

def scan(f, init, xs, length=None):
  if xs is None:
    xs = [None] * length
  carry = init
  ys = []
  for x in xs:
    carry, y = f(carry, x)
    ys.append(y)
  return carry, np.stack(ys)

we rely quite a bit on the implicit append and stack calls that happen inside lax.scan. I think the core of my question is, is there a way to avoid the pre-allocation as you suggest in https://github.com/patrick-kidger/diffrax/issues/60#issuecomment-1034768386 . My guess is the answer is no but figured I’d see if you had any ideas.

TY in advance!

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
patrick-kidgercommented, Jun 7, 2022

Sounds good! I’ve adjusted the title of this issue to make this a feature request. (Which if you ever feel like digging into the guts of Diffrax I’d be happy to shepard a PR on.)

0reactions
patrick-kidgercommented, Jun 7, 2022

Yep! It’s this big block of code. The idea will be to change from state.ys – which is where we save our output – to state.out.

Now the bad news is that this part of the code is pretty complicated to read, as it needs to carefully make sure it gets good performance. Fortunately the good news is that you shouldn’t need to change any of that – just carefully figure out what’s what, and replace saving ys with saving save_fn(ys).

I’d suggest that the saving-function should be specified as part of the diffeqsolve(..., saveat=...) argument, and that when called it should take state as an argument.

As a nice bonus, I’ve realised that this makes the solver_state, controller_state, made_jump arguments to SaveAt superfluous: these can be obtained simply by using the appropriate metric-saving function.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The Importance of Implementing Effective Metrics - iSixSigma
Metrics indicate the priorities of the company and provide a window on performance, ethos and ambition. Ultimately, metrics will help tell the organization: ......
Read more >
Understanding The Problem You're Trying to Solve With Metrics
Metrics aren't going to help if you don't understand the problem you're trying to solve by implementing them. Learn more in this episode...
Read more >
Don't Let Metrics Undermine Your Business
Let's try to solve this problem—and by the way, here's some data we can look at to see how we're doing.'” Loosen the...
Read more >
6 Key Metrics to Track When Automating Your Business - Make
6 key metrics to track when automating your business. 1. Time saved. In the business world, people like to say that there aren't...
Read more >
9 Tips for Using HR Metrics Strategically - SHRM
Though metrics can be used to monitor performance, most data scientists emphasize their use in gathering the intelligence needed to resolve ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found