GPUFlightAll performance labs

A Harmless contiguous() Call Copied My Whole Tensor

Experimental performance lab. Correctness is graded; speed and memory observations await GPU calibration. A transpose changes shape/strides without copying data.

Sign in to run this lab. GPU availability and credits are shown in the app.

Languages: PyTorch

Lesson

A transpose changes shape/strides without copying data. The starter then materializes the whole view before a reduction that can consume strides. Remove only that unnecessary materialization and preserve the output. Compare copy/clone operators, allocation peaks, input/view strides and latency. COPY_OPERATOR_EVIDENCE is a separate operator-profiler capture; GPU transfer evidence remains in Trace. Some downstream operators genuinely require or benefit from contiguous data, so this result does not justify deleting every contiguous call.

Measurement contract: the real read-only driver defines WORKLOAD. Two warmups precede five paired trials with alternating baseline/candidate order. Each trial uses fresh deterministic inputs. Synchronized host time includes solve and completion, excludes input construction and reference verification. METRICS reports every sample, median and IQR; memory includes persistent buffers and allocator state. One additional solve is isolated in judged for Trace. No speedup is promised. Run the unchanged starter first.

What you will learn

  • Identify the bottleneck from the appropriate evidence.
  • Preserve the output contract on fresh inputs.
  • Compare paired measurements and numerical error.

Starter code

    return baseline(case)

Sign in to run