-
Notifications
You must be signed in to change notification settings - Fork 12
feature/jax_cpu_batch_size_1 #1169
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,7 +44,6 @@ def __init__( | |
| use_jax_vmap : bool = False, | ||
| batch_size : Optional[int] = None, | ||
| iterations_per_quick_update: Optional[int] = None, | ||
| xp=np, | ||
| ): | ||
| """ | ||
| Interfaces with any non-linear search to fit the model to the data and return a log likelihood via | ||
|
|
@@ -109,7 +108,8 @@ def __init__( | |
| self.model = model | ||
| self.paths = paths | ||
| self.fom_is_log_likelihood = fom_is_log_likelihood | ||
| self.resample_figure_of_merit = resample_figure_of_merit or -xp.inf | ||
|
|
||
| self.resample_figure_of_merit = resample_figure_of_merit or -self._xp.inf | ||
| self.convert_to_chi_squared = convert_to_chi_squared | ||
| self.store_history = store_history | ||
|
|
||
|
|
@@ -123,10 +123,20 @@ def __init__( | |
| if self.use_jax_vmap: | ||
| self._call = self._vmap | ||
|
|
||
| if analysis._use_jax: | ||
|
|
||
| import jax | ||
|
|
||
| if jax.default_backend() == "cpu": | ||
|
|
||
| logger.info("JAX using CPU backend, batch size set to 1 which will improve performance.") | ||
|
|
||
|
Comment on lines
+129
to
+133
|
||
| batch_size = 1 | ||
|
|
||
| self.batch_size = batch_size | ||
| self.iterations_per_quick_update = iterations_per_quick_update | ||
| self.quick_update_max_lh_parameters = None | ||
| self.quick_update_max_lh = -xp.inf | ||
| self.quick_update_max_lh = -self._xp.inf | ||
| self.quick_update_count = 0 | ||
|
|
||
| if self.paths is not None: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
xpparameter was removed from__init__, butxpis still referenced later in this method (e.g.,-xp.infforresample_figure_of_merit/quick_update_max_lh). This will raiseNameErrorat runtime duringFitnessconstruction. Replace remainingxpreferences withnporself._xp(consistent with the existing_xpproperty) and ensureresample_figure_of_merit/quick_update_max_lhare initialized using that backend.