Experiment - Detaching from computation graph
Problem:You have a PyTorch model training loop where you want to use intermediate tensor values for logging or further calculations without affecting the gradient computation.
Current Metrics:Training loss decreases smoothly, but memory usage is high and training slows down over time.
Issue:Not detaching intermediate tensors causes PyTorch to keep the entire computation graph, leading to high memory use and slower training.