InterviewStack.io LogoInterviewStack.io

TensorFlow/PyTorch Framework Fundamentals Questions

Practical knowledge of a major deep learning framework. Includes understanding tensors, operations, building neural network layers, constructing models, and training loops. Ability to read and modify existing code in these frameworks. Knowledge of how to work with pre-built layers and models.

MediumTechnical
39 practiced
Describe how to convert a PyTorch model to TorchScript using torch.jit.trace and torch.jit.script. Provide code examples for both approaches, explain differences, and give examples of failures (e.g., data-dependent control flow) where scripting is required instead of tracing.
HardTechnical
48 practiced
Outline how to implement pipeline parallelism for a very large model using torch.distributed.rpc or torch.distributed.pipeline.sync. Describe how to partition the model across worker ranks, schedule forward and backward passes, manage micro-batches to keep the pipeline filled, handle parameter synchronization and checkpointing, and measure the latency vs throughput trade-offs.
MediumTechnical
41 practiced
Write a TensorFlow Keras Callback (subclassing tf.keras.callbacks.Callback) that implements early stopping with a patience parameter and saves the best model weights to a provided path. It should monitor a named metric and optionally restore best weights at the end of training.
MediumTechnical
44 practiced
Explain how to save and restore complete training checkpoints in both TensorFlow and PyTorch, including model weights, optimizer state, learning rate scheduler state, epoch counters, and RNG states. Provide concise code snippets for saving/loading and explain why restoring optimizer state is necessary to resume training reliably.
EasyTechnical
39 practiced
What is gradient clipping and why is it used? Explain the difference between clipping by norm and clipping by value. Provide a short PyTorch code snippet using torch.nn.utils.clip_grad_norm_ and discuss when gradient clipping is a bandaid vs a valid tool.

Unlock Full Question Bank

Get access to hundreds of TensorFlow/PyTorch Framework Fundamentals interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.