Skip to content
This repository has been archived by the owner on Dec 18, 2021. It is now read-only.

Fix issue 170 #171

Merged
merged 2 commits into from
Nov 15, 2021
Merged

Fix issue 170 #171

merged 2 commits into from
Nov 15, 2021

Conversation

GiggleLiu
Copy link
Member

This PR will fix #170 .
The previous gradient of a circuit is a vector of circuit parameter gradients. This causes the problem in #170 .
The gradient of a circuit now is a Yao Block instead of a vector type.

This solution is not yet perfect, the best return type should be Tagent{<:AbstractBlock}, because when you want to accumulate gradients, the block arithmetics does not do the right thing. As a result, you still need a patch for Zygote:

function Zygote.accum(a::AbstractBlock, b::AbstractBlock)
    dispatch(a, parameters(a) + parameters(b))
end

@codecov
Copy link

codecov bot commented Nov 15, 2021

Codecov Report

Merging #171 (e0dc9b4) into master (37aea0e) will increase coverage by 0.08%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #171      +/-   ##
==========================================
+ Coverage   81.04%   81.13%   +0.08%     
==========================================
  Files          46       46              
  Lines        2126     2136      +10     
==========================================
+ Hits         1723     1733      +10     
  Misses        403      403              
Impacted Files Coverage Δ
src/autodiff/chainrules_patch.jl 95.74% <100.00%> (+1.15%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 37aea0e...e0dc9b4. Read the comment docs.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Zygote: transposing a block yields DimensionMismatch (or missing adjoint)
2 participants