question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Recursive instantiation

See original GitHub issue

this would go well with a change to the config definition of an instantiated object:

Current

model:
  cls: foo.bar.ResNet
  params:
    num_layers: 50

New

model:
  _target_: model.ResNet
  num_layers: 50

Once this is implemented, we can describe recursive instantiation like:

trainer:
  _target_: trainer.Trainer
  batch_size: 32
  model:
    _target_: model.ResNet
    num_layers: 50

An remaining open question is how to support passthrough for nested objects.

Currently, passthrough can override individual values:

trainer = instantiate(cfg.trainer, batch_size=64)

a possible approach is for nested objects is to use a dictionary:

trainer = instantiate(cfg.trainer, batch_size=64, overrides={"trainer.model.num_layers": 50})

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:19
  • Comments:9 (8 by maintainers)

github_iconTop GitHub Comments

13reactions
omrycommented, Sep 23, 2020

This is coming in Hydra 1.1. I have a question for people who liked this issue (indicating that they would like to have this supported):

I would like to make recursive instantiation the default, but this is a breaking change for people that are actually interested in it because right now they are getting the nested config as a config and they need to manually call instantiate on it. Assuming that there will be an alternative way to instantiate non recursively, is such a breaking change acceptable to folks here?

Like this comment to indicate yes and dislike it to indicate no. Feel free to followup with a discussion.

6reactions
omrycommented, Sep 28, 2020

This is now in Hydra master branch. Feedback welcome.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is recursive instantiation possible in Verilog? - Stack Overflow
We need a parameterizable module with N inputs. Inside the module, if N is greater than 2, we instantiate 2 copies of the...
Read more >
Recursive instantiation? - Google Groups
I'm trying to create a library of parametrizable components. I'm looking at a priority encoder. I found some code on the web that...
Read more >
Recursive instantiation: a synthesis no no?
Hi, What is expected synthesizability of recursively generated instantiation (see below for trivial test case) Is this explicitely prohibited by Verilog ...
Read more >
illegal recursive module instantiation of %s" errors
This error occurs if a module attempts to create an instance of itself within the definition (module/endmodule keyword pair of the module). WHAT ......
Read more >
Error: "illegal recursive design instantiation" for a well-defined ...
Error: "illegal recursive design instantiation" for a well-defined recursive popcnt module. Elaborates just fine, but throws this error when ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found