Lilith.jl icon indicating copy to clipboard operation
Lilith.jl copied to clipboard

Error when calling zoo/realnvp/main.jl

Open ngiann opened this issue 3 years ago • 12 comments

Unfortunately, I get the message:

┌ Error: Failed to find a derivative for %633 = sum##kw(%631, %632, %582)::Array{Float64,2} at position 1, current state of backpropagation saved to Yota.DEBUG_STATE[] └ @ Yota ~/.julia/packages/Yota/m7eWr/src/grad.jl:168 ERROR: Can't find differentiation rule for (Base.var"#sum##kw"())(var"%631", var"%632", var"%582") at 1 with types DataType[NamedTuple{(:dims,),Tuple{Int64}}, typeof(sum), Array{Float64,2}]) That's a bit too advanced for my knowledge to make any reasonable guess as to what the error may be.

ngiann avatar Dec 01 '20 22:12 ngiann

I also got something similar when trying to run zoo/vae/main.jl:

Epoch 1: ┌ Error: Failed to find a derivative for %138 = sum##kw(%136, %137, %133)::Array{Float64,2} at position 1, current state of backpropagation saved to Yota.DEBUG_STATE[]
└ @ Yota ~/.julia/packages/Yota/m7eWr/src/grad.jl:168

I don't understand the message but I guess it may be related to the above one.

ngiann avatar Dec 01 '20 22:12 ngiann

Hi! I just wanted to let you know that I've received notification about the issue and will look at it tomorrow evening.

For context, this kind of errors ("Can't find differentiation rule for ...") usually happens when the derivative of some function is missing. In this case the function is sum##kw(), which is Julia's internal name for sum() with keywords. I'm pretty much sure I fixed a similar issue some time ago, but I didn't re-run examples from the zoo on recent versions of the lib and the language itself.

For me to find the fix quicker, can you share the version of Julia you use and version of Lilith/Yota if it differs from the latest published?

dfdx avatar Dec 02 '20 00:12 dfdx

Hello and thanks for the fast reply. I am using the following Julia version "Version 1.5.0 (2020-08-01)". I hope what I write below makes some sense. Please bear with me using some terms the wrong way:

Though I am not particularly technically inclined, I am aware (by looking in Project.toml) that Lilith requires Julia 1.4. When I tried to install Lilith with add Lilith in package mode, I got a whole lot of incomprehensible to me errors that prevented me from installing. I guessed that this was not a big surprise at this point.

Then I thought (following some advice on a forum on a package comparability issue) that I could circumvent this by cloning Lilith.jl and using it by first activating a "local environment" using in package mode activate . . In this fashion, I managed to install Lilith and also create the structures metnioned in the example under section Usage in the readme file. For example, I can succesfully create:

Net() = Net(
    Conv2d(1, 20, 5),
    Conv2d(20, 50, 5),
    Linear(4 * 4 * 50, 500),
    Linear(500, 10)
)

This made me think that everything would work now.

Concerning the versions you need to know: after starting Julia 1.5, I do activate . . Then I use st Yota and st Lilith and get the following:

Project Lilith v0.2.0
Status `~/GITHUB/Lilith.jl/Project.toml`
  [cd998857] Yota v0.4.1

and

Project Lilith v0.2.0
No Matches in `~/GITHUB/Lilith.jl/Project.toml`

I hope my tediously verbose answer gives you the relevant bits of information you need. Thanks very much for your time.

ngiann avatar Dec 02 '20 09:12 ngiann

Ok, I've found a bug in Yota and partially fixed it, but another, more tricky issue appeared. I think I will need a few days to make sure both - RealNVP and VAE examples - work on the latest versions of Lilith and Yota, and release new versions of the libs.

(If you need it urgently, I can find a workaround, but be prepared for a deeper dive)

Also, I observe issues during installation via ] add Lilith on Julia 1.5, exactly as you described. Mine issue due to incompatible 3rd party libraries. Can you try installing Lilith again and post your specific error? Note that you don't need to do anything with the checked out version of Lilith, just activate default Julia environment and try to install the latest release:

] activate
] add Lilith

dfdx avatar Dec 02 '20 23:12 dfdx

Thanks for getting back.

After doing ] add Lilith in the default environment, I get:

