Skip to content

Serialization/conversion performance improvements #2081

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

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

mattwthompson
Copy link
Member

Copy link

codecov bot commented Jul 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.61%. Comparing base (54f7402) to head (bdd8556).
Report is 2 commits behind head on main.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mattwthompson
Copy link
Member Author

mattwthompson commented Jul 9, 2025

Bummer, the behavior seems fine:

In [3]: hash(ForceField("openff-2.0.0.offxml")['vdW'])
Out[3]: -7474900899989015509

In [4]: hash(ForceField("openff-2.1.0.offxml")['vdW'])
Out[4]: -7474900899989015509

In [5]: hash(ForceField("openff-2.2.1.offxml")['vdW'])
Out[5]: -2512421923988562758

and the raw performance isn't terrible:

In [6]: %%timeit
   ...: hash(ForceField("openff-2.2.1.offxml")['vdW'])
   ...:
   ...:
80.5 ms ± 1.44 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)

but something somewhere is causing huge slowdowns, or this just doesn't scale well to large systems. That's what's up next.

@mattwthompson mattwthompson changed the title Implement ParameterHandler.__hash__ Serialization/conversion performance improvements Jul 18, 2025
Comment on lines -166 to +168
unitless_value: float | int | NDArray | list = input_quantity.m_as(input_quantity.units)
unitless_value: float | int | NDArray | list = input_quantity.m
Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think there was a reason to convert this quantity into the units it already has

# Try matching the case where there are two indices
# this indicates a index_mapped parameter
attr_name, index, key = self._split_attribute_index_mapping(item)
if not item.isalpha():
Copy link
Member Author

Choose a reason for hiding this comment

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

This check is not free, but it improves the current design by not checking for indexed or indexed + mapped attributes if an attribute name is alphabetic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants