code-switch-mtp / docs /hardware-notes.md
Anupam-Rawat-IITB's picture
Add code, result files and documentation
3bbd5dd verified
|
Raw History Blame Contribute Delete
5.56 kB

Hardware notes — Pascal cluster (Stage 1 PoC)

Hardware

GPU Model Memory Arch Role
0 GTX 1080 Ti 11 GB GP102, sm_61 per-condition job
1 GTX 1080 Ti 11 GB GP102, sm_61 per-condition job
2 GTX 1080 Ti 11 GB GP102, sm_61 per-condition job
3 Quadro P6000 24 GB GP102, sm_61 larger model / longer sequences

Indices above are nvidia-smi / PCI-bus order. This only matches torch's device indexing if CUDA_DEVICE_ORDER=PCI_BUS_ID is set before torch is imported — by default torch orders devices fastest-first, which puts the P6000 at cuda:0. Every script in this repo sets this env var at the top, before importing torch; do the same in anything ad hoc.

Precision and kernel constraints

  • No tensor cores (Pascal, pre-Volta). fp16 matmul throughput does not benefit from dedicated tensor-core paths on this hardware. All training and inference in this project runs in fp32. No autocast, no bf16 (Ampere-only), no fp16 model weights.
  • FlashAttention requires Turing (FA1) or Ampere (FA2) at minimum; neither builds or runs on sm_61. Attention goes through torch.nn.functional.scaled_dot_product_attention, which selects the memory-efficient backend here (confirmed in a prior environment validation pass on this machine; flash correctly raises "no available kernel" if forced).
  • Do not install flash-attn, xformers, bitsandbytes, apex, deepspeed, or any bf16-only path.

sm_61 arch-list caveat

torch==2.5.1+cu121's torch.cuda.get_arch_list() does not contain the literal string 'sm_61':

['sm_50', 'sm_60', 'sm_70', 'sm_75', 'sm_80', 'sm_86', 'sm_90']

torch.cuda.get_device_capability() correctly reports (6, 1) for all four devices, and real kernels (matmul, attention, full model forward and backward) execute correctly. The mechanism is PTX forward-compatibility: the wheel embeds PTX for sm_60, and the driver JIT-recompiles it for the actual sm_61 device on first use. Consequence: the first call of any new kernel shape pays a one-time JIT-compile cost, cached afterward under ~/.nv/ComputeCache. This was hit and manually verified (real matmuls on all four GPUs, correct results, no "no kernel image available" error) in a prior environment-validation pass. scripts/phase0_sanity_check.py checks and logs both facts (arch-list substring and per-device capability) on every run; capability is the actual pass criterion, not the substring.

No older/newer torch build was found that ships a native sm_61 cubin for a current-enough CUDA toolkit on this driver; cu121 with PTX JIT is the accepted path for this project.

Measured throughput

From scripts/phase0_sanity_check.py, meta-llama/Llama-3.2-1B, fp32, on GPU 0 (GTX 1080 Ti), batch 4, seq 512, 5 warmup + 20 timed iterations, two runs:

Measurement Run 1 Run 2
Forward-pass peak memory 4769.1 MiB 4769.1 MiB
Forward-pass avg wall time 28.14 ms/iter 28.46 ms/iter
Training-step throughput (frozen backbone + 1 MTP head) 2510.9 tok/s 2493.6 tok/s
Training-step avg wall time 815.65 ms/step 821.30 ms/step

Training step = frozen-backbone forward (no grad) + ResBlock -> shared frozen unembedding head forward + backward + AdamW step on the head's ~(hidden_size^2) params only. This is the actual Phase 3 per-condition architecture, not a placeholder.

Budget implication for Phase 3: at ~2500 tok/s on one 1080 Ti, 30M tokens is ~3.3 hours, not the brief's planning estimate of ~6.5 hours (which assumed ~3 TFLOP/s/card). A prior, separate environment-validation pass measured raw fp32 matmul throughput at 8.4–9.9 TFLOP/s across all four cards (4096x4096, cuBLAS SGEMM) — well above the 3 TFLOP/s planning number, consistent with the faster-than-expected training-step result here. This number is for GPU 0 only; the P6000 (GPU 3) was not separately timed in Phase 0. Still re-measure the first real Phase 3 run per the brief's own instruction before extrapolating the 7-condition budget — this Phase 0 number uses random synthetic tokens and a single head, not real data density or four heads.

One more measured-but-unexpected result from the prior environment validation, relevant to any future precision decision: fp16 matmul on this hardware was not dramatically slower than fp32 (8.1 vs 8.4-9.9 TFLOP/s), contrary to the naive "1/64 rate, no tensor cores" expectation. Likely cause: cuBLAS dispatches fp16 GEMM through an fp32-accumulate path on hardware without efficient native fp16 arithmetic, sidestepping the crippled path that only shows up in raw half2-instruction microbenchmarks. Practical conclusion is unchanged (fp32 stays the default: no speed benefit from fp16 here, and it costs precision), but the "dramatically slower" framing does not hold for GEMM specifically.

Scratch and disk

Scratch directory: /data/cs769_mtp/scratch — confirmed writable, ~105.7 TB free at time of writing. Use this for corpora, checkpoints, and anything gitignored.

Environment

  • torch==2.5.1+cu121, transformers==5.16.1, full pin list in requirements.txt at repo root.
  • Python venv at .venv/ (not committed). Activate before running any script here.
  • HF auth: gated model access (meta-llama/Llama-3.2-1B) requires a token with "read access to public gated repos" enabled, not just a valid token — a plain valid token without that scope fails with 403, not 401, which is easy to misdiagnose as a connectivity problem.