ERROR: Unsatisfiable requirements detected for package Zygote [e88e6eb3]:
 Zygote [e88e6eb3] log:
 ├─possible versions are: [0.1.0, 0.2.0, 0.3.0-0.3.4, 0.4.0-0.4.22, 0.5.0-0.5.14] or uninstalled
 ├─restricted by compatibility requirements with Stheno [8188c328] to versions: [0.3.4, 0.4.1-0.4.22, 0.5.0-0.5.14]
 │ └─Stheno [8188c328] log:
 │   ├─possible versions are: [0.1.0-0.1.1, 0.2.0-0.2.1, 0.3.0-0.3.2, 0.4.0-0.4.2, 0.5.0, 0.6.0-0.6.17] or uninstalled
 │   ├─restricted to versions * by an explicit requirement, leaving only versions [0.1.0-0.1.1, 0.2.0-0.2.1, 0.3.0-0.3.2, 0.4.0-0.4.2, 0.5.0, 0.6.0-0.6.17]
 │   ├─restricted by compatibility requirements with FillArrays [1a297f60] to versions: [0.4.1-0.4.2, 0.5.0, 0.6.0-0.6.17] or uninstalled, leaving only versions: [0.4.1-0.4.2, 0.5.0, 0.6.0-0.6.17]
 │   │ └─FillArrays [1a297f60] log:
 │   │   ├─possible versions are: [0.2.0-0.2.1, 0.3.0, 0.4.0, 0.5.0, 0.6.0-0.6.4, 0.7.0-0.7.4, 0.8.0-0.8.14, 0.9.0-0.9.7, 0.10.0-0.10.1] or uninstalled
 │   │   ├─restricted to versions * by an explicit requirement, leaving only versions [0.2.0-0.2.1, 0.3.0, 0.4.0, 0.5.0, 0.6.0-0.6.4, 0.7.0-0.7.4, 0.8.0-0.8.14, 0.9.0-0.9.7, 0.10.0-0.10.1]
 │   │   ├─restricted by compatibility requirements with AbstractGPs [99985d1d] to versions: [0.7.0-0.7.4, 0.8.0-0.8.14, 0.9.0-0.9.7]
 │   │   │ └─AbstractGPs [99985d1d] log:
 │   │   │   ├─possible versions are: [0.1.0-0.1.3, 0.2.0-0.2.14] or uninstalled
 │   │   │   ├─restricted to versions * by an explicit requirement, leaving only versions [0.1.0-0.1.3, 0.2.0-0.2.14]
 │   │   │   └─restricted by compatibility requirements with FillArrays [1a297f60] to versions: 0.2.5-0.2.14 or uninstalled, leaving only versions: 0.2.5-0.2.14
 │   │   │     └─FillArrays [1a297f60] log: see above
 │   │   ├─restricted by compatibility requirements with BandedMatrices [aae01518] to versions: [0.6.4, 0.7.0-0.7.4, 0.8.0-0.8.14, 0.9.1-0.9.7, 0.10.0-0.10.1], leaving only versions: [0.7.0-0.7.4, 0.8.0-0.8.14, 0.9.1-0.9.7]
 │   │   │ └─BandedMatrices [aae01518] log:
 │   │   │   ├─possible versions are: [0.5.1-0.5.2, 0.6.0, 0.7.0-0.7.2, 0.8.0-0.8.2, 0.9.0-0.9.4, 0.10.0-0.10.1, 0.11.0-0.11.1, 0.12.0-0.12.4, 0.13.0-0.13.2, 0.14.0-0.14.3, 0.15.0-0.15.25] or uninstalled
 │   │   │   ├─restricted to versions * by an explicit requirement, leaving only versions [0.5.1-0.5.2, 0.6.0, 0.7.0-0.7.2, 0.8.0-0.8.2, 0.9.0-0.9.4, 0.10.0-0.10.1, 0.11.0-0.11.1, 0.12.0-0.12.4, 0.13.0-0.13.2, 0.14.0-0.14.3, 0.15.0-0.15.25]
 │   │   │   ├─restricted by compatibility requirements with FillArrays [1a297f60] to versions: [0.11.0-0.11.1, 0.12.0-0.12.4, 0.13.0-0.13.2, 0.14.0-0.14.3, 0.15.0-0.15.25] or uninstalled, leaving only versions: [0.11.0-0.11.1, 0.12.0-0.12.4, 0.13.0-0.13.2, 0.14.0-0.14.3, 0.15.0-0.15.25]
 │   │   │   │ └─FillArrays [1a297f60] log: see above
 │   │   │   └─restricted by compatibility requirements with FillArrays [1a297f60] to versions: 0.15.16-0.15.25 or uninstalled, leaving only versions: 0.15.16-0.15.25
 │   │   │     └─FillArrays [1a297f60] log: see above
 │   │   └─restricted by compatibility requirements with Distributions [31c24e10] to versions: 0.9.0-0.9.7, leaving only versions: 0.9.1-0.9.7
 │   │     └─Distributions [31c24e10] log:
 │   │       ├─possible versions are: [0.16.0-0.16.4, 0.17.0, 0.18.0, 0.19.1-0.19.2, 0.20.0, 0.21.0-0.21.3, 0.21.5-0.21.12, 0.22.0-0.22.6, 0.23.0-0.23.12, 0.24.0-0.24.6] or uninstalled
 │   │       ├─restricted to versions * by an explicit requirement, leaving only versions [0.16.0-0.16.4, 0.17.0, 0.18.0, 0.19.1-0.19.2, 0.20.0, 0.21.0-0.21.3, 0.21.5-0.21.12, 0.22.0-0.22.6, 0.23.0-0.23.12, 0.24.0-0.24.6]
 │   │       ├─restricted by compatibility requirements with Bootstrap [e28b5b4c] to versions: [0.16.0-0.16.4, 0.17.0, 0.18.0, 0.19.1-0.19.2, 0.20.0, 0.21.0-0.21.3, 0.21.5-0.21.12, 0.22.0-0.22.6, 0.23.0-0.23.12]
 │   │       │ └─Bootstrap [e28b5b4c] log:
 │   │       │   ├─possible versions are: [2.0.0-2.0.1, 2.1.0, 2.2.0] or uninstalled
 │   │       │   ├─restricted to versions * by an explicit requirement, leaving only versions [2.0.0-2.0.1, 2.1.0, 2.2.0]
 │   │       │   └─restricted by compatibility requirements with StatsModels [3eaba693] to versions: 2.2.0 or uninstalled, leaving only versions: 2.2.0
 │   │       │     └─StatsModels [3eaba693] log:
 │   │       │       ├─possible versions are: [0.3.0-0.3.1, 0.4.0, 0.5.0, 0.6.0-0.6.15] or uninstalled
 │   │       │       ├─restricted by compatibility requirements with Bootstrap [e28b5b4c] to versions: [0.3.0-0.3.1, 0.4.0, 0.5.0, 0.6.0-0.6.15]
 │   │       │       │ └─Bootstrap [e28b5b4c] log: see above
 │   │       │       └─restricted by compatibility requirements with Compat [34da2185] to versions: 0.6.0-0.6.15 or uninstalled, leaving only versions: 0.6.0-0.6.15
 │   │       │         └─Compat [34da2185] log:
 │   │       │           ├─possible versions are: [1.0.0-1.0.1, 1.1.0, 1.2.0, 1.3.0, 1.4.0, 1.5.0-1.5.1, 2.0.0, 2.1.0, 2.2.0-2.2.1, 3.0.0, 3.1.0, 3.2.0, 3.3.0-3.3.1, 3.4.0, 3.5.0, 3.6.0, 3.7.0, 3.8.0, 3.9.0-3.9.1, 3.10.0, 3.11.0, 3.12.0, 3.13.0, 3.14.0, 3.15.0, 3.16.0, 3.17.0, 3.18.0, 3.19.0, 3.20.0, 3.21.0, 3.22.0, 3.23.0] or uninstalled
 │   │       │           ├─restricted by compatibility requirements with BlackBoxOptim [a134a8b2] to versions: [1.0.0-1.0.1, 1.1.0, 1.2.0, 1.3.0, 1.4.0, 1.5.0-1.5.1, 2.0.0, 2.1.0, 2.2.0-2.2.1, 3.0.0, 3.1.0, 3.2.0, 3.3.0-3.3.1, 3.4.0, 3.5.0, 3.6.0, 3.7.0, 3.8.0, 3.9.0-3.9.1, 3.10.0, 3.11.0, 3.12.0, 3.13.0, 3.14.0, 3.15.0, 3.16.0, 3.17.0, 3.18.0, 3.19.0, 3.20.0, 3.21.0, 3.22.0, 3.23.0]
 │   │       │           │ └─BlackBoxOptim [a134a8b2] log:
 │   │       │           │   ├─possible versions are: [0.4.0, 0.5.0] or uninstalled
 │   │       │           │   ├─restricted to versions * by an explicit requirement, leaving only versions [0.4.0, 0.5.0]
 │   │       │           │   └─restricted by compatibility requirements with Compat [34da2185] to versions: 0.5.0 or uninstalled, leaving only versions: 0.5.0
 │   │       │           │     └─Compat [34da2185] log: see above
 │   │       │           └─restricted by compatibility requirements with Optim [429524aa] to versions: [3.2.0, 3.3.0-3.3.1, 3.4.0, 3.5.0, 3.6.0, 3.7.0, 3.8.0, 3.9.0-3.9.1, 3.10.0, 3.11.0, 3.12.0, 3.13.0, 3.14.0, 3.15.0, 3.16.0, 3.17.0, 3.18.0, 3.19.0, 3.20.0, 3.21.0, 3.22.0, 3.23.0]
 │   │       │             └─Optim [429524aa] log:
 │   │       │               ├─possible versions are: [0.15.3, 0.16.0, 0.17.0-0.17.2, 0.18.0-0.18.1, 0.19.0-0.19.7, 0.20.0-0.20.6, 0.21.0, 0.22.0, 1.0.0, 1.1.0, 1.2.0] or uninstalled
 │   │       │               ├─restricted to versions * by an explicit requirement, leaving only versions [0.15.3, 0.16.0, 0.17.0-0.17.2, 0.18.0-0.18.1, 0.19.0-0.19.7, 0.20.0-0.20.6, 0.21.0, 0.22.0, 1.0.0, 1.1.0, 1.2.0]
 │   │       │               └─restricted by compatibility requirements with ApproximateVI [e67a2193] to versions: 1.2.0
 │   │       │                 └─ApproximateVI [e67a2193] log:
 │   │       │                   ├─possible versions are: 0.1.0-0.1.4 or uninstalled
 │   │       │                   └─restricted to versions * by an explicit requirement, leaving only versions 0.1.0-0.1.4
 │   │       ├─restricted by compatibility requirements with AbstractGPs [99985d1d] to versions: [0.19.1-0.19.2, 0.20.0, 0.21.0-0.21.3, 0.21.5-0.21.12, 0.22.0-0.22.6, 0.23.0-0.23.12, 0.24.0-0.24.6], leaving only versions: [0.19.1-0.19.2, 0.20.0, 0.21.0-0.21.3, 0.21.5-0.21.12, 0.22.0-0.22.6, 0.23.0-0.23.12]
 │   │       │ └─AbstractGPs [99985d1d] log: see above
 │   │       └─restricted by compatibility requirements with ApproximateVI [e67a2193] to versions: [0.23.12, 0.24.0-0.24.6], leaving only versions: 0.23.12
 │   │         └─ApproximateVI [e67a2193] log: see above
 │   ├─restricted by compatibility requirements with Distributions [31c24e10] to versions: 0.6.2-0.6.17 or uninstalled, leaving only versions: 0.6.2-0.6.17
 │   │ └─Distributions [31c24e10] log: see above
 │   └─restricted by compatibility requirements with FillArrays [1a297f60] to versions: [0.4.2, 0.5.0, 0.6.9-0.6.17] or uninstalled, leaving only versions: 0.6.9-0.6.17
 │     └─FillArrays [1a297f60] log: see above
 ├─restricted by compatibility requirements with FillArrays [1a297f60] to versions: [0.1.0, 0.2.0, 0.3.0-0.3.1, 0.5.5-0.5.14] or uninstalled, leaving only versions: 0.5.5-0.5.14
 │ └─FillArrays [1a297f60] log: see above
 └─restricted by compatibility requirements with NNlib [872c559c] to versions: [0.3.0-0.3.4, 0.4.0-0.4.22] or uninstalled — no versions left
   └─NNlib [872c559c] log:
     ├─possible versions are: [0.3.2, 0.4.0-0.4.3, 0.5.0, 0.6.0-0.6.6, 0.7.0-0.7.7] or uninstalled
     └─restricted by compatibility requirements with Lilith [94c2ca8e] to versions: 0.6.0-0.6.6
       └─Lilith [94c2ca8e] log:
         ├─possible versions are: [0.1.0, 0.2.0] or uninstalled
         ├─restricted to versions * by an explicit requirement, leaving only versions [0.1.0, 0.2.0]
         └─restricted by compatibility requirements with Distributions [31c24e10] to versions: 0.2.0 or uninstalled, leaving only versions: 0.2.0
           └─Distributions [31c24e10] log: see above

