Code Monkey home page Code Monkey logo

Comments (6)

95-martin-orion avatar 95-martin-orion commented on June 14, 2024

Some context on the qsim side: this should only affect the *for.h, simulator_*.h, and statespace_*.h files. TFQ calls the methods provided by simulator and statespace, so the new For object could be passed in from there.

This is in the simulation "hot path", but by passing reference objects I think we can avoid any significant performance impact.

from qsim.

sergeisakov avatar sergeisakov commented on June 14, 2024

I think this is a good proposal. I'll do this in a slightly different way like this:

template <typename For>
class SimulatorAVX {
...

  template <typename... Args>
  SimulatorAVX(unsigned num_qubits, Args&&... args)
      : for_(args...), num_qubits_(num_qubits) {}

...

  For for_;

...

};

Instead of passing a For object to every function, I keep the classes templated and add a (lightweight) For object to them. This requires only minimal changes to statespace*.h and to simulator*.h and basically no changes to the existing client code and tests.

from qsim.

MichaelBroughton avatar MichaelBroughton commented on June 14, 2024

Ok, just to clarify with this new way of doing things can I still do something like this ?

auto my_for = tfq::TFQFor(tfOpKernelContext->get_available_cpu_workers())
auto qsim_simulator = SimulatorAVX<tfq::TFQFor>(num_qubits, ... , my_for);  // my_far passed in as a const TFQFor& ?

and expect things to work ?

from qsim.

sergeisakov avatar sergeisakov commented on June 14, 2024

Yes, it is expected to work if tfq::TFQFor has a copy constructor (user-defined or implicit). One doesn't have to define my_for. The following will also work:

qsim_simulator = SimulatorAVX<tfq::TFQFor>(num_qubits, tfOpKernelContext->get_available_cpu_workers());

from qsim.

MichaelBroughton avatar MichaelBroughton commented on June 14, 2024

Ok great.

I’ll do this in a slightly different way ...

When could we expect this to be a part of qsim with a new GitHub release ?

from qsim.

sergeisakov avatar sergeisakov commented on June 14, 2024

Hopefully, it will be in the repository in less than a week.

from qsim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.