jacobian solver for matching - #1164
swhite2401 wants to merge 4 commits into
Conversation
|
Here is a notebook showing the usage and advantages of the new jacobian solver. |
|
Parellization is not so efficicent for this simple test, I will try on a heavier test case |
|
Excellent !The notebook works perfectly and the method looks efficient. Are you sure that using a global for the variables really improves the speed ? As a consequence, you have to rebuild a VariableList several times (ex.: By the way, this should rather be |
|
Variable list is not pickled because of the persistent pool, if we pickle VariableList we would then need to send new updated variables every time the jacobian is recalculated. However, an alternative was proposed using the pool initializer, this helps also for other start method, we should consider it for platticepass and other methods using python multiprocessing! |
|
This looks interesting. For a better understanding, it could be wise to rename the |
|
I have gone through a final round of simplification / optimization. Ready to take comments, meanwhile I switch back to testing integrators refactoring |
|
|
||
| def _step(step_fun): | ||
| step_fun(ring=ring) | ||
| observables.evaluate(ring, **kwargs) | ||
| return observables.flat_values | ||
|
|
||
| x0 = variable.initial_value | ||
| vmin, vmax = variable.bounds | ||
| delta = variable.delta | ||
| down = x0 - delta >= vmin | ||
| up = x0 + delta <= vmax or not down | ||
| if up and down and f0 is None: | ||
| fp, fm, h = _step(variable.step_up), _step(variable.step_down), 2.0 | ||
| else: | ||
| base = _step(variable.reset) if f0 is None else f0 | ||
| if up: | ||
| fp, fm, h = _step(variable.step_up), base, 1.0 | ||
| else: | ||
| fp, fm, h = base, _step(variable.step_down), 1.0 |
There was a problem hiding this comment.
I do not see any good reason why we should restrict the response computation with bounds. The goal is to compute the derivative at point x0 (which is within bounds). nothing will burn if the step is outside the bounds. The bounds are there to prevent the matching to overpass them, but this does not apply to response computation.
There was a problem hiding this comment.
Nothing will burn for sure, but the bounds are set at the Variable level so it raises an error if we try to set it to a value beyond the bounds, right?
Then I agree with you.... bounds should be ignore when computing the response matrix, should I implement this?
There was a problem hiding this comment.
Oh, I did not think to that…
I think that the cleanest solution is to add a force boolean keyword to the Variable.set and similar methods. This is trivial and I opened a separate PR for that (#1169). Have a look
This PR introduce the XSuite jacobian method for matching into AT.
The jacobian is calculated using the response_matrix module from AT, several changes were required for matching application:
-global variable preventing to pickle the ring at each call is activated for fork start method
-possibility to use existing mp pool, this prevent creating a new mp pool every time the jacobian is updated
-possibility to compute the jacobian using one sided delta (facotr 2 speed-up)
The default behavior of response_matrix is preserved.
This PR was used as a benchmark for Claude assisted developments.