These errors look quite strange to me as they seem to concern packages that are not (directly) required by Lilith. Also, package Zygote which is mentioned at the top, is not even installed on my Julia environment (I double checked whether Zygote is installed). Even weirder to me, a package of my own called ApproximateVI, which can't have nothing to do with all this, appears in the errors.

(If you need it urgently, I can find a workaround, but be prepared for a deeper dive)

I can wait, there is no rush whatsoever. I randomly encountered Lilith and I like the clean style of it and I am considering to use it for research purposes if possible. Many thanks.

ngiann avatar Dec 03 '20 08:12 ngiann

Yeah, logs of unsatisfiable requirements look a bit messy for me too, but can be decoded to some degree. Here's the shortened version of your log:

ERROR: Unsatisfiable requirements detected for package Zygote [e88e6eb3]:
 Zygote [e88e6eb3] log:
 ├─possible versions are: [0.1.0, 0.2.0, 0.3.0-0.3.4, 0.4.0-0.4.22, 0.5.0-0.5.14] or uninstalled
 ├─restricted by compatibility requirements with Stheno [8188c328] to versions: [0.3.4, 0.4.1-0.4.22, 0.5.0-0.5.14]
 ├─restricted by compatibility requirements with FillArrays [1a297f60] to versions: [0.1.0, 0.2.0, 0.3.0-0.3.1, 0.5.5-0.5.14] or uninstalled, leaving only versions: 0.5.5-0.5.14
 └─restricted by compatibility requirements with NNlib [872c559c] to versions: [0.3.0-0.3.4, 0.4.0-0.4.22] or uninstalled — no versions left
   └─NNlib [872c559c] log:
     ├─possible versions are: [0.3.2, 0.4.0-0.4.3, 0.5.0, 0.6.0-0.6.6, 0.7.0-0.7.7] or uninstalled
     └─restricted by compatibility requirements with Lilith [94c2ca8e] to versions: 0.6.0-0.6.6

