When to use jit.trace, and when to use jit.script?

After I read this toturial, which I learnt is that I should use jit.script to transfer my module into TorchScript if there are conditional expressions or other uncertainties during execution in its forward propagation.

If my comprehension is correct, then can I say that it’s OK to use jit.script any time to replace jit.trace? Since I figure no drawback of jit.script against jit.trace.

Also I cannot understand why the toturial calls somthing like jit.trace(jit.script(module)) then. Does this make any sense? Can’t I just use jit.script(module) alone?

Yeah, jit.trace is of limited use. It can process some python code without requiring modifications (type annotations, etc.), but at the same time non-trivial code may fail to work correctly, if any non-tensor non-constants get captured.

No, this doesn’t make sense. Note that jit.script(module) returns a new module, old one remains in uncompiled state.