Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Torch 2.6 is still no good enough for its compiling module #4

Open
refraction-ray opened this issue Oct 22, 2024 · 0 comments
Open
Labels
bug Something isn't working

Comments

@refraction-ray
Copy link
Member

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
@refraction-ray refraction-ray added the bug Something isn't working label Oct 22, 2024
@refraction-ray refraction-ray changed the title Torch 2.5 is still no good enough for its compiling module Torch 2.6 is still no good enough for its compiling module Feb 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant