Deployment & Responsible Vision
CSC3104 · Lab

Quantisation & model size

See what quantisation does to model size, then quantise a single weight to INT8 by hand — scale, zero-point and the rounding error you pay.

  1. 1 · Predict0/1
  2. 2 · Experiment0/2
  3. 3 · Explain0/1
  4. 4 · Code it0/2
  5. 5 · Challenge
  6. 0/4 tasks done

Predict first

Commit to a guess before you touch anything. Being wrong here is how it sticks.

A 60 M-parameter model in FP16 (2 bytes/param). How many MB of weights?

Experiment

Move the controls and watch the outputs. Goals tick off automatically when you reach them.

Model size by precision

FP32100 MB
FP16 / BF1650 MB
INT825 MB
INT412.5 MB

Weights only — activations, the runtime and the batch add memory at inference.

Quantise one weight

Stored as
q = 191 → 0.2980
scale s = (0.8 − -1.2)/255 = 0.00784, zero-point z = 153 q = round(x/s) + z · error = 1.96e-3

Explain it

Put what you saw into words. This is what the exam will ask you to do.

How does Grad-CAM explain a CNN's prediction, and how should you audit a vision model for bias?

Code it

Write real code against real data. Python and SQL run right here in your browser and hidden tests check your work; the AI reviews it like an examiner.

Pythoncore

Grad-CAM from activations and gradients

Write grad_cam(A, G) for activations A and gradients G of shape C × H × W:

  1. alpha_k = mean of G[k] over the spatial dimensions (global average pooling);
  2. heatmap = ReLU(Σ_k alpha_k · A[k]);
  3. normalise to [0, 1] by dividing by the maximum (if it's > 0).

Return the H × W heatmap and say in a comment why the ReLU is there.

Ctrl/⌘ + Enter to run

Challenge

Fixed variations, a new problem every day, and unlimited AI challenges built from your current settings.

FP32 Weight Memory Footprint

A vision model has 25 million parameters. How many MB (1 MB = 10⁶ bytes) do its weights occupy in FP32?