Signed-off-by: ale <ale@manalejandro.com>
Este commit está contenido en:
ale
2025-10-08 05:13:41 +02:00
padre 99feacd547
commit 8caca27b22
Se han modificado 3 ficheros con 62 adiciones y 8 borrados

Ver fichero

@@ -200,6 +200,16 @@ class QuantumExecutor:
def sample(self, kernel_name: str, shots: int = 1000,
parameters: Optional[Dict] = None) -> Dict:
"""Execute quantum circuit and sample measurement results"""
if not CUDAQ_AVAILABLE:
# Mock sampling results
return {
"success": True,
"counts": {"00": shots//2, "11": shots//2},
"shots": shots,
"most_probable": "00",
"mode": "mock"
}
if kernel_name not in kernel_manager.kernels:
return {"error": f"Kernel {kernel_name} not found"}
@@ -240,6 +250,15 @@ class QuantumExecutor:
def observe(self, kernel_name: str, hamiltonian_terms: List[Dict],
shots: int = 1000, parameters: Optional[Dict] = None) -> Dict:
"""Calculate expectation value of Hamiltonian"""
if not CUDAQ_AVAILABLE:
# Mock observation result
return {
"success": True,
"expectation_value": 0.0,
"shots": shots,
"mode": "mock"
}
if kernel_name not in kernel_manager.kernels:
return {"error": f"Kernel {kernel_name} not found"}
@@ -281,6 +300,18 @@ class QuantumExecutor:
def get_state(self, kernel_name: str, parameters: Optional[Dict] = None) -> Dict:
"""Get quantum state vector"""
if not CUDAQ_AVAILABLE:
# Mock state vector
return {
"success": True,
"state_vector": [
{"real": 1.0, "imag": 0.0},
{"real": 0.0, "imag": 0.0}
],
"num_qubits": 1,
"mode": "mock"
}
if kernel_name not in kernel_manager.kernels:
return {"error": f"Kernel {kernel_name} not found"}
@@ -343,6 +374,13 @@ class QuantumExecutor:
def get_available_targets_standalone() -> Dict:
"""Standalone function to get available targets"""
if not CUDAQ_AVAILABLE:
return {
"success": True,
"targets": ["mock-cpu", "mock-gpu"],
"mode": "mock"
}
try:
targets = cudaq.get_targets()
return {"success": True, "targets": list(targets)}
@@ -363,6 +401,16 @@ def get_target_info_standalone() -> Dict:
def get_platform_info() -> Dict:
"""Get platform and hardware information"""
if not CUDAQ_AVAILABLE:
info = {
"cuda_quantum_version": "mock-0.8.0",
"available_targets": ["mock-cpu", "mock-gpu"],
"python_version": sys.version,
"platform": sys.platform,
"mode": "mock"
}
return {"success": True, "platform_info": info}
try:
info = {
"cuda_quantum_version": "0.8.0", # Would get from cudaq.__version__ if available