Skip to content
NVIDIA Generative AI Multimodal Associate (NCA-GENM) Exam Prep

Lesson 5 of 7 · 12 min

x
5/7

Performance Optimization (10%)

Video lesson: NCA-GENM Domain 5: Performance Optimization

Official exam topics: exam-guide/nca-genm-exam-page.md ("Performance Optimization"). NVIDIA defines this area as refining multimodal AI models for energy efficiency, trustworthiness and accuracy through design contributions, transfer learning content development, supervised training enhancements, hyperparameter tuning, rigorous testing and computational advancements. Expect which technique questions: the model is too slow, too big, too costly to train, or not accurate enough; pick mixed precision, quantization, pruning, distillation, TensorRT, transfer learning or a hyperparameter search. The reading list: Mixed Precision Training (Micikevicius et al.), Basics of Quantization in Machine Learning, Neural Network Pruning With Combinatorial Optimization, and the Dive into Deep Learning hyperparameter optimization chapter. Shared topic: multimodal transfer learning is taught in D1.6; this file covers it as a way to save compute and raise accuracy.

Exam topics in this domain 1. 5.1 Enhance computational efficiency and improve the accuracy of outputs 2. 5.2 Optimize performance, including tuning hyperparameters 3. 5.3 Develop content for multimodal-specific transfer learning (efficiency view) 4. 5.4 Assist in model training and training optimization

5.1 Computational Efficiency

Number formats

FormatBytesNotes
FP324Full precision; master copy of weights in mixed precision
TF32(stored as 4)A Tensor Core mode on Ampere and newer for FP32 maths: FP32 range, reduced mantissa, big speedup (PyTorch uses it for convolutions by default; for matrix multiplies it is opt-in)
FP162Narrow range: needs loss scaling in training
BF162Same exponent range as FP32: no loss scaling needed; preferred on Ampere and newer
FP81Transformer Engine on Ada Lovelace, Hopper and newer GPUs
INT81Inference quantization; needs calibration
INT4 / FP40.5Aggressive weight quantization; FP4 Tensor Cores on Blackwell

Mixed precision training (Mixed Precision Training, 2017) 1. Keep an FP32 master copy of the weights. 2. Run the forward and backward passes in FP16 (or BF16) on Tensor Cores. 3. Loss scaling: multiply the loss by a scale factor before backpropagation so small FP16 gradients don't underflow to zero; unscale before the weight update. Dynamic loss scaling lowers the scale when overflows (inf/NaN) appear and raises it when training is stable. 4. Results: about half the memory for activations and up to several times faster maths, with accuracy matching FP32.

