Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility with gradient accumulation #426

Open
quasimik opened this issue Jan 17, 2021 · 1 comment
Open

Compatibility with gradient accumulation #426

quasimik opened this issue Jan 17, 2021 · 1 comment

Comments

@quasimik
Copy link

I'm bringing my own PyTorch training script, and I'm interested in using SM Debugger to profile function calls in my training jobs. The API Glossary states:

Step: Step means one the work done by the training job for one batch (i.e. forward and backward pass).

I assume I will have to register my module with hook.register_module(module) in the training script for SM Debugger to work at all. I further assume that SM Debugger then registers its own hooks into the module's forward() and/or backward() passes to track when a "step" happens.

However, my training script accumulates gradients from several forward() passes before running a single backward() pass.

My questions:

  1. Will this interfere with the functionality of SM Debugger?
  2. Assuming this is okay, does SM Debugger consider the forward() or the backward() pass to be one "step"?
@quasimik
Copy link
Author

After looking at the code, I think I can answer question (2) for myself.

Here, register_module() registers a function self.forward_pre_hook() on the module's forward call.

module.register_forward_pre_hook(self.forward_pre_hook)

Here, self.forward_pre_hook() increments the step count.

self._increment_step()

I'm still curious about question (1), though. Any insight is appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant