Week 6 — Coding Projects

Core

Work with random variables and build elementwise operator pipelines.

  • NumPy: Simulate discrete random variables. Estimate expectation and variance. Implement elementwise square, exp, sigmoid, and clamp.
  • Metal: Chain elementwise compute kernels over large buffers. · Reading: MBT — multiple compute passes, resource reuse, command encoding patterns.
  • Vulkan: Compute pipeline chain for elementwise ops with descriptor reuse. · Reading: Vulkan Book — compute dispatch chaining, descriptor reuse, buffer ping-pong.
  • CUDA: Elementwise kernels plus a fused kernel version. · Reading: CUDA Book — kernel fusion intuition, launch overhead, data locality.
  • Stretch: Compare fused vs. multi-pass kernels. Measure cost of extra memory traffic.
  • Verify: Empirical expectation approaches analytic expectation · Chained kernels produce same results as CPU · Fused and unfused outputs agree.