qpandalite.task.originq_dummy package#
Submodules#
qpandalite.task.originq_dummy.task module#
OriginQ dummy backend — local simulator that emulates the Origin Quantum Cloud API.
This module provides the same public interface as origin_qcloud but
executes circuits on a local simulator instead of a real quantum device.
It is primarily intended for development, testing, and debugging without
consuming real quantum computing resources.
Noise simulation is supported through ErrorLoader configurations passed
via **kwargs (generic_error, gatetype_error,
gate_specific_error, readout_error).
Requires the QPandaLiteCpp C++ extension for the underlying simulator.
- Public API:
submit_task — Submit circuit(s) for simulated execution.
query_by_taskid — Retrieve simulated results by task ID.
query_by_taskid_sync — Blocking version of
query_by_taskid.query_all_tasks — Query all locally recorded dummy tasks.
- class qpandalite.task.originq_dummy.task.DummyCacheContainer[源代码]
基类:
objectIn-memory and on-disk cache for dummy simulation results.
Stores results keyed by task ID, optionally persisting them to a JSONL file for later retrieval across sessions.
- clear_dummy_cache()[源代码]
Remove all cached results from memory.
- load_dummy_cache(taskid)[源代码]
Retrieve a cached result by task ID.
Checks in-memory cache first, then falls back to the on-disk JSONL file (if
dummy_pathis set).- 参数:
taskid (str) -- Task identifier to look up.
- 返回:
The cached result, or
Noneif not found.- 返回类型:
dict or None
- save_dummy_cache(extra_savepath)[源代码]
Dump all cached results to a timestamped JSONL file.
- 参数:
extra_savepath (os.PathLike) -- Output directory.
- write_dummy_cache(taskid, result_body)[源代码]
Store a result body under the given task ID.
- 参数:
taskid (str) -- Unique task identifier.
result_body (dict) -- Result payload to cache.
- 抛出:
ValueError -- If taskid already exists in the cache.
- qpandalite.task.originq_dummy.task.clear_dummy()[源代码]
Clear all cached dummy simulation results from memory.
- qpandalite.task.originq_dummy.task.query_all_task(savepath=None, url=None)[源代码]
Deprecated!! Use query_all_tasks instead
- qpandalite.task.originq_dummy.task.query_all_tasks(savepath=None, url=None)[源代码]
Query all task info in the savepath. If you only want to query from taskid, then you can use query_by_taskid instead.
- 参数:
url (str, optional) -- The url for querying. Defaults to default_query_url.
savepath (PathLikeObject(str, pathlib.Path, etc...), optional) -- The savepath for loading the online info. Defaults to None.
- 返回:
Two integers (finished task count, all task count)
- 返回类型:
tuple[int,int]
- qpandalite.task.originq_dummy.task.query_by_taskid(taskid, url=None)[源代码]
Query circuit status by taskid (Async). This function will return without waiting.
- 参数:
taskid (str) -- The taskid.
- 抛出:
ValueError -- Taskid invalid.
ValueError -- URL invalid.
RuntimeError -- Error when querying.
- 返回:
- The status and the result
status : success | failed | running result (when success): List[Dict[str,list]] result (when failed): {'errcode': str, 'errinfo': str} result (when running): N/A
- 返回类型:
Dict[str, dict]
- qpandalite.task.originq_dummy.task.query_by_taskid_sync(taskid, interval=2.0, timeout=60.0, retry=0, url=None)[源代码]
Query circuit status by taskid (synchronous version), it will wait until the task finished.
- 参数:
taskid (str) -- The taskid.
interval (float) -- Interval time between two queries. (in seconds)
timeout (float) -- Interval time between two queries. (in seconds)
retry (int)
- 抛出:
RuntimeError -- Taskid invalid.
RuntimeError -- URL invalid.
TimeoutError -- Timeout reached
- 返回:
- The status and the result
status : success | failed | running result (when success): List[Dict[str,list]] result (when failed): {'errcode': str, 'errinfo': str} result (when running): N/A
- 返回类型:
Dict[str, dict]
- qpandalite.task.originq_dummy.task.save_dummy_cache(extra_savepath)[源代码]
Export the current in-memory dummy cache to a file.
- 参数:
extra_savepath (os.PathLike) -- Output directory.
- qpandalite.task.originq_dummy.task.set_dummy_path(dummy_path)[源代码]
Set the on-disk storage path for dummy simulation results.
- 参数:
dummy_path (os.PathLike) -- Directory for persisting dummy results.
- qpandalite.task.originq_dummy.task.submit_task(circuit, task_name=None, tasktype=None, chip_id=None, shots=1000, circuit_optimize=True, measurement_amend=False, auto_mapping=False, specified_block=None, savepath=PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/qpanda-lite/checkouts/stable/docs/online_info'), url=None, **kwargs)[源代码]
Submit circuit(s) for dummy (simulated) execution.
Accepts a single OriginIR circuit string or a list thereof. The circuits are simulated locally using the built-in simulator and the results are cached for later retrieval via
query_by_taskid.- 参数:
circuit (Union[str, List[str]]) -- One or more OriginIR circuit strings.
task_name (str, optional) -- Human-readable task name.
tasktype -- Ignored (dummy parameter kept for API compatibility).
chip_id -- Ignored (dummy parameter).
shots (int, optional) -- Number of shots. Ignored — the simulator returns probabilities directly.
circuit_optimize (bool, optional) -- Ignored (dummy parameter).
measurement_amend (bool, optional) -- Ignored (dummy parameter).
auto_mapping (bool, optional) -- Whether to use automatic qubit mapping in the simulator.
specified_block -- Ignored (dummy parameter).
savepath (os.PathLike, optional) -- Directory for local task records.
url -- Ignored (dummy parameter).
**kwargs -- Noise parameters forwarded to the simulator.
- 返回:
The task ID assigned to this submission.
- 返回类型:
str
- 抛出:
ValueError -- If circuit is not a
strorlistofstr.
Module contents#
OriginQ dummy backend — local simulator emulating the Origin Quantum Cloud.