Skip to content
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

Implement cudaq::run API #2526

Open
1 of 10 tasks
annagrin opened this issue Jan 21, 2025 · 0 comments
Open
1 of 10 tasks

Implement cudaq::run API #2526

annagrin opened this issue Jan 21, 2025 · 0 comments
Labels
enhancement New feature or request

Comments

@annagrin
Copy link
Collaborator

annagrin commented Jan 21, 2025

Required prerequisites

  • Search the issue tracker to check if your feature has already been mentioned or rejected in other issues.

Describe the feature

Implement cudaq::run API

template<typename T, typename … ARGS> 
std::vector<T> cudaq::run( 
     size_t shots, 
     std::function<T(ARGS…)>&& kernel, ARGS…); 

Examples (c++)

__qpu__ bool kernel(int n) {
  cudaq::qvector q(n);
  x(q[0]);
  return mz(q[0]);
}

int main() {
  auto results = cudaq::run<bool>(/*shots=*/1000, kernel, 2);
  std::cout << results << std::endl;
}

Output:
[1,1, ... 1] // 1000 results

Currently we would like to support returning the following types:

bool
int
float
double
std::vector<bool> // For measurements of qvectors (const size after opts)
structs of elements above (next version)

Examples (python)

@cudaq.kernel()
def kernel(n: int): bool
  q = cudaq.qvector(n)
  x(q[0])
  return mz(q[0])

results = cudaq.run(shots=1000, kernel, 2)
print(results)

Output:
[1,1, ... 1] // 1000 results

Currently we would like to support returning the following types:

bool
int
np.float32
np.float64
list[bool] // For measurements of qvectors (const size after opts)
structs of elements above (next version)

Tasks

  • Define log parsing API in c++ (no templates)

Idea:

struct OutputRecord {
 void* ptr;
 std::size_t byteSize;
};

class OutputParser {
 virtual std::vector<OutputRecord> parse(std::istream& s);
};
  • Implement log parsing API for backends that will use logs for output (quantum devices and remote simulator)
  • Implement log parsing API for backends that use memory for output (local simulators)
    • will need runtime QIR functions implementation
    • make sure we handle multiple and single shot scenarios
  • Implement cudaq::run API in c++
  • Implement cudaq.run API in Python
  • Implement retrieving logs from quantum backends (start with quantinuum)
  • Implement creating and retrieving logs from remote simulator server
  • Make sure quantum emulation works with new output log functionality
    • run LLVM generated from QIR on the simulator (needs runtime functions implementations)
  • Convert returns to log function calls in QIR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant