MCPcopy Create free account
hub / github.com/NVIDIA/cuda-quantum / dem_from_kernel

Function dem_from_kernel

python/cudaq/runtime/dem.py:25–53  ·  view source on GitHub ↗

Generate a detector error model (DEM) from a CUDA-Q kernel. Runs `kernel` under the internal `"dem"` execution context, captures the recorded circuit from the backend, and returns Stim's standard `.dem` text via `stim::DetectorErrorModel::str()`. The active CUDA-Q target is unaffect

(kernel, *args, noise_model=None)

Source from the content-addressed store, hash-verified

23
24@trace.traced
25def dem_from_kernel(kernel, *args, noise_model=None):
26 """Generate a detector error model (DEM) from a CUDA-Q kernel.
27
28 Runs `kernel` under the internal `"dem"` execution context, captures
29 the recorded circuit from the backend, and returns Stim's standard
30 `.dem` text via `stim::DetectorErrorModel::str()`. The active CUDA-Q
31 target is unaffected; the analysis simulator is an internal,
32 thread-local override.
33
34 Args:
35 kernel (:class:`Kernel`): The :class:`Kernel` to analyze.
36 *arguments: Concrete argument values forwarded to the kernel invocation.
37 noise_model (:class:`NoiseModel`, optional): Noise model layered on
38 top of any `apply_noise` ops already present in the kernel.
39
40 Returns:
41 UTF-8 string in Stim's standard `.dem` file format. Consumers
42 that need a structured DEM can parse it with
43 `stim.DetectorErrorModel(text)`.
44 """
45 _detail_check_conditionals_on_measure(kernel)
46
47 if isa_kernel_decorator(kernel):
48 decorator = kernel
49 else:
50 decorator = mk_decorator(kernel)
51 processedArgs, module = decorator.prepare_call(*args)
52 return cudaq_runtime.dem_from_kernel_impl(decorator.uniqName, module,
53 noise_model, *processedArgs)

Callers 5

mainFunction · 0.50
runCaseFunction · 0.50
runTrivialFunction · 0.50
runNoNoiseCaseFunction · 0.50
runCaseFunction · 0.50

Calls 4

isa_kernel_decoratorFunction · 0.90
mk_decoratorFunction · 0.90
prepare_callMethod · 0.80

Tested by

no test coverage detected