Signed-off-by: ale <ale@manalejandro.com>
Este commit está contenido en:
ale
2025-10-08 05:31:25 +02:00
padre 268914def2
commit cc6f8b733e

Ver fichero

@@ -169,19 +169,20 @@ class QuantumExecutor:
try:
# Get available targets first
available_targets = cudaq.get_targets()
available_target_names = [str(target) if hasattr(target, '__str__') else repr(target) for target in available_targets]
# Validate target exists
if target_name not in available_targets:
if target_name not in available_target_names:
# Try common fallbacks
fallback_targets = ['qpp-cpu', 'density-matrix-cpu', 'default']
for fallback in fallback_targets:
if fallback in available_targets:
if fallback in available_target_names:
print(f"WARNING - Target {target_name} not available, using {fallback}", flush=True)
cudaq.set_target(fallback, **kwargs)
self.current_target = fallback
return {"success": True, "target": fallback, "fallback": True}
return {"error": f"Invalid target name ({target_name})", "available_targets": available_targets}
return {"error": f"Invalid target name ({target_name})", "available_targets": available_target_names}
# Set the target
cudaq.set_target(target_name, **kwargs)
@@ -383,7 +384,9 @@ def get_available_targets_standalone() -> Dict:
try:
targets = cudaq.get_targets()
return {"success": True, "targets": list(targets)}
# Convert Target objects to strings for JSON serialization
target_names = [str(target) if hasattr(target, '__str__') else repr(target) for target in targets]
return {"success": True, "targets": target_names}
except Exception as e:
logger.error(f"Error getting available targets: {e}")
return {"error": str(e), "traceback": traceback.format_exc()}
@@ -391,9 +394,18 @@ def get_available_targets_standalone() -> Dict:
def get_target_info_standalone() -> Dict:
"""Standalone function to get target info"""
if not CUDAQ_AVAILABLE:
return {
"success": True,
"available_targets": ["mock-cpu", "mock-gpu"],
"mode": "mock"
}
try:
targets = cudaq.get_targets()
return {"success": True, "available_targets": list(targets)}
# Convert Target objects to strings for JSON serialization
target_names = [str(target) if hasattr(target, '__str__') else repr(target) for target in targets]
return {"success": True, "available_targets": target_names}
except Exception as e:
logger.error(f"Error getting target info: {e}")
return {"error": str(e), "traceback": traceback.format_exc()}
@@ -412,9 +424,13 @@ def get_platform_info() -> Dict:
return {"success": True, "platform_info": info}
try:
targets = cudaq.get_targets()
# Convert Target objects to strings for JSON serialization
target_names = [str(target) if hasattr(target, '__str__') else repr(target) for target in targets]
info = {
"cuda_quantum_version": "0.8.0", # Would get from cudaq.__version__ if available
"available_targets": list(cudaq.get_targets()),
"cuda_quantum_version": getattr(cudaq, '__version__', '0.8.0'),
"available_targets": target_names,
"python_version": sys.version,
"platform": sys.platform
}