Open
Description
Issue Description
<--! Insert a short description of the bug here, along with what you expected the behavior to be. -->
JIT is still a long way to go in torch, naive torch is much much slower than jax in TC use cases.
How to Reproduce
def vqe(L, d):
K = tc.backend
def loss(param):
c = tc.Circuit(L)
c.h(range(L))
for i in range(d):
c.rzz(range(L-1),range(1, L), theta=param[i, 0][:L-1])
c.rx(range(L), theta=param[i, 1])
return K.real(c.expectation_ps(z=[1, 2])+c.expectation_ps(x=[L-2]))
vgf = K.jit(K.value_and_grad(loss), jit_compile=True)
param = K.ones([d, 2, L])
time0 = time.time()
print(vgf(param)[1].shape)
time1 = time.time()
print("jitting time,", time1-time0)
for _ in range(5):
vgf(param)
time2 = time.time()
print("running time,", (time2-time1)/5)
with tc.runtime_backend("pytorch"):
vqe(14, 8)
Error Output
InternalTorchDynamoError: AttributeError: 'NoneType' object has no attribute 'make_guard'
Environment Context
<--! Please report your OS version, Python environment and version, TensorCircuit version and necessary dependent package (NumPy, TensorFlow, Jax, Jaxlib, PyTorch) version here. -->
Output of tc.about()
and tc.__version__
.
OS info: macOS-14.5-arm64-arm-64bit
Python version: 3.12.0
Numpy version: 1.26.4
Scipy version: 1.14.0
Pandas version: 2.2.2
TensorNetwork version: 0.5.0
Cotengra version: 0.6.2
TensorFlow version: 2.17.0
TensorFlow GPU: []
TensorFlow CUDA infos: {'is_cuda_build': False, 'is_rocm_build': False, 'is_tensorrt_build': False}
Jax version: 0.4.31
Jax installation doesn't support GPU
JaxLib version: 0.4.31
PyTorch version: 2.5.0
PyTorch GPU support: False
PyTorch GPUs: []
Cupy is not installed
Qiskit version: 0.46.2
Cirq version: 1.3.0
TensorCircuit version 1.0.0
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
[-]Torch 2.5 is still no good enough for its compiling module[/-][+]Torch 2.6 is still no good enough for its compiling module[/+]