prefetch: Overlapping data production and model calculations

If no advance is taken, the model may wait for data to be prepared before the calculations are performed and the next batch will be repeated.

• Step by stepCollate in 1 diagram2 self-measured2 First-hand sources
Start Body
Learning objectives and first steps2 objectives 2 first fixes

Try to do it after reading

  • Timeline understanding of the upper limit of advance earnings
  • Distinguishing elements of queue capacity from sample units

Suggested first

  • Python Basic Syntax:
  • Counting and training closed

Two jobs can go on simultaneously

If no advance is taken, the model may wait for data to be prepared before the calculations are performed and the next batch will be repeated. prefetch uses backstage production and buffers to prepare the next data during the current calculation. It changes the waiting relationship, does not reduce the amount of arithmetic of decoding itself, and does not directly accelerate the network matrix multiplication.

Assuming a batch of 40 milliseconds, the model calculation would be 60 milliseconds. (a) about 100 ms per batch of complete serialization; The ideal stable flow line is limited by a slower 60 millisecond phase, which can be close to 60 milliseconds per batch at the moment of commencement and closing. If 90 milliseconds of data and 20 milliseconds for models are prepared, the desired lower limit remains 90 milliseconds, and continued expansion of the pre-cancellation queue will not allow production capacity to turn into 20 milliseconds.

The unit of queuing capacity is the Dataset element. Before batch, prefetch(2) indicated two samples; After batch, two batches are indicated. If the batch is 64, the latter can buffer 128 samples, and RAM may vary considerably. When checking configurations, the elements should be drawn from shape, after each calculation, to avoid using the same number as the same cost.

It's an average time to watch the shakes

Even if the average production is slightly faster than consumption, occasional documentation delays can drain the queue. A limited buffer can absorb short-lived fluctuations, but it cannot address the continuing supply deficit. Observation queue waits, decodes CPU, disk bandwidth and model equipment utilization rates are much more in the direction of increasing buffer alone.

The measurements also need to separate the first cold start. The first time a document is opened, a trace map is tracked and the device memory is allocated to introduce additional costs; The first batch alone could lead to an erroneous conclusion that “pre-emption is useless”. Conversely, measurements of data that are already fully stored do not represent a true remote reading of the training process.

The order of output and the semantic nature of the sample remain controlled by the water line agreed upon. Advances should not be used to mask problems where upstream feature labels are wrong or failure records are quietly skipped. If a batch parsing anomaly requires a stable sample identification, location of actual data, and not a default to swallow all errors in order to run fast.

This section is explained by the TensorFlow2 pre-position mechanism, with 40 and 60 ms of synthetic time, not the base of the aircraft. Real vomiting is also influenced by data transmission, equipment synchronization and buffer strategies, and the ideal time ratio cannot be considered an acceleration multiplier of commitments.

Serial and Waterline TimelinesOn the same axis, prepare 40 milliseconds and calculate 60 milliseconds to overlap in the current lineSerialWaterlinesGreen: prepare 40 ms Blue: calculate 60 ms time to the right
Synthetic time lines display overlapping relationships, not equipment performance tests.
90 milliseconds, calculation of 20 milliseconds, and what is the desired stabilization cycle after pre-emption?

It's about 90 milliseconds. The two phases overlap, but the swallowing remains controlled at the slowest stage.

After batch, why could prefetch(2) significantly increase memory?

The buffer unit has become a complete batch, and the two elements may contain hundreds of samples and their decoded loads.

Sources and reconciliations

Definitions, methods and interfaces are available.

  1. TensorFlow — tf.data: Build TensorFlow input pipelines
  2. TensorFlow — Better performance with tf.data

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.

← Back to the knowledge directory
Ask Max Ask about this site
Ask Max ↗

Opening the assistant…

Paper figure

Photo comments

LEAVE A NOTE

About this photograph

Connecting to the discussion board…

    Comments become public after moderation. You can delete your own comments from this browser.
    No email is required. Clearing cookies prevents this browser from claiming earlier comments.

    MAX WANG / INDEX

    Find something

    Enter a keyword, or explore the directory below.