Sharing parameters of multiple traces

Is it possible to share parameters of multiple JIT traces? I have a module that has two methods that I’d like to call from C++. Both methods touch the same hierarchy of submodules of the module, but in different ways (e.g. different order). I also need to optimize the parameters in C++, so the parameters will change gradually and both methods need to see the latest values.

My understanding is that if I trace each method (in 1.1), I will obtain two ScriptModule objects, each having its own copy of the parameters. It is not clear to me if it is possible to share the parameters somehow.

Looking at the docs of 1.2 (1.2.0a0+84c2c89), it seems one can trace multiple methods of one module. Will the parameters be shared correctly?

Finally, since the submodules are hierarchical, will parameters() on the module return all parameters touched by the traces?

Will the parameters be shared correctly?

Yes, parameters should be shared across module’s methods.

In this test, for example, conv.weight is shared by both forward and weighted_kernel_sum.

Finally, since the submodules are hierarchical, will parameters() on the module return all parameters touched by the traces

Yes, that should work as well, unless I’ve misunderstood the question.