Logging¶
The Python interface for Fulqrum has verbose logging functionality built in. Here we show an example of logging inside the Jupyter notebook from which this docuement is generated.
[1]:
import fulqrum as fq
Formatting the logger¶
Here we show how to format the logger for useful output. Importantly, when using Jupyter notebooks we need to include force=True in the config in order to have the logs show up in the cell output
[2]:
import logging
logging.basicConfig(
level=logging.INFO,
force=True,
format="%(asctime)s - %(levelname)s - %(name)s - %(message)s",
)
Small example¶
Here we load a molecule, transform it, build a subspace, and finally put them all together in a SubspaceHamiltonian. Having set the logging config above, the ouput from each logger entry will be displayed in the cell output.
[3]:
fop = fq.FermionicOperator.from_json("./data/lih.json")
op = fop.extended_jw_transformation()
counts = []
for kk in range(2**op.width):
counts.append(bin(kk)[2:].zfill(op.width))
S = fq.Subspace([counts])
Hsub = fq.SubspaceHamiltonian(op, S)
2026-08-20 17:43:19,387 - INFO - fulqrum.core.fermi_operator - Extended JW time: 2.099 ms
2026-08-20 17:43:19,389 - INFO - fulqrum.core.subspace - Initializing Subspace
2026-08-20 17:43:19,390 - INFO - fulqrum.core.subspace - Full subspace bit-strings
2026-08-20 17:43:19,390 - INFO - fulqrum.core.subspace - Subspace size: 4096
2026-08-20 17:43:19,391 - INFO - fulqrum.core.subspace - Number of bits: 12
2026-08-20 17:43:19,391 - INFO - fulqrum.core.subspace - Using all bitset blocks: True
2026-08-20 17:43:19,392 - INFO - fulqrum.core.subspace - Reserve multiplier: 2
2026-08-20 17:43:19,393 - INFO - fulqrum.core.subspace - Subspace total init time: 3.342 ms
2026-08-20 17:43:19,394 - INFO - fulqrum.core.linear_operator - Initializing SubspaceHamiltonian
2026-08-20 17:43:19,394 - INFO - fulqrum.core.linear_operator - Number of qubits: 12
2026-08-20 17:43:19,396 - INFO - fulqrum.core.linear_operator - Num. diagonal terms 78
2026-08-20 17:43:19,396 - INFO - fulqrum.core.linear_operator - Num. off-diagonal terms 552
2026-08-20 17:43:19,397 - INFO - fulqrum.core.qubit_operator - Term grouping time: 0.225 ms
2026-08-20 17:43:19,397 - INFO - fulqrum.core.linear_operator - Term grouping time: 0.875 ms
2026-08-20 17:43:19,398 - INFO - fulqrum.core.qubit_operator - Starting ladder int grouping, ladder_width = 2
2026-08-20 17:43:19,398 - INFO - fulqrum.core.qubit_operator - Ladder int grouping time: 0.141 ms
2026-08-20 17:43:19,399 - INFO - fulqrum.core.linear_operator - Num. off-diagonal groups: 83
2026-08-20 17:43:19,399 - INFO - fulqrum.core.spmv - Initializing FulqrumSpMV
2026-08-20 17:43:19,399 - INFO - fulqrum.core.spmv - Operator is real
2026-08-20 17:43:19,400 - INFO - fulqrum.core.spmv - Operator type = 2
2026-08-20 17:43:19,400 - INFO - fulqrum.core.spmv - FulqrumSpMV total init time: 0.864 ms
2026-08-20 17:43:19,401 - INFO - fulqrum.core.linear_operator - SubspaceHamiltonian total init time: 6.412 ms
[ ]: