ITensor / ITensor/ITensorMPS.jl

[ITensors] [BUG] logdot and lognorm are not compatible with AD due to try/catch

Open
#77 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Julia
Stars
85
Forks
27
Avg merge
22m
Merged PRs (30d)
1

Description

Description of bug

Due to try/catch in lognorm and logdot, they are not supported by AD.

Minimal code demonstrating the bug or unexpected behavior

Minimal runnable code

l1 = x -> logdot(x, b)
l2 = x -> lognorm(x, b)
l3 = x -> norm(x, b)
inds = [Index(2) for _ in 1:10]
a = randomMPS(inds)
b = randomMPS(inds)
l1'(a)
l2'(a)
l3'(a)

Expected output or behavior

Return a valid gradient.

Actual output or behavior

Output of minimal runnable code

Compiling Tuple{ITensors.var"##_log_or_not_dot#663", Bool, typeof(ITensors._log_or_not_dot), MPS, MPS, Bool}: try/catch is not supported.

Version information

  • Output from versioninfo():
julia> versioninfo()
Julia Version 1.8.2
Commit 36034abf260 (2022-09-29 15:21 UTC)
Platform Info:
  OS: macOS (arm64-apple-darwin21.3.0)
  CPU: 10 × Apple M1 Max
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-13.0.1 (ORCJIT, apple-m1)
  Threads: 1 on 8 virtual cores
  • Output from using Pkg; Pkg.status("ITensors"):
julia> using Pkg; Pkg.status("ITensors")
Status `~/.julia/environments/v1.8/Project.toml`
  [9136182c] ITensors v0.3.20

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the Julia snippet with ITensors v0.3.20, then inspect the logdot and lognorm implementation around _log_or_not_dot, named in the compiler error. Confirm that automatic differentiation returns valid gradients and add a regression test covering both functions.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.