[Feature Request]: Make Unitary Calculations Differentiable
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 30/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- python, tensorflow
- Lĩnh vực
- machine-learning
Hướng nghiên cứu
Bắt đầu với ví dụ đồ chơi và các điểm vào tfq.get_unitary_op() và tfq.layers.Unitary(); tái hiện LookupError khi vi phân qua phép toán unitary. Hoàn thành có nghĩa là có thể tính gradient cho một hàm có sử dụng ma trận unitary, bằng một phương pháp vi phân phù hợp.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
In the TFQ sync today there was talk of potential new features, and I wanted to suggest something that I think would be useful (to me and the larger community): making the unitary op differentiable. Currently if you try to differentiate through the unitary op (either via tfq.get_unitary_op() or tfq.layers.Unitary()) the following error is encountered: LookupError: gradient registry has no entry for: TfqCalculateUnitary. I don't know enough to say if the unitary is actually a differentiable function or if you can apply adjoint differentiation to it. However, I do know that given the nature of sampling based differentiators (e.g. parameter shift), using these techniques one could calculate the gradient for a function that involved the unitary matrix.
See below for a toy example which errors out currently:
import cirq
import sympy
import tensorflow as tf
import tensorflow_quantum as tfq
import numpy as np
params = sympy.symbols('q0:6')
qubits = [cirq.GridQubit(0, i) for i in range(2)]
circuit = cirq.Circuit()
for i in range(2):
for j in range(3):
r = np.random.uniform()
p = params[i * 3 + j]
if r < 1/3:
circuit += cirq.rx(p).on(qubits[i])
elif r < 2/3:
circuit += cirq.ry(p).on(qubits[i])
else:
circuit += cirq.rz(p).on(qubits[i])
opt = tf.keras.optimizers.Adam(lr=0.1)
target_unitary = tf.convert_to_tensor(np.identity(4), dtype=tf.complex64)
tensor_circuit = tfq.convert_to_tensor([circuit])
names = [s.name for s in params]
init = tf.Variable(initial_value=np.random.uniform(0, 2 * np.pi, (1, 6)), dtype="float32", trainable=True)
# Unitary Op
unitary_op = tfq.get_unitary_op()
with tf.GradientTape() as tape:
tape.watch(init)
unitary = unitary_op(tensor_circuit, names, init).to_tensor()
cost = tf.math.abs(tf.reduce_mean(target_unitary - unitary))
grads = tape.gradient(cost, init)
opt.apply_gradients(zip([grads], [init]))
# Unitary Layer
inputs = tf.keras.Input(shape=(), dtype=tf.dtypes.string)
unitary_layer = tfq.layers.Unitary()(inputs, symbol_names=names, symbol_values=init)
output = unitary_layer.to_tensor()
model = tf.keras.models.Model(inputs=inputs, outputs=output)
with tf.GradientTape() as tape:
cost = tf.math.abs(tf.reduce_mean(target_unitary - model(tensor_circuit)))
grads = tape.gradient(cost, model.trainable_variables)
opt.apply_gradients(zip(grads, model.trainable_variables))
- Ngôn ngữ chính
- Python
- Star
- 2.2k
- Fork
- 665
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của tensorflow/quantum
-
area/devops help wanted no QC knowledge needed priority/before-0.7.7
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
tensorflow/quantum#1082 · 1 bình luận · 1 reaction ·
-
Support Keras 3Có thể làm lại được @rosspeili đã nhận 76 ngày trước và không có pull request nào đang mở. Đang mởarea/keras help wanted skill-level/intermediate
tensorflow/quantum#1090 · 4 bình luận · 1 người được giao ·
-
Investigate support for JAXĐang mởskill-level/expert
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 30/100
tensorflow/quantum#1089 · 2 bình luận ·
-
area/core priority/after-0.7.7 skill-level/expert
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
tensorflow/quantum#1088 ·
-
Support dynamic quantum circuitsĐang mởarea/circuits priority/after-0.7.7 skill-level/expert
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
tensorflow/quantum#1087 ·
Tất cả issue của tensorflow/quantum
Issue tương tự
-
Claiming namespace `apoint`Đang mởnamespace operations
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100
EclipseFdn/open-vsx.org#13573 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
collective/icalendar#1854 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
rancher/rancher-ai-agent#412 ·
Maintainer thường phản hồi trong vòng 6 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
TUDelftGeodesy/DePSI#134 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
HenriquesLab/rxiv-maker#335 ·