Skip to content
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

Optimizing HROM Setup Performance #12270

Merged
merged 25 commits into from
Apr 29, 2024
Merged

Optimizing HROM Setup Performance #12270

merged 25 commits into from
Apr 29, 2024

Conversation

SADPR
Copy link
Contributor

@SADPR SADPR commented Apr 12, 2024

Summary

This PR introduces substantial improvements to the setup process for HROMs in Kratos. It replaces the previous dictionary-based storage for ROM elements and weights with a more efficient list-based approach. This change addresses performance bottlenecks identified during the handling of large datasets, where the former method was projected to take impractically long execution times (up to weeks for extensive cases like the motor setup; now, it takes a few seconds).

Changes

Replaced Data Structures

  • Old Implementation: Used a dictionary to store weights and indices for ROM elements and conditions. This method was not only memory-intensive but also significantly slower for large data sets due to the overhead associated with dictionary operations in Python and C++.

  • New Implementation: Shifts to using lists and numpy arrays that streamline the data handling and improve the execution speed. The new method directly loads and processes .npy files for element and condition IDs, and weights into numpy arrays, facilitating faster access and operations.

Additional Enhancements

  • Minor Bug Fixes: Addressed a few default minor bugs that were affecting the efficiency and correctness of the HROM setups.

  • SVD Type Setting: Introduced a new setting (svd_type) that allows users to choose between using the randomized SVD (rSVD) and numpy's SVD.

  • HROM Creation Test: Added a test for the HROM creation process, an essential part of our testing suite that was previously missing.

Copy link
Member

@Rbravo555 Rbravo555 left a comment

Choose a reason for hiding this comment

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

minor comments to be addressed

@@ -167,7 +175,7 @@ def ModifyAfterSolverInitialize(self):
aux[j,i] = petrov_galerkin_nodal_modes[node_id][j][i].GetDouble()
node.SetValue(KratosROM.ROM_LEFT_BASIS, aux)

elif self.rom_parameters["rom_format"].GetString() == "numpy":
Copy link
Member

Choose a reason for hiding this comment

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

let us name the options:
"numpy_svd", "numpy_rsvd", later on we could add: "dislib_tsqr_svd", "dask_rsvd", and so on

@@ -0,0 +1,1463 @@
Begin ModelPartData
Copy link
Member

Choose a reason for hiding this comment

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

Why arent we refering to the original file, therefore avoiding copying it in the RomApp folder? I mean:
"input_filename" : "../../../../FluidDynamicsApplication/tests/CouetteFlowTest/couette_flow_test"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Change done.

@Rbravo555
Copy link
Member

Not passing the tests. Is this related to the use of the model part from the CFDApp?

@Rbravo555
Copy link
Member

as a TODO for future PRs, we should create an SVD class, so that we can move there the svds implemented in this PR in the hrom_training_untility.py

@SADPR SADPR merged commit f35cf49 into master Apr 29, 2024
11 checks passed
@SADPR SADPR deleted the Kratos_HROM_Avoid_Dictionary branch April 29, 2024 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

7 participants