As I mentioned before, I will consider a “module” everything that is returned by model.modules(). They are also the only thing you can attach forward hooks to.
Some people may decide to write their models in a different way, such that model.modules() will be empty or missing pieces, as you point out. But since there is no way around it, I will accept this limitation.
Essentially I want this:
for idx, md in model.named_modules(): 
    if idx == idx_to_stop_execution_to:
        md.register_forward_hook(my_function)
_ = model(inputs)

and my_function is defined in such a way that it will save the output of that module, and then stop the forward pass of model to save time. I tried to raise an exception in my_function, but the outputs were not being correctly saved.
*** EDIT***
It turns out, the error was that I forgot to de-register the forward hooks. The code below works as intended.
for idx, md in model.named_modules(): 
    if idx == idx_to_stop_execution_to:
        md.register_forward_hook(my_function)
try: _ = model(inputs)
except CustomException: pass