TeamGraphix / graphix

measurement-based quantum computing (MBQC) compiler and simulator
https://graphix.readthedocs.io
Apache License 2.0
55 stars 20 forks source link

Optimize flow computation #165

Open EarlMilktea opened 3 weeks ago

EarlMilktea commented 3 weeks ago

Describe the feature you'd like

Refactor & optimize gflow.py.

We may need to resort to C++ or Rust bindings if numba doesn't work.

EarlMilktea commented 1 week ago

@shinich1

I'm temped to try binding mainly because numba is not good at nesting pythonic data structures (such as list), which are inherently required to represent graphs.

EarlMilktea commented 1 week ago

In addition to baseline speedups (ex. faster for-loop), as flow/gflow algorithm repeatedly allocate/discard expensive data structures, we may be benefited by carefully managing/reusing working memories.

For that purpose, Rust would be better than C++.

shinich1 commented 1 week ago

@shinich1

I'm temped to try binding mainly because numba is not good at nesting pythonic data structures (such as list), which are inherently required to represent graphs.

@EarlMilktea Sounds good! binding with Rust seems to be the best way. Shall we try implementing in this repo, and once there's a PR, that would be a good place to discuss whether or not to move to a separate repo (as flow-finding algorithms and related linalg functions can be independent of graphix).

EarlMilktea commented 1 week ago

I'm pretty sure that flow/gflow calculator CAN be independent. Do you want it to be in the same repo?

shinich1 commented 1 week ago

independent repo souds good, here's new one: https://github.com/TeamGraphix/fastflow I'm open to other naming ideas.. (nb fastflow seems to be available on pypi https://pypi.org/search/?q=fastflow&o=, though there's a ML related paper with same name )