TeamGraphix / graphix

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

Faster graph state simulator #79

Closed shinich1 closed 6 months ago

shinich1 commented 10 months ago

Is your feature request related to a problem? Please describe. The graph state simulator is slow for large-scale simulations, for example the pauli measurement preprocessing part of https://github.com/TeamGraphix/graphix/blob/master/examples/qft_with_tn.py

Describe the feature you'd like add rustworkx as backend for the graph state simulator. Perhaps best to keep it optional since it is not supported for all platforms. Also consider adding 'stabilizer backend' for MBQC simulations (simulate with graph state simulator), which may be useful for e.g. QEC simulation.

king-p3nguin commented 7 months ago

Hi @shinich1, if no one is working on it, I would like to implement a graph state simulator with rustworkx. I am thinking of creating another class for graph state simulator with rustworkx and abstract graph state class to store common methods.

shinich1 commented 7 months ago

@king-p3nguin sounds great! it would be good to benchmark full rustworkx implementation of graphstate simulator. I was thinking about switching the backend between networkx and rustworkx internally of the graph state class based on availability of rustworkx (try-catch type syntax for import rustworkx; with option to specify by hand explicitly which to use), what do you think about that? also see #95 for @masa10-f 's idea on speeding up local complementation by matrix backend.

king-p3nguin commented 7 months ago

I understand. In that case, how about something like

class GraphState:  # a factory class for graph states
    def __init__(self, use_rustworkx=True):
        if use_rustworkx:
            # check if rustworkx is installed
            # ...
            if rustworkx_installed:
                return RustworkxGraphState()
            else:
                throw_warning()
                return NetworkxGraphState()
        else:
            return NetworkxGraphState()

class AbstractGraphState:
    @abstractmethod
    def ...

class NetworkxGraphState(AbstractGraphState):
    def ...

class RustworkxGraphState(AbstractGraphState):
    def ...

?

king-p3nguin commented 7 months ago

@shinich1