Skip to content

Conversation

@Renaud-K
Copy link
Collaborator

@Renaud-K Renaud-K commented Dec 16, 2025

In preparation for the runtime refactor and the transition of QPU based classes (qpu.h) to trait based classes. I propose the use of the any_qpu type in the quantum platform, which call hold both.

  1. Introducing a new directory where the new files are added. The idea is to make it easier to remove the old files once the migration is done.
  2. The quantum_platforms holds the any_qpu type, instead of the QPU type. It turns out, that this was the only place where the change has to happen.
  3. A non LLVM based type-erased registry is introduced to hold both types. The LLVM based registry only supports type which have a common base, however trait based class have no common base.
    • The registry is made to work with more than QPUs, so it is split in 2 files: type_erased_registry.h and any_qpu.h
    • The interface to the registry mimics that of the current LLVM based registry.
  4. In the case of overloaded members, all overloads need to be present in a class for the look-up mechanism to work.
  5. For this registry to work across executables, shared libs and dynamically loaded libs, the trick it to explicitly instantiate only once the get function of the registry, in this aggregate, to insure that all binaries call a unique one. This is also the reason why there is LLVM_INSTANTIATE_REGISTRY.
  6. There is an emerging task for the refactor to allow the use of the logger in the header files in a way that the fmtlib package does not bleed into user code. For now, I have split it into Logger.h and logger_lite.h, so basic logging can be done. This was a major pain point to debug the code.

@copy-pr-bot
Copy link

copy-pr-bot bot commented Dec 16, 2025

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

launchVQE = [](void *i, const std::string &name, const void *kernelArgs,
gradient *grad, const spin_op &H, optimizer &opt,
const int n_params, const std::size_t shots) {
static_cast<T *>(i)->launchVQE(name, kernelArgs, grad, H, opt, n_params,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think VQE is going to be moved to CUDA-QX. @bmhowe23 would you please confirm?

Copy link
Collaborator

@lmondada lmondada left a comment

Choose a reason for hiding this comment

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

I like this proposal a lot!

The only drawback is that the any_qpu definition is very verbose: each method appears three times:

  • as attribute in the qpu_dispatch_table,
  • in the build method
  • as a method on any_qpu

My C++ hackery skills are at a limit here. I don't see how this redundancy could be resolved with a macro. Any chance tablegen could help here? I am not familiar enough with what it can/cannot do.

Anyways, I think this is a good approach and I am in favour of merging this in!

@Renaud-K
Copy link
Collaborator Author

Thank you for the support. I have not had a chance to give too much thoughts about the drawbacks mentioned here. I am also not able to reply there. My focus on the past two days has been on making it work across executables, shared libs and dynamically loaded libs. The trick it to explicitly instantiate only once the get function of the registry, this aggregate to insure that all binaries call the same. This is the reason why there is LLVM_INSTANTIATE_REGISTRY.

Reflections would probably help best with this issue. Macros could help a little too I think. I am not sure I want to get too sophisticated this early in the process with tablegen.

Reducing the size of the interface will help too which should be where we are headed.

@Renaud-K Renaud-K changed the title WIP: any_qpu type Introducinf any_qpu type to hold both qpus based on the QPU base class and trait based qpus. Dec 18, 2025
@Renaud-K Renaud-K changed the title Introducinf any_qpu type to hold both qpus based on the QPU base class and trait based qpus. Introducing any_qpu type to hold both qpus based on the QPU base class and trait based qpus. Dec 18, 2025
@Renaud-K
Copy link
Collaborator Author

Renaud-K commented Dec 18, 2025

/ok to test 32911ed

Command Bot: Processing...

@Renaud-K Renaud-K force-pushed the any_qpu branch 2 times, most recently from 17d1b0c to cc96114 Compare December 18, 2025 22:02
@Renaud-K
Copy link
Collaborator Author

Renaud-K commented Dec 18, 2025

/ok to test cc96114

Command Bot: Processing...

@Renaud-K
Copy link
Collaborator Author

Renaud-K commented Dec 18, 2025

/ok to test f2785df

Command Bot: Processing...

@Renaud-K
Copy link
Collaborator Author

Renaud-K commented Dec 19, 2025

/ok to test d007f5f

Command Bot: Processing...

@Renaud-K
Copy link
Collaborator Author

Renaud-K commented Dec 19, 2025

/ok to test bb314c6

Command Bot: Processing...

@Renaud-K
Copy link
Collaborator Author

Renaud-K commented Jan 6, 2026

/ok to test 47771b1

Command Bot: Processing...

Signed-off-by: Renaud Kauffmann <[email protected]>
Signed-off-by: Renaud Kauffmann <[email protected]>
Signed-off-by: Renaud Kauffmann <[email protected]>
Signed-off-by: Renaud Kauffmann <[email protected]>
… singleton accross dynamically loaded libs

Signed-off-by: Renaud Kauffmann <[email protected]>
Signed-off-by: Renaud Kauffmann <[email protected]>
…. Removed the extra registry instantiation

Signed-off-by: Renaud Kauffmann <[email protected]>
DCO Remediation Commit for Renaud Kauffmann <[email protected]>

I, Renaud Kauffmann <[email protected]>, hereby add my Signed-off-by to this commit: e16a515

Signed-off-by: Renaud Kauffmann <[email protected]>
DCO Remediation Commit for Renaud Kauffmann <[email protected]>

I, Renaud Kauffmann <[email protected]>, hereby add my Signed-off-by to this commit: 5c8d9ff

Signed-off-by: Renaud Kauffmann <[email protected]>
Signed-off-by: Renaud Kauffmann <[email protected]>
Signed-off-by: Renaud Kauffmann <[email protected]>
Signed-off-by: Renaud Kauffmann <[email protected]>
…cannot be controlled.

Signed-off-by: Renaud Kauffmann <[email protected]>
Signed-off-by: Renaud Kauffmann <[email protected]>
Signed-off-by: Renaud Kauffmann <[email protected]>
Signed-off-by: Renaud Kauffmann <[email protected]>
@Renaud-K
Copy link
Collaborator Author

Renaud-K commented Jan 7, 2026

/ok to test 8ca28c5

Command Bot: Processing...

@copy-pr-bot
Copy link

copy-pr-bot bot commented Jan 7, 2026

/ok to test 8ca28c5

@Renaud-K, there was an error processing your request: E2

See the following link for more information: https://docs.gha-runners.nvidia.com/cpr/e/2/

@Renaud-K
Copy link
Collaborator Author

Renaud-K commented Jan 7, 2026

/ok to test 21ed030

Command Bot: Processing...

github-actions bot pushed a commit that referenced this pull request Jan 7, 2026
@github-actions
Copy link

github-actions bot commented Jan 7, 2026

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

I, Renaud Kauffmann <[email protected]>, hereby add my Signed-off-by to this commit: 8ca28c5

Signed-off-by: Renaud Kauffmann <[email protected]>
@Renaud-K
Copy link
Collaborator Author

Renaud-K commented Jan 7, 2026

/ok to test a8f4f3e

Command Bot: Processing...

github-actions bot pushed a commit that referenced this pull request Jan 7, 2026
@github-actions
Copy link

github-actions bot commented Jan 7, 2026

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

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.

4 participants