Device timer: Submission completion is not the same as calculation completion
The GPU operation is often submitted by CPU to be performed in a step after the device queue.
Learning objectives and first steps2 objectives 2 first fixes
Try to do it after reading
- Identification of time traps for atrophy devices
- Separate cold start and stabilize toss
Suggested first
- Target function to oversee learning
- Basic training and validation cycle
CPU sees the function returned and the device may still be working
The GPU operation is often submitted by CPU to be performed in a step after the device queue. If only a CPU clock is used for one call, it may be mainly to submit expenses rather than actual calculations. To compare the time of implementation of the equipment, the appropriate device event should be used or synchronized at a clear boundary, and indicate whether data transmission is included.
Assuming that CPU submits a task at 0.2 milliseconds, GPU takes 8 milliseconds to perform. The normal function immediately ceases to run CPU on return and may report close to 0.2 ms; The full 8 millisecond submission and synchronization costs will be nearing completion of the equipment. Both are real measurements, but the answers are different.
Each calculation is synchronized to facilitate positioning, but it can destroy normal flow lines and overlap, and the total ingestion obtained does not mean production operations. The diagnostic phase can be partially synchronized with problems and performance comparisons should, to the extent possible, retain the target execution modality and use consistent measurement protocols at batch or iterative boundaries.
First call should be a separate column
Chart compilation, kernel selection, memory allocation and cache creation slow down the first steps. It is difficult to judge whether the proceeds are derived from algorithms or cold starters if measured only once. Preheat can be used before multiple stabilizations can be measured, and the first delay can be reported separately. Interactive services focus on cold start-up and long-term training on sustained infestation, and it is not appropriate to give one average.
Profiler will result in extra costs. Limited windows and clear phase tags should be used to identify the proportion of data waiting, transmitting, forward, reverse and optimizers before going deeper into hot spots. When you see a function that is always time-consuming, you also distinguish between the time you spend on your own and the time you call on your sub-sections, and avoid repeating the suming of the nested areas.
The unit of vomiting must also be clear. The number of batch per second is not equal to the number of samples per second, and the number of samples per second is not equal to the number of token per second valid at the time of the change in length. For sequence tasks, a ratio of effective workload to padding should be recorded at the same time, otherwise the “fast” processing of less effective information may be reduced.
This section is subject to PyTorch 2 CUDA and Profiler Semantics state that 0.2 and 8 milliseconds are synthetic times and not home-grown measurements.
CPU in 0.2 milliseconds. Can you conclude that GPU is only 0.2 milliseconds?
Can't. Apologized submissions may have returned and equipment is required to complete the border or equipment incident to measure actual implementation.
Why can't the total time taken for each nested event be added together?
The parent event contains a sub-event and the equipment tasks may overlap, and simple additions may be counted repeatedly, distinguishing between time spent and time included.
Sources and reconciliations
Definitions, methods and interfaces are available.
Figures and calculations are reorganized according to this chapter. Mathematical measurements, framework operations and real business effects are described separately in the body of the text.