Installing and running Tencent’s SRPO (Sampling with Reward Preference Optimization) opens up an exciting new way to fine-tune diffusion models with precision, speed, and stability. Unlike conventional approaches, SRPO directly aligns the entire diffusion trajectory with fine-grained human preference, making it capable of restoring highly noisy images while maintaining a smoother optimization process with lower computational cost. Its standout strength lies in efficiency: with a novel single-image rollout strategy and analytical gradients, SRPO enables performance boosts for models like FLUX.1.dev in under 10 minutes of training, something previously unimaginable. Even more impressive, this method can skip expensive online rollouts by leveraging fewer than 1,500 real images, making advanced fine-tuning accessible even to small teams and individual creators. At the same time, SRPO tackles reward hacking head-on by regularizing models with negative rewards directly, removing the need for KL divergence or separate reward systems, ensuring both authenticity and robustness in the generated outputs. For researchers and developers, SRPO isn’t just an incremental improvement, it’s a new paradigm that unlocks faster, fairer, and more controllable AI creativity.
In this article, we’ll see the step-by-step comprehensive process to get this model up and running locally or in GPU accelerated environment and further using it to generate stunning realistic & aesthetic images.
Prerequisites
The minimum system requirements for running this model are:
- GPU: 1x H100 or 1x H200
- Storage: 250 GB (preferable)
- VRAM: at least 64 GB
- Anaconda installed
Step-by-step process to install and run SRPO
For the purpose of this tutorial, we’ll use a GPU-powered Virtual Machine by NodeShift since it provides high compute Virtual Machines at a very affordable cost on a scale that meets GDPR, SOC2, and ISO27001 requirements. Also, it offers an intuitive and user-friendly interface, making it easier for beginners to get started with Cloud deployments. However, feel free to use any cloud provider of your choice and follow the same steps for the rest of the tutorial.
Step 1: Setting up a NodeShift Account
Visit app.nodeshift.com and create an account by filling in basic details, or continue signing up with your Google/GitHub account.
If you already have an account, login straight to your dashboard.
Step 2: Create a GPU Node
After accessing your account, you should see a dashboard (see image), now:
- Navigate to the menu on the left side.
- Click on the GPU Nodes option.
- Click on Start to start creating your very first GPU node.
These GPU nodes are GPU-powered virtual machines by NodeShift. These nodes are highly customizable and let you control different environmental configurations for GPUs ranging from H100s to A100s, CPUs, RAM, and storage, according to your needs.
Step 3: Selecting configuration for GPU (model, region, storage)
- For this tutorial, we’ll be using 1x H200 GPU, however, you can choose any GPU as per the prerequisites.
- Similarly, we’ll opt for 200GB storage by sliding the bar. You can also select the region where you want your GPU to reside from the available ones.
Step 4: Choose GPU Configuration and Authentication method
- After selecting your required configuration options, you’ll see the available GPU nodes in your region and according to (or very close to) your configuration. In our case, we’ll choose a 1x H200 140GB GPU node with 192 vCPUs/252GB RAM/200GB SSD.
2. Next, you’ll need to select an authentication method. Two methods are available: Password and SSH Key. We recommend using SSH keys, as they are a more secure option. To create one, head over to our official documentation.
Step 5: Choose an Image
The final step is to choose an image for the VM, which in our case is Nvidia Cuda.
In our previous blogs, we used pre-built images from the Templates tab when creating a Virtual Machine. However, for running a CUDA dependent model like HunyuanImage-2.1, we need a latest CUDA version like CUDA12.4. Therefore, in this case, we switched to the Custom Image tab and selected a specific Docker image that meets all runtime and compatibility requirements.
We chose the following image:
nvidia/cuda:12.4.0-devel-ubuntu24.04
This image is essential because it includes:
- Full CUDA toolkit (including
nvcc
)
- Proper support for building and running GPU-based applications
- Compatibility with CUDA 12.4.0 required by model operations
Launch Mode
We selected:
Interactive shell server
This gives us SSH access and full control over terminal operations — perfect for installing dependencies, running benchmarks, and launching models.
Docker Repository Authentication
We left all fields empty here.
Since the Docker image is publicly available on Docker Hub, no login credentials are required.
Identification
nvidia/cuda:12.4.0-devel-ubuntu24.04
That’s it! You are now ready to deploy the node. Finalize the configuration summary, and if it looks good, click Create to deploy the node.
Step 6: Connect to active Compute Node using SSH
- As soon as you create the node, it will be deployed in a few seconds or a minute. Once deployed, you will see a status Running in green, meaning that our Compute node is ready to use!
- Once your GPU shows this status, navigate to the three dots on the right, click on Connect with SSH, and copy the SSH details that appear.
As you copy the details, follow the below steps to connect to the running GPU VM via SSH:
- Open your terminal, paste the SSH command, and run it.
2. In some cases, your terminal may take your consent before connecting. Enter ‘yes’.
3. A prompt will request a password. Type the SSH password, and you should be connected.
Output:
Next, If you want to check the GPU details, run the following command in the terminal:
!nvidia-smi
Step 7: Set up the project environment with dependencies
- Create a virtual environment using Anaconda.
conda create -n srpo python=3.10.16 -y && conda activate srpo
Output:
2. Clone the official repository of the project.
https://github.com/Tencent-Hunyuan/SRPO.git && cd SRPO
Output:
3. Install required dependencies.
pip install torch==2.6.0 torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124
pip install packaging ninja && pip install flash-attn --no-build-isolation
pip install -r requirements-lint.txt
pip install -e .
pip uninstall trition
pip install triton==2.3.0
pip install ml-collections absl-py inflect==6.0.4 pydantic==1.10.9 huggingface_hub==0.24.0 protobuf==3.20.0 accelerate
git clone https://github.com/tgxs002/HPSv2.git
cd HPSv2
pip install -e .
cd ..
pip3 install trl
4. Login to Hugging Face CLI.
huggingface-cli login
5. Create a directory for srpo checkpoints and download the checkpoints
mkdir ./srpo
huggingface-cli download --resume-download Tencent/SRPO diffusion_pytorch_model.safetensors --local-dir ./srpo/
Output:
6. Create directory to store Flux checkpoints and download the checkpoints.
mkdir ./data
mkdir ./data/flux
huggingface-cli download --resume-download black-forest-labs/FLUX.1-dev --local-dir ./data/flux
Output:
7. Install and run jupyter notebook.
conda install -c conda-forge --override-channels notebook -y
conda install -c conda-forge --override-channels ipywidgets -y
jupyter notebook --allow-root
8. If you’re on a remote machine (e.g., NodeShift GPU), you’ll need to do SSH port forwarding in order to access the jupyter notebook session on your local browser.
Run the following command in your local terminal after replacing:
<YOUR_SERVER_PORT>
with the PORT allotted to your remote server (For the NodeShift server – you can find it in the deployed GPU details on the dashboard).
<PATH_TO_SSH_KEY>
with the path to the location where your SSH key is stored.
<YOUR_SERVER_IP>
with the IP address of your remote server.
ssh -L 8888:localhost:8888 -p <YOUR_SERVER_PORT> -i <PATH_TO_SSH_KEY> root@<YOUR_SERVER_IP>
Output:
After this copy the URL you received in your remote server:
And paste this on your local browser to access the Jupyter Notebook session.
Step 8: Run the model for inference
- Open a Python notebook inside Jupyter.
2. Run the model for inference by specifying your desired prompt.
import torch
from diffusers import FluxPipeline
from safetensors.torch import load_file
generator = torch.Generator(device="cuda").manual_seed(42)
prompt='A high-resolution oil painting in the style of Caravaggio, depicting a scientist in a dimly lit study surrounded by old manuscripts, glowing alchemical instruments, and beams of light highlighting their face. Dramatic chiaroscuro lighting, intricate details, museum-quality realism.'
pipe = FluxPipeline.from_pretrained('./data/flux',
torch_dtype=torch.bfloat16,
use_safetensors=True
).to("cuda")
state_dict = load_file("./srpo/diffusion_pytorch_model.safetensors")
pipe.transformer.load_state_dict(state_dict)
image = pipe(
prompt,
guidance_scale=3.5,
height=1024,
width=1024,
num_inference_steps=50,
max_sequence_length=512,
generator=generator
).images[0]
image.save("output.png")
Output:
Here’s the final generated image:
https://drive.google.com/drive/folders/1YcqbNhTO1bitY3KwcZawM6SN187Ht2hi?usp=sharing
Conclusion
SRPO represents a practical upgrade for diffusion fine-tuning, directly aligning the full diffusion trajectory with human preference yields more stable optimization, rapid training (single-image rollouts and analytical gradients), resistance to reward-hacking, and fine-grained controllability that together make models like FLUX.1.dev both higher-quality and far cheaper to iterate on. NodeShift Cloud complements those technical gains by removing infrastructure friction, with fast GPU provisioning, reproducible environments and artifact storage, and streamlined deployment/inference workflows, it lets you move from tutorial steps to real experiments and demos in minutes rather than days.