Which tell us that Zygote:

  • is required by Stheno, which limits Zygote versions to [0.3.4, 0.4.1-0.4.22, 0.5.0-0.5.14]
  • requires FillArrays, which further restricts versions to 0.5.5-0.5.14
  • requires NNlib of specific versions, which restricts Zygote itself to, which leaves no versions compatible with all previous requirements

Lilith has restricts NNlib to versions 0.6.0-0.6.6 because previously I already had issues with it caused by low backward compatibility, which contradicts Lilith's philosophy. But the world moves forward, so I'll try to update Lilith's version of NNlib too.

As a workaround, remember that you can always create a new project-specific environment independent of all the packages in your default environment, mitigating some of your issues. Yet, I hope it will not be needed when I release updated versions of Yota and Lilith.

dfdx avatar Dec 03 '20 23:12 dfdx

By the way, I'm currently in the process of renaming Lilith to Avalon. Same package, same guarantees, just another name which easier to type and pronounce (you won't believe how many times I misspelled "Lilith" myself).

dfdx avatar Dec 03 '20 23:12 dfdx

Thanks for taking the time to explain the problem with the unwieldy requirements, I understand it now.

By the way, I'm currently in the process of renaming Lilith to Avalon. Same package, same guarantees, just another name which easier to type and pronounce (you won't believe how many times I misspelled "Lilith" myself).