In PyTorch: torch.autocast(device_type="cuda", dtype=torch.float16) plus torch.amp.GradScaler("cuda") (the scaler isn't needed for BF16). In Keras: keras.mixed_precision.set_global_policy("mixed_float16").

Quantization (Basics of Quantization) - Map floating-point values to low-bit integers: q = round(x / scale) + zero_point. Symmetric quantization uses zero_point = 0; asymmetric fits a range that isn't centred on zero (common for activations after ReLU). - Per-tensor vs per-channel scales: per-channel keeps more accuracy for convolution weights. - Post-training quantization (PTQ): quantize a trained model; calibrate activation ranges on a few hundred representative inputs. Fast, small accuracy loss. - Quantization-aware training (QAT): simulate quantization during fine-tuning so the model adapts. Recovers accuracy when PTQ loses too much. - Benefits: smaller model, less memory bandwidth, faster INT8 Tensor Core maths, lower energy per inference. Always re-evaluate accuracy (and FID or WER for generative and speech models) after quantizing.

Pruning (Neural Network Pruning With Combinatorial Optimization) - Remove weights that matter least. Unstructured pruning zeroes individual weights (usually by smallest magnitude): high sparsity possible, but speedups need sparse-aware kernels. Structured pruning removes whole channels, filters, heads or layers: the model becomes genuinely smaller and faster on ordinary hardware. - 2:4 structured sparsity: two of every four weights are zero; NVIDIA Ampere and newer Tensor Cores accelerate it. - The paper frames pruning as an optimization problem: choose which weights to remove jointly, accounting for how they interact (using second-order information), rather than one at a time by magnitude, which keeps more accuracy at high sparsity. - Prune → fine-tune to recover accuracy → repeat (iterative pruning).

Other efficiency techniques | Technique | What it does | |---|---| | Knowledge distillation | A small student learns to match a large teacher's outputs (soft labels); keeps much of the accuracy at a fraction of the cost | | TensorRT | Compiles a trained network (usually via ONNX) into an optimized engine: layer and tensor fusion, kernel auto-tuning, FP16/INT8 precision, memory reuse | | Efficient architectures | Smaller backbones (MobileNet, EfficientNet), fewer diffusion sampling steps (DDIM, distilled samplers), latent diffusion (denoise a compressed latent instead of full-resolution pixels) | | Caching | Reuse computed embeddings (precompute image embeddings for a catalogue once) | | Batching | Larger inference batches raise GPU utilization and throughput (at some latency cost) | | Lower resolution or fewer frames | Cut compute for images and video where accuracy allows |

Improving output accuracy More and cleaner data, augmentation (D3), a pretrained backbone (5.3), the right loss and class weighting for imbalance, better fusion (D4), ensembling, test-time augmentation, hyperparameter tuning (5.2), and for generative models more sampling steps or a tuned guidance scale (D6). Efficiency and accuracy trade off: measure both on the same test set.

5.2 Hyperparameter Tuning (Dive into Deep Learning, Hyperparameter Optimization)

What to tune Learning rate (the most important), batch size, optimizer and its settings (Adam β, weight decay), LR schedule and warmup, dropout, number of layers and width, augmentation strength, fusion design, LoRA rank, diffusion steps and guidance scale.

Search strategies

StrategyHowWhen
ManualExpert intuition, one change at a timeFirst runs
Grid searchEvery combination of listed valuesFew hyperparameters; cost grows exponentially
Random searchSample configurations at randomUsually beats grid for the same budget, because only a few hyperparameters matter much
Bayesian optimizationFit a surrogate model (for example a Gaussian process) of score vs configuration; choose the next trial with an acquisition functionExpensive trials; uses past results
Successive halving / Hyperband (multi-fidelity)Start many configurations on a small budget (few epochs), keep the best fraction, give them moreLarge search spaces; stops bad runs early
Population-based trainingTrain a population in parallel, copy and perturb the bestLarge compute budgets

Practical rules: search the learning rate on a log scale (1e-5 to 1e-2); tune on the validation set, never the test set; fix seeds and compare across several; use tools such as Optuna, Ray Tune or Keras Tuner; log every trial (MLflow).

Batch size and learning rate Larger batches use the GPU better but may need a larger learning rate (roughly scale linearly, with warmup) and can generalize slightly worse. Gradient accumulation simulates a large batch when memory is short.

5.3 Transfer Learning for Efficiency

  • Starting from pretrained encoders (ResNet, ViT, CLIP, BERT, a speech encoder) cuts training compute and data by orders of magnitude compared with training from scratch.
  • Freeze most layers: fewer gradients to compute and store, so training is faster and uses less memory.
  • Precompute embeddings from a frozen encoder once and train only the head on them.
  • PEFT (LoRA, adapters) trains well under 1% of the parameters of a large model and stores only small task-specific weights.
  • Choose a pretrained model whose domain and modality match (a medical-image backbone for X-rays); the further the domain, the more layers need fine-tuning.
  • Use the energy saved as a design argument: transfer learning is part of building energy-efficient AI (D1.9, D7).

5.4 Training Optimization

BottleneckSymptomFix
Data loadingLow GPU utilization, CPU at 100%More DataLoader workers, pin_memory=True, prefetching, GPU decoding and augmentation (DALI), pre-resized or pre-encoded data
GPU memoryOut-of-memory errorsMixed precision, smaller batch + gradient accumulation, activation (gradient) checkpointing (recompute activations in the backward pass, about 20–30% more compute), freeze layers, lower resolution
Compute speedSlow steps with a busy GPUMixed precision / TF32, fused kernels, torch.compile, efficient attention (FlashAttention)
ScaleOne GPU is too slowData parallelism (DDP: each GPU holds a model copy and processes part of the batch; gradients are averaged); model or tensor parallelism when the model doesn't fit
Wasted runsTraining past the best pointEarly stopping on validation loss; checkpoints so runs can resume
ConvergenceSlow or unstable lossLR warmup and cosine decay, AdamW, normalization, gradient clipping (D1.5)

Profile before optimizing: PyTorch Profiler, NVIDIA Nsight Systems, and nvidia-smi utilization show where time goes.

Exam Tips - Mixed precision = FP16/BF16 compute + FP32 master weights + loss scaling (FP16 only). - BF16 has FP32's range, so no loss scaling. - PTQ + calibration first; QAT if accuracy drops too much. - Structured pruning gives real speedups on ordinary hardware; 2:4 sparsity is accelerated on Ampere and newer. - Distillation: small student matches large teacher. - TensorRT: layer fusion, kernel auto-tuning, FP16/INT8. - Random search beats grid search for the same budget; Hyperband stops bad trials early. - Low GPU utilization usually means a data-loading bottleneck. - Out of memory: mixed precision, gradient accumulation, activation checkpointing.

References

  1. NVIDIA NCA-GENM certification exam page — checked Nov 11, 2026

Check your understanding

  • Does BF16 training need loss scaling?Show answer

    Answer

    No. BF16 has FP32's exponent range, so gradients don't underflow; loss scaling is for FP16.
  • After quantizing a model, can you skip re-evaluation?Show answer

    Answer

    No. Quantization can change accuracy. Start with post-training quantization and calibration, check accuracy, and use quantization-aware training if it drops too much.
  • Does unstructured pruning speed up inference on any GPU?Show answer

    Answer

    No. Structured pruning gives real speedups on ordinary hardware; NVIDIA accelerates 2:4 structured sparsity on Ampere and newer.
  • For many hyperparameters, is grid search the most efficient search?Show answer

    Answer

    No. Random search covers the space better for the same budget, and Hyperband stops bad trials early.
Previous

Progress is saved in this browser.

Next Lesson