Possible speed improvement
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4.8k
- Forks
- 726
- Avg merge
- 5d 21h
- Merged PRs (30d)
- 5
Description
Description
I recently noticed possible speed improvement when porting segmentation example to code-generator.
According to the docs, examples, helper functions, and tests, we are calling model.train() or model.eval() inside the process function given to the Engine.
And as per this line, I think model.train() or model.eval() gets called every iteration which I think not necessary.
To my knowledge, .train() or .eval() is only needed when changing the context (e.g. training or evaluation).
And in pytorch example, model.train() or model.eval() gets called only once when changing context (training -> evaluation, or vice versa)
Possible solution
I think we can address in the ongoing High level API development or address in the refactor of Engine design.
Workaround
For now, we can workaround by calling model.train() before every training epoch and model.eval() before every evaluation epoch.
Thanks!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at ignite/engine/engine.py#L853 and trace how the Engine process function invokes model.train() or model.eval() each iteration. Compare the segmentation example, code-generator work, documented examples, helper functions, tests, and linked PyTorch VAE example; done means avoiding unnecessary per-iteration mode changes without breaking training or evaluation behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- machine-learning, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 32/100