I thought Lilith was great (had to google to find its meaning). How about Liliput? I suppose it's equally difficult to spell but befitting for a package that packs a lot in a tight way. But you must have thought of that already.

Looking forward to Avalon.

ngiann avatar Dec 04 '20 08:12 ngiann

A funny fact about Lilith.jl is that it's named not after Lilith from the Bible, but instead after a much weirder creature - I was in a pretty bad mood when though about it :)

Similarly, Avalon is a reference to the film of the same name by Mamoru Oshii (creator of the Ghost in the Shell, among others). So Lilith -> Avalon is a kind of sci-fi -> sci-fi name change.

On the other hand, isn't Guilliver en Liliput a sci-fi book? Hmm...


Meanwhile, although Avalon is still waiting for registration, its master branch already includes all necessary fixes and updated dependencies, so don't hesitate to clone and try it out!

dfdx avatar Dec 06 '20 19:12 dfdx

Hey, thanks for the apocryphal background on the names ;)


I will clone Avalon later tonight and try it out. Thanks for all your time. Most likely I will be back here with more questions... and maybe naming suggestions ;)

ngiann avatar Dec 06 '20 20:12 ngiann

Actually, instead of here, I should have said that I will be continuing with questions on the Avalon pages...

ngiann avatar Dec 06 '20 20:12 ngiann

Just tried Avalon: realnvp and vae work great, thanks!

ngiann avatar Dec 07 '20 08:12 ngiann