viiccwen commented on code in PR #1257:
URL: https://github.com/apache/mahout/pull/1257#discussion_r3195833044
##########
qdp/qdp-python/benchmark/README.md:
##########
@@ -87,7 +87,7 @@ Notes:
- `--frameworks` is a comma-separated list or `all`.
Options: `mahout`, `pennylane`, `qiskit-init`, `qiskit-statevector`.
-- `--encoding-method` selects the encoding method: `amplitude` (default) or
`basis`.
+- `--encoding-method` selects the encoding method: `amplitude` (default),
`angle`, `basis`, `iqp`, or `iqp-z`.
- The latency test reports average milliseconds per vector.
- Flags:
- `--qubits`: controls vector length (`2^qubits`).
Review Comment:
Updated the benchmark README to describe the input-size formulas per
encoding method. Basis now documents the single-index input shape, while
amplitude/angle/iqp/iqp-z list their respective sample lengths. Fixed in
986683879.
##########
qdp/qdp-python/qumat_qdp/torch_ref.py:
##########
@@ -337,24 +337,30 @@ def encode(
encoding_method: str = "amplitude",
*,
device: torch.device | str | None = None,
- **kwargs: object,
+ enable_zz: bool = True,
) -> torch.Tensor:
"""Dispatch to the appropriate encoding function by method name.
Args:
data: Input tensor.
num_qubits: Number of qubits.
- encoding_method: One of ``"amplitude"``, ``"angle"``, ``"basis"``,
``"iqp"``.
+ encoding_method: One of ``"amplitude"``, ``"angle"``, ``"basis"``,
``"iqp"``, ``"iqp-z"``.
device: Target device.
- **kwargs: Extra arguments forwarded to the encoder (e.g. *enable_zz*
for IQP).
+ enable_zz: Whether IQP encoding includes ZZ interaction terms. Ignored
for
+ non-IQP encodings. ``"iqp-z"`` always forces this to ``False``.
Returns:
Complex tensor of shape ``(batch, 2**num_qubits)``.
"""
+ if encoding_method == "iqp-z":
+ return iqp_encode(data, num_qubits, device=device, enable_zz=False)
+ if encoding_method == "iqp":
+ return iqp_encode(data, num_qubits, device=device, enable_zz=enable_zz)
+
fn = _ENCODERS.get(encoding_method)
if fn is None:
raise ValueError(
f"Unknown encoding method {encoding_method!r}. "
f"Supported: {', '.join(sorted(_ENCODERS))}"
)
Review Comment:
Adjusted the torch_ref dispatcher error path so the supported-method list
includes the iqp-z special case as well. Added a regression test for the
message. Fixed in 986683879.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]