Speedup QMCPy - #620
Open
sou-cheng-choi wants to merge 349 commits into
Open
Conversation
README.md: * Corrected filename references. * Removed references to non-existent files. averaged_mae.py: * Fixed PEP 8 spacing for parameter qp_seed and use the parameter in code. *Enhanced documentation with. *Removed an unused import. * Cleaned up code by removing a commented-out block.
…tware/QMCSoftware into geometric_brownian_motion
…tware/QMCSoftware into geometric_brownian_motion
* Initial plan * Add error log capture and display in parsl_test_runner.py Co-authored-by: sou-cheng-choi <18743024+sou-cheng-choi@users.noreply.github.com> * Simplify error logging by removing redundant stderr checks Co-authored-by: sou-cheng-choi <18743024+sou-cheng-choi@users.noreply.github.com> * Add error handling for log file reading operations Co-authored-by: sou-cheng-choi <18743024+sou-cheng-choi@users.noreply.github.com> --------- Co-authored-by: alegresor <agsorokin3@gmail.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: sou-cheng-choi <18743024+sou-cheng-choi@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
sou-cheng-choi
requested review from
JiangruiKang,
Laasya-73,
alegresor,
algo-hawk,
fjhickernell,
larissensium and
park1428
and removed request for
JiangruiKang
September 13, 2026 02:36
…el-batched transform
alegresor
requested changes
Sep 13, 2026
| + (self.interest_rate - self.volatility**2 / 2) * self.t_final | ||
| ) | ||
| fp = self.start_price * norm.cdf(term1 / denom) - decay * norm.cdf( | ||
| fp = self.start_price * ndtr(term1 / denom) - decay * ndtr( |
Member
There was a problem hiding this comment.
I like the ndtr and ndtri updates
|
|
||
| def g(self, x): | ||
| z = np.einsum("...j,ij->...i", x, self.feature_array) | ||
| z = x @ self.feature_array.T |
Member
There was a problem hiding this comment.
x may be three dimensional, in which case I think this will break. Also, I think np.einsum is usually as fast as possible, so maybe this line doesn't need to be changed?
Member
There was a problem hiding this comment.
What has been changed here? Something new added?
| z = norm.ppf(u) | ||
| quad = np.einsum("...i,ij,...j->...", z, self._corr_inv_minus_eye, z) | ||
| z = ndtri(u) | ||
| quad = ((z @ self._corr_inv_minus_eye) * z).sum(-1) |
Member
There was a problem hiding this comment.
Same comment as earlier, I think this will break if z is three dimensional.
Comment on lines
-152
to
-176
| n = len(t) | ||
|
|
||
| # Use most efficient method based on problem size | ||
| if n <= 200: # For small-medium matrices, broadcasting is fastest | ||
| t_sum = t[:, None] + t[None, :] # Shape: (n, n) | ||
| t_min = minimum.outer(t, t) # Shape: (n, n) | ||
| cov_matrix = S0_sq * exp(mu * t_sum) * (exp(self.diffusion * t_min) - 1) | ||
| else: # For larger matrices, use memory-efficient computation | ||
| cov_matrix = zeros((n, n)) | ||
| exp_mu_t = exp(mu * t) # Pre-compute exp(mu * t_i) | ||
| exp_diff_t = exp(self.diffusion * t) # Pre-compute exp(diffusion * t_i) | ||
| for i in range(n): # Optimized symmetric matrix computation | ||
| cov_matrix[i, i] = S0_sq * exp_mu_t[i] ** 2 * (exp_diff_t[i] - 1) | ||
| for j in range(i + 1, n): | ||
| t_min_ij = min(t[i], t[j]) | ||
| cov_ij = ( | ||
| S0_sq | ||
| * exp_mu_t[i] | ||
| * exp_mu_t[j] | ||
| * (exp(self.diffusion * t_min_ij) - 1) | ||
| ) | ||
| cov_matrix[i, j] = cov_ij | ||
| cov_matrix[j, i] = cov_ij # Symmetric | ||
|
|
||
| return cov_matrix |
Member
There was a problem hiding this comment.
No need to split this into small + large cases anymore? More efficient to just use simplified construction?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See demo
demos/performance_optimizations_demo.ipynbAs a result of these changes, All Tests on GitHub Actions reduced from ~25 minutes to <20 minutes.