Solved by driazati in post #4 
              
              
                torch.jit.trace doesn’t record data flowing over Python values, they instead just get recorded as constants with respect to the inputs provided to torch.jit.trace. So it looks like for your model the batch size is being recorded into the graph and will be fixed so no other batch sizes work: 
Conside…