aws-samples / aws-samples/sagemaker-studio-foundation-models

Model response generation in RLHF DPO training has to be optimized. for use-cases/dpo

Open
#18 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Jupyter Notebook
Stars
30
Forks
10
PR merge metrics
No merged PRs in 30d

Description

The Notebook RLHF-with-Llama3-on-Studio-DPO.ipynb uses LLM for response generation, it is fine for a question file for upto 30 questions, does not take much of a time but when using a customized dataset, it can go ahead and use the entire cuda code which is far more simpler and easier with batching under the current pipelines method.

My inital run for a dataset containing 300 questions took approx 2.3 hours. with batching and pipelining the response generation part it takes around 1 hour only for 3947 data channels. Please check and update to use all of the cuda that is available provided we are using g5.48xlarge instance.

Default

if you do a `torch.cuda.device_count()` you will see that you have around 8 GPU available

# Set CUDA optimization flags
torch.backends.cudnn.enabled = True
torch.backends.cudnn.benchmark = True
torch.backends.cuda.matmul.allow_tf32 = True

this will go ahead and utilize the maximum GPU memory

eg from my nvidia SMI

Tue Apr 29 21:55:30 2025
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 550.144.03 Driver Version: 550.144.03 CUDA Version: 12.4 |
|-----------------------------------------+------------------------+----------------------+
| GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|=========================================+========================+======================|
| 0 NVIDIA A10G On | 00000000:00:16.0 Off | 0 |
| 0% 39C P0 64W / 300W | 1917MiB / 23028MiB | 4% Default |
| | | N/A |
+-----------------------------------------+------------------------+----------------------+
| 1 NVIDIA A10G On | 00000000:00:17.0 Off | 0 |
| 0% 40C P0 77W / 300W | 2575MiB / 23028MiB | 12% Default |
| | | N/A |
+-----------------------------------------+------------------------+----------------------+
| 2 NVIDIA A10G On | 00000000:00:18.0 Off | 0 |
| 0% 41C P0 82W / 300W | 2575MiB / 23028MiB | 15% Default |
| | | N/A |
+-----------------------------------------+------------------------+----------------------+
| 3 NVIDIA A10G On | 00000000:00:19.0 Off | 0 |
| 0% 41C P0 81W / 300W | 2575MiB / 23028MiB | 12% Default |
| | | N/A |
+-----------------------------------------+------------------------+----------------------+
| 4 NVIDIA A10G On | 00000000:00:1A.0 Off | 0 |
| 0% 41C P0 79W / 300W | 2575MiB / 23028MiB | 12% Default |
| | | N/A |
+-----------------------------------------+------------------------+----------------------+
| 5 NVIDIA A10G On | 00000000:00:1B.0 Off | 0 |
| 0% 41C P0 79W / 300W | 2575MiB / 23028MiB | 15% Default |
| | | N/A |
+-----------------------------------------+------------------------+----------------------+
| 6 NVIDIA A10G On | 00000000:00:1C.0 Off | 0 |
| 0% 42C P0 83W / 300W | 2575MiB / 23028MiB | 15% Default |
| | | N/A |
+-----------------------------------------+------------------------+----------------------+
| 7 NVIDIA A10G On | 00000000:00:1D.0 Off | 0 |
| 0% 40C P0 73W / 300W | 1915MiB / 23028MiB | 8% Default |
| | | N/A |
+-----------------------------------------+------------------------+----------------------+

+-----------------------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=========================================================================================|
+-----------------------------------------------------------------------------------------+

Contributor guide

Open the contributing guide

Research direction

Start in RLHF-with-Llama3-on-Studio-DPO.ipynb, focusing on the model response-generation section and the existing torch.cuda.device_count() and CUDA settings. Run it with a representative customized dataset, then verify that generation uses the available GPUs and achieves a meaningful runtime improvement over the current approach.

Written by the indexing model from the issue text.

Assessment

Tech stack
jupyter-notebook, python, pytorch
Domain
machine-learning, performance
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.